From b5c10aa9d716b13fb9bcb5efa8e3e14213316580 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Fri, 31 Jan 2025 10:05:34 +0100 Subject: [PATCH] Improve serialization --- .../Elastic.Clients.Elasticsearch.csproj | 5 + .../AsyncSearch/AsyncSearchStatusRequest.g.cs | 8 + .../AsyncSearchStatusResponse.g.cs | 158 +- .../AsyncSearch/DeleteAsyncSearchRequest.g.cs | 8 + .../DeleteAsyncSearchResponse.g.cs | 37 +- .../AsyncSearch/GetAsyncSearchRequest.g.cs | 8 + .../AsyncSearch/GetAsyncSearchResponse.g.cs | 153 +- .../AsyncSearch/SubmitAsyncSearchRequest.g.cs | 745 +++---- .../SubmitAsyncSearchResponse.g.cs | 153 +- .../_Generated/Api/BulkRequest.g.cs | 8 + .../_Generated/Api/BulkResponse.g.cs | 59 +- .../_Generated/Api/ClearScrollResponse.g.cs | 48 +- .../Api/ClosePointInTimeResponse.g.cs | 48 +- .../Cluster/AllocationExplainResponse.g.cs | 301 ++- .../Api/Cluster/ClusterInfoRequest.g.cs | 8 + .../Api/Cluster/ClusterInfoResponse.g.cs | 81 +- .../Api/Cluster/ClusterStatsRequest.g.cs | 8 + .../Api/Cluster/ClusterStatsResponse.g.cs | 103 +- .../DeleteComponentTemplateRequest.g.cs | 8 + .../DeleteComponentTemplateResponse.g.cs | 37 +- .../ExistsComponentTemplateRequest.g.cs | 9 + .../Cluster/GetClusterSettingsResponse.g.cs | 59 +- .../Cluster/GetComponentTemplateRequest.g.cs | 9 + .../Cluster/GetComponentTemplateResponse.g.cs | 37 +- .../_Generated/Api/Cluster/HealthRequest.g.cs | 8 + .../Api/Cluster/HealthResponse.g.cs | 225 +- .../Api/Cluster/PendingTasksResponse.g.cs | 37 +- .../Cluster/PutComponentTemplateRequest.g.cs | 12 + .../Cluster/PutComponentTemplateResponse.g.cs | 37 +- .../_Generated/Api/CountRequest.g.cs | 10 + .../_Generated/Api/CountResponse.g.cs | 48 +- .../_Generated/Api/CreateRequest.g.cs | 28 +- .../_Generated/Api/CreateResponse.g.cs | 114 +- .../CcrStatsResponse.g.cs | 48 +- .../DeleteAutoFollowPatternRequest.g.cs | 8 + .../DeleteAutoFollowPatternResponse.g.cs | 37 +- .../FollowInfoRequest.g.cs | 8 + .../FollowInfoResponse.g.cs | 37 +- .../FollowRequest.g.cs | 8 + .../FollowResponse.g.cs | 59 +- .../FollowStatsRequest.g.cs | 8 + .../FollowStatsResponse.g.cs | 37 +- .../ForgetFollowerRequest.g.cs | 7 + .../ForgetFollowerResponse.g.cs | 37 +- .../GetAutoFollowPatternRequest.g.cs | 8 + .../GetAutoFollowPatternResponse.g.cs | 37 +- .../PauseAutoFollowPatternRequest.g.cs | 8 + .../PauseAutoFollowPatternResponse.g.cs | 37 +- .../PauseFollowRequest.g.cs | 8 + .../PauseFollowResponse.g.cs | 37 +- .../PutAutoFollowPatternRequest.g.cs | 8 + .../PutAutoFollowPatternResponse.g.cs | 37 +- .../ResumeAutoFollowPatternRequest.g.cs | 8 + .../ResumeAutoFollowPatternResponse.g.cs | 37 +- .../ResumeFollowRequest.g.cs | 7 + .../ResumeFollowResponse.g.cs | 37 +- .../UnfollowRequest.g.cs | 8 + .../UnfollowResponse.g.cs | 37 +- .../ListDanglingIndicesResponse.g.cs | 37 +- .../_Generated/Api/DeleteByQueryRequest.g.cs | 10 + .../_Generated/Api/DeleteByQueryResponse.g.cs | 202 +- .../Api/DeleteByQueryRethrottleRequest.g.cs | 8 + .../Api/DeleteByQueryRethrottleResponse.g.cs | 70 +- .../_Generated/Api/DeleteRequest.g.cs | 16 + .../_Generated/Api/DeleteResponse.g.cs | 114 +- .../_Generated/Api/DeleteScriptRequest.g.cs | 8 + .../_Generated/Api/DeleteScriptResponse.g.cs | 37 +- .../Api/Enrich/DeletePolicyRequest.g.cs | 8 + .../Api/Enrich/DeletePolicyResponse.g.cs | 37 +- .../Api/Enrich/EnrichStatsResponse.g.cs | 59 +- .../Api/Enrich/ExecutePolicyRequest.g.cs | 8 + .../Api/Enrich/ExecutePolicyResponse.g.cs | 48 +- .../Api/Enrich/GetPolicyRequest.g.cs | 9 + .../Api/Enrich/GetPolicyResponse.g.cs | 37 +- .../Api/Enrich/PutPolicyRequest.g.cs | 8 + .../Api/Enrich/PutPolicyResponse.g.cs | 37 +- .../_Generated/Api/Eql/EqlDeleteRequest.g.cs | 10 + .../_Generated/Api/Eql/EqlDeleteResponse.g.cs | 37 +- .../_Generated/Api/Eql/EqlGetRequest.g.cs | 8 + .../_Generated/Api/Eql/EqlGetResponse.g.cs | 120 +- .../_Generated/Api/Eql/EqlSearchRequest.g.cs | 222 +- .../_Generated/Api/Eql/EqlSearchResponse.g.cs | 120 +- .../Api/Eql/GetEqlStatusRequest.g.cs | 8 + .../Api/Eql/GetEqlStatusResponse.g.cs | 92 +- .../_Generated/Api/ExistsRequest.g.cs | 17 + .../_Generated/Api/ExistsSourceRequest.g.cs | 17 + .../_Generated/Api/ExplainRequest.g.cs | 17 + .../_Generated/Api/ExplainResponse.g.cs | 98 +- .../Api/Features/GetFeaturesResponse.g.cs | 37 +- .../Api/Features/ResetFeaturesResponse.g.cs | 37 +- .../_Generated/Api/FieldCapsRequest.g.cs | 72 +- .../_Generated/Api/FieldCapsResponse.g.cs | 50 +- .../_Generated/Api/GetRequest.g.cs | 16 + .../_Generated/Api/GetResponse.g.cs | 154 +- .../Api/GetScriptContextResponse.g.cs | 37 +- .../Api/GetScriptLanguagesResponse.g.cs | 48 +- .../_Generated/Api/GetScriptRequest.g.cs | 8 + .../_Generated/Api/GetScriptResponse.g.cs | 59 +- .../_Generated/Api/GetSourceRequest.g.cs | 16 + .../_Generated/Api/Graph/ExploreRequest.g.cs | 8 + .../_Generated/Api/Graph/ExploreResponse.g.cs | 81 +- .../_Generated/Api/HealthReportRequest.g.cs | 8 + .../_Generated/Api/HealthReportResponse.g.cs | 59 +- .../DeleteLifecycleRequest.g.cs | 8 + .../DeleteLifecycleResponse.g.cs | 37 +- .../GetIlmStatusResponse.g.cs | 37 +- .../GetLifecycleRequest.g.cs | 8 + .../MigrateToDataTiersResponse.g.cs | 104 +- .../MoveToStepRequest.g.cs | 7 + .../MoveToStepResponse.g.cs | 37 +- .../PutLifecycleRequest.g.cs | 8 + .../PutLifecycleResponse.g.cs | 37 +- .../RemovePolicyRequest.g.cs | 8 + .../RemovePolicyResponse.g.cs | 48 +- .../RetryRequest.g.cs | 8 + .../RetryResponse.g.cs | 37 +- .../StartIlmResponse.g.cs | 37 +- .../StopIlmResponse.g.cs | 37 +- .../IndexManagement/AnalyzeIndexRequest.g.cs | 133 +- .../IndexManagement/AnalyzeIndexResponse.g.cs | 48 +- .../IndexManagement/ClearCacheRequest.g.cs | 10 + .../IndexManagement/ClearCacheResponse.g.cs | 37 +- .../IndexManagement/CloneIndexRequest.g.cs | 16 + .../IndexManagement/CloneIndexResponse.g.cs | 59 +- .../IndexManagement/CloseIndexRequest.g.cs | 8 + .../IndexManagement/CloseIndexResponse.g.cs | 60 +- .../CreateDataStreamRequest.g.cs | 13 + .../CreateDataStreamResponse.g.cs | 37 +- .../IndexManagement/CreateIndexRequest.g.cs | 8 + .../IndexManagement/CreateIndexResponse.g.cs | 59 +- .../DataStreamsStatsRequest.g.cs | 10 + .../DataStreamsStatsResponse.g.cs | 92 +- .../IndexManagement/DeleteAliasRequest.g.cs | 18 + .../IndexManagement/DeleteAliasResponse.g.cs | 37 +- .../DeleteDataLifecycleRequest.g.cs | 8 + .../DeleteDataLifecycleResponse.g.cs | 37 +- .../DeleteDataStreamRequest.g.cs | 8 + .../DeleteDataStreamResponse.g.cs | 37 +- .../IndexManagement/DeleteIndexRequest.g.cs | 11 + .../IndexManagement/DeleteIndexResponse.g.cs | 48 +- .../DeleteIndexTemplateRequest.g.cs | 8 + .../DeleteIndexTemplateResponse.g.cs | 37 +- .../DeleteTemplateRequest.g.cs | 9 + .../DeleteTemplateResponse.g.cs | 37 +- .../Api/IndexManagement/DiskUsageRequest.g.cs | 9 + .../IndexManagement/DownsampleRequest.g.cs | 23 +- .../IndexManagement/ExistsAliasRequest.g.cs | 17 + .../ExistsIndexTemplateRequest.g.cs | 8 + .../Api/IndexManagement/ExistsRequest.g.cs | 8 + .../ExistsTemplateRequest.g.cs | 8 + .../ExplainDataLifecycleRequest.g.cs | 8 + .../ExplainDataLifecycleResponse.g.cs | 38 +- .../FieldUsageStatsRequest.g.cs | 8 + .../FieldUsageStatsResponse.g.cs | 37 +- .../Api/IndexManagement/FlushRequest.g.cs | 10 + .../Api/IndexManagement/FlushResponse.g.cs | 37 +- .../IndexManagement/ForcemergeRequest.g.cs | 8 + .../IndexManagement/ForcemergeResponse.g.cs | 48 +- .../Api/IndexManagement/GetAliasRequest.g.cs | 20 + .../GetDataLifecycleRequest.g.cs | 10 + .../GetDataLifecycleResponse.g.cs | 37 +- .../IndexManagement/GetDataStreamRequest.g.cs | 9 + .../GetDataStreamResponse.g.cs | 37 +- .../GetFieldMappingRequest.g.cs | 18 + .../Api/IndexManagement/GetIndexRequest.g.cs | 9 + .../GetIndexTemplateRequest.g.cs | 8 + .../GetIndexTemplateResponse.g.cs | 37 +- .../GetIndicesSettingsRequest.g.cs | 18 + .../IndexManagement/GetMappingRequest.g.cs | 10 + .../IndexManagement/GetTemplateRequest.g.cs | 10 + .../IndexManagement/IndicesStatsRequest.g.cs | 16 + .../IndexManagement/IndicesStatsResponse.g.cs | 59 +- .../MigrateToDataStreamRequest.g.cs | 8 + .../MigrateToDataStreamResponse.g.cs | 37 +- .../ModifyDataStreamResponse.g.cs | 37 +- .../Api/IndexManagement/OpenIndexRequest.g.cs | 12 + .../IndexManagement/OpenIndexResponse.g.cs | 48 +- .../PromoteDataStreamRequest.g.cs | 8 + .../Api/IndexManagement/PutAliasRequest.g.cs | 20 + .../Api/IndexManagement/PutAliasResponse.g.cs | 37 +- .../PutDataLifecycleRequest.g.cs | 20 +- .../PutDataLifecycleResponse.g.cs | 37 +- .../PutIndexTemplateRequest.g.cs | 8 + .../PutIndexTemplateResponse.g.cs | 37 +- .../PutIndicesSettingsRequest.g.cs | 20 +- .../PutIndicesSettingsResponse.g.cs | 37 +- .../IndexManagement/PutMappingRequest.g.cs | 159 +- .../IndexManagement/PutMappingResponse.g.cs | 48 +- .../IndexManagement/PutTemplateRequest.g.cs | 100 +- .../IndexManagement/PutTemplateResponse.g.cs | 37 +- .../Api/IndexManagement/RecoveryRequest.g.cs | 10 + .../Api/IndexManagement/RefreshRequest.g.cs | 10 + .../Api/IndexManagement/RefreshResponse.g.cs | 37 +- .../ReloadSearchAnalyzersRequest.g.cs | 8 + .../ReloadSearchAnalyzersResponse.g.cs | 48 +- .../ResolveClusterRequest.g.cs | 9 + .../IndexManagement/ResolveIndexRequest.g.cs | 9 + .../IndexManagement/ResolveIndexResponse.g.cs | 59 +- .../Api/IndexManagement/RolloverRequest.g.cs | 18 + .../Api/IndexManagement/RolloverResponse.g.cs | 103 +- .../Api/IndexManagement/SegmentsRequest.g.cs | 10 + .../Api/IndexManagement/SegmentsResponse.g.cs | 48 +- .../IndexManagement/ShardStoresRequest.g.cs | 8 + .../IndexManagement/ShardStoresResponse.g.cs | 38 +- .../IndexManagement/ShrinkIndexRequest.g.cs | 16 + .../IndexManagement/ShrinkIndexResponse.g.cs | 59 +- .../SimulateIndexTemplateRequest.g.cs | 8 + .../SimulateIndexTemplateResponse.g.cs | 48 +- .../SimulateTemplateRequest.g.cs | 9 + .../SimulateTemplateResponse.g.cs | 48 +- .../IndexManagement/SplitIndexRequest.g.cs | 16 + .../IndexManagement/SplitIndexResponse.g.cs | 59 +- .../UpdateAliasesResponse.g.cs | 37 +- .../IndexManagement/ValidateQueryRequest.g.cs | 10 + .../ValidateQueryResponse.g.cs | 70 +- .../_Generated/Api/IndexRequest.g.cs | 26 +- .../_Generated/Api/IndexResponse.g.cs | 114 +- .../Api/Inference/DeleteInferenceRequest.g.cs | 16 + .../Inference/DeleteInferenceResponse.g.cs | 48 +- .../Api/Inference/GetInferenceRequest.g.cs | 16 + .../Api/Inference/GetInferenceResponse.g.cs | 37 +- .../Api/Inference/InferenceRequest.g.cs | 73 +- .../Api/Inference/InferenceResponse.g.cs | 24 + .../Api/Inference/PutInferenceRequest.g.cs | 23 +- .../Api/Inference/PutInferenceResponse.g.cs | 81 +- .../_Generated/Api/InfoResponse.g.cs | 81 +- .../Ingest/DeleteGeoipDatabaseRequest.g.cs | 8 + .../Ingest/DeleteGeoipDatabaseResponse.g.cs | 37 +- .../DeleteIpLocationDatabaseRequest.g.cs | 8 + .../DeleteIpLocationDatabaseResponse.g.cs | 37 +- .../Api/Ingest/DeletePipelineRequest.g.cs | 9 + .../Api/Ingest/DeletePipelineResponse.g.cs | 37 +- .../Api/Ingest/GeoIpStatsResponse.g.cs | 48 +- .../Api/Ingest/GetGeoipDatabaseRequest.g.cs | 10 + .../Api/Ingest/GetGeoipDatabaseResponse.g.cs | 37 +- .../Ingest/GetIpLocationDatabaseRequest.g.cs | 10 + .../Ingest/GetIpLocationDatabaseResponse.g.cs | 37 +- .../Api/Ingest/GetPipelineRequest.g.cs | 10 + .../Api/Ingest/ProcessorGrokResponse.g.cs | 37 +- .../Api/Ingest/PutGeoipDatabaseRequest.g.cs | 8 + .../Api/Ingest/PutGeoipDatabaseResponse.g.cs | 37 +- .../Ingest/PutIpLocationDatabaseRequest.g.cs | 18 +- .../Ingest/PutIpLocationDatabaseResponse.g.cs | 37 +- .../Api/Ingest/PutPipelineRequest.g.cs | 8 + .../Api/Ingest/PutPipelineResponse.g.cs | 37 +- .../Api/Ingest/SimulateRequest.g.cs | 9 + .../Api/Ingest/SimulateResponse.g.cs | 37 +- .../DeleteLicenseResponse.g.cs | 37 +- .../GetBasicStatusResponse.g.cs | 37 +- .../LicenseManagement/GetLicenseResponse.g.cs | 37 +- .../GetTrialStatusResponse.g.cs | 37 +- .../Api/LicenseManagement/PostResponse.g.cs | 59 +- .../PostStartBasicResponse.g.cs | 81 +- .../PostStartTrialResponse.g.cs | 70 +- ...earTrainedModelDeploymentCacheRequest.g.cs | 8 + ...arTrainedModelDeploymentCacheResponse.g.cs | 37 +- .../Api/MachineLearning/CloseJobRequest.g.cs | 8 + .../Api/MachineLearning/CloseJobResponse.g.cs | 37 +- .../DeleteCalendarEventRequest.g.cs | 17 + .../DeleteCalendarEventResponse.g.cs | 37 +- .../DeleteCalendarJobRequest.g.cs | 17 + .../DeleteCalendarJobResponse.g.cs | 60 +- .../DeleteCalendarRequest.g.cs | 8 + .../DeleteCalendarResponse.g.cs | 37 +- .../DeleteDataFrameAnalyticsRequest.g.cs | 8 + .../DeleteDataFrameAnalyticsResponse.g.cs | 37 +- .../DeleteDatafeedRequest.g.cs | 11 + .../DeleteDatafeedResponse.g.cs | 37 +- .../DeleteExpiredDataRequest.g.cs | 9 + .../DeleteExpiredDataResponse.g.cs | 37 +- .../MachineLearning/DeleteFilterRequest.g.cs | 8 + .../MachineLearning/DeleteFilterResponse.g.cs | 37 +- .../DeleteForecastRequest.g.cs | 18 + .../DeleteForecastResponse.g.cs | 37 +- .../Api/MachineLearning/DeleteJobRequest.g.cs | 8 + .../MachineLearning/DeleteJobResponse.g.cs | 37 +- .../DeleteModelSnapshotRequest.g.cs | 16 + .../DeleteModelSnapshotResponse.g.cs | 37 +- .../DeleteTrainedModelAliasRequest.g.cs | 16 + .../DeleteTrainedModelAliasResponse.g.cs | 37 +- .../DeleteTrainedModelRequest.g.cs | 8 + .../DeleteTrainedModelResponse.g.cs | 37 +- .../EstimateModelMemoryResponse.g.cs | 37 +- .../EvaluateDataFrameResponse.g.cs | 59 +- .../ExplainDataFrameAnalyticsRequest.g.cs | 10 + .../ExplainDataFrameAnalyticsResponse.g.cs | 48 +- .../Api/MachineLearning/FlushJobRequest.g.cs | 8 + .../Api/MachineLearning/FlushJobResponse.g.cs | 48 +- .../Api/MachineLearning/ForecastRequest.g.cs | 9 + .../Api/MachineLearning/ForecastResponse.g.cs | 48 +- .../MachineLearning/GetBucketsRequest.g.cs | 17 + .../MachineLearning/GetBucketsResponse.g.cs | 48 +- .../GetCalendarEventsRequest.g.cs | 8 + .../GetCalendarEventsResponse.g.cs | 48 +- .../MachineLearning/GetCalendarsRequest.g.cs | 8 + .../MachineLearning/GetCalendarsResponse.g.cs | 48 +- .../MachineLearning/GetCategoriesRequest.g.cs | 20 + .../GetCategoriesResponse.g.cs | 48 +- .../GetDataFrameAnalyticsRequest.g.cs | 10 + .../GetDataFrameAnalyticsResponse.g.cs | 48 +- .../GetDataFrameAnalyticsStatsRequest.g.cs | 10 + .../GetDataFrameAnalyticsStatsResponse.g.cs | 48 +- .../GetDatafeedStatsRequest.g.cs | 10 + .../GetDatafeedStatsResponse.g.cs | 48 +- .../MachineLearning/GetDatafeedsRequest.g.cs | 10 + .../MachineLearning/GetDatafeedsResponse.g.cs | 48 +- .../MachineLearning/GetFiltersRequest.g.cs | 8 + .../MachineLearning/GetFiltersResponse.g.cs | 48 +- .../GetInfluencersRequest.g.cs | 8 + .../GetInfluencersResponse.g.cs | 48 +- .../MachineLearning/GetJobStatsRequest.g.cs | 11 + .../MachineLearning/GetJobStatsResponse.g.cs | 48 +- .../Api/MachineLearning/GetJobsRequest.g.cs | 10 + .../Api/MachineLearning/GetJobsResponse.g.cs | 48 +- .../GetMemoryStatsRequest.g.cs | 9 + .../GetMemoryStatsResponse.g.cs | 59 +- .../GetModelSnapshotUpgradeStatsRequest.g.cs | 18 + .../GetModelSnapshotUpgradeStatsResponse.g.cs | 48 +- .../GetModelSnapshotsRequest.g.cs | 18 + .../GetModelSnapshotsResponse.g.cs | 48 +- .../GetOverallBucketsRequest.g.cs | 14 + .../GetOverallBucketsResponse.g.cs | 48 +- .../MachineLearning/GetRecordsRequest.g.cs | 8 + .../MachineLearning/GetRecordsResponse.g.cs | 48 +- .../GetTrainedModelsRequest.g.cs | 13 + .../GetTrainedModelsResponse.g.cs | 48 +- .../GetTrainedModelsStatsRequest.g.cs | 9 + .../GetTrainedModelsStatsResponse.g.cs | 48 +- .../InferTrainedModelRequest.g.cs | 8 + .../InferTrainedModelResponse.g.cs | 37 +- .../Api/MachineLearning/MlInfoResponse.g.cs | 70 +- .../Api/MachineLearning/OpenJobRequest.g.cs | 8 + .../Api/MachineLearning/OpenJobResponse.g.cs | 48 +- .../PostCalendarEventsRequest.g.cs | 8 + .../PostCalendarEventsResponse.g.cs | 37 +- .../PreviewDataFrameAnalyticsRequest.g.cs | 8 + .../PreviewDataFrameAnalyticsResponse.g.cs | 37 +- .../PutCalendarJobRequest.g.cs | 16 + .../PutCalendarJobResponse.g.cs | 60 +- .../MachineLearning/PutCalendarRequest.g.cs | 8 + .../MachineLearning/PutCalendarResponse.g.cs | 60 +- .../PutDataFrameAnalyticsRequest.g.cs | 10 + .../PutDataFrameAnalyticsResponse.g.cs | 169 +- .../MachineLearning/PutDatafeedRequest.g.cs | 329 ++- .../MachineLearning/PutDatafeedResponse.g.cs | 191 +- .../Api/MachineLearning/PutFilterRequest.g.cs | 8 + .../MachineLearning/PutFilterResponse.g.cs | 59 +- .../Api/MachineLearning/PutJobResponse.g.cs | 246 +- .../PutTrainedModelAliasRequest.g.cs | 16 + .../PutTrainedModelAliasResponse.g.cs | 37 +- .../PutTrainedModelDefinitionPartRequest.g.cs | 17 + ...PutTrainedModelDefinitionPartResponse.g.cs | 37 +- .../PutTrainedModelRequest.g.cs | 8 + .../PutTrainedModelResponse.g.cs | 246 +- .../PutTrainedModelVocabularyRequest.g.cs | 8 + .../PutTrainedModelVocabularyResponse.g.cs | 37 +- .../Api/MachineLearning/ResetJobRequest.g.cs | 8 + .../Api/MachineLearning/ResetJobResponse.g.cs | 37 +- .../RevertModelSnapshotRequest.g.cs | 18 + .../RevertModelSnapshotResponse.g.cs | 37 +- .../SetUpgradeModeResponse.g.cs | 37 +- .../StartDataFrameAnalyticsRequest.g.cs | 10 + .../StartDataFrameAnalyticsResponse.g.cs | 48 +- .../MachineLearning/StartDatafeedRequest.g.cs | 10 + .../StartDatafeedResponse.g.cs | 49 +- .../StartTrainedModelDeploymentRequest.g.cs | 8 + .../StartTrainedModelDeploymentResponse.g.cs | 37 +- .../StopDataFrameAnalyticsRequest.g.cs | 10 + .../StopDataFrameAnalyticsResponse.g.cs | 37 +- .../MachineLearning/StopDatafeedRequest.g.cs | 10 + .../MachineLearning/StopDatafeedResponse.g.cs | 37 +- .../StopTrainedModelDeploymentRequest.g.cs | 8 + .../StopTrainedModelDeploymentResponse.g.cs | 37 +- .../UpdateDataFrameAnalyticsRequest.g.cs | 10 + .../UpdateDataFrameAnalyticsResponse.g.cs | 158 +- .../UpdateDatafeedRequest.g.cs | 307 ++- .../UpdateDatafeedResponse.g.cs | 191 +- .../MachineLearning/UpdateFilterRequest.g.cs | 8 + .../MachineLearning/UpdateFilterResponse.g.cs | 59 +- .../Api/MachineLearning/UpdateJobRequest.g.cs | 8 + .../MachineLearning/UpdateJobResponse.g.cs | 257 ++- .../UpdateModelSnapshotRequest.g.cs | 16 + .../UpdateModelSnapshotResponse.g.cs | 48 +- .../UpdateTrainedModelDeploymentRequest.g.cs | 8 + .../UpdateTrainedModelDeploymentResponse.g.cs | 37 +- .../UpgradeJobSnapshotRequest.g.cs | 16 + .../UpgradeJobSnapshotResponse.g.cs | 48 +- .../ValidateDetectorRequest.g.cs | 10 +- .../ValidateDetectorResponse.g.cs | 37 +- .../Api/MachineLearning/ValidateResponse.g.cs | 37 +- .../_Generated/Api/MultiGetRequest.g.cs | 8 + .../_Generated/Api/MultiGetResponse.g.cs | 54 +- .../_Generated/Api/MultiSearchRequest.g.cs | 8 + .../_Generated/Api/MultiSearchResponse.g.cs | 65 +- .../Api/MultiSearchTemplateRequest.g.cs | 10 + .../Api/MultiSearchTemplateResponse.g.cs | 65 +- .../Api/MultiTermVectorsRequest.g.cs | 8 + .../Api/MultiTermVectorsResponse.g.cs | 37 +- ...earRepositoriesMeteringArchiveRequest.g.cs | 17 + ...arRepositoriesMeteringArchiveResponse.g.cs | 59 +- .../GetRepositoriesMeteringInfoRequest.g.cs | 9 + .../GetRepositoriesMeteringInfoResponse.g.cs | 59 +- .../Api/Nodes/HotThreadsRequest.g.cs | 8 + .../Api/Nodes/HotThreadsResponse.g.cs | 24 + .../Api/Nodes/NodesInfoRequest.g.cs | 16 + .../Api/Nodes/NodesInfoResponse.g.cs | 59 +- .../Api/Nodes/NodesStatsRequest.g.cs | 24 + .../Api/Nodes/NodesStatsResponse.g.cs | 59 +- .../Api/Nodes/NodesUsageRequest.g.cs | 17 + .../Api/Nodes/NodesUsageResponse.g.cs | 59 +- .../Nodes/ReloadSecureSettingsRequest.g.cs | 8 + .../Nodes/ReloadSecureSettingsResponse.g.cs | 59 +- .../Api/OpenPointInTimeRequest.g.cs | 8 + .../Api/OpenPointInTimeResponse.g.cs | 48 +- .../_Generated/Api/PutScriptRequest.g.cs | 18 + .../_Generated/Api/PutScriptResponse.g.cs | 37 +- .../Api/QueryRules/DeleteRuleRequest.g.cs | 16 + .../Api/QueryRules/DeleteRuleResponse.g.cs | 37 +- .../Api/QueryRules/DeleteRulesetRequest.g.cs | 8 + .../Api/QueryRules/DeleteRulesetResponse.g.cs | 37 +- .../Api/QueryRules/GetRuleRequest.g.cs | 16 + .../Api/QueryRules/GetRuleResponse.g.cs | 82 +- .../Api/QueryRules/GetRulesetRequest.g.cs | 8 + .../Api/QueryRules/GetRulesetResponse.g.cs | 48 +- .../Api/QueryRules/ListRulesetsResponse.g.cs | 48 +- .../Api/QueryRules/PutRuleRequest.g.cs | 82 +- .../Api/QueryRules/PutRuleResponse.g.cs | 37 +- .../Api/QueryRules/PutRulesetRequest.g.cs | 42 +- .../Api/QueryRules/PutRulesetResponse.g.cs | 37 +- .../Api/QueryRules/TestRequest.g.cs | 7 + .../Api/QueryRules/TestResponse.g.cs | 48 +- .../_Generated/Api/RankEvalRequest.g.cs | 9 + .../_Generated/Api/RankEvalResponse.g.cs | 59 +- .../_Generated/Api/ReindexResponse.g.cs | 202 +- .../Api/ReindexRethrottleRequest.g.cs | 8 + .../Api/ReindexRethrottleResponse.g.cs | 37 +- .../Api/RenderSearchTemplateRequest.g.cs | 8 + .../Api/RenderSearchTemplateResponse.g.cs | 37 +- .../Api/Rollup/DeleteJobRequest.g.cs | 8 + .../Api/Rollup/DeleteJobResponse.g.cs | 48 +- .../_Generated/Api/Rollup/GetJobsRequest.g.cs | 9 + .../Api/Rollup/GetJobsResponse.g.cs | 37 +- .../Api/Rollup/GetRollupCapsRequest.g.cs | 9 + .../Api/Rollup/GetRollupIndexCapsRequest.g.cs | 9 + .../_Generated/Api/Rollup/PutJobRequest.g.cs | 12 + .../_Generated/Api/Rollup/PutJobResponse.g.cs | 37 +- .../Api/Rollup/RollupSearchRequest.g.cs | 94 +- .../Api/Rollup/RollupSearchResponse.g.cs | 109 +- .../Api/Rollup/StartJobRequest.g.cs | 8 + .../Api/Rollup/StartJobResponse.g.cs | 37 +- .../_Generated/Api/Rollup/StopJobRequest.g.cs | 8 + .../Api/Rollup/StopJobResponse.g.cs | 37 +- .../Api/ScriptsPainlessExecuteResponse.g.cs | 55 +- .../_Generated/Api/ScrollResponse.g.cs | 197 +- .../DeleteBehavioralAnalyticsRequest.g.cs | 8 + .../DeleteBehavioralAnalyticsResponse.g.cs | 37 +- .../DeleteSearchApplicationRequest.g.cs | 8 + .../DeleteSearchApplicationResponse.g.cs | 37 +- .../GetBehavioralAnalyticsRequest.g.cs | 8 + .../GetSearchApplicationRequest.g.cs | 8 + .../GetSearchApplicationResponse.g.cs | 81 +- .../Api/SearchApplication/ListResponse.g.cs | 48 +- .../PutBehavioralAnalyticsRequest.g.cs | 8 + .../PutBehavioralAnalyticsResponse.g.cs | 48 +- .../PutSearchApplicationRequest.g.cs | 18 +- .../PutSearchApplicationResponse.g.cs | 37 +- .../SearchApplicationSearchRequest.g.cs | 8 + .../SearchApplicationSearchResponse.g.cs | 197 +- .../_Generated/Api/SearchMvtRequest.g.cs | 215 +- .../_Generated/Api/SearchRequest.g.cs | 790 +++---- .../_Generated/Api/SearchResponse.g.cs | 197 +- .../_Generated/Api/SearchShardsRequest.g.cs | 8 + .../_Generated/Api/SearchShardsResponse.g.cs | 60 +- .../_Generated/Api/SearchTemplateRequest.g.cs | 9 + .../Api/SearchTemplateResponse.g.cs | 197 +- .../CacheStatsRequest.g.cs | 7 + .../CacheStatsResponse.g.cs | 37 +- .../ClearCacheRequest.g.cs | 8 + .../Api/SearchableSnapshots/MountRequest.g.cs | 16 + .../SearchableSnapshots/MountResponse.g.cs | 37 +- .../SearchableSnapshotsStatsRequest.g.cs | 8 + .../SearchableSnapshotsStatsResponse.g.cs | 48 +- .../Security/ActivateUserProfileResponse.g.cs | 103 +- .../Api/Security/AuthenticateResponse.g.cs | 147 +- .../Api/Security/BulkDeleteRoleResponse.g.cs | 59 +- .../Api/Security/BulkPutRoleResponse.g.cs | 70 +- .../Api/Security/ChangePasswordRequest.g.cs | 9 + .../Api/Security/ChangePasswordResponse.g.cs | 24 + .../Api/Security/ClearApiKeyCacheRequest.g.cs | 10 + .../Security/ClearApiKeyCacheResponse.g.cs | 59 +- .../ClearCachedPrivilegesRequest.g.cs | 8 + .../ClearCachedPrivilegesResponse.g.cs | 59 +- .../Security/ClearCachedRealmsRequest.g.cs | 8 + .../Security/ClearCachedRealmsResponse.g.cs | 59 +- .../Api/Security/ClearCachedRolesRequest.g.cs | 8 + .../Security/ClearCachedRolesResponse.g.cs | 59 +- .../ClearCachedServiceTokensRequest.g.cs | 24 + .../ClearCachedServiceTokensResponse.g.cs | 59 +- .../Api/Security/CreateApiKeyResponse.g.cs | 81 +- .../CreateCrossClusterApiKeyResponse.g.cs | 81 +- .../Security/CreateServiceTokenRequest.g.cs | 24 + .../Security/CreateServiceTokenResponse.g.cs | 48 +- .../Api/Security/DeletePrivilegesRequest.g.cs | 16 + .../Security/DeleteRoleMappingRequest.g.cs | 8 + .../Security/DeleteRoleMappingResponse.g.cs | 37 +- .../Api/Security/DeleteRoleRequest.g.cs | 8 + .../Api/Security/DeleteRoleResponse.g.cs | 37 +- .../Security/DeleteServiceTokenRequest.g.cs | 24 + .../Security/DeleteServiceTokenResponse.g.cs | 37 +- .../Api/Security/DeleteUserRequest.g.cs | 8 + .../Api/Security/DeleteUserResponse.g.cs | 37 +- .../Security/DisableUserProfileRequest.g.cs | 8 + .../Security/DisableUserProfileResponse.g.cs | 37 +- .../Api/Security/DisableUserRequest.g.cs | 8 + .../Api/Security/DisableUserResponse.g.cs | 24 + .../Security/EnableUserProfileRequest.g.cs | 8 + .../Security/EnableUserProfileResponse.g.cs | 37 +- .../Api/Security/EnableUserRequest.g.cs | 8 + .../Api/Security/EnableUserResponse.g.cs | 24 + .../Api/Security/EnrollKibanaResponse.g.cs | 48 +- .../Api/Security/EnrollNodeResponse.g.cs | 92 +- .../Api/Security/GetApiKeyResponse.g.cs | 37 +- .../GetBuiltinPrivilegesResponse.g.cs | 59 +- .../Api/Security/GetPrivilegesRequest.g.cs | 16 + .../Api/Security/GetRoleMappingRequest.g.cs | 8 + .../Api/Security/GetRoleRequest.g.cs | 8 + .../Security/GetServiceAccountsRequest.g.cs | 16 + .../GetServiceCredentialsRequest.g.cs | 16 + .../GetServiceCredentialsResponse.g.cs | 70 +- .../Api/Security/GetTokenResponse.g.cs | 103 +- .../Security/GetUserPrivilegesResponse.g.cs | 81 +- .../Api/Security/GetUserProfileRequest.g.cs | 8 + .../Api/Security/GetUserProfileResponse.g.cs | 48 +- .../Api/Security/GetUserRequest.g.cs | 8 + .../Api/Security/GrantApiKeyResponse.g.cs | 81 +- .../Api/Security/HasPrivilegesRequest.g.cs | 7 + .../Api/Security/HasPrivilegesResponse.g.cs | 82 +- .../HasPrivilegesUserProfileResponse.g.cs | 48 +- .../Security/InvalidateApiKeyResponse.g.cs | 70 +- .../Api/Security/InvalidateTokenResponse.g.cs | 70 +- .../Api/Security/PutPrivilegesRequest.g.cs | 9 +- .../Api/Security/PutRoleMappingRequest.g.cs | 8 + .../Api/Security/PutRoleMappingResponse.g.cs | 48 +- .../Api/Security/PutRoleRequest.g.cs | 8 + .../Api/Security/PutRoleResponse.g.cs | 37 +- .../Api/Security/PutUserResponse.g.cs | 37 +- .../Api/Security/QueryApiKeysRequest.g.cs | 152 +- .../Api/Security/QueryApiKeysResponse.g.cs | 70 +- .../Api/Security/QueryRoleRequest.g.cs | 80 +- .../Api/Security/QueryRoleResponse.g.cs | 59 +- .../Api/Security/QueryUserRequest.g.cs | 81 +- .../Api/Security/QueryUserResponse.g.cs | 59 +- .../Security/SamlAuthenticateResponse.g.cs | 81 +- .../Api/Security/SamlInvalidateResponse.g.cs | 59 +- .../Api/Security/SamlLogoutResponse.g.cs | 37 +- .../SamlPrepareAuthenticationResponse.g.cs | 59 +- .../SamlServiceProviderMetadataRequest.g.cs | 8 + .../SamlServiceProviderMetadataResponse.g.cs | 37 +- .../Security/SuggestUserProfilesRequest.g.cs | 69 +- .../Security/SuggestUserProfilesResponse.g.cs | 59 +- .../Api/Security/UpdateApiKeyRequest.g.cs | 8 + .../Api/Security/UpdateApiKeyResponse.g.cs | 37 +- .../UpdateCrossClusterApiKeyRequest.g.cs | 8 + .../UpdateCrossClusterApiKeyResponse.g.cs | 37 +- .../UpdateUserProfileDataRequest.g.cs | 8 + .../UpdateUserProfileDataResponse.g.cs | 37 +- .../Snapshot/CleanupRepositoryRequest.g.cs | 8 + .../Snapshot/CleanupRepositoryResponse.g.cs | 37 +- .../Api/Snapshot/CloneSnapshotRequest.g.cs | 24 + .../Api/Snapshot/CloneSnapshotResponse.g.cs | 37 +- .../Api/Snapshot/CreateRepositoryRequest.g.cs | 18 +- .../Snapshot/CreateRepositoryResponse.g.cs | 37 +- .../Api/Snapshot/CreateSnapshotRequest.g.cs | 16 + .../Api/Snapshot/CreateSnapshotResponse.g.cs | 48 +- .../Api/Snapshot/DeleteRepositoryRequest.g.cs | 8 + .../Snapshot/DeleteRepositoryResponse.g.cs | 37 +- .../Api/Snapshot/DeleteSnapshotRequest.g.cs | 16 + .../Api/Snapshot/DeleteSnapshotResponse.g.cs | 37 +- .../Api/Snapshot/GetRepositoryRequest.g.cs | 8 + .../Api/Snapshot/GetSnapshotRequest.g.cs | 28 + .../Api/Snapshot/GetSnapshotResponse.g.cs | 70 +- .../RepositoryVerifyIntegrityRequest.g.cs | 8 + .../Api/Snapshot/RestoreRequest.g.cs | 16 + .../Api/Snapshot/RestoreResponse.g.cs | 48 +- .../Api/Snapshot/SnapshotStatusRequest.g.cs | 16 + .../Api/Snapshot/SnapshotStatusResponse.g.cs | 37 +- .../Api/Snapshot/VerifyRepositoryRequest.g.cs | 8 + .../Snapshot/VerifyRepositoryResponse.g.cs | 37 +- .../DeleteLifecycleRequest.g.cs | 8 + .../DeleteLifecycleResponse.g.cs | 37 +- .../ExecuteLifecycleRequest.g.cs | 8 + .../ExecuteLifecycleResponse.g.cs | 37 +- .../ExecuteRetentionResponse.g.cs | 37 +- .../GetLifecycleRequest.g.cs | 8 + .../GetSlmStatusResponse.g.cs | 37 +- .../GetStatsResponse.g.cs | 136 +- .../PutLifecycleRequest.g.cs | 8 + .../PutLifecycleResponse.g.cs | 37 +- .../StartSlmResponse.g.cs | 37 +- .../StopSlmResponse.g.cs | 37 +- .../Api/Sql/ClearCursorResponse.g.cs | 37 +- .../Api/Sql/DeleteAsyncRequest.g.cs | 8 + .../Api/Sql/DeleteAsyncResponse.g.cs | 37 +- .../_Generated/Api/Sql/GetAsyncRequest.g.cs | 8 + .../_Generated/Api/Sql/GetAsyncResponse.g.cs | 81 +- .../Api/Sql/GetAsyncStatusRequest.g.cs | 8 + .../Api/Sql/GetAsyncStatusResponse.g.cs | 92 +- .../_Generated/Api/Sql/QueryResponse.g.cs | 81 +- .../_Generated/Api/Sql/TranslateResponse.g.cs | 93 +- .../Api/Synonyms/DeleteSynonymRequest.g.cs | 8 + .../Api/Synonyms/DeleteSynonymResponse.g.cs | 37 +- .../Synonyms/DeleteSynonymRuleRequest.g.cs | 16 + .../Synonyms/DeleteSynonymRuleResponse.g.cs | 48 +- .../Api/Synonyms/GetSynonymRequest.g.cs | 8 + .../Api/Synonyms/GetSynonymResponse.g.cs | 48 +- .../Api/Synonyms/GetSynonymRuleRequest.g.cs | 16 + .../Api/Synonyms/GetSynonymRuleResponse.g.cs | 48 +- .../Api/Synonyms/GetSynonymsSetsResponse.g.cs | 48 +- .../Api/Synonyms/PutSynonymRequest.g.cs | 43 +- .../Api/Synonyms/PutSynonymResponse.g.cs | 48 +- .../Api/Synonyms/PutSynonymRuleRequest.g.cs | 15 + .../Api/Synonyms/PutSynonymRuleResponse.g.cs | 48 +- .../_Generated/Api/Tasks/CancelRequest.g.cs | 8 + .../_Generated/Api/Tasks/CancelResponse.g.cs | 70 +- .../_Generated/Api/Tasks/GetTasksRequest.g.cs | 8 + .../Api/Tasks/GetTasksResponse.g.cs | 70 +- .../_Generated/Api/Tasks/ListResponse.g.cs | 70 +- .../_Generated/Api/TermVectorsRequest.g.cs | 100 +- .../_Generated/Api/TermVectorsResponse.g.cs | 93 +- .../_Generated/Api/TermsEnumRequest.g.cs | 8 + .../_Generated/Api/TermsEnumResponse.g.cs | 59 +- .../FindFieldStructureResponse.g.cs | 192 +- .../FindMessageStructureResponse.g.cs | 192 +- .../TestGrokPatternResponse.g.cs | 37 +- .../DeleteTransformRequest.g.cs | 8 + .../DeleteTransformResponse.g.cs | 37 +- .../GetTransformRequest.g.cs | 11 + .../GetTransformResponse.g.cs | 48 +- .../GetTransformStatsRequest.g.cs | 11 + .../GetTransformStatsResponse.g.cs | 48 +- .../PreviewTransformRequest.g.cs | 9 + .../PreviewTransformResponse.g.cs | 65 +- .../PutTransformRequest.g.cs | 9 + .../PutTransformResponse.g.cs | 37 +- .../ResetTransformRequest.g.cs | 9 + .../ResetTransformResponse.g.cs | 37 +- .../ScheduleNowTransformRequest.g.cs | 8 + .../ScheduleNowTransformResponse.g.cs | 37 +- .../StartTransformRequest.g.cs | 8 + .../StartTransformResponse.g.cs | 37 +- .../StopTransformRequest.g.cs | 9 + .../StopTransformResponse.g.cs | 37 +- .../UpdateTransformRequest.g.cs | 8 + .../UpdateTransformResponse.g.cs | 180 +- .../UpgradeTransformsResponse.g.cs | 59 +- .../_Generated/Api/UpdateByQueryRequest.g.cs | 10 + .../_Generated/Api/UpdateByQueryResponse.g.cs | 202 +- .../Api/UpdateByQueryRethrottleRequest.g.cs | 8 + .../Api/UpdateByQueryRethrottleResponse.g.cs | 37 +- .../_Generated/Api/UpdateRequest.g.cs | 145 +- .../_Generated/Api/UpdateResponse.g.cs | 142 +- .../Api/Xpack/XpackInfoResponse.g.cs | 70 +- .../Api/Xpack/XpackUsageResponse.g.cs | 345 ++- .../AdjacencyMatrixAggregate.g.cs | 2 + .../Aggregations/AdjacencyMatrixBucket.g.cs | 75 +- .../Aggregations/AggregateDictionary.g.cs | 825 +++---- .../Types/Aggregations/Aggregation.g.cs | 1171 +++++----- .../AutoDateHistogramAggregate.g.cs | 2 + .../Types/Aggregations/AverageAggregate.g.cs | 2 + .../Types/Aggregations/BoxplotAggregate.g.cs | 2 + .../BucketMetricValueAggregate.g.cs | 2 + .../Aggregations/BucketSortAggregation.g.cs | 69 +- .../Aggregations/CardinalityAggregate.g.cs | 2 + .../Types/Aggregations/ChildrenAggregate.g.cs | 77 +- .../Aggregations/CompositeAggregate.g.cs | 2 + .../Types/Aggregations/CompositeBucket.g.cs | 75 +- .../CumulativeCardinalityAggregate.g.cs | 2 + .../Aggregations/DateHistogramAggregate.g.cs | 2 + .../DateHistogramAggregation.g.cs | 168 +- .../Aggregations/DateHistogramBucket.g.cs | 90 +- .../Aggregations/DateRangeAggregate.g.cs | 2 + .../Aggregations/DerivativeAggregate.g.cs | 2 + .../Aggregations/DoubleTermsAggregate.g.cs | 2 + .../Types/Aggregations/DoubleTermsBucket.g.cs | 105 +- .../Aggregations/ExtendedStatsAggregate.g.cs | 2 + .../ExtendedStatsBucketAggregate.g.cs | 2 + .../Types/Aggregations/FilterAggregate.g.cs | 77 +- .../Types/Aggregations/FiltersAggregate.g.cs | 2 + .../Types/Aggregations/FiltersBucket.g.cs | 60 +- .../FrequentItemSetsAggregate.g.cs | 2 + .../Aggregations/FrequentItemSetsBucket.g.cs | 90 +- .../Aggregations/GeoBoundsAggregate.g.cs | 2 + .../Aggregations/GeoCentroidAggregate.g.cs | 2 + .../Aggregations/GeoDistanceAggregate.g.cs | 2 + .../Types/Aggregations/GeoLineAggregate.g.cs | 2 + .../Aggregations/GeohashGridAggregate.g.cs | 2 + .../Types/Aggregations/GeohashGridBucket.g.cs | 75 +- .../Aggregations/GeohexGridAggregate.g.cs | 2 + .../Types/Aggregations/GeohexGridBucket.g.cs | 75 +- .../Aggregations/GeotileGridAggregate.g.cs | 2 + .../Types/Aggregations/GeotileGridBucket.g.cs | 75 +- .../Types/Aggregations/GlobalAggregate.g.cs | 77 +- .../HdrPercentileRanksAggregate.g.cs | 2 + .../Aggregations/HdrPercentilesAggregate.g.cs | 2 + .../Aggregations/HistogramAggregate.g.cs | 2 + .../Aggregations/HistogramAggregation.g.cs | 135 +- .../Types/Aggregations/HistogramBucket.g.cs | 90 +- .../Aggregations/InferenceAggregate.g.cs | 117 +- .../Types/Aggregations/InferenceConfig.g.cs | 85 +- .../Types/Aggregations/IpPrefixAggregate.g.cs | 2 + .../Types/Aggregations/IpPrefixBucket.g.cs | 120 +- .../Types/Aggregations/IpRangeAggregate.g.cs | 2 + .../Types/Aggregations/IpRangeBucket.g.cs | 105 +- .../Aggregations/LongRareTermsAggregate.g.cs | 2 + .../Aggregations/LongRareTermsBucket.g.cs | 90 +- .../Aggregations/LongTermsAggregate.g.cs | 2 + .../Types/Aggregations/LongTermsBucket.g.cs | 105 +- .../Aggregations/MatrixStatsAggregate.g.cs | 2 + .../Aggregations/MatrixStatsAggregation.g.cs | 58 +- .../Types/Aggregations/MatrixStatsFields.g.cs | 2 - .../Types/Aggregations/MaxAggregate.g.cs | 2 + .../MedianAbsoluteDeviationAggregate.g.cs | 2 + .../Types/Aggregations/MinAggregate.g.cs | 2 + .../Types/Aggregations/MissingAggregate.g.cs | 77 +- .../Aggregations/MultiTermsAggregate.g.cs | 2 + .../Aggregations/MultiTermsAggregation.g.cs | 113 +- .../Types/Aggregations/MultiTermsBucket.g.cs | 105 +- .../Types/Aggregations/NestedAggregate.g.cs | 77 +- .../Types/Aggregations/ParentAggregate.g.cs | 77 +- .../PercentilesBucketAggregate.g.cs | 2 + .../Types/Aggregations/RangeAggregate.g.cs | 2 + .../Types/Aggregations/RangeBucket.g.cs | 145 +- .../Types/Aggregations/RateAggregate.g.cs | 2 + .../Aggregations/ReverseNestedAggregate.g.cs | 77 +- .../Types/Aggregations/SamplerAggregate.g.cs | 77 +- .../Aggregations/ScriptedMetricAggregate.g.cs | 2 + .../SignificantLongTermsAggregate.g.cs | 2 + .../SignificantLongTermsBucket.g.cs | 120 +- .../SignificantStringTermsAggregate.g.cs | 2 + .../SignificantStringTermsBucket.g.cs | 105 +- .../SignificantTextAggregation.g.cs | 212 +- .../Aggregations/SimpleValueAggregate.g.cs | 2 + .../Types/Aggregations/StatsAggregate.g.cs | 2 + .../Aggregations/StatsBucketAggregate.g.cs | 2 + .../StringRareTermsAggregate.g.cs | 2 + .../Aggregations/StringRareTermsBucket.g.cs | 75 +- .../Aggregations/StringStatsAggregate.g.cs | 2 + .../Aggregations/StringTermsAggregate.g.cs | 2 + .../Types/Aggregations/StringTermsBucket.g.cs | 90 +- .../Types/Aggregations/SumAggregate.g.cs | 2 + .../TDigestPercentileRanksAggregate.g.cs | 2 + .../TDigestPercentilesAggregate.g.cs | 2 + .../Types/Aggregations/TTestAggregate.g.cs | 2 + .../Types/Aggregations/TermsAggregation.g.cs | 212 +- .../Aggregations/TimeSeriesAggregate.g.cs | 2 + .../Types/Aggregations/TimeSeriesBucket.g.cs | 75 +- .../Types/Aggregations/TopHitsAggregate.g.cs | 2 + .../Aggregations/TopHitsAggregation.g.cs | 202 +- .../Aggregations/TopMetricsAggregate.g.cs | 2 + .../Aggregations/TopMetricsAggregation.g.cs | 92 +- .../UnmappedRareTermsAggregate.g.cs | 2 + .../UnmappedSamplerAggregate.g.cs | 77 +- .../UnmappedSignificantTermsAggregate.g.cs | 2 + .../Aggregations/UnmappedTermsAggregate.g.cs | 2 + .../Aggregations/ValueCountAggregate.g.cs | 2 + .../VariableWidthHistogramAggregate.g.cs | 2 + .../VariableWidthHistogramBucket.g.cs | 162 +- .../WeightedAverageAggregate.g.cs | 2 + .../_Generated/Types/Analysis/Analyzers.g.cs | 391 ++-- .../Types/Analysis/ArabicAnalyzer.g.cs | 67 +- .../Types/Analysis/ArmenianAnalyzer.g.cs | 67 +- .../Types/Analysis/BasqueAnalyzer.g.cs | 67 +- .../Types/Analysis/BengaliAnalyzer.g.cs | 67 +- .../Types/Analysis/BrazilianAnalyzer.g.cs | 56 +- .../Types/Analysis/BulgarianAnalyzer.g.cs | 67 +- .../Types/Analysis/CatalanAnalyzer.g.cs | 67 +- .../Types/Analysis/CharFilters.g.cs | 77 +- .../Types/Analysis/ChineseAnalyzer.g.cs | 56 +- .../Types/Analysis/CjkAnalyzer.g.cs | 56 +- .../Types/Analysis/CustomAnalyzer.g.cs | 90 +- .../Types/Analysis/CzechAnalyzer.g.cs | 67 +- .../Types/Analysis/DanishAnalyzer.g.cs | 56 +- .../Types/Analysis/DutchAnalyzer.g.cs | 67 +- .../Types/Analysis/EnglishAnalyzer.g.cs | 67 +- .../Types/Analysis/EstonianAnalyzer.g.cs | 56 +- .../Types/Analysis/FingerprintAnalyzer.g.cs | 100 +- .../Types/Analysis/FinnishAnalyzer.g.cs | 67 +- .../Types/Analysis/FrenchAnalyzer.g.cs | 67 +- .../Types/Analysis/GalicianAnalyzer.g.cs | 67 +- .../Types/Analysis/GermanAnalyzer.g.cs | 67 +- .../Types/Analysis/GreekAnalyzer.g.cs | 56 +- .../Types/Analysis/HindiAnalyzer.g.cs | 67 +- .../Types/Analysis/HungarianAnalyzer.g.cs | 67 +- .../Types/Analysis/IndonesianAnalyzer.g.cs | 67 +- .../Types/Analysis/IrishAnalyzer.g.cs | 67 +- .../Types/Analysis/ItalianAnalyzer.g.cs | 67 +- .../Analysis/KeywordMarkerTokenFilter.g.cs | 89 +- .../Types/Analysis/LanguageAnalyzer.g.cs | 89 +- .../Types/Analysis/LatvianAnalyzer.g.cs | 67 +- .../Types/Analysis/LithuanianAnalyzer.g.cs | 67 +- .../Types/Analysis/Normalizers.g.cs | 55 +- .../Types/Analysis/NorwegianAnalyzer.g.cs | 67 +- .../Types/Analysis/PatternAnalyzer.g.cs | 89 +- .../Types/Analysis/PersianAnalyzer.g.cs | 56 +- .../Types/Analysis/PhoneticTokenFilter.g.cs | 111 +- .../Types/Analysis/PortugueseAnalyzer.g.cs | 67 +- .../Types/Analysis/RomanianAnalyzer.g.cs | 67 +- .../Types/Analysis/RussianAnalyzer.g.cs | 67 +- .../Types/Analysis/SerbianAnalyzer.g.cs | 67 +- .../Types/Analysis/SnowballAnalyzer.g.cs | 67 +- .../Types/Analysis/SoraniAnalyzer.g.cs | 67 +- .../Types/Analysis/SpanishAnalyzer.g.cs | 67 +- .../Types/Analysis/StandardAnalyzer.g.cs | 56 +- .../Types/Analysis/StemmerTokenFilter.g.cs | 72 +- .../Types/Analysis/StopAnalyzer.g.cs | 67 +- .../Types/Analysis/StopTokenFilter.g.cs | 89 +- .../Types/Analysis/SwedishAnalyzer.g.cs | 67 +- .../Types/Analysis/ThaiAnalyzer.g.cs | 56 +- .../Types/Analysis/TokenFilters.g.cs | 371 ++- .../_Generated/Types/Analysis/Tokenizers.g.cs | 168 +- .../Types/Analysis/TurkishAnalyzer.g.cs | 67 +- .../Types/AsyncSearch/AsyncSearch.g.cs | 195 +- .../Cluster/ComponentTemplateSummary.g.cs | 1 - .../_Generated/Types/CompletionStats.g.cs | 1 - .../Types/Core/FieldCaps/FieldCapability.g.cs | 159 +- .../_Generated/Types/Core/Get/GetResult.g.cs | 152 +- .../DiagnosisAffectedResources.g.cs | 80 +- .../Types/Core/MGet/MultiGetOperation.g.cs | 102 +- .../Types/Core/MSearch/MultiSearchItem.g.cs | 206 +- .../Types/Core/MSearch/MultisearchBody.g.cs | 655 +++--- .../Types/Core/MSearch/MultisearchHeader.g.cs | 146 +- .../MultiTermVectorsOperation.g.cs | 168 +- .../Mtermvectors/MultiTermVectorsResult.g.cs | 1 - .../Types/Core/RankEval/RankEvalQuery.g.cs | 56 +- .../_Generated/Types/Core/Reindex/Source.g.cs | 114 +- .../Types/Core/Search/CompletionContext.g.cs | 89 +- .../Types/Core/Search/CompletionSuggest.g.cs | 88 +- .../Core/Search/CompletionSuggestOption.g.cs | 152 +- .../Types/Core/Search/FieldCollapse.g.cs | 69 +- .../Types/Core/Search/FieldSuggester.g.cs | 150 +- .../Types/Core/Search/HighlightField.g.cs | 267 ++- .../_Generated/Types/Core/Search/Hit.g.cs | 262 ++- .../Types/Core/Search/HitsMetadata.g.cs | 74 +- .../Types/Core/Search/InnerHits.g.cs | 203 +- .../Types/Core/Search/PhraseSuggest.g.cs | 71 +- .../_Generated/Types/Core/Search/Rescore.g.cs | 104 +- .../Types/Core/Search/SmoothingModel.g.cs | 99 +- .../Types/Core/Search/SourceFilter.g.cs | 75 +- .../Types/Core/Search/SuggestDictionary.g.cs | 107 +- .../Types/Core/Search/Suggester.g.cs | 56 +- .../Types/Core/Search/TermSuggest.g.cs | 71 +- .../Types/DanglingIndices/DanglingIndex.g.cs | 69 +- .../_Generated/Types/Enrich/EnrichPolicy.g.cs | 91 +- .../Types/Enums/Enums.Aggregations.g.cs | 874 +++++--- .../Types/Enums/Enums.Analysis.g.cs | 1804 +++++++++------ .../_Generated/Types/Enums/Enums.Cluster.g.cs | 366 +-- .../Types/Enums/Enums.Core.HealthReport.g.cs | 124 +- .../Types/Enums/Enums.Core.Search.g.cs | 420 ++-- .../Types/Enums/Enums.Core.SearchMvt.g.cs | 88 +- .../Enums/Enums.CrossClusterReplication.g.cs | 38 +- .../_Generated/Types/Enums/Enums.Enrich.g.cs | 112 +- .../_Generated/Types/Enums/Enums.Eql.g.cs | 38 +- .../_Generated/Types/Enums/Enums.Esql.g.cs | 110 +- .../Types/Enums/Enums.IndexManagement.g.cs | 694 +++--- .../Types/Enums/Enums.Inference.g.cs | 62 +- .../_Generated/Types/Enums/Enums.Ingest.g.cs | 440 ++-- .../Types/Enums/Enums.LicenseManagement.g.cs | 184 +- .../Types/Enums/Enums.MachineLearning.g.cs | 1144 ++++++---- .../_Generated/Types/Enums/Enums.Mapping.g.cs | 1444 +++++++----- .../Types/Enums/Enums.NoNamespace.g.cs | 1984 ++++++++++------- .../Types/Enums/Enums.QueryDsl.g.cs | 814 ++++--- .../Types/Enums/Enums.QueryRules.g.cs | 202 +- .../_Generated/Types/Enums/Enums.Rollup.g.cs | 148 +- .../Enums/Enums.SearchableSnapshots.g.cs | 50 +- .../Types/Enums/Enums.Security.g.cs | 270 ++- .../Types/Enums/Enums.Snapshot.g.cs | 172 +- .../_Generated/Types/Enums/Enums.Sql.g.cs | 98 +- .../_Generated/Types/Enums/Enums.Tasks.g.cs | 50 +- .../Types/Enums/Enums.TextStructure.g.cs | 100 +- .../_Generated/Types/Enums/Enums.Watcher.g.cs | 62 +- .../_Generated/Types/Enums/Enums.Xpack.g.cs | 50 +- .../_Generated/Types/Eql/EqlHits.g.cs | 74 +- .../_Generated/Types/Eql/HitsEvent.g.cs | 98 +- .../_Generated/Types/Eql/HitsSequence.g.cs | 63 +- .../_Generated/Types/ErrorCause.g.cs | 140 +- .../_Generated/Types/FieldSort.g.cs | 107 +- .../_Generated/Types/FielddataStats.g.cs | 1 - .../_Generated/Types/GeoDistanceSort.g.cs | 163 +- .../Types/IndexManagement/AddAction.g.cs | 146 +- .../IndexManagement/ExplainAnalyzeToken.g.cs | 191 +- .../IndexModifyDataStreamAction.g.cs | 85 +- .../IndexManagement/IndexSegmentSort.g.cs | 72 +- .../Types/IndexManagement/IndexSettings.g.cs | 1172 +++++----- .../Types/IndexManagement/IndexTemplate.g.cs | 136 +- .../IndexManagement/IndexTemplateSummary.g.cs | 1 - .../IndexUpdateAliasesAction.g.cs | 99 +- .../Types/IndexManagement/RemoveAction.g.cs | 80 +- .../ResolveIndexAliasItem.g.cs | 47 +- .../ResolveIndexDataStreamsItem.g.cs | 58 +- .../IndexManagement/SettingsSimilarities.g.cs | 98 +- .../Types/IndexManagement/ShardStats.g.cs | 1 - .../Types/IndexManagement/ShardStore.g.cs | 82 +- .../Types/IndexManagement/Template.g.cs | 1 - .../IndexManagement/TemplateMapping.g.cs | 1 - .../IndexManagement/TypeFieldMappings.g.cs | 1 - .../_Generated/Types/IndicesOptions.g.cs | 69 +- .../Types/Ingest/AppendProcessor.g.cs | 113 +- .../_Generated/Types/Ingest/CsvProcessor.g.cs | 157 +- .../Types/Ingest/DatabaseConfiguration.g.cs | 104 +- .../Ingest/DatabaseConfigurationFull.g.cs | 132 +- .../Types/Ingest/DocumentSimulation.g.cs | 157 +- .../Types/Ingest/FingerprintProcessor.g.cs | 135 +- .../Types/Ingest/InferenceConfig.g.cs | 85 +- .../_Generated/Types/Ingest/Processor.g.cs | 687 +++--- .../Types/Ingest/RemoveProcessor.g.cs | 114 +- .../Types/Ingest/RerouteProcessor.g.cs | 114 +- .../_Generated/Types/InlineGet.g.cs | 159 +- .../_Generated/Types/KnnQuery.g.cs | 124 +- .../_Generated/Types/KnnRetriever.g.cs | 113 +- .../_Generated/Types/KnnSearch.g.cs | 124 +- .../Types/MachineLearning/AnalysisConfig.g.cs | 146 +- .../Types/MachineLearning/Datafeed.g.cs | 294 ++- .../Types/MachineLearning/DatafeedConfig.g.cs | 303 ++- .../MachineLearning/DataframeAnalysis.g.cs | 99 +- .../DataframeAnalysisAnalyzedFields.g.cs | 52 +- .../DataframeAnalysisClassification.g.cs | 426 ++-- .../DataframeAnalysisFeatureProcessor.g.cs | 127 +- .../DataframeAnalysisRegression.g.cs | 426 ++-- .../MachineLearning/DataframeEvaluation.g.cs | 99 +- .../InferenceConfigCreate.g.cs | 197 +- .../InferenceConfigUpdate.g.cs | 197 +- .../InferenceResponseResult.g.cs | 124 +- .../Types/MachineLearning/Preprocessor.g.cs | 99 +- .../MachineLearning/TokenizationConfig.g.cs | 113 +- .../Types/Mapping/BinaryProperty.g.cs | 122 +- .../Types/Mapping/BooleanProperty.g.cs | 166 +- .../Types/Mapping/ByteNumberProperty.g.cs | 221 +- .../Types/Mapping/CompletionProperty.g.cs | 188 +- .../Types/Mapping/DateNanosProperty.g.cs | 188 +- .../Types/Mapping/DateProperty.g.cs | 210 +- .../Types/Mapping/DateRangeProperty.g.cs | 166 +- .../Types/Mapping/DoubleNumberProperty.g.cs | 221 +- .../Types/Mapping/DoubleRangeProperty.g.cs | 155 +- .../Types/Mapping/DynamicProperty.g.cs | 364 ++- .../Types/Mapping/DynamicTemplate.g.cs | 200 +- .../Types/Mapping/FloatNumberProperty.g.cs | 221 +- .../Types/Mapping/FloatRangeProperty.g.cs | 155 +- .../Types/Mapping/GeoPointProperty.g.cs | 188 +- .../Types/Mapping/GeoShapeProperty.g.cs | 177 +- .../Mapping/HalfFloatNumberProperty.g.cs | 221 +- .../Types/Mapping/IcuCollationProperty.g.cs | 298 ++- .../Types/Mapping/IntegerNumberProperty.g.cs | 221 +- .../Types/Mapping/IntegerRangeProperty.g.cs | 155 +- .../_Generated/Types/Mapping/IpProperty.g.cs | 199 +- .../Types/Mapping/IpRangeProperty.g.cs | 155 +- .../Types/Mapping/KeywordProperty.g.cs | 254 ++- .../Types/Mapping/LongNumberProperty.g.cs | 221 +- .../Types/Mapping/LongRangeProperty.g.cs | 155 +- .../Types/Mapping/MatchOnlyTextProperty.g.cs | 67 +- .../Types/Mapping/Murmur3HashProperty.g.cs | 122 +- .../Types/Mapping/NestedProperty.g.cs | 144 +- .../Types/Mapping/ObjectProperty.g.cs | 133 +- .../Mapping/PassthroughObjectProperty.g.cs | 144 +- .../Types/Mapping/PointProperty.g.cs | 155 +- .../_Generated/Types/Mapping/Properties.g.cs | 391 ++-- .../Mapping/RuntimeFieldFetchFields.g.cs | 52 +- .../Mapping/ScaledFloatNumberProperty.g.cs | 232 +- .../Mapping/SearchAsYouTypeProperty.g.cs | 210 +- .../Types/Mapping/ShapeProperty.g.cs | 166 +- .../Types/Mapping/ShortNumberProperty.g.cs | 221 +- .../Types/Mapping/TextProperty.g.cs | 276 ++- .../Types/Mapping/TokenCountProperty.g.cs | 177 +- .../Mapping/UnsignedLongNumberProperty.g.cs | 221 +- .../Types/Mapping/VersionProperty.g.cs | 122 +- .../Types/Mapping/WildcardProperty.g.cs | 133 +- .../Types/Nodes/NodeInfoDiscover.g.cs | 85 +- .../_Generated/Types/Nodes/NodeInfoPath.g.cs | 69 +- .../Types/Nodes/NodeInfoSettingsHttpType.g.cs | 41 +- .../Types/Nodes/NodeInfoSettingsNetwork.g.cs | 36 +- .../Nodes/NodeInfoSettingsTransportType.g.cs | 41 +- .../_Generated/Types/Nodes/NodeJvmInfo.g.cs | 224 +- .../_Generated/Types/Nodes/Stats.g.cs | 268 ++- .../_Generated/Types/QueryDsl/BoolQuery.g.cs | 105 +- .../Types/QueryDsl/CombinedFieldsQuery.g.cs | 113 +- .../Types/QueryDsl/DateDecayFunction.g.cs | 69 +- .../QueryDsl/DateDistanceFeatureQuery.g.cs | 5 +- .../Types/QueryDsl/DateRangeQuery.g.cs | 227 +- .../Types/QueryDsl/DecayFunction.g.cs | 63 + .../Types/QueryDsl/DecayPlacement.g.cs | 88 +- .../Types/QueryDsl/DistanceFeatureQuery.g.cs | 60 + .../Types/QueryDsl/FieldAndFormat.g.cs | 63 +- .../Types/QueryDsl/FunctionScore.g.cs | 185 +- .../Types/QueryDsl/FunctionScoreQuery.g.cs | 118 +- .../_Generated/Types/QueryDsl/FuzzyQuery.g.cs | 208 +- .../Types/QueryDsl/GeoBoundingBoxQuery.g.cs | 123 +- .../Types/QueryDsl/GeoDecayFunction.g.cs | 69 +- .../QueryDsl/GeoDistanceFeatureQuery.g.cs | 5 +- .../Types/QueryDsl/GeoDistanceQuery.g.cs | 159 +- .../Types/QueryDsl/GeoShapeQuery.g.cs | 103 +- .../_Generated/Types/QueryDsl/Intervals.g.cs | 141 +- .../Types/QueryDsl/IntervalsFilter.g.cs | 183 +- .../Types/QueryDsl/IntervalsQuery.g.cs | 192 +- .../Types/QueryDsl/LikeDocument.g.cs | 113 +- .../Types/QueryDsl/MatchBoolPrefixQuery.g.cs | 272 ++- .../QueryDsl/MatchPhrasePrefixQuery.g.cs | 188 +- .../Types/QueryDsl/MatchPhraseQuery.g.cs | 168 +- .../_Generated/Types/QueryDsl/MatchQuery.g.cs | 334 ++- .../Types/QueryDsl/MoreLikeThisQuery.g.cs | 248 ++- .../Types/QueryDsl/MultiMatchQuery.g.cs | 223 +- .../Types/QueryDsl/NumberRangeQuery.g.cs | 187 +- .../Types/QueryDsl/NumericDecayFunction.g.cs | 69 +- .../Types/QueryDsl/PinnedQuery.g.cs | 136 +- .../Types/QueryDsl/PrefixQuery.g.cs | 148 +- .../_Generated/Types/QueryDsl/Query.g.cs | 847 ++++--- .../Types/QueryDsl/QueryStringQuery.g.cs | 322 ++- .../_Generated/Types/QueryDsl/RangeQuery.g.cs | 63 + .../Types/QueryDsl/RegexpQuery.g.cs | 188 +- .../_Generated/Types/QueryDsl/ShapeQuery.g.cs | 103 +- .../QueryDsl/SimpleQueryStringQuery.g.cs | 190 +- .../_Generated/Types/QueryDsl/SpanQuery.g.cs | 197 +- .../Types/QueryDsl/SpanTermQuery.g.cs | 104 +- .../Types/QueryDsl/SparseVectorQuery.g.cs | 170 +- .../_Generated/Types/QueryDsl/TermQuery.g.cs | 129 +- .../Types/QueryDsl/TermRangeQuery.g.cs | 187 +- .../_Generated/Types/QueryDsl/TermsQuery.g.cs | 83 +- .../Types/QueryDsl/TermsSetQuery.g.cs | 165 +- .../Types/QueryDsl/UntypedDecayFunction.g.cs | 69 +- .../QueryDsl/UntypedDistanceFeatureQuery.g.cs | 5 +- .../Types/QueryDsl/UntypedRangeQuery.g.cs | 227 +- .../Types/QueryDsl/WildcardQuery.g.cs | 170 +- .../Types/QueryRules/QueryRule.g.cs | 80 +- .../_Generated/Types/QueryVectorBuilder.g.cs | 71 +- .../_Generated/Types/RRFRetriever.g.cs | 80 +- .../_Generated/Types/Rank.g.cs | 71 +- .../_Generated/Types/Retriever.g.cs | 127 +- .../Types/Rollup/HistogramGrouping.g.cs | 47 +- .../Types/Rollup/RollupCapabilitySummary.g.cs | 1 - .../Types/Rollup/RollupJobSummary.g.cs | 1 - .../Types/Rollup/TermsGrouping.g.cs | 36 +- .../_Generated/Types/RuleRetriever.g.cs | 91 +- .../_Generated/Types/Script.g.cs | 85 +- .../SearchableSnapshots/MountedSnapshot.g.cs | 58 +- .../Types/Security/ApiKeyAggregation.g.cs | 219 +- .../Types/Security/ApiKeyQuery.g.cs | 214 +- .../_Generated/Types/Security/FieldRule.g.cs | 99 +- .../Types/Security/FieldSecurity.g.cs | 48 +- .../Types/Security/GrantApiKey.g.cs | 69 +- .../Types/Security/IndicesPrivileges.g.cs | 80 +- .../_Generated/Types/Security/QueryRole.g.cs | 241 +- .../Security/RemoteIndicesPrivileges.g.cs | 91 +- .../Types/Security/ReplicationAccess.g.cs | 47 +- .../Types/Security/RoleDescriptor.g.cs | 250 +-- .../Types/Security/RoleDescriptorRead.g.cs | 207 +- .../Types/Security/RoleMappingRule.g.cs | 113 +- .../_Generated/Types/Security/RoleQuery.g.cs | 214 +- .../Types/Security/SearchAccess.g.cs | 69 +- .../Types/Security/UserIndicesPrivileges.g.cs | 80 +- .../_Generated/Types/Security/UserQuery.g.cs | 214 +- .../Types/Snapshot/InfoFeatureState.g.cs | 47 +- .../Types/Snapshot/Repositories.g.cs | 84 +- .../Types/Snapshot/SnapshotInfo.g.cs | 1 - .../SourceOnlyRepositorySettings.g.cs | 162 +- .../Statistics.g.cs | 193 +- .../Types/SpecUtils/OverloadOf.g.cs | 39 + .../_Generated/Types/StandardRetriever.g.cs | 103 +- .../Types/TextSimilarityReranker.g.cs | 102 +- .../Types/TransformManagement/Latest.g.cs | 47 +- .../Types/TransformManagement/Pivot.g.cs | 62 +- .../TransformManagement/PivotGroupBy.g.cs | 113 +- .../TransformManagement/RetentionPolicy.g.cs | 71 +- .../Types/TransformManagement/Sync.g.cs | 71 +- .../_Shared/Api/GetSourceResponse.cs | 24 +- .../_Shared/Api/IndexRequest.cs | 2 - .../_Shared/Api/SearchRequest.cs | 1 + .../_Shared/Core/IEnumStruct.cs | 11 - .../_Shared/Core/Infer/Field/Field.cs | 64 +- .../Core/Infer/Field/FieldConverter.cs | 96 +- .../_Shared/Core/Infer/Fields/Fields.cs | 80 +- .../Core/Infer/Fields/FieldsConverter.cs | 107 +- .../_Shared/Core/ReadOnlyFieldDictionary.cs | 56 - .../Core/ReadOnlyIndexNameDictionary.cs | 56 - .../_Shared/Core/Request/Request.cs | 13 +- .../_Shared/Core/Static/Infer.cs | 17 +- .../_Shared/CrossPlatform/IsExternalInit.cs | 20 - .../CrossPlatform/NullableAttributes.cs | 142 -- .../_Shared/CrossPlatform/TypeExtensions.cs | 30 - .../_Shared/Next/ContextProvider.cs | 99 + .../DoubleWithFractionalPortionConverter.cs | 107 + .../_Shared/Next/DynamicallyAccessed.cs | 30 + .../EnumStructConverter.cs | 28 +- .../IEnumStruct.cs} | 18 +- .../_Shared/Next/IMarkerTypeConverter.cs | 18 + .../_Shared/Next/JsonReaderExtensions.cs | 174 ++ .../Next/JsonSerializerOptionsExtensions.cs | 35 + .../_Shared/Next/JsonWriterExtensions.cs | 115 + .../_Shared/Next/LocalJsonValue.cs | 42 + .../ObjectToInferredTypesConverter.cs | 24 +- .../_Shared/Next/RequestResponseConverter.cs | 29 + .../_Shared/Next/SingleOrManyConverter.cs | 121 + .../Next/SingleOrManyDictionaryConverter.cs | 109 + .../SingleWithFractionalPortionConverter.cs | 107 + .../_Shared/Next/SourceConverter.cs | 91 + .../_Shared/Next/StringifiedConverters.cs | 100 + .../DefaultRequestResponseSerializer.cs | 18 +- .../Serialization/DefaultSourceSerializer.cs | 3 +- .../DoubleWithFractionalPortionConverter.cs | 122 - .../GenericConverterAttribute.cs | 79 - .../_Shared/Serialization/ISourceMarker.cs | 7 - .../Serialization/InterfaceConverter.cs | 19 - .../IntermediateSourceConverter.cs | 35 - .../_Shared/Serialization/JsonConstants.cs | 41 - .../_Shared/Serialization/JsonHelper.cs | 24 - .../JsonSerializerOptionsExtensions.cs | 10 +- .../Serialization/NumericAliasConverter.cs | 30 - .../ReadOnlyFieldDictionaryConverter.cs | 38 - .../ReadOnlyIndexNameDictionaryConverter.cs | 38 - ...vableReadonlyDictionaryConverterFactory.cs | 72 - .../_Shared/Serialization/SelfSerializable.cs | 9 - .../SelfSerializableConverterFactory.cs | 33 +- .../Serialization/SimpleInterfaceConverter.cs | 18 - .../SingleOrManyCollectionAttribute.cs | 18 - .../SingleOrManyCollectionConverter.cs | 21 - .../SingleWithFractionalPortionConverter.cs | 122 - .../_Shared/Serialization/SourceConverter.cs | 25 - .../Serialization/SourceConverterAttribute.cs | 13 - .../Serialization/SourceConverterFactory.cs | 31 - .../_Shared/Serialization/SourceMarker.cs | 10 - .../_Shared/Serialization/Stringified.cs | 90 - .../TermsAggregateSerializationHelper.cs | 110 - .../_Shared/Temp.cs | 102 + .../_Shared/Types/FieldSort.cs | 131 -- .../_Shared/Types/QueryDsl/FunctionScore.cs | 2 - src/Playground/Playground.csproj | 2 +- 1133 files changed, 64866 insertions(+), 21997 deletions(-) create mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Core/IEnumStruct.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Core/ReadOnlyFieldDictionary.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Core/ReadOnlyIndexNameDictionary.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/CrossPlatform/IsExternalInit.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/CrossPlatform/NullableAttributes.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/CrossPlatform/TypeExtensions.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/ContextProvider.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/DoubleWithFractionalPortionConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/DynamicallyAccessed.cs rename src/Elastic.Clients.Elasticsearch/_Shared/{Serialization => Next}/EnumStructConverter.cs (59%) rename src/Elastic.Clients.Elasticsearch/_Shared/{Serialization/InterfaceConverterAttribute.cs => Next/IEnumStruct.cs} (52%) create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/IMarkerTypeConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/JsonReaderExtensions.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/JsonSerializerOptionsExtensions.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/JsonWriterExtensions.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/LocalJsonValue.cs rename src/Elastic.Clients.Elasticsearch/_Shared/{Serialization => Next}/ObjectToInferredTypesConverter.cs (59%) create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/RequestResponseConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/SingleOrManyConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/SingleOrManyDictionaryConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/SingleWithFractionalPortionConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/SourceConverter.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Next/StringifiedConverters.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/DoubleWithFractionalPortionConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/GenericConverterAttribute.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ISourceMarker.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/InterfaceConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/IntermediateSourceConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/JsonConstants.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/JsonHelper.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/NumericAliasConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ReadOnlyFieldDictionaryConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ReadOnlyIndexNameDictionaryConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/ResolvableReadonlyDictionaryConverterFactory.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SimpleInterfaceConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SingleOrManyCollectionAttribute.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SingleOrManyCollectionConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SingleWithFractionalPortionConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SourceConverter.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SourceConverterAttribute.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SourceConverterFactory.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/SourceMarker.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/Stringified.cs delete mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Serialization/TermsAggregateSerializationHelper.cs create mode 100644 src/Elastic.Clients.Elasticsearch/_Shared/Temp.cs diff --git a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj index d21f64b5921..111c0c9bdce 100644 --- a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj +++ b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj @@ -16,9 +16,14 @@ true true annotations + true + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs index ed385a30bf7..2bb7a2d0e9a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs @@ -64,6 +64,14 @@ public AsyncSearchStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override string OperationName => "async_search.status"; + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies how long the async search needs to be available. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs index 126481dc53a..f7c967ea50f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs @@ -22,10 +22,156 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class AsyncSearchStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override AsyncSearchStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusters = default; + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propShards = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AsyncSearchStatusResponse + { + Clusters = propClusters.Value +, + CompletionStatus = propCompletionStatus.Value +, + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Shards = propShards.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AsyncSearchStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AsyncSearchStatusResponseConverter))] public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse { /// @@ -34,7 +180,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Not shown for local-only searches. /// /// - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } /// @@ -44,7 +189,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// 503 indicates that the async search was completed with an error. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -53,9 +197,7 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -63,11 +205,8 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -76,7 +215,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -85,7 +223,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -93,10 +230,7 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse /// Indicates how many shards have run the query so far. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs index e59001fda74..a530d5fd198 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs @@ -57,6 +57,14 @@ public DeleteAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "async_search.delete"; + + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs index ea208db9469..e1bf1d1743f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class DeleteAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAsyncSearchResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncSearchResponseConverter))] public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs index c2884fe1b43..c109e997696 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs @@ -83,6 +83,14 @@ public GetAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override string OperationName => "async_search.get"; + /// + /// + /// A unique identifier for the async search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies how long the async search should be available in the cluster. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs index 3dd949e280f..b70544edbfb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchResponse.g.cs @@ -22,10 +22,153 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class GetAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue> propResponse = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propResponse.TryRead(ref reader, options, PropResponse)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncSearchResponse + { + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Response = propResponse.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropResponse, value.Response); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetAsyncSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetAsyncSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetAsyncSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetAsyncSearchResponseConverterFactory))] public sealed partial class GetAsyncSearchResponse : ElasticsearchResponse { /// @@ -34,9 +177,7 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -44,11 +185,8 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -57,7 +195,6 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -66,12 +203,8 @@ public sealed partial class GetAsyncSearchResponse : ElasticsearchRes /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } - [JsonInclude, JsonPropertyName("response")] public Elastic.Clients.Elasticsearch.AsyncSearch.AsyncSearch Response { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs index db47e9c2ee2..886fd6100e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs @@ -231,410 +231,346 @@ public sealed partial class SubmitAsyncSearchRequestParameters : RequestParamete public Elastic.Clients.Elasticsearch.Duration? WaitForCompletionTimeout { get => Q("wait_for_completion_timeout"); set => Q("wait_for_completion_timeout", value); } } -internal sealed partial class SubmitAsyncSearchRequestConverter : JsonConverter +internal sealed partial class SubmitAsyncSearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override SubmitAsyncSearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SubmitAsyncSearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SubmitAsyncSearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slice") - { - variant.Slice = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, SubmitAsyncSearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SubmitAsyncSearchRequest + { + Aggregations = propAggregations.Value + , + Collapse = propCollapse.Value + , + DocvalueFields = propDocvalueFields.Value + , + Explain = propExplain.Value + , + Ext = propExt.Value + , + Fields = propFields.Value + , + From = propFrom.Value + , + Highlight = propHighlight.Value + , + IndicesBoost = propIndicesBoost.Value + , + Knn = propKnn.Value + , + MinScore = propMinScore.Value + , + Pit = propPit.Value + , + PostFilter = propPostFilter.Value + , + Profile = propProfile.Value + , + Query = propQuery.Value + , + Rescore = propRescore.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + SearchAfter = propSearchAfter.Value + , + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value + , + Size = propSize.Value + , + Slice = propSlice.Value + , + Sort = propSort.Value + , + Source = propSource.Value + , + Stats = propStats.Value + , + StoredFields = propStoredFields.Value + , + Suggest = propSuggest.Value + , + TerminateAfter = propTerminateAfter.Value + , + Timeout = propTimeout.Value + , + TrackScores = propTrackScores.Value + , + TrackTotalHits = propTrackTotalHits.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SubmitAsyncSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRescore, value.Rescore, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } @@ -673,12 +609,18 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) internal override string OperationName => "async_search.submit"; + /// + /// + /// A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -686,7 +628,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Indicate if an error should be returned if there is a partial search failure or timeout /// /// - [JsonIgnore] public bool? AllowPartialSearchResults { get => Q("allow_partial_search_results"); set => Q("allow_partial_search_results", value); } /// @@ -694,7 +635,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The analyzer to use for the query string /// /// - [JsonIgnore] public string? Analyzer { get => Q("analyzer"); set => Q("analyzer", value); } /// @@ -702,7 +642,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify whether wildcard and prefix queries should be analyzed (default: false) /// /// - [JsonIgnore] public bool? AnalyzeWildcard { get => Q("analyze_wildcard"); set => Q("analyze_wildcard", value); } /// @@ -711,7 +650,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default). /// /// - [JsonIgnore] public long? BatchedReduceSize { get => Q("batched_reduce_size"); set => Q("batched_reduce_size", value); } /// @@ -719,7 +657,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The default value is the only supported value. /// /// - [JsonIgnore] public bool? CcsMinimizeRoundtrips { get => Q("ccs_minimize_roundtrips"); set => Q("ccs_minimize_roundtrips", value); } /// @@ -727,7 +664,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The default operator for query string query (AND or OR) /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -735,7 +671,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The field to use as default where no field prefix is given in the query string /// /// - [JsonIgnore] public string? Df { get => Q("df"); set => Q("df", value); } /// @@ -743,7 +678,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Whether to expand wildcard expression to concrete indices that are open, closed or both. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -751,7 +685,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Whether specified concrete, expanded or aliased indices should be ignored when throttled /// /// - [JsonIgnore] public bool? IgnoreThrottled { get => Q("ignore_throttled"); set => Q("ignore_throttled", value); } /// @@ -759,7 +692,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Whether specified concrete indices should be ignored when unavailable (missing or closed) /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -767,7 +699,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, results are stored for later retrieval when the search completes within the wait_for_completion_timeout. /// /// - [JsonIgnore] public bool? KeepOnCompletion { get => Q("keep_on_completion"); set => Q("keep_on_completion", value); } /// @@ -775,7 +706,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify whether format-based query failures (such as providing text to a numeric field) should be ignored /// /// - [JsonIgnore] public bool? Lenient { get => Q("lenient"); set => Q("lenient", value); } /// @@ -783,7 +713,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests /// /// - [JsonIgnore] public long? MaxConcurrentShardRequests { get => Q("max_concurrent_shard_requests"); set => Q("max_concurrent_shard_requests", value); } /// @@ -791,7 +720,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify the node or shard the operation should be performed on (default: random) /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -799,7 +727,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Query in the Lucene query string syntax /// /// - [JsonIgnore] public string? QueryLuceneSyntax { get => Q("q"); set => Q("q", value); } /// @@ -807,7 +734,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify if request cache should be used for this request or not, defaults to true /// /// - [JsonIgnore] public bool? RequestCache { get => Q("request_cache"); set => Q("request_cache", value); } /// @@ -815,7 +741,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Indicates whether hits.total should be rendered as an integer or an object in the rest search response /// /// - [JsonIgnore] public bool? RestTotalHitsAsInt { get => Q("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); } /// @@ -823,7 +748,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A comma-separated list of specific routing values /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -831,7 +755,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Search operation type /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -839,7 +762,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A list of fields to exclude from the returned _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -847,7 +769,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// A list of fields to extract and return from the _source field /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -855,7 +776,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -863,7 +783,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify suggest mode /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -871,7 +790,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// How many suggestions to return in response /// /// - [JsonIgnore] public long? SuggestSize { get => Q("suggest_size"); set => Q("suggest_size", value); } /// @@ -879,7 +797,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// The source text for which the suggestions should be returned. /// /// - [JsonIgnore] public string? SuggestText { get => Q("suggest_text"); set => Q("suggest_text", value); } /// @@ -887,7 +804,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Specify whether aggregation and suggester names should be prefixed by their respective types in the response /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -896,11 +812,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// When the async search completes within the timeout, the response won’t include the ID as the results are not stored in the cluster. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? WaitForCompletionTimeout { get => Q("wait_for_completion_timeout"); set => Q("wait_for_completion_timeout", value); } - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -909,7 +822,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -917,7 +829,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -925,7 +836,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -934,7 +844,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -944,9 +853,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } /// @@ -954,7 +861,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -962,8 +868,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -972,7 +876,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -981,11 +884,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; set; } - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; set; } - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -993,10 +893,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("rescore")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1005,7 +902,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1013,9 +909,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Retrieve a script evaluation (based on different fields) for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -1024,7 +918,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// of each hit. See Optimistic concurrency control. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -1034,12 +927,8 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1048,7 +937,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -1058,7 +946,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1069,10 +956,7 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// and stored fields in the search response. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; set; } /// @@ -1082,7 +966,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// before sorting. Defaults to 0, which does not terminate query execution early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1092,7 +975,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1100,7 +982,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, calculate and return document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -1111,7 +992,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// Defaults to 10,000 hits. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1119,7 +999,6 @@ public SubmitAsyncSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs index 1eaf8d1c848..530dbcf43ac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchResponse.g.cs @@ -22,10 +22,153 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class SubmitAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time"); + private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override SubmitAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompletionTime = default; + LocalJsonValue propCompletionTimeInMillis = default; + LocalJsonValue propExpirationTime = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue> propResponse = default; + LocalJsonValue propStartTime = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime)) + { + continue; + } + + if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis)) + { + continue; + } + + if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propResponse.TryRead(ref reader, options, PropResponse)) + { + continue; + } + + if (propStartTime.TryRead(ref reader, options, PropStartTime)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SubmitAsyncSearchResponse + { + CompletionTime = propCompletionTime.Value +, + CompletionTimeInMillis = propCompletionTimeInMillis.Value +, + ExpirationTime = propExpirationTime.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + Response = propResponse.Value +, + StartTime = propStartTime.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SubmitAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionTime, value.CompletionTime); + writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis); + writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropResponse, value.Response); + writer.WriteProperty(options, PropStartTime, value.StartTime); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +internal sealed partial class SubmitAsyncSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SubmitAsyncSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SubmitAsyncSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SubmitAsyncSearchResponseConverterFactory))] public sealed partial class SubmitAsyncSearchResponse : ElasticsearchResponse { /// @@ -34,9 +177,7 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// when the search has completed. /// /// - [JsonInclude, JsonPropertyName("completion_time")] public DateTimeOffset? CompletionTime { get; init; } - [JsonInclude, JsonPropertyName("completion_time_in_millis")] public long? CompletionTimeInMillis { get; init; } /// @@ -44,11 +185,8 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// Indicates when the async search will expire. /// /// - [JsonInclude, JsonPropertyName("expiration_time")] public DateTimeOffset? ExpirationTime { get; init; } - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -57,7 +195,6 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// While the query is running, is_partial is always set to true. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -66,12 +203,8 @@ public sealed partial class SubmitAsyncSearchResponse : Elasticsearch /// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though is_running is false. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } - [JsonInclude, JsonPropertyName("response")] public Elastic.Clients.Elasticsearch.AsyncSearch.AsyncSearch Response { get; init; } - [JsonInclude, JsonPropertyName("start_time")] public DateTimeOffset? StartTime { get; init; } - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs index 6e2ebd29f2a..31dccb5f39c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkRequest.g.cs @@ -139,6 +139,14 @@ public BulkRequest(Elastic.Clients.Elasticsearch.IndexName? index) : base(r => r internal override string OperationName => "bulk"; + /// + /// + /// Name of the data stream, index, or index alias to perform bulk actions on. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// If true, the response will include the ingest pipelines that were executed for each index or create. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs index a2c342a8ee7..78bb05e5a14 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/BulkResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class BulkResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropIngestTook = System.Text.Json.JsonEncodedText.Encode("ingest_took"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override BulkResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propErrors = default; + LocalJsonValue propIngestTook = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propIngestTook.TryRead(ref reader, options, PropIngestTook)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkResponse + { + Errors = propErrors.Value +, + IngestTook = propIngestTook.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropIngestTook, value.IngestTook); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkResponseConverter))] public sealed partial class BulkResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("errors")] public bool Errors { get; init; } - [JsonInclude, JsonPropertyName("ingest_took")] public long? IngestTook { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs index 29bfde63e45..c71e3721a05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClearScrollResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ClearScrollResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNumFreed = System.Text.Json.JsonEncodedText.Encode("num_freed"); + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClearScrollResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNumFreed = default; + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryRead(ref reader, options, PropNumFreed)) + { + continue; + } + + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearScrollResponse + { + NumFreed = propNumFreed.Value +, + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearScrollResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNumFreed, value.NumFreed); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearScrollResponseConverter))] public sealed partial class ClearScrollResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("num_freed")] public int NumFreed { get; init; } - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs index 1fdf5b5b3ae..3da6ee8aa37 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ClosePointInTimeResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ClosePointInTimeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNumFreed = System.Text.Json.JsonEncodedText.Encode("num_freed"); + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClosePointInTimeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNumFreed = default; + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNumFreed.TryRead(ref reader, options, PropNumFreed)) + { + continue; + } + + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClosePointInTimeResponse + { + NumFreed = propNumFreed.Value +, + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClosePointInTimeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNumFreed, value.NumFreed); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClosePointInTimeResponseConverter))] public sealed partial class ClosePointInTimeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("num_freed")] public int NumFreed { get; init; } - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs index a17abac6f3c..1bdfc85cca3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/AllocationExplainResponse.g.cs @@ -22,60 +22,311 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class AllocationExplainResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllocateExplanation = System.Text.Json.JsonEncodedText.Encode("allocate_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationDelay = System.Text.Json.JsonEncodedText.Encode("allocation_delay"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationDelayInMillis = System.Text.Json.JsonEncodedText.Encode("allocation_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropCanAllocate = System.Text.Json.JsonEncodedText.Encode("can_allocate"); + private static readonly System.Text.Json.JsonEncodedText PropCanMoveToOtherNode = System.Text.Json.JsonEncodedText.Encode("can_move_to_other_node"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceCluster = System.Text.Json.JsonEncodedText.Encode("can_rebalance_cluster"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceClusterDecisions = System.Text.Json.JsonEncodedText.Encode("can_rebalance_cluster_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropCanRebalanceToOtherNode = System.Text.Json.JsonEncodedText.Encode("can_rebalance_to_other_node"); + private static readonly System.Text.Json.JsonEncodedText PropCanRemainDecisions = System.Text.Json.JsonEncodedText.Encode("can_remain_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropCanRemainOnCurrentNode = System.Text.Json.JsonEncodedText.Encode("can_remain_on_current_node"); + private static readonly System.Text.Json.JsonEncodedText PropClusterInfo = System.Text.Json.JsonEncodedText.Encode("cluster_info"); + private static readonly System.Text.Json.JsonEncodedText PropConfiguredDelay = System.Text.Json.JsonEncodedText.Encode("configured_delay"); + private static readonly System.Text.Json.JsonEncodedText PropConfiguredDelayInMillis = System.Text.Json.JsonEncodedText.Encode("configured_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropCurrentNode = System.Text.Json.JsonEncodedText.Encode("current_node"); + private static readonly System.Text.Json.JsonEncodedText PropCurrentState = System.Text.Json.JsonEncodedText.Encode("current_state"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMoveExplanation = System.Text.Json.JsonEncodedText.Encode("move_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropNodeAllocationDecisions = System.Text.Json.JsonEncodedText.Encode("node_allocation_decisions"); + private static readonly System.Text.Json.JsonEncodedText PropNote = System.Text.Json.JsonEncodedText.Encode("note"); + private static readonly System.Text.Json.JsonEncodedText PropPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + private static readonly System.Text.Json.JsonEncodedText PropRebalanceExplanation = System.Text.Json.JsonEncodedText.Encode("rebalance_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropRemainingDelay = System.Text.Json.JsonEncodedText.Encode("remaining_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRemainingDelayInMillis = System.Text.Json.JsonEncodedText.Encode("remaining_delay_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropShard = System.Text.Json.JsonEncodedText.Encode("shard"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedInfo = System.Text.Json.JsonEncodedText.Encode("unassigned_info"); + + public override AllocationExplainResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllocateExplanation = default; + LocalJsonValue propAllocationDelay = default; + LocalJsonValue propAllocationDelayInMillis = default; + LocalJsonValue propCanAllocate = default; + LocalJsonValue propCanMoveToOtherNode = default; + LocalJsonValue propCanRebalanceCluster = default; + LocalJsonValue?> propCanRebalanceClusterDecisions = default; + LocalJsonValue propCanRebalanceToOtherNode = default; + LocalJsonValue?> propCanRemainDecisions = default; + LocalJsonValue propCanRemainOnCurrentNode = default; + LocalJsonValue propClusterInfo = default; + LocalJsonValue propConfiguredDelay = default; + LocalJsonValue propConfiguredDelayInMillis = default; + LocalJsonValue propCurrentNode = default; + LocalJsonValue propCurrentState = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMoveExplanation = default; + LocalJsonValue?> propNodeAllocationDecisions = default; + LocalJsonValue propNote = default; + LocalJsonValue propPrimary = default; + LocalJsonValue propRebalanceExplanation = default; + LocalJsonValue propRemainingDelay = default; + LocalJsonValue propRemainingDelayInMillis = default; + LocalJsonValue propShard = default; + LocalJsonValue propUnassignedInfo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllocateExplanation.TryRead(ref reader, options, PropAllocateExplanation)) + { + continue; + } + + if (propAllocationDelay.TryRead(ref reader, options, PropAllocationDelay)) + { + continue; + } + + if (propAllocationDelayInMillis.TryRead(ref reader, options, PropAllocationDelayInMillis)) + { + continue; + } + + if (propCanAllocate.TryRead(ref reader, options, PropCanAllocate)) + { + continue; + } + + if (propCanMoveToOtherNode.TryRead(ref reader, options, PropCanMoveToOtherNode)) + { + continue; + } + + if (propCanRebalanceCluster.TryRead(ref reader, options, PropCanRebalanceCluster)) + { + continue; + } + + if (propCanRebalanceClusterDecisions.TryRead(ref reader, options, PropCanRebalanceClusterDecisions)) + { + continue; + } + + if (propCanRebalanceToOtherNode.TryRead(ref reader, options, PropCanRebalanceToOtherNode)) + { + continue; + } + + if (propCanRemainDecisions.TryRead(ref reader, options, PropCanRemainDecisions)) + { + continue; + } + + if (propCanRemainOnCurrentNode.TryRead(ref reader, options, PropCanRemainOnCurrentNode)) + { + continue; + } + + if (propClusterInfo.TryRead(ref reader, options, PropClusterInfo)) + { + continue; + } + + if (propConfiguredDelay.TryRead(ref reader, options, PropConfiguredDelay)) + { + continue; + } + + if (propConfiguredDelayInMillis.TryRead(ref reader, options, PropConfiguredDelayInMillis)) + { + continue; + } + + if (propCurrentNode.TryRead(ref reader, options, PropCurrentNode)) + { + continue; + } + + if (propCurrentState.TryRead(ref reader, options, PropCurrentState)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMoveExplanation.TryRead(ref reader, options, PropMoveExplanation)) + { + continue; + } + + if (propNodeAllocationDecisions.TryRead(ref reader, options, PropNodeAllocationDecisions)) + { + continue; + } + + if (propNote.TryRead(ref reader, options, PropNote)) + { + continue; + } + + if (propPrimary.TryRead(ref reader, options, PropPrimary)) + { + continue; + } + + if (propRebalanceExplanation.TryRead(ref reader, options, PropRebalanceExplanation)) + { + continue; + } + + if (propRemainingDelay.TryRead(ref reader, options, PropRemainingDelay)) + { + continue; + } + + if (propRemainingDelayInMillis.TryRead(ref reader, options, PropRemainingDelayInMillis)) + { + continue; + } + + if (propShard.TryRead(ref reader, options, PropShard)) + { + continue; + } + + if (propUnassignedInfo.TryRead(ref reader, options, PropUnassignedInfo)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AllocationExplainResponse + { + AllocateExplanation = propAllocateExplanation.Value +, + AllocationDelay = propAllocationDelay.Value +, + AllocationDelayInMillis = propAllocationDelayInMillis.Value +, + CanAllocate = propCanAllocate.Value +, + CanMoveToOtherNode = propCanMoveToOtherNode.Value +, + CanRebalanceCluster = propCanRebalanceCluster.Value +, + CanRebalanceClusterDecisions = propCanRebalanceClusterDecisions.Value +, + CanRebalanceToOtherNode = propCanRebalanceToOtherNode.Value +, + CanRemainDecisions = propCanRemainDecisions.Value +, + CanRemainOnCurrentNode = propCanRemainOnCurrentNode.Value +, + ClusterInfo = propClusterInfo.Value +, + ConfiguredDelay = propConfiguredDelay.Value +, + ConfiguredDelayInMillis = propConfiguredDelayInMillis.Value +, + CurrentNode = propCurrentNode.Value +, + CurrentState = propCurrentState.Value +, + Index = propIndex.Value +, + MoveExplanation = propMoveExplanation.Value +, + NodeAllocationDecisions = propNodeAllocationDecisions.Value +, + Note = propNote.Value +, + Primary = propPrimary.Value +, + RebalanceExplanation = propRebalanceExplanation.Value +, + RemainingDelay = propRemainingDelay.Value +, + RemainingDelayInMillis = propRemainingDelayInMillis.Value +, + Shard = propShard.Value +, + UnassignedInfo = propUnassignedInfo.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AllocationExplainResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllocateExplanation, value.AllocateExplanation); + writer.WriteProperty(options, PropAllocationDelay, value.AllocationDelay); + writer.WriteProperty(options, PropAllocationDelayInMillis, value.AllocationDelayInMillis); + writer.WriteProperty(options, PropCanAllocate, value.CanAllocate); + writer.WriteProperty(options, PropCanMoveToOtherNode, value.CanMoveToOtherNode); + writer.WriteProperty(options, PropCanRebalanceCluster, value.CanRebalanceCluster); + writer.WriteProperty(options, PropCanRebalanceClusterDecisions, value.CanRebalanceClusterDecisions); + writer.WriteProperty(options, PropCanRebalanceToOtherNode, value.CanRebalanceToOtherNode); + writer.WriteProperty(options, PropCanRemainDecisions, value.CanRemainDecisions); + writer.WriteProperty(options, PropCanRemainOnCurrentNode, value.CanRemainOnCurrentNode); + writer.WriteProperty(options, PropClusterInfo, value.ClusterInfo); + writer.WriteProperty(options, PropConfiguredDelay, value.ConfiguredDelay); + writer.WriteProperty(options, PropConfiguredDelayInMillis, value.ConfiguredDelayInMillis); + writer.WriteProperty(options, PropCurrentNode, value.CurrentNode); + writer.WriteProperty(options, PropCurrentState, value.CurrentState); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMoveExplanation, value.MoveExplanation); + writer.WriteProperty(options, PropNodeAllocationDecisions, value.NodeAllocationDecisions); + writer.WriteProperty(options, PropNote, value.Note); + writer.WriteProperty(options, PropPrimary, value.Primary); + writer.WriteProperty(options, PropRebalanceExplanation, value.RebalanceExplanation); + writer.WriteProperty(options, PropRemainingDelay, value.RemainingDelay); + writer.WriteProperty(options, PropRemainingDelayInMillis, value.RemainingDelayInMillis); + writer.WriteProperty(options, PropShard, value.Shard); + writer.WriteProperty(options, PropUnassignedInfo, value.UnassignedInfo); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AllocationExplainResponseConverter))] public sealed partial class AllocationExplainResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allocate_explanation")] public string? AllocateExplanation { get; init; } - [JsonInclude, JsonPropertyName("allocation_delay")] public Elastic.Clients.Elasticsearch.Duration? AllocationDelay { get; init; } - [JsonInclude, JsonPropertyName("allocation_delay_in_millis")] public long? AllocationDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("can_allocate")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanAllocate { get; init; } - [JsonInclude, JsonPropertyName("can_move_to_other_node")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanMoveToOtherNode { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_cluster")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanRebalanceCluster { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_cluster_decisions")] public IReadOnlyCollection? CanRebalanceClusterDecisions { get; init; } - [JsonInclude, JsonPropertyName("can_rebalance_to_other_node")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanRebalanceToOtherNode { get; init; } - [JsonInclude, JsonPropertyName("can_remain_decisions")] public IReadOnlyCollection? CanRemainDecisions { get; init; } - [JsonInclude, JsonPropertyName("can_remain_on_current_node")] public Elastic.Clients.Elasticsearch.Cluster.Decision? CanRemainOnCurrentNode { get; init; } - [JsonInclude, JsonPropertyName("cluster_info")] public Elastic.Clients.Elasticsearch.Cluster.ClusterInfo? ClusterInfo { get; init; } - [JsonInclude, JsonPropertyName("configured_delay")] public Elastic.Clients.Elasticsearch.Duration? ConfiguredDelay { get; init; } - [JsonInclude, JsonPropertyName("configured_delay_in_millis")] public long? ConfiguredDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("current_node")] public Elastic.Clients.Elasticsearch.Cluster.CurrentNode? CurrentNode { get; init; } - [JsonInclude, JsonPropertyName("current_state")] public string CurrentState { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("move_explanation")] public string? MoveExplanation { get; init; } - [JsonInclude, JsonPropertyName("node_allocation_decisions")] public IReadOnlyCollection? NodeAllocationDecisions { get; init; } - [JsonInclude, JsonPropertyName("note")] public string? Note { get; init; } - [JsonInclude, JsonPropertyName("primary")] public bool Primary { get; init; } - [JsonInclude, JsonPropertyName("rebalance_explanation")] public string? RebalanceExplanation { get; init; } - [JsonInclude, JsonPropertyName("remaining_delay")] public Elastic.Clients.Elasticsearch.Duration? RemainingDelay { get; init; } - [JsonInclude, JsonPropertyName("remaining_delay_in_millis")] public long? RemainingDelayInMillis { get; init; } - [JsonInclude, JsonPropertyName("shard")] public int Shard { get; init; } - [JsonInclude, JsonPropertyName("unassigned_info")] public Elastic.Clients.Elasticsearch.Cluster.UnassignedInformation? UnassignedInfo { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs index 64573f02d86..aa62823518e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoRequest.g.cs @@ -53,6 +53,14 @@ public ClusterInfoRequest(IReadOnlyCollection false; internal override string OperationName => "cluster.info"; + + /// + /// + /// Limits the information returned to the specific target. Supports a comma-separated list, such as http,ingest. + /// + /// + [JsonIgnore] + public ICollection Target { get => P>("target"); set => PR("target", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs index 3a0c28fa600..99a541a12d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterInfoResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class ClusterInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + + public override ClusterInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue propHttp = default; + LocalJsonValue propIngest = default; + LocalJsonValue propScript = default; + LocalJsonValue?> propThreadPool = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propHttp.TryRead(ref reader, options, PropHttp)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propThreadPool.TryRead(ref reader, options, PropThreadPool)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClusterInfoResponse + { + ClusterName = propClusterName.Value +, + Http = propHttp.Value +, + Ingest = propIngest.Value +, + Script = propScript.Value +, + ThreadPool = propThreadPool.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropHttp, value.Http); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClusterInfoResponseConverter))] public sealed partial class ClusterInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("http")] public Elastic.Clients.Elasticsearch.Nodes.Http? Http { get; init; } - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Nodes.Ingest? Ingest { get; init; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Nodes.Scripting? Script { get; init; } - [JsonInclude, JsonPropertyName("thread_pool")] public IReadOnlyDictionary? ThreadPool { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs index f9395e795b6..8f7fe43cd02 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsRequest.g.cs @@ -73,6 +73,14 @@ public ClusterStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base internal override string OperationName => "cluster.stats"; + /// + /// + /// Comma-separated list of node filters used to limit returned information. Defaults to all nodes in the cluster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Include remote cluster data into the response diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs index 75d8dfb2977..21f3d258e8b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ClusterStatsResponse.g.cs @@ -22,10 +22,106 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class ClusterStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropClusterUuid = System.Text.Json.JsonEncodedText.Encode("cluster_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTimestamp = System.Text.Json.JsonEncodedText.Encode("timestamp"); + + public override ClusterStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue propClusterUuid = default; + LocalJsonValue propIndices = default; + LocalJsonValue propNodes = default; + LocalJsonValue propNodeStats = default; + LocalJsonValue propStatus = default; + LocalJsonValue propTimestamp = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propClusterUuid.TryRead(ref reader, options, PropClusterUuid)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTimestamp.TryRead(ref reader, options, PropTimestamp)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClusterStatsResponse + { + ClusterName = propClusterName.Value +, + ClusterUuid = propClusterUuid.Value +, + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value +, + Status = propStatus.Value +, + Timestamp = propTimestamp.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTimestamp, value.Timestamp); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClusterStatsResponseConverter))] public sealed partial class ClusterStatsResponse : ElasticsearchResponse { /// @@ -33,7 +129,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Name of the cluster, based on the cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +136,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Unique identifier for the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } /// @@ -49,7 +143,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about indices with shards assigned to selected nodes. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Cluster.ClusterIndices Indices { get; init; } /// @@ -57,7 +150,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("nodes")] public Elastic.Clients.Elasticsearch.Cluster.ClusterNodes Nodes { get; init; } /// @@ -65,7 +157,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } /// @@ -73,7 +164,6 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Health status of the cluster, based on the state of its primary and replica shards. /// /// - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.HealthStatus Status { get; init; } /// @@ -81,6 +171,5 @@ public sealed partial class ClusterStatsResponse : ElasticsearchResponse /// Unix timestamp, in milliseconds, for the last time the cluster statistics were refreshed. /// /// - [JsonInclude, JsonPropertyName("timestamp")] public long Timestamp { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs index b0db2cd21b4..5c94f9cdd92 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateRequest.g.cs @@ -70,6 +70,14 @@ public DeleteComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) internal override string OperationName => "cluster.delete_component_template"; + /// + /// + /// Comma-separated list or wildcard expression of component template names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs index 7f8b65c9cbe..50949432619 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/DeleteComponentTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class DeleteComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteComponentTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteComponentTemplateResponseConverter))] public sealed partial class DeleteComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteComponentTemplateResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs index 8f2da988a43..cbbe6ac6c5e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/ExistsComponentTemplateRequest.g.cs @@ -70,6 +70,15 @@ public ExistsComponentTemplateRequest(Elastic.Clients.Elasticsearch.Names name) internal override string OperationName => "cluster.exists_component_template"; + /// + /// + /// Comma-separated list of component template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, the request retrieves information from the local node only. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs index febb734d698..c3ad702de8b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetClusterSettingsResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class GetClusterSettingsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefaults = System.Text.Json.JsonEncodedText.Encode("defaults"); + private static readonly System.Text.Json.JsonEncodedText PropPersistent = System.Text.Json.JsonEncodedText.Encode("persistent"); + private static readonly System.Text.Json.JsonEncodedText PropTransient = System.Text.Json.JsonEncodedText.Encode("transient"); + + public override GetClusterSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propDefaults = default; + LocalJsonValue> propPersistent = default; + LocalJsonValue> propTransient = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryRead(ref reader, options, PropDefaults)) + { + continue; + } + + if (propPersistent.TryRead(ref reader, options, PropPersistent)) + { + continue; + } + + if (propTransient.TryRead(ref reader, options, PropTransient)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetClusterSettingsResponse + { + Defaults = propDefaults.Value +, + Persistent = propPersistent.Value +, + Transient = propTransient.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetClusterSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefaults, value.Defaults); + writer.WriteProperty(options, PropPersistent, value.Persistent); + writer.WriteProperty(options, PropTransient, value.Transient); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetClusterSettingsResponseConverter))] public sealed partial class GetClusterSettingsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("defaults")] public IReadOnlyDictionary? Defaults { get; init; } - [JsonInclude, JsonPropertyName("persistent")] public IReadOnlyDictionary Persistent { get; init; } - [JsonInclude, JsonPropertyName("transient")] public IReadOnlyDictionary Transient { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs index a344e42d854..fe17010c00a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateRequest.g.cs @@ -87,6 +87,15 @@ public GetComponentTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : b internal override string OperationName => "cluster.get_component_template"; + /// + /// + /// Comma-separated list of component template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs index 629ad116f00..a2d7117e077 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/GetComponentTemplateResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class GetComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropComponentTemplates = System.Text.Json.JsonEncodedText.Encode("component_templates"); + + public override GetComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propComponentTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComponentTemplates.TryRead(ref reader, options, PropComponentTemplates)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetComponentTemplateResponse + { + ComponentTemplates = propComponentTemplates.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropComponentTemplates, value.ComponentTemplates); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetComponentTemplateResponseConverter))] public sealed partial class GetComponentTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("component_templates")] public IReadOnlyCollection ComponentTemplates { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs index 07c6a721bf8..5c4f29cd710 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthRequest.g.cs @@ -144,6 +144,14 @@ public HealthRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "cluster.health"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard expressions (*) are supported. To target all data streams and indices in a cluster, omit this parameter or use _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to expand wildcard expression to concrete indices that are open, closed or both. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs index e3fca0ec657..704fb56e14a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/HealthResponse.g.cs @@ -22,10 +22,216 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class HealthResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActivePrimaryShards = System.Text.Json.JsonEncodedText.Encode("active_primary_shards"); + private static readonly System.Text.Json.JsonEncodedText PropActiveShards = System.Text.Json.JsonEncodedText.Encode("active_shards"); + private static readonly System.Text.Json.JsonEncodedText PropActiveShardsPercentAsNumber = System.Text.Json.JsonEncodedText.Encode("active_shards_percent_as_number"); + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedUnassignedShards = System.Text.Json.JsonEncodedText.Encode("delayed_unassigned_shards"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropInitializingShards = System.Text.Json.JsonEncodedText.Encode("initializing_shards"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfDataNodes = System.Text.Json.JsonEncodedText.Encode("number_of_data_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfInFlightFetch = System.Text.Json.JsonEncodedText.Encode("number_of_in_flight_fetch"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfNodes = System.Text.Json.JsonEncodedText.Encode("number_of_nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfPendingTasks = System.Text.Json.JsonEncodedText.Encode("number_of_pending_tasks"); + private static readonly System.Text.Json.JsonEncodedText PropRelocatingShards = System.Text.Json.JsonEncodedText.Encode("relocating_shards"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTaskMaxWaitingInQueue = System.Text.Json.JsonEncodedText.Encode("task_max_waiting_in_queue"); + private static readonly System.Text.Json.JsonEncodedText PropTaskMaxWaitingInQueueMillis = System.Text.Json.JsonEncodedText.Encode("task_max_waiting_in_queue_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedPrimaryShards = System.Text.Json.JsonEncodedText.Encode("unassigned_primary_shards"); + private static readonly System.Text.Json.JsonEncodedText PropUnassignedShards = System.Text.Json.JsonEncodedText.Encode("unassigned_shards"); + + public override HealthResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propActivePrimaryShards = default; + LocalJsonValue propActiveShards = default; + LocalJsonValue propActiveShardsPercentAsNumber = default; + LocalJsonValue propClusterName = default; + LocalJsonValue propDelayedUnassignedShards = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propInitializingShards = default; + LocalJsonValue propNumberOfDataNodes = default; + LocalJsonValue propNumberOfInFlightFetch = default; + LocalJsonValue propNumberOfNodes = default; + LocalJsonValue propNumberOfPendingTasks = default; + LocalJsonValue propRelocatingShards = default; + LocalJsonValue propStatus = default; + LocalJsonValue propTaskMaxWaitingInQueue = default; + LocalJsonValue propTaskMaxWaitingInQueueMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propUnassignedPrimaryShards = default; + LocalJsonValue propUnassignedShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActivePrimaryShards.TryRead(ref reader, options, PropActivePrimaryShards)) + { + continue; + } + + if (propActiveShards.TryRead(ref reader, options, PropActiveShards)) + { + continue; + } + + if (propActiveShardsPercentAsNumber.TryRead(ref reader, options, PropActiveShardsPercentAsNumber)) + { + continue; + } + + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propDelayedUnassignedShards.TryRead(ref reader, options, PropDelayedUnassignedShards)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propInitializingShards.TryRead(ref reader, options, PropInitializingShards)) + { + continue; + } + + if (propNumberOfDataNodes.TryRead(ref reader, options, PropNumberOfDataNodes)) + { + continue; + } + + if (propNumberOfInFlightFetch.TryRead(ref reader, options, PropNumberOfInFlightFetch)) + { + continue; + } + + if (propNumberOfNodes.TryRead(ref reader, options, PropNumberOfNodes)) + { + continue; + } + + if (propNumberOfPendingTasks.TryRead(ref reader, options, PropNumberOfPendingTasks)) + { + continue; + } + + if (propRelocatingShards.TryRead(ref reader, options, PropRelocatingShards)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTaskMaxWaitingInQueue.TryRead(ref reader, options, PropTaskMaxWaitingInQueue)) + { + continue; + } + + if (propTaskMaxWaitingInQueueMillis.TryRead(ref reader, options, PropTaskMaxWaitingInQueueMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propUnassignedPrimaryShards.TryRead(ref reader, options, PropUnassignedPrimaryShards)) + { + continue; + } + + if (propUnassignedShards.TryRead(ref reader, options, PropUnassignedShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HealthResponse + { + ActivePrimaryShards = propActivePrimaryShards.Value +, + ActiveShards = propActiveShards.Value +, + ActiveShardsPercentAsNumber = propActiveShardsPercentAsNumber.Value +, + ClusterName = propClusterName.Value +, + DelayedUnassignedShards = propDelayedUnassignedShards.Value +, + Indices = propIndices.Value +, + InitializingShards = propInitializingShards.Value +, + NumberOfDataNodes = propNumberOfDataNodes.Value +, + NumberOfInFlightFetch = propNumberOfInFlightFetch.Value +, + NumberOfNodes = propNumberOfNodes.Value +, + NumberOfPendingTasks = propNumberOfPendingTasks.Value +, + RelocatingShards = propRelocatingShards.Value +, + Status = propStatus.Value +, + TaskMaxWaitingInQueue = propTaskMaxWaitingInQueue.Value +, + TaskMaxWaitingInQueueMillis = propTaskMaxWaitingInQueueMillis.Value +, + TimedOut = propTimedOut.Value +, + UnassignedPrimaryShards = propUnassignedPrimaryShards.Value +, + UnassignedShards = propUnassignedShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActivePrimaryShards, value.ActivePrimaryShards); + writer.WriteProperty(options, PropActiveShards, value.ActiveShards); + writer.WriteProperty(options, PropActiveShardsPercentAsNumber, value.ActiveShardsPercentAsNumber); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropDelayedUnassignedShards, value.DelayedUnassignedShards); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropInitializingShards, value.InitializingShards); + writer.WriteProperty(options, PropNumberOfDataNodes, value.NumberOfDataNodes); + writer.WriteProperty(options, PropNumberOfInFlightFetch, value.NumberOfInFlightFetch); + writer.WriteProperty(options, PropNumberOfNodes, value.NumberOfNodes); + writer.WriteProperty(options, PropNumberOfPendingTasks, value.NumberOfPendingTasks); + writer.WriteProperty(options, PropRelocatingShards, value.RelocatingShards); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTaskMaxWaitingInQueue, value.TaskMaxWaitingInQueue); + writer.WriteProperty(options, PropTaskMaxWaitingInQueueMillis, value.TaskMaxWaitingInQueueMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropUnassignedPrimaryShards, value.UnassignedPrimaryShards); + writer.WriteProperty(options, PropUnassignedShards, value.UnassignedShards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HealthResponseConverter))] public sealed partial class HealthResponse : ElasticsearchResponse { /// @@ -33,7 +239,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of active primary shards. /// /// - [JsonInclude, JsonPropertyName("active_primary_shards")] public int ActivePrimaryShards { get; init; } /// @@ -41,7 +246,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The total number of active primary and replica shards. /// /// - [JsonInclude, JsonPropertyName("active_shards")] public int ActiveShards { get; init; } /// @@ -49,7 +253,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The ratio of active shards in the cluster expressed as a percentage. /// /// - [JsonInclude, JsonPropertyName("active_shards_percent_as_number")] public double ActiveShardsPercentAsNumber { get; init; } /// @@ -57,7 +260,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The name of the cluster. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -65,10 +267,7 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards whose allocation has been delayed by the timeout settings. /// /// - [JsonInclude, JsonPropertyName("delayed_unassigned_shards")] public int DelayedUnassignedShards { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Cluster.IndexHealthStats))] public IReadOnlyDictionary? Indices { get; init; } /// @@ -76,7 +275,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are under initialization. /// /// - [JsonInclude, JsonPropertyName("initializing_shards")] public int InitializingShards { get; init; } /// @@ -84,7 +282,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of nodes that are dedicated data nodes. /// /// - [JsonInclude, JsonPropertyName("number_of_data_nodes")] public int NumberOfDataNodes { get; init; } /// @@ -92,7 +289,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of unfinished fetches. /// /// - [JsonInclude, JsonPropertyName("number_of_in_flight_fetch")] public int NumberOfInFlightFetch { get; init; } /// @@ -100,7 +296,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of nodes within the cluster. /// /// - [JsonInclude, JsonPropertyName("number_of_nodes")] public int NumberOfNodes { get; init; } /// @@ -108,7 +303,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of cluster-level changes that have not yet been executed. /// /// - [JsonInclude, JsonPropertyName("number_of_pending_tasks")] public int NumberOfPendingTasks { get; init; } /// @@ -116,9 +310,7 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are under relocation. /// /// - [JsonInclude, JsonPropertyName("relocating_shards")] public int RelocatingShards { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.HealthStatus Status { get; init; } /// @@ -126,7 +318,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The time since the earliest initiated task is waiting for being performed. /// /// - [JsonInclude, JsonPropertyName("task_max_waiting_in_queue")] public Elastic.Clients.Elasticsearch.Duration? TaskMaxWaitingInQueue { get; init; } /// @@ -134,7 +325,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The time expressed in milliseconds since the earliest initiated task is waiting for being performed. /// /// - [JsonInclude, JsonPropertyName("task_max_waiting_in_queue_millis")] public long TaskMaxWaitingInQueueMillis { get; init; } /// @@ -142,7 +332,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// If false the response returned within the period of time that is specified by the timeout parameter (30s by default) /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } /// @@ -150,7 +339,6 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of primary shards that are not allocated. /// /// - [JsonInclude, JsonPropertyName("unassigned_primary_shards")] public int UnassignedPrimaryShards { get; init; } /// @@ -158,6 +346,5 @@ public sealed partial class HealthResponse : ElasticsearchResponse /// The number of shards that are not allocated. /// /// - [JsonInclude, JsonPropertyName("unassigned_shards")] public int UnassignedShards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs index 024b4bad879..8e053692e22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PendingTasksResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class PendingTasksResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override PendingTasksResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PendingTasksResponse + { + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PendingTasksResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PendingTasksResponseConverter))] public sealed partial class PendingTasksResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("tasks")] public IReadOnlyCollection Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs index 2670838909f..0256f090778 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateRequest.g.cs @@ -86,6 +86,18 @@ public PutComponentTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "cluster.put_component_template"; + /// + /// + /// Name of the component template to create. + /// Elasticsearch includes the following built-in component templates: logs-mappings; logs-settings; metrics-mappings; metrics-settings;synthetics-mapping; synthetics-settings. + /// Elastic Agent uses these templates to configure backing indices for its data streams. + /// If you use Elastic Agent and want to overwrite one of these templates, set the version for your replacement template higher than the current version. + /// If you don’t use Elastic Agent and want to disable all built-in component and index templates, set stack.templates.enabled to false using the cluster update settings API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, this request cannot replace or update existing component templates. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs index 5b48a459f7a..7a2ef2e0ae9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Cluster/PutComponentTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Cluster; +internal sealed partial class PutComponentTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutComponentTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutComponentTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutComponentTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutComponentTemplateResponseConverter))] public sealed partial class PutComponentTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutComponentTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs index a6dcb0989ca..603793447c2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountRequest.g.cs @@ -165,6 +165,16 @@ public CountRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "count"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs index e225c0dee65..d7bad7df043 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CountResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class CountResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override CountResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CountResponse + { + Count = propCount.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CountResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CountResponseConverter))] public sealed partial class CountResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs index e9cf25961c7..9fb04cc736d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateRequest.g.cs @@ -94,7 +94,7 @@ public sealed partial class CreateRequestParameters : RequestParameters /// If the target is an index and the document already exists, the request updates the document and increments its version. /// /// -public sealed partial class CreateRequest : PlainRequest, ISelfSerializable +public sealed partial class CreateRequest : PlainRequest, ISelfTwoWaySerializable { public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", index).Required("id", id)) { @@ -108,6 +108,24 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "create"; + /// + /// + /// Unique identifier for the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the data stream or index to target. + /// If the target doesn’t exist and matches the name or wildcard (*) pattern of an index template with a data_stream definition, this request creates the data stream. + /// If the target doesn’t exist and doesn’t match a data stream template, this request creates the index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// ID of the pipeline to use to preprocess incoming documents. @@ -168,13 +186,17 @@ public CreateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } - [JsonIgnore] public TDocument Document { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { settings.SourceSerializer.Serialize(Document, writer); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Document = settings.SourceSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs index edeaeb613d2..6715a5563be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CreateResponse.g.cs @@ -22,26 +22,124 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class CreateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override CreateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateResponseConverter))] public sealed partial class CreateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs index 774d051bff4..72f269538bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/CcrStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class CcrStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAutoFollowStats = System.Text.Json.JsonEncodedText.Encode("auto_follow_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFollowStats = System.Text.Json.JsonEncodedText.Encode("follow_stats"); + + public override CcrStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAutoFollowStats = default; + LocalJsonValue propFollowStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAutoFollowStats.TryRead(ref reader, options, PropAutoFollowStats)) + { + continue; + } + + if (propFollowStats.TryRead(ref reader, options, PropFollowStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CcrStatsResponse + { + AutoFollowStats = propAutoFollowStats.Value +, + FollowStats = propFollowStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CcrStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAutoFollowStats, value.AutoFollowStats); + writer.WriteProperty(options, PropFollowStats, value.FollowStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CcrStatsResponseConverter))] public sealed partial class CcrStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("auto_follow_stats")] public Elastic.Clients.Elasticsearch.CrossClusterReplication.AutoFollowStats AutoFollowStats { get; init; } - [JsonInclude, JsonPropertyName("follow_stats")] public Elastic.Clients.Elasticsearch.CrossClusterReplication.FollowStats FollowStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs index 838922632ca..7887a0f4343 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternRequest.g.cs @@ -53,6 +53,14 @@ public DeleteAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.delete_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs index 99617d5ed3d..1dc43db84f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/DeleteAutoFollowPatternResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class DeleteAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAutoFollowPatternResponseConverter))] public sealed partial class DeleteAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteAutoFollowPatternResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs index 75a456deb2a..67666762a8f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoRequest.g.cs @@ -54,6 +54,14 @@ public FollowInfoRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override bool SupportsBody => false; internal override string OperationName => "ccr.follow_info"; + + /// + /// + /// A comma-separated list of index patterns; use _all to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs index 54fcd7202df..f3be80864d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowInfoResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFollowerIndices = System.Text.Json.JsonEncodedText.Encode("follower_indices"); + + public override FollowInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFollowerIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFollowerIndices.TryRead(ref reader, options, PropFollowerIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowInfoResponse + { + FollowerIndices = propFollowerIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFollowerIndices, value.FollowerIndices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowInfoResponseConverter))] public sealed partial class FollowInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("follower_indices")] public IReadOnlyCollection FollowerIndices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs index 713e143d421..5c3390e4a97 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowRequest.g.cs @@ -64,6 +64,14 @@ public FollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => internal override string OperationName => "ccr.follow"; + /// + /// + /// The name of the follower index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the number of shards to wait on being active before responding. This defaults to waiting on none of the shards to be diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs index c30f351af3c..edfa21adcce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFollowIndexCreated = System.Text.Json.JsonEncodedText.Encode("follow_index_created"); + private static readonly System.Text.Json.JsonEncodedText PropFollowIndexShardsAcked = System.Text.Json.JsonEncodedText.Encode("follow_index_shards_acked"); + private static readonly System.Text.Json.JsonEncodedText PropIndexFollowingStarted = System.Text.Json.JsonEncodedText.Encode("index_following_started"); + + public override FollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFollowIndexCreated = default; + LocalJsonValue propFollowIndexShardsAcked = default; + LocalJsonValue propIndexFollowingStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFollowIndexCreated.TryRead(ref reader, options, PropFollowIndexCreated)) + { + continue; + } + + if (propFollowIndexShardsAcked.TryRead(ref reader, options, PropFollowIndexShardsAcked)) + { + continue; + } + + if (propIndexFollowingStarted.TryRead(ref reader, options, PropIndexFollowingStarted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowResponse + { + FollowIndexCreated = propFollowIndexCreated.Value +, + FollowIndexShardsAcked = propFollowIndexShardsAcked.Value +, + IndexFollowingStarted = propIndexFollowingStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFollowIndexCreated, value.FollowIndexCreated); + writer.WriteProperty(options, PropFollowIndexShardsAcked, value.FollowIndexShardsAcked); + writer.WriteProperty(options, PropIndexFollowingStarted, value.IndexFollowingStarted); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowResponseConverter))] public sealed partial class FollowResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("follow_index_created")] public bool FollowIndexCreated { get; init; } - [JsonInclude, JsonPropertyName("follow_index_shards_acked")] public bool FollowIndexShardsAcked { get; init; } - [JsonInclude, JsonPropertyName("index_following_started")] public bool IndexFollowingStarted { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs index a08fd5c57f4..c252015f405 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsRequest.g.cs @@ -54,6 +54,14 @@ public FollowStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( internal override bool SupportsBody => false; internal override string OperationName => "ccr.follow_stats"; + + /// + /// + /// A comma-separated list of index patterns; use _all to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs index 46fc142371f..136f64a45e4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/FollowStatsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class FollowStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override FollowStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FollowStatsResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FollowStatsResponseConverter))] public sealed partial class FollowStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs index 83afef716e7..2162b0c217c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerRequest.g.cs @@ -66,6 +66,13 @@ public ForgetFollowerRequest(Elastic.Clients.Elasticsearch.IndexName index) : ba internal override string OperationName => "ccr.forget_follower"; + /// + /// + /// the name of the leader index for which specified follower retention leases should be removed + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("follower_cluster")] public string? FollowerCluster { get; set; } [JsonInclude, JsonPropertyName("follower_index")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs index cb86186b4b9..1eaca5ae4a7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ForgetFollowerResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ForgetFollowerResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ForgetFollowerResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForgetFollowerResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForgetFollowerResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForgetFollowerResponseConverter))] public sealed partial class ForgetFollowerResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs index 0d67104509e..e08e058e18a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternRequest.g.cs @@ -57,6 +57,14 @@ public GetAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name? name) : b internal override bool SupportsBody => false; internal override string OperationName => "ccr.get_auto_follow_pattern"; + + /// + /// + /// Specifies the auto-follow pattern collection that you want to retrieve. If you do not specify a name, the API returns information for all collections. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs index 7e0562b9122..42c54bcca6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/GetAutoFollowPatternResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class GetAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPatterns = System.Text.Json.JsonEncodedText.Encode("patterns"); + + public override GetAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propPatterns = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPatterns.TryRead(ref reader, options, PropPatterns)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAutoFollowPatternResponse + { + Patterns = propPatterns.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPatterns, value.Patterns); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAutoFollowPatternResponseConverter))] public sealed partial class GetAutoFollowPatternResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("patterns")] public IReadOnlyCollection Patterns { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs index 6d1d06ba408..58e612bc84f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternRequest.g.cs @@ -60,6 +60,14 @@ public PauseAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.pause_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern that should pause discovering new indices to follow. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs index bb6d5fb3a2e..b98fd464c23 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseAutoFollowPatternResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PauseAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PauseAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PauseAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PauseAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PauseAutoFollowPatternResponseConverter))] public sealed partial class PauseAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PauseAutoFollowPatternResponse : ElasticsearchRespon /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs index ba974a7ce62..83f1ea7dbf6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowRequest.g.cs @@ -56,6 +56,14 @@ public PauseFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override bool SupportsBody => false; internal override string OperationName => "ccr.pause_follow"; + + /// + /// + /// The name of the follower index that should pause following its leader index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs index 1d2496b5ce9..26dde00f2ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PauseFollowResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PauseFollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PauseFollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PauseFollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PauseFollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PauseFollowResponseConverter))] public sealed partial class PauseFollowResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PauseFollowResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs index 0d2b49c3377..e268b7ba838 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternRequest.g.cs @@ -60,6 +60,14 @@ public PutAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "ccr.put_auto_follow_pattern"; + /// + /// + /// The name of the collection of auto-follow patterns. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// The name of follower index. The template {{leader_index}} can be used to derive the name of the follower index from the name of the leader index. When following a data stream, use {{leader_index}}; CCR does not support changes to the names of a follower data stream’s backing indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs index 12a5140d0b3..d407d0c056c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/PutAutoFollowPatternResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class PutAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutAutoFollowPatternResponseConverter))] public sealed partial class PutAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutAutoFollowPatternResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs index 33dd4afe9a4..cd26c055f97 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternRequest.g.cs @@ -55,6 +55,14 @@ public ResumeAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "ccr.resume_auto_follow_pattern"; + + /// + /// + /// The name of the auto follow pattern to resume discovering new indices to follow. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs index c7cab6b189b..d4ca97fedd3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeAutoFollowPatternResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ResumeAutoFollowPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResumeAutoFollowPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResumeAutoFollowPatternResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResumeAutoFollowPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResumeAutoFollowPatternResponseConverter))] public sealed partial class ResumeAutoFollowPatternResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ResumeAutoFollowPatternResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs index ab0686ccb90..91ac423bf3b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowRequest.g.cs @@ -57,6 +57,13 @@ public ResumeFollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base internal override string OperationName => "ccr.resume_follow"; + /// + /// + /// The name of the follow index to resume following. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("max_outstanding_read_requests")] public long? MaxOutstandingReadRequests { get; set; } [JsonInclude, JsonPropertyName("max_outstanding_write_requests")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs index 0a11009556d..0eed0447d14 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/ResumeFollowResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class ResumeFollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResumeFollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResumeFollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResumeFollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResumeFollowResponseConverter))] public sealed partial class ResumeFollowResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ResumeFollowResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs index ab1fab0076b..b7eae253cba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowRequest.g.cs @@ -58,6 +58,14 @@ public UnfollowRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "ccr.unfollow"; + + /// + /// + /// The name of the follower index that should be turned into a regular index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs index ee58b3bcbb8..4b155a9d477 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/CrossClusterReplication/UnfollowResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.CrossClusterReplication; +internal sealed partial class UnfollowResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UnfollowResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnfollowResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnfollowResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UnfollowResponseConverter))] public sealed partial class UnfollowResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class UnfollowResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs index b84dd6c6f7f..26a7dc9140b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DanglingIndices/ListDanglingIndicesResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.DanglingIndices; +internal sealed partial class ListDanglingIndicesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDanglingIndices = System.Text.Json.JsonEncodedText.Encode("dangling_indices"); + + public override ListDanglingIndicesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDanglingIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDanglingIndices.TryRead(ref reader, options, PropDanglingIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListDanglingIndicesResponse + { + DanglingIndices = propDanglingIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListDanglingIndicesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDanglingIndices, value.DanglingIndices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListDanglingIndicesResponseConverter))] public sealed partial class ListDanglingIndicesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("dangling_indices")] public IReadOnlyCollection DanglingIndices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs index 34541aa28c1..bcea9109462 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRequest.g.cs @@ -264,6 +264,16 @@ public DeleteByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas internal override string OperationName => "delete_by_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs index 04d1a451f0d..ee90952d332 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryResponse.g.cs @@ -22,42 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class DeleteByQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropSliceId = System.Text.Json.JsonEncodedText.Encode("slice_id"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntil = System.Text.Json.JsonEncodedText.Encode("throttled_until"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override DeleteByQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBatches = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propSliceId = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottled = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntil = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propSliceId.TryRead(ref reader, options, PropSliceId)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottled.TryRead(ref reader, options, PropThrottled)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntil.TryRead(ref reader, options, PropThrottledUntil)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteByQueryResponse + { + Batches = propBatches.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + SliceId = propSliceId.Value +, + Task = propTask.Value +, + Throttled = propThrottled.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntil = propThrottledUntil.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteByQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropSliceId, value.SliceId); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottled, value.Throttled); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteByQueryResponseConverter))] public sealed partial class DeleteByQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.Duration? ThrottledUntil { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs index 2b09f0d917c..bdc65725a1a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleRequest.g.cs @@ -63,6 +63,14 @@ public DeleteByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.TaskId taskI internal override string OperationName => "delete_by_query_rethrottle"; + /// + /// + /// The ID for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.TaskId TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs index 1835de4dc4b..de5ed14feb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteByQueryRethrottleResponse.g.cs @@ -22,13 +22,78 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class DeleteByQueryRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodeFailures = System.Text.Json.JsonEncodedText.Encode("node_failures"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override DeleteByQueryRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryRead(ref reader, options, PropNodeFailures)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propTaskFailures.TryRead(ref reader, options, PropTaskFailures)) + { + continue; + } + + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteByQueryRethrottleResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteByQueryRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteByQueryRethrottleResponseConverter))] public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +101,7 @@ public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchRespo /// Task information grouped by node, if group_by was set to node (the default). /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary? Nodes { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } /// @@ -47,6 +110,5 @@ public sealed partial class DeleteByQueryRethrottleResponse : ElasticsearchRespo /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs index 479d7e6c9a3..88789d897fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteRequest.g.cs @@ -112,6 +112,22 @@ public DeleteRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "delete"; + /// + /// + /// Unique identifier for the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the target index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Only perform the operation if the document has this primary term. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs index 035076c71fd..4ec30115dd0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteResponse.g.cs @@ -22,26 +22,124 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class DeleteResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override DeleteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteResponseConverter))] public sealed partial class DeleteResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs index 42659a1f2b2..76e455ee1b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptRequest.g.cs @@ -69,6 +69,14 @@ public DeleteScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override string OperationName => "delete_script"; + /// + /// + /// Identifier for the stored script or search template. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs index 660b7f3a641..5af95930786 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/DeleteScriptResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class DeleteScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteScriptResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteScriptResponseConverter))] public sealed partial class DeleteScriptResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteScriptResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs index 6e2547bbd3c..cab6bb4a935 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyRequest.g.cs @@ -53,6 +53,14 @@ public DeletePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "enrich.delete_policy"; + + /// + /// + /// Enrich policy to delete. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs index ce4f5649cb9..787c86ad9ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/DeletePolicyResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class DeletePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeletePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeletePolicyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeletePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePolicyResponseConverter))] public sealed partial class DeletePolicyResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeletePolicyResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs index 9e9551fdeb4..d0e06166ff5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/EnrichStatsResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class EnrichStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCacheStats = System.Text.Json.JsonEncodedText.Encode("cache_stats"); + private static readonly System.Text.Json.JsonEncodedText PropCoordinatorStats = System.Text.Json.JsonEncodedText.Encode("coordinator_stats"); + private static readonly System.Text.Json.JsonEncodedText PropExecutingPolicies = System.Text.Json.JsonEncodedText.Encode("executing_policies"); + + public override EnrichStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propCacheStats = default; + LocalJsonValue> propCoordinatorStats = default; + LocalJsonValue> propExecutingPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCacheStats.TryRead(ref reader, options, PropCacheStats)) + { + continue; + } + + if (propCoordinatorStats.TryRead(ref reader, options, PropCoordinatorStats)) + { + continue; + } + + if (propExecutingPolicies.TryRead(ref reader, options, PropExecutingPolicies)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrichStatsResponse + { + CacheStats = propCacheStats.Value +, + CoordinatorStats = propCoordinatorStats.Value +, + ExecutingPolicies = propExecutingPolicies.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCacheStats, value.CacheStats); + writer.WriteProperty(options, PropCoordinatorStats, value.CoordinatorStats); + writer.WriteProperty(options, PropExecutingPolicies, value.ExecutingPolicies); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrichStatsResponseConverter))] public sealed partial class EnrichStatsResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about the enrich cache stats on each ingest node. /// /// - [JsonInclude, JsonPropertyName("cache_stats")] public IReadOnlyCollection? CacheStats { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about each coordinating ingest node for configured enrich processors. /// /// - [JsonInclude, JsonPropertyName("coordinator_stats")] public IReadOnlyCollection CoordinatorStats { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class EnrichStatsResponse : ElasticsearchResponse /// Objects containing information about each enrich policy that is currently executing. /// /// - [JsonInclude, JsonPropertyName("executing_policies")] public IReadOnlyCollection ExecutingPolicies { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs index daa404fd68f..4552246a332 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyRequest.g.cs @@ -60,6 +60,14 @@ public ExecutePolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override string OperationName => "enrich.execute_policy"; + /// + /// + /// Enrich policy to execute. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, the request blocks other enrich policy execution requests until complete. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs index 16db521cad5..49773ddcbbd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/ExecutePolicyResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class ExecutePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropTaskId = System.Text.Json.JsonEncodedText.Encode("task_id"); + + public override ExecutePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStatus = default; + LocalJsonValue propTaskId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propTaskId.TryRead(ref reader, options, PropTaskId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecutePolicyResponse + { + Status = propStatus.Value +, + TaskId = propTaskId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecutePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropTaskId, value.TaskId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecutePolicyResponseConverter))] public sealed partial class ExecutePolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Enrich.ExecuteEnrichPolicyStatus? Status { get; init; } - [JsonInclude, JsonPropertyName("task_id")] public Elastic.Clients.Elasticsearch.TaskId? TaskId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs index 48e5c1b5181..06aeccf2723 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyRequest.g.cs @@ -57,6 +57,15 @@ public GetPolicyRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r internal override bool SupportsBody => false; internal override string OperationName => "enrich.get_policy"; + + /// + /// + /// Comma-separated list of enrich policy names used to limit the request. + /// To return information for all enrich policies, omit this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs index cadd77f15f8..a7f711149ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/GetPolicyResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class GetPolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPolicies = System.Text.Json.JsonEncodedText.Encode("policies"); + + public override GetPolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propPolicies = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicies.TryRead(ref reader, options, PropPolicies)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetPolicyResponse + { + Policies = propPolicies.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetPolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPolicies, value.Policies); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetPolicyResponseConverter))] public sealed partial class GetPolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("policies")] public IReadOnlyCollection Policies { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs index 7431d4cedbb..eb3ce9ff847 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyRequest.g.cs @@ -54,6 +54,14 @@ public PutPolicyRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.R internal override string OperationName => "enrich.put_policy"; + /// + /// + /// Name of the enrich policy to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Matches enrich data to incoming documents based on a geo_shape query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs index b1c1eb5625c..f3a17a86a56 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Enrich/PutPolicyResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class PutPolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutPolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutPolicyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutPolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPolicyResponseConverter))] public sealed partial class PutPolicyResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutPolicyResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs index ab270a990cd..f4dcf53db5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteRequest.g.cs @@ -54,6 +54,16 @@ public EqlDeleteRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override bool SupportsBody => false; internal override string OperationName => "eql.delete"; + + /// + /// + /// Identifier for the search to delete. + /// A search ID is provided in the EQL search API's response for an async search. + /// A search ID is also provided if the request’s keep_on_completion parameter is true. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs index 2ab88cfe2cc..014c6fdc06e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlDeleteResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class EqlDeleteResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override EqlDeleteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlDeleteResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlDeleteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EqlDeleteResponseConverter))] public sealed partial class EqlDeleteResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class EqlDeleteResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs index bb6b31ce705..ca1bd023624 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetRequest.g.cs @@ -69,6 +69,14 @@ public EqlGetRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required internal override string OperationName => "eql.get"; + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period for which the search and its results are stored on the cluster. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs index ccdd1f5ef9d..6b73180f9dc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlGetResponse.g.cs @@ -22,10 +22,123 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class EqlGetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShardFailures = System.Text.Json.JsonEncodedText.Encode("shard_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override EqlGetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propHits = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue?> propShardFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShardFailures.TryRead(ref reader, options, PropShardFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlGetResponse + { + Hits = propHits.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + ShardFailures = propShardFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlGetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlGetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlGetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(EqlGetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(EqlGetResponseConverterFactory))] public sealed partial class EqlGetResponse : ElasticsearchResponse { /// @@ -33,7 +146,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +153,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +160,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -57,7 +167,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the search request is still executing. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } /// @@ -65,7 +174,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Contains information about shard failures (if any), in case allow_partial_search_results=true /// /// - [JsonInclude, JsonPropertyName("shard_failures")] public IReadOnlyCollection? ShardFailures { get; init; } /// @@ -73,7 +181,6 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// If true, the request timed out before completion. /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } /// @@ -81,6 +188,5 @@ public sealed partial class EqlGetResponse : ElasticsearchResponse /// Milliseconds it took Elasticsearch to execute the request. /// /// - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs index 5f88564f66a..7e752a5f798 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchRequest.g.cs @@ -43,6 +43,199 @@ public sealed partial class EqlSearchRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } +internal sealed partial class EqlSearchRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSearchResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_search_results"); + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSequenceResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_sequence_results"); + private static readonly System.Text.Json.JsonEncodedText PropCaseSensitive = System.Text.Json.JsonEncodedText.Encode("case_sensitive"); + private static readonly System.Text.Json.JsonEncodedText PropEventCategoryField = System.Text.Json.JsonEncodedText.Encode("event_category_field"); + private static readonly System.Text.Json.JsonEncodedText PropFetchSize = System.Text.Json.JsonEncodedText.Encode("fetch_size"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropKeepAlive = System.Text.Json.JsonEncodedText.Encode("keep_alive"); + private static readonly System.Text.Json.JsonEncodedText PropKeepOnCompletion = System.Text.Json.JsonEncodedText.Encode("keep_on_completion"); + private static readonly System.Text.Json.JsonEncodedText PropMaxSamplesPerKey = System.Text.Json.JsonEncodedText.Encode("max_samples_per_key"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropResultPosition = System.Text.Json.JsonEncodedText.Encode("result_position"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropTiebreakerField = System.Text.Json.JsonEncodedText.Encode("tiebreaker_field"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + private static readonly System.Text.Json.JsonEncodedText PropWaitForCompletionTimeout = System.Text.Json.JsonEncodedText.Encode("wait_for_completion_timeout"); + + public override EqlSearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowPartialSearchResults = default; + LocalJsonValue propAllowPartialSequenceResults = default; + LocalJsonValue propCaseSensitive = default; + LocalJsonValue propEventCategoryField = default; + LocalJsonValue propFetchSize = default; + LocalJsonValue?> propFields = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propKeepAlive = default; + LocalJsonValue propKeepOnCompletion = default; + LocalJsonValue propMaxSamplesPerKey = default; + LocalJsonValue propQuery = default; + LocalJsonValue propResultPosition = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue propTiebreakerField = default; + LocalJsonValue propTimestampField = default; + LocalJsonValue propWaitForCompletionTimeout = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowPartialSearchResults.TryRead(ref reader, options, PropAllowPartialSearchResults)) + { + continue; + } + + if (propAllowPartialSequenceResults.TryRead(ref reader, options, PropAllowPartialSequenceResults)) + { + continue; + } + + if (propCaseSensitive.TryRead(ref reader, options, PropCaseSensitive)) + { + continue; + } + + if (propEventCategoryField.TryRead(ref reader, options, PropEventCategoryField)) + { + continue; + } + + if (propFetchSize.TryRead(ref reader, options, PropFetchSize)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormat>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propKeepAlive.TryRead(ref reader, options, PropKeepAlive)) + { + continue; + } + + if (propKeepOnCompletion.TryRead(ref reader, options, PropKeepOnCompletion)) + { + continue; + } + + if (propMaxSamplesPerKey.TryRead(ref reader, options, PropMaxSamplesPerKey)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propResultPosition.TryRead(ref reader, options, PropResultPosition)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propTiebreakerField.TryRead(ref reader, options, PropTiebreakerField)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + if (propWaitForCompletionTimeout.TryRead(ref reader, options, PropWaitForCompletionTimeout)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlSearchRequest + { + AllowPartialSearchResults = propAllowPartialSearchResults.Value + , + AllowPartialSequenceResults = propAllowPartialSequenceResults.Value + , + CaseSensitive = propCaseSensitive.Value + , + EventCategoryField = propEventCategoryField.Value + , + FetchSize = propFetchSize.Value + , + Fields = propFields.Value + , + Filter = propFilter.Value + , + KeepAlive = propKeepAlive.Value + , + KeepOnCompletion = propKeepOnCompletion.Value + , + MaxSamplesPerKey = propMaxSamplesPerKey.Value + , + Query = propQuery.Value + , + ResultPosition = propResultPosition.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + Size = propSize.Value + , + TiebreakerField = propTiebreakerField.Value + , + TimestampField = propTimestampField.Value + , + WaitForCompletionTimeout = propWaitForCompletionTimeout.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowPartialSearchResults, value.AllowPartialSearchResults); + writer.WriteProperty(options, PropAllowPartialSequenceResults, value.AllowPartialSequenceResults); + writer.WriteProperty(options, PropCaseSensitive, value.CaseSensitive); + writer.WriteProperty(options, PropEventCategoryField, value.EventCategoryField); + writer.WriteProperty(options, PropFetchSize, value.FetchSize); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormat>)); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropKeepAlive, value.KeepAlive); + writer.WriteProperty(options, PropKeepOnCompletion, value.KeepOnCompletion); + writer.WriteProperty(options, PropMaxSamplesPerKey, value.MaxSamplesPerKey); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropResultPosition, value.ResultPosition); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropTiebreakerField, value.TiebreakerField); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteProperty(options, PropWaitForCompletionTimeout, value.WaitForCompletionTimeout); + writer.WriteEndObject(); + } +} + /// /// /// Get EQL search results. @@ -50,6 +243,7 @@ public sealed partial class EqlSearchRequestParameters : RequestParameters /// EQL assumes each document in a data stream or index corresponds to an event. /// /// +[JsonConverter(typeof(EqlSearchRequestConverter))] public sealed partial class EqlSearchRequest : PlainRequest { public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) @@ -64,9 +258,13 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "eql.search"; - [JsonIgnore] + /// + /// + /// The name of the index to scope the operation + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -74,13 +272,9 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If true, missing or closed indices are not included in the response. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } - [JsonInclude, JsonPropertyName("allow_partial_search_results")] public bool? AllowPartialSearchResults { get; set; } - [JsonInclude, JsonPropertyName("allow_partial_sequence_results")] public bool? AllowPartialSequenceResults { get; set; } - [JsonInclude, JsonPropertyName("case_sensitive")] public bool? CaseSensitive { get; set; } /// @@ -88,7 +282,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field containing the event classification, such as process, file, or network. /// /// - [JsonInclude, JsonPropertyName("event_category_field")] public Elastic.Clients.Elasticsearch.Field? EventCategoryField { get; set; } /// @@ -96,7 +289,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Maximum number of events to search at a time for sequence queries. /// /// - [JsonInclude, JsonPropertyName("fetch_size")] public int? FetchSize { get; set; } /// @@ -104,8 +296,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Array of wildcard (*) patterns. The response returns values for field names matching these patterns in the fields property of each hit. /// /// - [JsonInclude, JsonPropertyName("fields")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.FieldAndFormat))] public ICollection? Fields { get; set; } /// @@ -113,12 +303,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Query, written in Query DSL, used to filter the events on which the EQL query runs. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } - [JsonInclude, JsonPropertyName("keep_alive")] public Elastic.Clients.Elasticsearch.Duration? KeepAlive { get; set; } - [JsonInclude, JsonPropertyName("keep_on_completion")] public bool? KeepOnCompletion { get; set; } /// @@ -128,7 +314,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// max_samples_per_key parameter. Pipes are not supported for sample queries. /// /// - [JsonInclude, JsonPropertyName("max_samples_per_key")] public int? MaxSamplesPerKey { get; set; } /// @@ -136,11 +321,8 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// EQL query you wish to run. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("result_position")] public Elastic.Clients.Elasticsearch.Eql.ResultPosition? ResultPosition { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -148,7 +330,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// For basic queries, the maximum number of matching events to return. Defaults to 10 /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -156,7 +337,6 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field used to sort hits with the same timestamp in ascending order /// /// - [JsonInclude, JsonPropertyName("tiebreaker_field")] public Elastic.Clients.Elasticsearch.Field? TiebreakerField { get; set; } /// @@ -164,9 +344,7 @@ public EqlSearchRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Field containing event timestamp. Default "@timestamp" /// /// - [JsonInclude, JsonPropertyName("timestamp_field")] public Elastic.Clients.Elasticsearch.Field? TimestampField { get; set; } - [JsonInclude, JsonPropertyName("wait_for_completion_timeout")] public Elastic.Clients.Elasticsearch.Duration? WaitForCompletionTimeout { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs index 720dbc35012..2acc4ea3e66 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/EqlSearchResponse.g.cs @@ -22,10 +22,123 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class EqlSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropShardFailures = System.Text.Json.JsonEncodedText.Encode("shard_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override EqlSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propHits = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue?> propShardFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propShardFailures.TryRead(ref reader, options, PropShardFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlSearchResponse + { + Hits = propHits.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + ShardFailures = propShardFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropShardFailures, value.ShardFailures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(EqlSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(EqlSearchResponseConverterFactory))] public sealed partial class EqlSearchResponse : ElasticsearchResponse { /// @@ -33,7 +146,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Contains matching events and sequences. Also contains related metadata. /// /// - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Eql.EqlHits Hits { get; init; } /// @@ -41,7 +153,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -49,7 +160,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -57,7 +167,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the search request is still executing. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } /// @@ -65,7 +174,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Contains information about shard failures (if any), in case allow_partial_search_results=true /// /// - [JsonInclude, JsonPropertyName("shard_failures")] public IReadOnlyCollection? ShardFailures { get; init; } /// @@ -73,7 +181,6 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// If true, the request timed out before completion. /// /// - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } /// @@ -81,6 +188,5 @@ public sealed partial class EqlSearchResponse : ElasticsearchResponse /// Milliseconds it took Elasticsearch to execute the request. /// /// - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs index faba4187dbb..e30770f76c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusRequest.g.cs @@ -53,6 +53,14 @@ public GetEqlStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override bool SupportsBody => false; internal override string OperationName => "eql.get_status"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs index a087b94c3a8..fc095c19f41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Eql/GetEqlStatusResponse.g.cs @@ -22,10 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class GetEqlStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetEqlStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetEqlStatusResponse + { + CompletionStatus = propCompletionStatus.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetEqlStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetEqlStatusResponseConverter))] public sealed partial class GetEqlStatusResponse : ElasticsearchResponse { /// @@ -33,7 +119,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// For a completed search shows the http status code of the completed search. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -41,7 +126,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// Shows a timestamp when the eql search will be expired, in milliseconds since the Unix epoch. When this time is reached, the search and its results are deleted, even if the search is still ongoing. /// /// - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long? ExpirationTimeInMillis { get; init; } /// @@ -49,7 +133,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -57,7 +140,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// If true, the search request is still executing. If false, the search is completed. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -65,7 +147,6 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// If true, the response does not contain complete search results. This could be because either the search is still running (is_running status is false), or because it is already completed (is_running status is true) and results are partial due to failures or timeouts. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -73,6 +154,5 @@ public sealed partial class GetEqlStatusResponse : ElasticsearchResponse /// For a running search shows a timestamp when the eql search started, in milliseconds since the Unix epoch. /// /// - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long? StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs index a69f181062f..ac3a4f58d54 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsRequest.g.cs @@ -127,6 +127,23 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "exists"; + /// + /// + /// Identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs index 92ee29cc3a7..83296a31c94 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExistsSourceRequest.g.cs @@ -118,6 +118,23 @@ public ExistsSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elasti internal override string OperationName => "exists_source"; + /// + /// + /// Identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs index a747706a688..576eddbf704 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainRequest.g.cs @@ -139,6 +139,23 @@ public ExplainRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Cli internal override string OperationName => "explain"; + /// + /// + /// Defines the document ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Index names used to limit the request. + /// Only a single index name can be provided to this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Analyzer to use for the query string. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs index 507b277bdfe..395ebc7b9ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ExplainResponse.g.cs @@ -22,20 +22,108 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ExplainResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropExplanation = System.Text.Json.JsonEncodedText.Encode("explanation"); + private static readonly System.Text.Json.JsonEncodedText PropGet = System.Text.Json.JsonEncodedText.Encode("get"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropMatched = System.Text.Json.JsonEncodedText.Encode("matched"); + + public override ExplainResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propExplanation = default; + LocalJsonValue?> propGet = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMatched = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryRead(ref reader, options, PropExplanation)) + { + continue; + } + + if (propGet.TryRead(ref reader, options, PropGet)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMatched.TryRead(ref reader, options, PropMatched)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainResponse + { + Explanation = propExplanation.Value +, + Get = propGet.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Matched = propMatched.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExplanation, value.Explanation); + writer.WriteProperty(options, PropGet, value.Get); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMatched, value.Matched); + writer.WriteEndObject(); + } +} + +internal sealed partial class ExplainResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ExplainResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(ExplainResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(ExplainResponseConverterFactory))] public sealed partial class ExplainResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("explanation")] public Elastic.Clients.Elasticsearch.Core.Explain.ExplanationDetail? Explanation { get; init; } - [JsonInclude, JsonPropertyName("get")] public Elastic.Clients.Elasticsearch.InlineGet? Get { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("matched")] public bool Matched { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs index 330a44bf3e4..9b1fe8874b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/GetFeaturesResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Features; +internal sealed partial class GetFeaturesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + + public override GetFeaturesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFeatures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatures.TryRead(ref reader, options, PropFeatures)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetFeaturesResponse + { + Features = propFeatures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetFeaturesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatures, value.Features); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetFeaturesResponseConverter))] public sealed partial class GetFeaturesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("features")] public IReadOnlyCollection Features { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs index d92067d295e..ec1ee027688 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Features/ResetFeaturesResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Features; +internal sealed partial class ResetFeaturesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + + public override ResetFeaturesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFeatures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatures.TryRead(ref reader, options, PropFeatures)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetFeaturesResponse + { + Features = propFeatures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetFeaturesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatures, value.Features); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetFeaturesResponseConverter))] public sealed partial class ResetFeaturesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("features")] public IReadOnlyCollection Features { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs index 40ca0aa9140..d825a7c20bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsRequest.g.cs @@ -84,6 +84,59 @@ public sealed partial class FieldCapsRequestParameters : RequestParameters public ICollection? Types { get => Q?>("types"); set => Q("types", value); } } +internal sealed partial class FieldCapsRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndexFilter = System.Text.Json.JsonEncodedText.Encode("index_filter"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + + public override FieldCapsRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue propIndexFilter = default; + LocalJsonValue?> propRuntimeMappings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIndexFilter.TryRead(ref reader, options, PropIndexFilter)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapsRequest + { + Fields = propFields.Value + , + IndexFilter = propIndexFilter.Value + , + RuntimeMappings = propRuntimeMappings.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapsRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIndexFilter, value.IndexFilter); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteEndObject(); + } +} + /// /// /// Get the field capabilities. @@ -97,6 +150,7 @@ public sealed partial class FieldCapsRequestParameters : RequestParameters /// For example, a runtime field with a type of keyword is returned the same as any other field that belongs to the keyword family. /// /// +[JsonConverter(typeof(FieldCapsRequestConverter))] public sealed partial class FieldCapsRequest : PlainRequest { public FieldCapsRequest() @@ -115,6 +169,13 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "field_caps"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, @@ -122,7 +183,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -130,7 +190,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -138,7 +197,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent /// /// - [JsonIgnore] public string? Filters { get => Q("filters"); set => Q("filters", value); } /// @@ -146,7 +204,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// If true, missing or closed indices are not included in the response. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -154,7 +211,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// If false, empty fields are not included in the response. /// /// - [JsonIgnore] public bool? IncludeEmptyFields { get => Q("include_empty_fields"); set => Q("include_empty_fields", value); } /// @@ -162,7 +218,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// If true, unmapped fields are included in the response. /// /// - [JsonIgnore] public bool? IncludeUnmapped { get => Q("include_unmapped"); set => Q("include_unmapped", value); } /// @@ -170,7 +225,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// Only return results for fields that have one of the types in the list /// /// - [JsonIgnore] public ICollection? Types { get => Q?>("types"); set => Q("types", value); } /// @@ -178,8 +232,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// List of fields to retrieve capabilities for. Wildcard (*) expressions are supported. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -187,7 +239,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// Allows to filter indices if the provided query rewrites to match_none on every shard. /// /// - [JsonInclude, JsonPropertyName("index_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? IndexFilter { get; set; } /// @@ -196,7 +247,6 @@ public FieldCapsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r /// These fields exist only as part of the query and take precedence over fields defined with the same name in the index mappings. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs index 1f2841fe397..64389806f3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/FieldCapsResponse.g.cs @@ -22,16 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class FieldCapsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override FieldCapsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propFields = default; + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapsResponse + { + Fields = propFields.Value +, + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIndices, value.Indices, null, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCapsResponseConverter))] public sealed partial class FieldCapsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyDictionary))] public IReadOnlyDictionary> Fields { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs index e71f67d6fca..3759f4eeec9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetRequest.g.cs @@ -134,6 +134,22 @@ public GetRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients internal override string OperationName => "get"; + /// + /// + /// Unique identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Should this request force synthetic _source? diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs index 09773e266f6..f9cf3b4dd9f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetResponse.g.cs @@ -22,31 +22,163 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override GetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetResponse + { + Fields = propFields.Value +, + Found = propFound.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetResponseConverterFactory))] public sealed partial class GetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.FieldValues? Fields { get; init; } - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs index 675104dff9c..63da152aa2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptContextResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetScriptContextResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + + public override GetScriptContextResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propContexts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propContexts.TryRead(ref reader, options, PropContexts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptContextResponse + { + Contexts = propContexts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptContextResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropContexts, value.Contexts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptContextResponseConverter))] public sealed partial class GetScriptContextResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("contexts")] public IReadOnlyCollection Contexts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs index 37a210be29b..cfe80745174 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptLanguagesResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetScriptLanguagesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguageContexts = System.Text.Json.JsonEncodedText.Encode("language_contexts"); + private static readonly System.Text.Json.JsonEncodedText PropTypesAllowed = System.Text.Json.JsonEncodedText.Encode("types_allowed"); + + public override GetScriptLanguagesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propLanguageContexts = default; + LocalJsonValue> propTypesAllowed = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguageContexts.TryRead(ref reader, options, PropLanguageContexts)) + { + continue; + } + + if (propTypesAllowed.TryRead(ref reader, options, PropTypesAllowed)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptLanguagesResponse + { + LanguageContexts = propLanguageContexts.Value +, + TypesAllowed = propTypesAllowed.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptLanguagesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguageContexts, value.LanguageContexts); + writer.WriteProperty(options, PropTypesAllowed, value.TypesAllowed); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptLanguagesResponseConverter))] public sealed partial class GetScriptLanguagesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("language_contexts")] public IReadOnlyCollection LanguageContexts { get; init; } - [JsonInclude, JsonPropertyName("types_allowed")] public IReadOnlyCollection TypesAllowed { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs index 27db2736d08..5706eb1849b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptRequest.g.cs @@ -60,6 +60,14 @@ public GetScriptRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override string OperationName => "get_script"; + /// + /// + /// Identifier for the stored script or search template. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specify timeout for connection to master diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs index e9e8fa8c010..1cd80230725 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetScriptResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class GetScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override GetScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetScriptResponse + { + Found = propFound.Value +, + Id = propId.Value +, + Script = propScript.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetScriptResponseConverter))] public sealed partial class GetScriptResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.StoredScript? Script { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs index d44b4d6b1a2..77a25122a89 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/GetSourceRequest.g.cs @@ -117,6 +117,22 @@ public GetSourceRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.C internal override string OperationName => "get_source"; + /// + /// + /// Unique identifier of the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Specifies the node or shard the operation should be performed on. Random by default. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs index 9a575d572f9..6e375bb4d21 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreRequest.g.cs @@ -73,6 +73,14 @@ public ExploreRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => internal override string OperationName => "graph.explore"; + /// + /// + /// Name of the index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// Custom value used to route operations to a specific shard. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs index b916b224e45..454e69518bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Graph/ExploreResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Graph; +internal sealed partial class ExploreResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropConnections = System.Text.Json.JsonEncodedText.Encode("connections"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropVertices = System.Text.Json.JsonEncodedText.Encode("vertices"); + + public override ExploreResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propConnections = default; + LocalJsonValue> propFailures = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue> propVertices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propConnections.TryRead(ref reader, options, PropConnections)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propVertices.TryRead(ref reader, options, PropVertices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExploreResponse + { + Connections = propConnections.Value +, + Failures = propFailures.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Vertices = propVertices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExploreResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropConnections, value.Connections); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropVertices, value.Vertices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExploreResponseConverter))] public sealed partial class ExploreResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("connections")] public IReadOnlyCollection Connections { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection Failures { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("vertices")] public IReadOnlyCollection Vertices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs index 1e319f394cf..66fcaf25af9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportRequest.g.cs @@ -99,6 +99,14 @@ public HealthReportRequest(IReadOnlyCollection? feature) : base(r => r.O internal override string OperationName => "health_report"; + /// + /// + /// A feature of the cluster, as returned by the top-level health report API. + /// + /// + [JsonIgnore] + public ICollection? Feature { get => P?>("feature"); set => PO("feature", value); } + /// /// /// Limit the number of affected resources the health report API returns. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs index a076c3eba52..02e62b53372 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/HealthReportResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class HealthReportResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropIndicators = System.Text.Json.JsonEncodedText.Encode("indicators"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + + public override HealthReportResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue propIndicators = default; + LocalJsonValue propStatus = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propIndicators.TryRead(ref reader, options, PropIndicators)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HealthReportResponse + { + ClusterName = propClusterName.Value +, + Indicators = propIndicators.Value +, + Status = propStatus.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthReportResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropIndicators, value.Indicators); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HealthReportResponseConverter))] public sealed partial class HealthReportResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("indicators")] public Elastic.Clients.Elasticsearch.Core.HealthReport.Indicators Indicators { get; init; } - [JsonInclude, JsonPropertyName("status")] public Elastic.Clients.Elasticsearch.Core.HealthReport.IndicatorHealthStatus? Status { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs index aac721e8e18..7beaa0f5730 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleRequest.g.cs @@ -67,6 +67,14 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "ilm.delete_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("policy"); set => PR("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs index 07ce56d24ab..5409538bf73 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/DeleteLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class DeleteLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLifecycleResponseConverter))] public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs index 0cb87d29c09..8d200a31a07 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetIlmStatusResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class GetIlmStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOperationMode = System.Text.Json.JsonEncodedText.Encode("operation_mode"); + + public override GetIlmStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propOperationMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOperationMode.TryRead(ref reader, options, PropOperationMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIlmStatusResponse + { + OperationMode = propOperationMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIlmStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOperationMode, value.OperationMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIlmStatusResponseConverter))] public sealed partial class GetIlmStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("operation_mode")] public Elastic.Clients.Elasticsearch.LifecycleOperationMode OperationMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs index c2d33b459fc..e5bcbd38424 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/GetLifecycleRequest.g.cs @@ -70,6 +70,14 @@ public GetLifecycleRequest(Elastic.Clients.Elasticsearch.Name? name) : base(r => internal override string OperationName => "ilm.get_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("policy"); set => PO("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs index d0d38a0096a..53a5b18e4c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MigrateToDataTiersResponse.g.cs @@ -22,25 +22,113 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class MigrateToDataTiersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDryRun = System.Text.Json.JsonEncodedText.Encode("dry_run"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedComponentTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_component_templates"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedComposableTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_composable_templates"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedIlmPolicies = System.Text.Json.JsonEncodedText.Encode("migrated_ilm_policies"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedIndices = System.Text.Json.JsonEncodedText.Encode("migrated_indices"); + private static readonly System.Text.Json.JsonEncodedText PropMigratedLegacyTemplates = System.Text.Json.JsonEncodedText.Encode("migrated_legacy_templates"); + private static readonly System.Text.Json.JsonEncodedText PropRemovedLegacyTemplate = System.Text.Json.JsonEncodedText.Encode("removed_legacy_template"); + + public override MigrateToDataTiersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDryRun = default; + LocalJsonValue> propMigratedComponentTemplates = default; + LocalJsonValue> propMigratedComposableTemplates = default; + LocalJsonValue> propMigratedIlmPolicies = default; + LocalJsonValue> propMigratedIndices = default; + LocalJsonValue> propMigratedLegacyTemplates = default; + LocalJsonValue propRemovedLegacyTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDryRun.TryRead(ref reader, options, PropDryRun)) + { + continue; + } + + if (propMigratedComponentTemplates.TryRead(ref reader, options, PropMigratedComponentTemplates)) + { + continue; + } + + if (propMigratedComposableTemplates.TryRead(ref reader, options, PropMigratedComposableTemplates)) + { + continue; + } + + if (propMigratedIlmPolicies.TryRead(ref reader, options, PropMigratedIlmPolicies)) + { + continue; + } + + if (propMigratedIndices.TryRead(ref reader, options, PropMigratedIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propMigratedLegacyTemplates.TryRead(ref reader, options, PropMigratedLegacyTemplates)) + { + continue; + } + + if (propRemovedLegacyTemplate.TryRead(ref reader, options, PropRemovedLegacyTemplate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MigrateToDataTiersResponse + { + DryRun = propDryRun.Value +, + MigratedComponentTemplates = propMigratedComponentTemplates.Value +, + MigratedComposableTemplates = propMigratedComposableTemplates.Value +, + MigratedIlmPolicies = propMigratedIlmPolicies.Value +, + MigratedIndices = propMigratedIndices.Value +, + MigratedLegacyTemplates = propMigratedLegacyTemplates.Value +, + RemovedLegacyTemplate = propRemovedLegacyTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MigrateToDataTiersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDryRun, value.DryRun); + writer.WriteProperty(options, PropMigratedComponentTemplates, value.MigratedComponentTemplates); + writer.WriteProperty(options, PropMigratedComposableTemplates, value.MigratedComposableTemplates); + writer.WriteProperty(options, PropMigratedIlmPolicies, value.MigratedIlmPolicies); + writer.WriteProperty(options, PropMigratedIndices, value.MigratedIndices, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropMigratedLegacyTemplates, value.MigratedLegacyTemplates); + writer.WriteProperty(options, PropRemovedLegacyTemplate, value.RemovedLegacyTemplate); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MigrateToDataTiersResponseConverter))] public sealed partial class MigrateToDataTiersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("dry_run")] public bool DryRun { get; init; } - [JsonInclude, JsonPropertyName("migrated_component_templates")] public IReadOnlyCollection MigratedComponentTemplates { get; init; } - [JsonInclude, JsonPropertyName("migrated_composable_templates")] public IReadOnlyCollection MigratedComposableTemplates { get; init; } - [JsonInclude, JsonPropertyName("migrated_ilm_policies")] public IReadOnlyCollection MigratedIlmPolicies { get; init; } - [JsonInclude, JsonPropertyName("migrated_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection MigratedIndices { get; init; } - [JsonInclude, JsonPropertyName("migrated_legacy_templates")] public IReadOnlyCollection MigratedLegacyTemplates { get; init; } - [JsonInclude, JsonPropertyName("removed_legacy_template")] public string RemovedLegacyTemplate { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs index e69e5d40c39..21fc7264d16 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepRequest.g.cs @@ -69,6 +69,13 @@ public MoveToStepRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r internal override string OperationName => "ilm.move_to_step"; + /// + /// + /// The name of the index whose lifecycle step is to change + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } [JsonInclude, JsonPropertyName("current_step")] public Elastic.Clients.Elasticsearch.IndexLifecycleManagement.StepKey CurrentStep { get; set; } [JsonInclude, JsonPropertyName("next_step")] diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs index 081d908885b..7ec146aef1c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/MoveToStepResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class MoveToStepResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override MoveToStepResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MoveToStepResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MoveToStepResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MoveToStepResponseConverter))] public sealed partial class MoveToStepResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class MoveToStepResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs index 3b17d1e0c82..3d0fe0f62ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleRequest.g.cs @@ -70,6 +70,14 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => internal override string OperationName => "ilm.put_lifecycle"; + /// + /// + /// Identifier for the policy. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("policy"); set => PR("policy", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs index d9f92f43a06..b7da05c3993 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/PutLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class PutLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutLifecycleResponseConverter))] public sealed partial class PutLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs index 9c0c9c4438b..8dcffe73cb7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyRequest.g.cs @@ -54,6 +54,14 @@ public RemovePolicyRequest(Elastic.Clients.Elasticsearch.IndexName index) : base internal override bool SupportsBody => false; internal override string OperationName => "ilm.remove_policy"; + + /// + /// + /// The name of the index to remove policy on + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs index 2b40e8f3b60..266963be915 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RemovePolicyResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class RemovePolicyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFailedIndexes = System.Text.Json.JsonEncodedText.Encode("failed_indexes"); + private static readonly System.Text.Json.JsonEncodedText PropHasFailures = System.Text.Json.JsonEncodedText.Encode("has_failures"); + + public override RemovePolicyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFailedIndexes = default; + LocalJsonValue propHasFailures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFailedIndexes.TryRead(ref reader, options, PropFailedIndexes)) + { + continue; + } + + if (propHasFailures.TryRead(ref reader, options, PropHasFailures)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemovePolicyResponse + { + FailedIndexes = propFailedIndexes.Value +, + HasFailures = propHasFailures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemovePolicyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFailedIndexes, value.FailedIndexes); + writer.WriteProperty(options, PropHasFailures, value.HasFailures); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemovePolicyResponseConverter))] public sealed partial class RemovePolicyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("failed_indexes")] public IReadOnlyCollection FailedIndexes { get; init; } - [JsonInclude, JsonPropertyName("has_failures")] public bool HasFailures { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs index 7ffff1bb01e..3c6370785d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryRequest.g.cs @@ -55,6 +55,14 @@ public RetryRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r internal override bool SupportsBody => false; internal override string OperationName => "ilm.retry"; + + /// + /// + /// The name of the indices (comma-separated) whose failed lifecycle step is to be retry + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs index 73e6389fe10..da40145b492 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/RetryResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class RetryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override RetryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RetryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RetryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RetryResponseConverter))] public sealed partial class RetryResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class RetryResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs index 039eca5b3fc..3278e62d454 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StartIlmResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class StartIlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartIlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartIlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartIlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartIlmResponseConverter))] public sealed partial class StartIlmResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StartIlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs index d41403aec0b..1d87cd436b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexLifecycleManagement/StopIlmResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexLifecycleManagement; +internal sealed partial class StopIlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopIlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopIlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopIlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopIlmResponseConverter))] public sealed partial class StopIlmResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StopIlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs index 0a17e30d21c..ea7718007fc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexRequest.g.cs @@ -34,12 +34,126 @@ public sealed partial class AnalyzeIndexRequestParameters : RequestParameters { } +internal sealed partial class AnalyzeIndexRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropCharFilter = System.Text.Json.JsonEncodedText.Encode("char_filter"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropNormalizer = System.Text.Json.JsonEncodedText.Encode("normalizer"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText PropTokenizer = System.Text.Json.JsonEncodedText.Encode("tokenizer"); + + public override AnalyzeIndexRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue?> propAttributes = default; + LocalJsonValue?> propCharFilter = default; + LocalJsonValue propExplain = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propNormalizer = default; + LocalJsonValue?> propText = default; + LocalJsonValue propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAttributes.TryRead(ref reader, options, PropAttributes)) + { + continue; + } + + if (propCharFilter.TryRead(ref reader, options, PropCharFilter)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propNormalizer.TryRead(ref reader, options, PropNormalizer)) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propTokenizer.TryRead(ref reader, options, PropTokenizer)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalyzeIndexRequest + { + Analyzer = propAnalyzer.Value +, + Attributes = propAttributes.Value +, + CharFilter = propCharFilter.Value +, + Explain = propExplain.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + Normalizer = propNormalizer.Value +, + Text = propText.Value +, + Tokenizer = propTokenizer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalyzeIndexRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAttributes, value.Attributes); + writer.WriteProperty(options, PropCharFilter, value.CharFilter); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropNormalizer, value.Normalizer); + writer.WriteProperty(options, PropText, value.Text, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer); + writer.WriteEndObject(); + } +} + /// /// /// Get tokens from text analysis. /// The analyze API performs analysis on a text string and returns the resulting tokens. /// /// +[JsonConverter(typeof(AnalyzeIndexRequestConverter))] public sealed partial class AnalyzeIndexRequest : PlainRequest { public AnalyzeIndexRequest() @@ -58,13 +172,21 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas internal override string OperationName => "indices.analyze"; + /// + /// + /// Index used to derive the analyzer. + /// If specified, the analyzer or field parameter overrides this value. + /// If no index is specified or the index does not have a default analyzer, the analyze API uses the standard analyzer. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// The name of the analyzer that should be applied to the provided text. /// This could be a built-in analyzer, or an analyzer that’s been configured in the index. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -72,7 +194,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of token attributes used to filter the output of the explain parameter. /// /// - [JsonInclude, JsonPropertyName("attributes")] public ICollection? Attributes { get; set; } /// @@ -80,7 +201,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of character filters used to preprocess characters before the tokenizer. /// /// - [JsonInclude, JsonPropertyName("char_filter")] public ICollection? CharFilter { get; set; } /// @@ -88,7 +208,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// If true, the response includes token attributes and additional details. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -98,7 +217,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// If specified, the analyzer parameter overrides this value. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -106,7 +224,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Array of token filters used to apply after the tokenizer. /// /// - [JsonInclude, JsonPropertyName("filter")] public ICollection? Filter { get; set; } /// @@ -114,7 +231,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Normalizer to use to convert text into a single token. /// /// - [JsonInclude, JsonPropertyName("normalizer")] public string? Normalizer { get; set; } /// @@ -123,8 +239,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// If an array of strings is provided, it is analyzed as a multi-value field. /// /// - [JsonInclude, JsonPropertyName("text")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Text { get; set; } /// @@ -132,7 +246,6 @@ public AnalyzeIndexRequest(Elastic.Clients.Elasticsearch.IndexName? index) : bas /// Tokenizer to use to convert text into tokens. /// /// - [JsonInclude, JsonPropertyName("tokenizer")] public Elastic.Clients.Elasticsearch.Analysis.ITokenizer? Tokenizer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs index 13b4f7e9f3a..3998799588b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/AnalyzeIndexResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class AnalyzeIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDetail = System.Text.Json.JsonEncodedText.Encode("detail"); + private static readonly System.Text.Json.JsonEncodedText PropTokens = System.Text.Json.JsonEncodedText.Encode("tokens"); + + public override AnalyzeIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDetail = default; + LocalJsonValue?> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetail.TryRead(ref reader, options, PropDetail)) + { + continue; + } + + if (propTokens.TryRead(ref reader, options, PropTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalyzeIndexResponse + { + Detail = propDetail.Value +, + Tokens = propTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalyzeIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetail, value.Detail); + writer.WriteProperty(options, PropTokens, value.Tokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AnalyzeIndexResponseConverter))] public sealed partial class AnalyzeIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("detail")] public Elastic.Clients.Elasticsearch.IndexManagement.AnalyzeDetail? Detail { get; init; } - [JsonInclude, JsonPropertyName("tokens")] public IReadOnlyCollection? Tokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs index 86ff0cc74bc..3e9043e033c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheRequest.g.cs @@ -112,6 +112,16 @@ public ClearCacheRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.clear_cache"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs index 889431a5852..e2c10141606 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ClearCacheResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ClearCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ClearCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCacheResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCacheResponseConverter))] public sealed partial class ClearCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs index e6c9e2e8529..d6c521341ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexRequest.g.cs @@ -128,6 +128,22 @@ public CloneIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.clone"; + /// + /// + /// Name of the source index to clone. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs index e4a02be3cea..8f2b9c72924 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloneIndexResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class CloneIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override CloneIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloneIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloneIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloneIndexResponseConverter))] public sealed partial class CloneIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs index e531c9a51b4..224b19040ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexRequest.g.cs @@ -122,6 +122,14 @@ public CloseIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.close"; + /// + /// + /// Comma-separated list or wildcard expression of index names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs index 388a41401eb..586c55df411 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CloseIndexResponse.g.cs @@ -22,17 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class CloseIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override CloseIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloseIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Indices = propIndices.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloseIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloseIndexResponseConverter))] public sealed partial class CloseIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.CloseIndexResult))] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs index 1c318a40ef9..95f8f086531 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamRequest.g.cs @@ -68,6 +68,19 @@ public CreateDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamName name internal override string OperationName => "indices.create_data_stream"; + /// + /// + /// Name of the data stream, which must meet the following criteria: + /// Lowercase only; + /// Cannot include \, /, *, ?, ", <, >, |, ,, #, :, or a space character; + /// Cannot start with -, _, +, or .ds-; + /// Cannot be . or ..; + /// Cannot be longer than 255 bytes. Multi-byte characters count towards this limit faster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs index 8317bdb2da9..1b827267108 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateDataStreamResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class CreateDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CreateDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateDataStreamResponseConverter))] public sealed partial class CreateDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class CreateDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs index 1cab06ad5e6..51d4b22cf3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexRequest.g.cs @@ -77,6 +77,14 @@ public CreateIndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override string OperationName => "indices.create"; + /// + /// + /// Name of the index you wish to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs index 8a847b2e204..b9b5301dcfe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/CreateIndexResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class CreateIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override CreateIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateIndexResponseConverter))] public sealed partial class CreateIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs index 91a722ceab5..b7e9c2eb8e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsRequest.g.cs @@ -65,6 +65,16 @@ public DataStreamsStatsRequest(Elastic.Clients.Elasticsearch.IndexName? name) : internal override string OperationName => "indices.data_streams_stats"; + /// + /// + /// Comma-separated list of data streams used to limit the request. + /// Wildcard expressions (*) are supported. + /// To target all data streams in a cluster, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Name { get => P("name"); set => PO("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs index e4b9e962207..fbc17c1ce5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DataStreamsStatsResponse.g.cs @@ -22,10 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DataStreamsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackingIndices = System.Text.Json.JsonEncodedText.Encode("backing_indices"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreamCount = System.Text.Json.JsonEncodedText.Encode("data_stream_count"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTotalStoreSizeBytes = System.Text.Json.JsonEncodedText.Encode("total_store_size_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropTotalStoreSizes = System.Text.Json.JsonEncodedText.Encode("total_store_sizes"); + + public override DataStreamsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBackingIndices = default; + LocalJsonValue propDataStreamCount = default; + LocalJsonValue> propDataStreams = default; + LocalJsonValue propShards = default; + LocalJsonValue propTotalStoreSizeBytes = default; + LocalJsonValue propTotalStoreSizes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryRead(ref reader, options, PropBackingIndices)) + { + continue; + } + + if (propDataStreamCount.TryRead(ref reader, options, PropDataStreamCount)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTotalStoreSizeBytes.TryRead(ref reader, options, PropTotalStoreSizeBytes)) + { + continue; + } + + if (propTotalStoreSizes.TryRead(ref reader, options, PropTotalStoreSizes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataStreamsStatsResponse + { + BackingIndices = propBackingIndices.Value +, + DataStreamCount = propDataStreamCount.Value +, + DataStreams = propDataStreams.Value +, + Shards = propShards.Value +, + TotalStoreSizeBytes = propTotalStoreSizeBytes.Value +, + TotalStoreSizes = propTotalStoreSizes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataStreamsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackingIndices, value.BackingIndices); + writer.WriteProperty(options, PropDataStreamCount, value.DataStreamCount); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTotalStoreSizeBytes, value.TotalStoreSizeBytes); + writer.WriteProperty(options, PropTotalStoreSizes, value.TotalStoreSizes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataStreamsStatsResponseConverter))] public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +119,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total number of backing indices for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("backing_indices")] public int BackingIndices { get; init; } /// @@ -41,7 +126,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total number of selected data streams. /// /// - [JsonInclude, JsonPropertyName("data_stream_count")] public int DataStreamCount { get; init; } /// @@ -49,7 +133,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Contains statistics for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } /// @@ -57,7 +140,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Contains information about shards that attempted to execute the request. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } /// @@ -65,7 +147,6 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// Total size, in bytes, of all shards for the selected data streams. /// /// - [JsonInclude, JsonPropertyName("total_store_size_bytes")] public long TotalStoreSizeBytes { get; init; } /// @@ -74,6 +155,5 @@ public sealed partial class DataStreamsStatsResponse : ElasticsearchResponse /// This property is included only if the human query parameter is true /// /// - [JsonInclude, JsonPropertyName("total_store_sizes")] public Elastic.Clients.Elasticsearch.ByteSize? TotalStoreSizes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs index 588bc1ad8f5..9d473ceef2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasRequest.g.cs @@ -69,6 +69,24 @@ public DeleteAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic internal override string OperationName => "indices.delete_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. + /// Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// Comma-separated list of aliases to remove. + /// Supports wildcards (*). To remove all aliases, use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs index ae5ec7e2278..0c2e6c09166 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteAliasResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAliasResponseConverter))] public sealed partial class DeleteAliasResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs index 0a961381c9e..ae59e36a01c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleRequest.g.cs @@ -74,6 +74,14 @@ public DeleteDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames internal override string OperationName => "indices.delete_data_lifecycle"; + /// + /// + /// A comma-separated list of data streams of which the data stream lifecycle will be deleted; use * to get all data streams + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Whether wildcard expressions should get expanded to open or closed indices (default: open) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs index f9d2038fc50..052ec9b957a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataLifecycleResponseConverter))] public sealed partial class DeleteDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteDataLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs index 80fccc1863f..472659d8462 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamRequest.g.cs @@ -67,6 +67,14 @@ public DeleteDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.delete_data_stream"; + /// + /// + /// Comma-separated list of data streams to delete. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. Supports comma-separated values,such as open,hidden. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs index fbecc62a90f..6c5149fb006 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteDataStreamResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataStreamResponseConverter))] public sealed partial class DeleteDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs index f73c4862ff4..7778a19223d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexRequest.g.cs @@ -94,6 +94,17 @@ public DeleteIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base( internal override string OperationName => "indices.delete"; + /// + /// + /// Comma-separated list of indices to delete. + /// You cannot specify index aliases. + /// By default, this parameter does not support wildcards (*) or _all. + /// To use wildcards or _all, set the action.destructive_requires_name cluster setting to false. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs index 1462583eece..c9c259de634 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override DeleteIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexResponseConverter))] public sealed partial class DeleteIndexResponse : ElasticsearchResponse { /// @@ -33,8 +79,6 @@ public sealed partial class DeleteIndexResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs index 196e97ac096..6c32e936ee0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateRequest.g.cs @@ -69,6 +69,14 @@ public DeleteIndexTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : ba internal override string OperationName => "indices.delete_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs index b80c8280abb..43a3f7ff820 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteIndexTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIndexTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIndexTemplateResponseConverter))] public sealed partial class DeleteIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteIndexTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs index 22c27dca5fb..2cddb0232a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateRequest.g.cs @@ -68,6 +68,15 @@ public DeleteTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = internal override string OperationName => "indices.delete_template"; + /// + /// + /// The name of the legacy index template to delete. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs index a4129c54a7c..348a8fbea08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DeleteTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class DeleteTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTemplateResponseConverter))] public sealed partial class DeleteTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs index f72d916026c..2da62c4122b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DiskUsageRequest.g.cs @@ -96,6 +96,15 @@ public DiskUsageRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.disk_usage"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// It’s recommended to execute this API with a single index (or the latest backing index of a data stream) as the API consumes resources significantly. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs index 0685bdc4ac9..a1a8bf75aeb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/DownsampleRequest.g.cs @@ -47,7 +47,7 @@ public sealed partial class DownsampleRequestParameters : RequestParameters /// The source index must be read only (index.blocks.write: true). /// /// -public sealed partial class DownsampleRequest : PlainRequest, ISelfSerializable +public sealed partial class DownsampleRequest : PlainRequest, ISelfTwoWaySerializable { public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.IndexName targetIndex) : base(r => r.Required("index", index).Required("target_index", targetIndex)) { @@ -61,13 +61,32 @@ public DownsampleRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.downsample"; + /// + /// + /// Name of the time series index to downsample. + /// + /// [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName TargetIndex { get => P("target_index"); set => PR("target_index", value); } public Elastic.Clients.Elasticsearch.IndexManagement.DownsampleConfig Config { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Config, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Config = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs index ee84ea82590..9d56d680353 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsAliasRequest.g.cs @@ -90,6 +90,23 @@ public ExistsAliasRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elasti internal override string OperationName => "indices.exists_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list of aliases to check. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs index 0fafea15669..643ad1a009f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsIndexTemplateRequest.g.cs @@ -60,6 +60,14 @@ public ExistsIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : bas internal override string OperationName => "indices.exists_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs index efbc7dff46a..d33e7ac0d0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsRequest.g.cs @@ -99,6 +99,14 @@ public ExistsRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => internal override string OperationName => "indices.exists"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs index 59042066550..fd4e455c3bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExistsTemplateRequest.g.cs @@ -74,6 +74,14 @@ public ExistsTemplateRequest(Elastic.Clients.Elasticsearch.Names name) : base(r internal override string OperationName => "indices.exists_template"; + /// + /// + /// The comma separated names of the index templates + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// Return settings in flat format (default: false) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs index 5eab5eca85d..a46e94dce57 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleRequest.g.cs @@ -67,6 +67,14 @@ public ExplainDataLifecycleRequest(Elastic.Clients.Elasticsearch.Indices indices internal override string OperationName => "indices.explain_data_lifecycle"; + /// + /// + /// The name of the index to explain + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// indicates if the API should return the default values the system uses for the index's lifecycle diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs index 8dfd1f29eeb..8551f177d71 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ExplainDataLifecycleResponse.g.cs @@ -22,13 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ExplainDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ExplainDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainDataLifecycleResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataLifecycleResponseConverter))] public sealed partial class ExplainDataLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycleExplain))] public IReadOnlyDictionary Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs index 32d5670584b..bc4277d791e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsRequest.g.cs @@ -111,6 +111,14 @@ public FieldUsageStatsRequest(Elastic.Clients.Elasticsearch.Indices indices) : b internal override string OperationName => "indices.field_usage_stats"; + /// + /// + /// Comma-separated list or wildcard expression of index names used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs index f5e5ded303a..bc3c908bdc9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FieldUsageStatsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class FieldUsageStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override FieldUsageStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldUsageStatsResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldUsageStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldUsageStatsResponseConverter))] public sealed partial class FieldUsageStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs index c11cb3fc5ee..704958472c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushRequest.g.cs @@ -108,6 +108,16 @@ public FlushRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "indices.flush"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to flush. + /// Supports wildcards (*). + /// To flush all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs index a65538aaae8..8d01eb5909f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/FlushResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class FlushResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override FlushResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FlushResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FlushResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushResponseConverter))] public sealed partial class FlushResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs index 9059a333f91..66c48001463 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeRequest.g.cs @@ -119,6 +119,14 @@ public ForcemergeRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.forcemerge"; + /// + /// + /// A comma-separated list of index names; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs index 31e852e84b8..a877d7a8619 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ForcemergeResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ForcemergeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + + public override ForcemergeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + LocalJsonValue propTask = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForcemergeResponse + { + Shards = propShards.Value +, + Task = propTask.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForcemergeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForcemergeResponseConverter))] public sealed partial class ForcemergeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } /// @@ -37,6 +82,5 @@ public sealed partial class ForcemergeResponse : ElasticsearchResponse /// you can use the task_id to get the status of the task at _tasks/<task_id> /// /// - [JsonInclude, JsonPropertyName("task")] public string? Task { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs index 0b66e257a11..12ddba6413a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetAliasRequest.g.cs @@ -98,6 +98,26 @@ public GetAliasRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.get_alias"; + /// + /// + /// Comma-separated list of data streams or indices used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list of aliases to retrieve. + /// Supports wildcards (*). + /// To retrieve all aliases, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs index 49f3058f361..83517f89de3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleRequest.g.cs @@ -76,6 +76,16 @@ public GetDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.get_data_lifecycle"; + /// + /// + /// Comma-separated list of data streams to limit the request. + /// Supports wildcards (*). + /// To target all data streams, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs index 9fcbcfc0c5c..e0d7b61b03a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataLifecycleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class GetDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + + public override GetDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataLifecycleResponse + { + DataStreams = propDataStreams.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataLifecycleResponseConverter))] public sealed partial class GetDataLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs index ce6a1e7e754..e76e196ee12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamRequest.g.cs @@ -86,6 +86,15 @@ public GetDataStreamRequest(Elastic.Clients.Elasticsearch.DataStreamNames? name) internal override string OperationName => "indices.get_data_stream"; + /// + /// + /// Comma-separated list of data stream names used to limit the request. + /// Wildcard (*) expressions are supported. If omitted, all data streams are returned. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames? Name { get => P("name"); set => PO("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs index f6c1a882edf..d4292095cb8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetDataStreamResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class GetDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + + public override GetDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDataStreams = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataStreamResponse + { + DataStreams = propDataStreams.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataStreamResponseConverter))] public sealed partial class GetDataStreamResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs index 960c83e0bab..ed81fee9355 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetFieldMappingRequest.g.cs @@ -97,6 +97,24 @@ public GetFieldMappingRequest(Elastic.Clients.Elasticsearch.Indices? indices, El internal override string OperationName => "indices.get_field_mapping"; + /// + /// + /// Comma-separated list or wildcard expression of fields used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Fields Fields { get => P("fields"); set => PR("fields", value); } + + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs index 69965de963b..a0e317478ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexRequest.g.cs @@ -114,6 +114,15 @@ public GetIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r = internal override string OperationName => "indices.get"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. + /// Wildcard expressions (*) are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs index b4c809766b6..fe40d04ff0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateRequest.g.cs @@ -85,6 +85,14 @@ public GetIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : base( internal override string OperationName => "indices.get_index_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs index bc57e63ef5e..235fdc92171 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndexTemplateResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class GetIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndexTemplates = System.Text.Json.JsonEncodedText.Encode("index_templates"); + + public override GetIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndexTemplates = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndexTemplates.TryRead(ref reader, options, PropIndexTemplates)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIndexTemplateResponse + { + IndexTemplates = propIndexTemplates.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndexTemplates, value.IndexTemplates); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIndexTemplateResponseConverter))] public sealed partial class GetIndexTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("index_templates")] public IReadOnlyCollection IndexTemplates { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs index 64fa5aa087b..80ab3e91f71 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetIndicesSettingsRequest.g.cs @@ -124,6 +124,24 @@ public GetIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Names? name) : ba internal override string OperationName => "indices.get_settings"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit + /// the request. Supports wildcards (*). To target all data streams and + /// indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Comma-separated list or wildcard expression of settings to retrieve. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs index ef614f8fa4e..dce2fff5f26 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetMappingRequest.g.cs @@ -98,6 +98,16 @@ public GetMappingRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "indices.get_mapping"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs index e65ca2399a7..611e00f2cd7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/GetTemplateRequest.g.cs @@ -79,6 +79,16 @@ public GetTemplateRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => internal override string OperationName => "indices.get_template"; + /// + /// + /// Comma-separated list of index template names used to limit the request. + /// Wildcard (*) expressions are supported. + /// To return all index templates, omit this parameter or use a value of _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs index ec9c41d2b62..5beaa4ab9ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsRequest.g.cs @@ -142,6 +142,22 @@ public IndicesStatsRequest(Elastic.Clients.Elasticsearch.Indices? indices, Elast internal override string OperationName => "indices.stats"; + /// + /// + /// A comma-separated list of index names; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + + /// + /// + /// Limit the information returned the specific metrics. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs index 7a78a645850..89f7422fd5d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/IndicesStatsResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class IndicesStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAll = System.Text.Json.JsonEncodedText.Encode("_all"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override IndicesStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAll = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAll.TryRead(ref reader, options, PropAll)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndicesStatsResponse + { + All = propAll.Value +, + Indices = propIndices.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicesStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAll, value.All); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndicesStatsResponseConverter))] public sealed partial class IndicesStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_all")] public Elastic.Clients.Elasticsearch.IndexManagement.IndicesStats All { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyDictionary? Indices { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs index c58975294e3..c22a4f3880f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamRequest.g.cs @@ -76,6 +76,14 @@ public MigrateToDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) internal override string OperationName => "indices.migrate_to_data_stream"; + /// + /// + /// Name of the index alias to convert to a data stream. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs index 48d6aa2e95e..28fc5e135d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/MigrateToDataStreamResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class MigrateToDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override MigrateToDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MigrateToDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MigrateToDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MigrateToDataStreamResponseConverter))] public sealed partial class MigrateToDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class MigrateToDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs index f55c2d8935d..f7bec2bbdda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ModifyDataStreamResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ModifyDataStreamResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ModifyDataStreamResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ModifyDataStreamResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ModifyDataStreamResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ModifyDataStreamResponseConverter))] public sealed partial class ModifyDataStreamResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ModifyDataStreamResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs index b1a51e3447a..89c4c8e9b5e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexRequest.g.cs @@ -102,6 +102,18 @@ public OpenIndexRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.open"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// By default, you must explicitly name the indices you using to limit the request. + /// To limit a request using _all, *, or other wildcard expressions, change the action.destructive_requires_name setting to false. + /// You can update this setting in the elasticsearch.yml file or using the cluster update settings API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs index bfbbff8b77c..0f408cee712 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/OpenIndexResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class OpenIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override OpenIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenIndexResponse + { + Acknowledged = propAcknowledged.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenIndexResponseConverter))] public sealed partial class OpenIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs index 1ba3ecb759f..35e16c1ba89 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PromoteDataStreamRequest.g.cs @@ -71,6 +71,14 @@ public PromoteDataStreamRequest(Elastic.Clients.Elasticsearch.IndexName name) : internal override string OperationName => "indices.promote_data_stream"; + /// + /// + /// The name of the data stream + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs index 19d5e829a83..0ec49210086 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasRequest.g.cs @@ -69,6 +69,26 @@ public PutAliasRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.Cl internal override string OperationName => "indices.put_alias"; + /// + /// + /// Comma-separated list of data streams or indices to add. + /// Supports wildcards (*). + /// Wildcard patterns that match both data streams and indices return an error. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// Alias to update. + /// If the alias doesn’t exist, the request creates it. + /// Index alias names support date math. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs index 4b2d5f8e957..8af31b149c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutAliasResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutAliasResponseConverter))] public sealed partial class PutAliasResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs index 85d023869c7..e4fb79f45e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleRequest.g.cs @@ -65,7 +65,7 @@ public sealed partial class PutDataLifecycleRequestParameters : RequestParameter /// Update the data stream lifecycle of the specified data streams. /// /// -public sealed partial class PutDataLifecycleRequest : PlainRequest, ISelfSerializable +public sealed partial class PutDataLifecycleRequest : PlainRequest, ISelfTwoWaySerializable { public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames name) : base(r => r.Required("name", name)) { @@ -79,6 +79,16 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam internal override string OperationName => "indices.put_data_lifecycle"; + /// + /// + /// Comma-separated list of data streams used to limit the request. + /// Supports wildcards (*). + /// To target all data streams use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.DataStreamNames Name { get => P("name"); set => PR("name", value); } + /// /// /// Type of data stream that wildcard patterns can match. @@ -107,13 +117,17 @@ public PutDataLifecycleRequest(Elastic.Clients.Elasticsearch.DataStreamNames nam /// [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycle Lifecycle { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Lifecycle, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Lifecycle = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs index ba771b59fb4..e6ff8d1fc08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutDataLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutDataLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutDataLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDataLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDataLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDataLifecycleResponseConverter))] public sealed partial class PutDataLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutDataLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs index 614820e2fd8..e603d546f52 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateRequest.g.cs @@ -75,6 +75,14 @@ public PutIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "indices.put_index_template"; + /// + /// + /// Index or template name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// User defined reason for creating/updating the index template diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs index ca9c859e0ba..fbe25326db9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndexTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIndexTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndexTemplateResponseConverter))] public sealed partial class PutIndexTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutIndexTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs index 9eb516eb4e1..90089859d84 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsRequest.g.cs @@ -99,7 +99,7 @@ public sealed partial class PutIndicesSettingsRequestParameters : RequestParamet /// changes are applied to all backing indices by default. /// /// -public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfSerializable +public sealed partial class PutIndicesSettingsRequest : PlainRequest, ISelfTwoWaySerializable { public PutIndicesSettingsRequest() { @@ -117,6 +117,16 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) internal override string OperationName => "indices.put_settings"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit + /// the request. Supports wildcards (*). To target all data streams and + /// indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index @@ -182,13 +192,17 @@ public PutIndicesSettingsRequest(Elastic.Clients.Elasticsearch.Indices? indices) /// [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings Settings { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Settings, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Settings = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs index f5ada21c60d..29a71be57a5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutIndicesSettingsResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutIndicesSettingsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIndicesSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIndicesSettingsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIndicesSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIndicesSettingsResponseConverter))] public sealed partial class PutIndicesSettingsResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutIndicesSettingsResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs index 708c10deaef..6599d7a2228 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingRequest.g.cs @@ -81,6 +81,139 @@ public sealed partial class PutMappingRequestParameters : RequestParameters public bool? WriteIndexOnly { get => Q("write_index_only"); set => Q("write_index_only", value); } } +internal sealed partial class PutMappingRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDateDetection = System.Text.Json.JsonEncodedText.Encode("date_detection"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropDynamicDateFormats = System.Text.Json.JsonEncodedText.Encode("dynamic_date_formats"); + private static readonly System.Text.Json.JsonEncodedText PropDynamicTemplates = System.Text.Json.JsonEncodedText.Encode("dynamic_templates"); + private static readonly System.Text.Json.JsonEncodedText PropFieldNames = System.Text.Json.JsonEncodedText.Encode("_field_names"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropNumericDetection = System.Text.Json.JsonEncodedText.Encode("numeric_detection"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override PutMappingRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDateDetection = default; + LocalJsonValue propDynamic = default; + LocalJsonValue?> propDynamicDateFormats = default; + LocalJsonValue>?> propDynamicTemplates = default; + LocalJsonValue propFieldNames = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNumericDetection = default; + LocalJsonValue propProperties = default; + LocalJsonValue propRouting = default; + LocalJsonValue?> propRuntime = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDateDetection.TryRead(ref reader, options, PropDateDetection)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propDynamicDateFormats.TryRead(ref reader, options, PropDynamicDateFormats)) + { + continue; + } + + if (propDynamicTemplates.TryRead(ref reader, options, PropDynamicTemplates, typeof(SingleOrManyMarker>?, IDictionary>))) + { + continue; + } + + if (propFieldNames.TryRead(ref reader, options, PropFieldNames)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNumericDetection.TryRead(ref reader, options, PropNumericDetection)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propRuntime.TryRead(ref reader, options, PropRuntime)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutMappingRequest + { + DateDetection = propDateDetection.Value + , + Dynamic = propDynamic.Value + , + DynamicDateFormats = propDynamicDateFormats.Value + , + DynamicTemplates = propDynamicTemplates.Value + , + FieldNames = propFieldNames.Value + , + Meta = propMeta.Value + , + NumericDetection = propNumericDetection.Value + , + Properties = propProperties.Value + , + Routing = propRouting.Value + , + Runtime = propRuntime.Value + , + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutMappingRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDateDetection, value.DateDetection); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropDynamicDateFormats, value.DynamicDateFormats); + writer.WriteProperty(options, PropDynamicTemplates, value.DynamicTemplates, null, typeof(SingleOrManyMarker>?, IDictionary>)); + writer.WriteProperty(options, PropFieldNames, value.FieldNames); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNumericDetection, value.NumericDetection); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropRuntime, value.Runtime); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteEndObject(); + } +} + /// /// /// Update field mappings. @@ -89,6 +222,7 @@ public sealed partial class PutMappingRequestParameters : RequestParameters /// For data streams, these changes are applied to all backing indices by default. /// /// +[JsonConverter(typeof(PutMappingRequestConverter))] public sealed partial class PutMappingRequest : PlainRequest { public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r => r.Required("index", indices)) @@ -103,13 +237,19 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r internal override string OperationName => "indices.put_mapping"; + /// + /// + /// A comma-separated list of index names the mapping should be added to (supports wildcards); use _all or omit to add the mapping on all indices. + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. /// This behavior applies even if the request targets other open indices. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -120,7 +260,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Valid values are: all, open, closed, hidden, none. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -128,7 +267,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If false, the request returns an error if it targets a missing or closed index. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -137,7 +275,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -146,7 +283,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If no response is received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -154,7 +290,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// If true, the mappings are applied only to the current write index for the target. /// /// - [JsonIgnore] public bool? WriteIndexOnly { get => Q("write_index_only"); set => Q("write_index_only", value); } /// @@ -162,7 +297,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Controls whether dynamic date detection is enabled. /// /// - [JsonInclude, JsonPropertyName("date_detection")] public bool? DateDetection { get; set; } /// @@ -170,7 +304,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Controls whether new fields are added dynamically. /// /// - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } /// @@ -180,7 +313,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// a new date field is added instead of string. /// /// - [JsonInclude, JsonPropertyName("dynamic_date_formats")] public ICollection? DynamicDateFormats { get; set; } /// @@ -188,8 +320,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Specify dynamic templates for the mapping. /// /// - [JsonInclude, JsonPropertyName("dynamic_templates")] - [SingleOrManyCollectionConverter(typeof(IReadOnlyDictionary))] public ICollection>? DynamicTemplates { get; set; } /// @@ -197,7 +327,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Control whether field names are enabled for the index. /// /// - [JsonInclude, JsonPropertyName("_field_names")] public Elastic.Clients.Elasticsearch.Mapping.FieldNamesField? FieldNames { get; set; } /// @@ -207,7 +336,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// application-specific metadata. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IDictionary? Meta { get; set; } /// @@ -215,7 +343,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Automatically map strings into numeric data types for all fields. /// /// - [JsonInclude, JsonPropertyName("numeric_detection")] public bool? NumericDetection { get; set; } /// @@ -240,7 +367,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// /// /// - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } /// @@ -248,7 +374,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Enable making a routing value required on indexed documents. /// /// - [JsonInclude, JsonPropertyName("_routing")] public Elastic.Clients.Elasticsearch.Mapping.RoutingField? Routing { get; set; } /// @@ -256,7 +381,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Mapping of runtime fields for the index. /// /// - [JsonInclude, JsonPropertyName("runtime")] public IDictionary? Runtime { get; set; } /// @@ -264,7 +388,6 @@ public PutMappingRequest(Elastic.Clients.Elasticsearch.Indices indices) : base(r /// Control whether the _source field is enabled on the index. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Mapping.SourceField? Source { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs index ee2d54544d5..fe57797d3b2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutMappingResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override PutMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutMappingResponse + { + Acknowledged = propAcknowledged.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutMappingResponseConverter))] public sealed partial class PutMappingResponse : ElasticsearchResponse { /// @@ -33,8 +79,6 @@ public sealed partial class PutMappingResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs index 6c14ce93433..53ec9f51491 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateRequest.g.cs @@ -50,6 +50,89 @@ public sealed partial class PutTemplateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } } +internal sealed partial class PutTemplateRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPatterns = System.Text.Json.JsonEncodedText.Encode("index_patterns"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutTemplateRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAliases = default; + LocalJsonValue?> propIndexPatterns = default; + LocalJsonValue propMappings = default; + LocalJsonValue propOrder = default; + LocalJsonValue propSettings = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAliases.TryRead(ref reader, options, PropAliases)) + { + continue; + } + + if (propIndexPatterns.TryRead(ref reader, options, PropIndexPatterns, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propMappings.TryRead(ref reader, options, PropMappings)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } + + if (propSettings.TryRead(ref reader, options, PropSettings)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTemplateRequest + { + Aliases = propAliases.Value + , + IndexPatterns = propIndexPatterns.Value + , + Mappings = propMappings.Value + , + Order = propOrder.Value + , + Settings = propSettings.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTemplateRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAliases, value.Aliases); + writer.WriteProperty(options, PropIndexPatterns, value.IndexPatterns, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMappings, value.Mappings); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropSettings, value.Settings); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + /// /// /// Create or update an index template. @@ -69,6 +152,7 @@ public sealed partial class PutTemplateRequestParameters : RequestParameters /// Settings and mappings specified in create index API requests override any settings or mappings specified in an index template. /// /// +[JsonConverter(typeof(PutTemplateRequestConverter))] public sealed partial class PutTemplateRequest : PlainRequest { public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) @@ -83,7 +167,12 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r internal override string OperationName => "indices.put_template"; - [JsonIgnore] + /// + /// + /// The name of the template + /// + /// + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } public string? Cause { get => Q("cause"); set => Q("cause", value); } /// @@ -91,7 +180,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// If true, this request cannot replace or update existing index templates. /// /// - [JsonIgnore] public bool? Create { get => Q("create"); set => Q("create", value); } /// @@ -100,7 +188,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// received before the timeout expires, the request fails and returns an error. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } /// @@ -108,7 +195,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Aliases for the index. /// /// - [JsonInclude, JsonPropertyName("aliases")] public IDictionary? Aliases { get; set; } /// @@ -117,8 +203,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// of indices during creation. /// /// - [JsonInclude, JsonPropertyName("index_patterns")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? IndexPatterns { get; set; } /// @@ -126,7 +210,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Mapping for fields in the index. /// /// - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping? Mappings { get; set; } /// @@ -139,7 +222,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// 'order' values are merged later, overriding templates with lower values. /// /// - [JsonInclude, JsonPropertyName("order")] public int? Order { get; set; } /// @@ -147,7 +229,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// Configuration options for the index. /// /// - [JsonInclude, JsonPropertyName("settings")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings? Settings { get; set; } /// @@ -156,7 +237,6 @@ public PutTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r /// is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs index 45918fda300..26811138356 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/PutTemplateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class PutTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTemplateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTemplateResponseConverter))] public sealed partial class PutTemplateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutTemplateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs index fa16870effe..a2619ece820 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RecoveryRequest.g.cs @@ -119,6 +119,16 @@ public RecoveryRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.recovery"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If true, the response only includes ongoing shard recoveries. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs index 7b6446a62d7..ef9d2e6b656 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshRequest.g.cs @@ -83,6 +83,16 @@ public RefreshRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r = internal override string OperationName => "indices.refresh"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs index 173d7f57182..56a659fdbc7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RefreshResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class RefreshResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override RefreshResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RefreshResponse + { + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RefreshResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RefreshResponseConverter))] public sealed partial class RefreshResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs index 736815127c6..dc2341e804f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersRequest.g.cs @@ -89,6 +89,14 @@ public ReloadSearchAnalyzersRequest(Elastic.Clients.Elasticsearch.Indices indice internal override string OperationName => "indices.reload_search_analyzers"; + /// + /// + /// A comma-separated list of index names to reload analyzers for + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs index 63b89ee9ae3..6ac27f48039 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ReloadSearchAnalyzersResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ReloadSearchAnalyzersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadDetails = System.Text.Json.JsonEncodedText.Encode("reload_details"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override ReloadSearchAnalyzersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propReloadDetails = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadDetails.TryRead(ref reader, options, PropReloadDetails)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReloadSearchAnalyzersResponse + { + ReloadDetails = propReloadDetails.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReloadSearchAnalyzersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadDetails, value.ReloadDetails); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReloadSearchAnalyzersResponseConverter))] public sealed partial class ReloadSearchAnalyzersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("reload_details")] public IReadOnlyCollection ReloadDetails { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs index 3081c88ff9d..bde01c1903b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveClusterRequest.g.cs @@ -124,6 +124,15 @@ public ResolveClusterRequest(Elastic.Clients.Elasticsearch.Names name) : base(r internal override string OperationName => "indices.resolve_cluster"; + /// + /// + /// Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + /// Resources on remote clusters can be specified using the <cluster>:<name> syntax. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs index 453bca1e4ff..affc2297d8c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexRequest.g.cs @@ -80,6 +80,15 @@ public ResolveIndexRequest(Elastic.Clients.Elasticsearch.Names name) : base(r => internal override string OperationName => "indices.resolve_index"; + /// + /// + /// Comma-separated name(s) or index pattern(s) of the indices, aliases, and data streams to resolve. + /// Resources on remote clusters can be specified using the <cluster>:<name> syntax. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs index 9fa71a9fca0..dc8fd518bcc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ResolveIndexResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ResolveIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ResolveIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propAliases = default; + LocalJsonValue> propDataStreams = default; + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAliases.TryRead(ref reader, options, PropAliases)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexResponse + { + Aliases = propAliases.Value +, + DataStreams = propDataStreams.Value +, + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAliases, value.Aliases); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexResponseConverter))] public sealed partial class ResolveIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aliases")] public IReadOnlyCollection Aliases { get; init; } - [JsonInclude, JsonPropertyName("data_streams")] public IReadOnlyCollection DataStreams { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs index 4d0efc47482..84d03189dbd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverRequest.g.cs @@ -88,6 +88,24 @@ public RolloverRequest(Elastic.Clients.Elasticsearch.IndexAlias alias, Elastic.C internal override string OperationName => "indices.rollover"; + /// + /// + /// Name of the data stream or index alias to roll over. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexAlias Alias { get => P("alias"); set => PR("alias", value); } + + /// + /// + /// Name of the index to create. + /// Supports date math. + /// Data streams do not support this parameter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? NewIndex { get => P("new_index"); set => PO("new_index", value); } + /// /// /// If true, checks whether the current index satisfies the specified conditions but does not perform a rollover. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs index cf9804a869f..a396fd680bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/RolloverResponse.g.cs @@ -22,24 +22,113 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class RolloverResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropConditions = System.Text.Json.JsonEncodedText.Encode("conditions"); + private static readonly System.Text.Json.JsonEncodedText PropDryRun = System.Text.Json.JsonEncodedText.Encode("dry_run"); + private static readonly System.Text.Json.JsonEncodedText PropNewIndex = System.Text.Json.JsonEncodedText.Encode("new_index"); + private static readonly System.Text.Json.JsonEncodedText PropOldIndex = System.Text.Json.JsonEncodedText.Encode("old_index"); + private static readonly System.Text.Json.JsonEncodedText PropRolledOver = System.Text.Json.JsonEncodedText.Encode("rolled_over"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override RolloverResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propConditions = default; + LocalJsonValue propDryRun = default; + LocalJsonValue propNewIndex = default; + LocalJsonValue propOldIndex = default; + LocalJsonValue propRolledOver = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propConditions.TryRead(ref reader, options, PropConditions)) + { + continue; + } + + if (propDryRun.TryRead(ref reader, options, PropDryRun)) + { + continue; + } + + if (propNewIndex.TryRead(ref reader, options, PropNewIndex)) + { + continue; + } + + if (propOldIndex.TryRead(ref reader, options, PropOldIndex)) + { + continue; + } + + if (propRolledOver.TryRead(ref reader, options, PropRolledOver)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RolloverResponse + { + Acknowledged = propAcknowledged.Value +, + Conditions = propConditions.Value +, + DryRun = propDryRun.Value +, + NewIndex = propNewIndex.Value +, + OldIndex = propOldIndex.Value +, + RolledOver = propRolledOver.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RolloverResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropConditions, value.Conditions); + writer.WriteProperty(options, PropDryRun, value.DryRun); + writer.WriteProperty(options, PropNewIndex, value.NewIndex); + writer.WriteProperty(options, PropOldIndex, value.OldIndex); + writer.WriteProperty(options, PropRolledOver, value.RolledOver); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RolloverResponseConverter))] public sealed partial class RolloverResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("conditions")] public IReadOnlyDictionary Conditions { get; init; } - [JsonInclude, JsonPropertyName("dry_run")] public bool DryRun { get; init; } - [JsonInclude, JsonPropertyName("new_index")] public string NewIndex { get; init; } - [JsonInclude, JsonPropertyName("old_index")] public string OldIndex { get; init; } - [JsonInclude, JsonPropertyName("rolled_over")] public bool RolledOver { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs index 935d749c917..532843b7c4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsRequest.g.cs @@ -83,6 +83,16 @@ public SegmentsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "indices.segments"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases used to limit the request. + /// Supports wildcards (*). + /// To target all data streams and indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs index eba31e77e85..98728a4cd41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SegmentsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class SegmentsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override SegmentsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SegmentsResponse + { + Indices = propIndices.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SegmentsResponseConverter))] public sealed partial class SegmentsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs index 7214e3d289d..83e4af821c6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresRequest.g.cs @@ -117,6 +117,14 @@ public ShardStoresRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base internal override string OperationName => "indices.shard_stores"; + /// + /// + /// List of data streams, indices, and aliases used to limit the request. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs index 09e274b9898..da09a549930 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShardStoresResponse.g.cs @@ -22,13 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ShardStoresResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + + public override ShardStoresResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShardStoresResponse + { + Indices = propIndices.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoresResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShardStoresResponseConverter))] public sealed partial class ShardStoresResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.IndicesShardStores))] public IReadOnlyDictionary Indices { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs index ad7eb567dd7..64b488a92f7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexRequest.g.cs @@ -160,6 +160,22 @@ public ShrinkIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic internal override string OperationName => "indices.shrink"; + /// + /// + /// Name of the source index to shrink. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs index 5cdc0a85eaf..f2e611699f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ShrinkIndexResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ShrinkIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override ShrinkIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShrinkIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShrinkIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShrinkIndexResponseConverter))] public sealed partial class ShrinkIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs index 94431e9a878..a629448de9f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateRequest.g.cs @@ -67,6 +67,14 @@ public SimulateIndexTemplateRequest(Elastic.Clients.Elasticsearch.Name name) : b internal override string OperationName => "indices.simulate_index_template"; + /// + /// + /// Name of the index to simulate + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, returns all relevant default configurations for the index template. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs index 1319b5304d7..299b07748b1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateIndexTemplateResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class SimulateIndexTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + + public override SimulateIndexTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propOverlapping = default; + LocalJsonValue propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryRead(ref reader, options, PropOverlapping)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateIndexTemplateResponse + { + Overlapping = propOverlapping.Value +, + Template = propTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateIndexTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOverlapping, value.Overlapping); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateIndexTemplateResponseConverter))] public sealed partial class SimulateIndexTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("overlapping")] public IReadOnlyCollection? Overlapping { get; init; } - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs index 51e33f2427e..e4891caa9ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateRequest.g.cs @@ -78,6 +78,15 @@ public SimulateTemplateRequest(Elastic.Clients.Elasticsearch.Name? name) : base( internal override string OperationName => "indices.simulate_template"; + /// + /// + /// Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit + /// this parameter and specify the template configuration in the request body. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + /// /// /// If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs index 13d495ed53a..0d466f69611 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SimulateTemplateResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class SimulateTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + + public override SimulateTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propOverlapping = default; + LocalJsonValue propTemplate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOverlapping.TryRead(ref reader, options, PropOverlapping)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateTemplateResponse + { + Overlapping = propOverlapping.Value +, + Template = propTemplate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOverlapping, value.Overlapping); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateTemplateResponseConverter))] public sealed partial class SimulateTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("overlapping")] public IReadOnlyCollection? Overlapping { get; init; } - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.IndexManagement.Template Template { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs index de7ea89236b..13fd7e14b1f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexRequest.g.cs @@ -149,6 +149,22 @@ public SplitIndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic. internal override string OperationName => "indices.split"; + /// + /// + /// Name of the source index to split. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + + /// + /// + /// Name of the target index to create. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Target { get => P("target"); set => PR("target", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs index f029453776f..483dc7726f8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/SplitIndexResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class SplitIndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropShardsAcknowledged = System.Text.Json.JsonEncodedText.Encode("shards_acknowledged"); + + public override SplitIndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propIndex = default; + LocalJsonValue propShardsAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propShardsAcknowledged.TryRead(ref reader, options, PropShardsAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SplitIndexResponse + { + Acknowledged = propAcknowledged.Value +, + Index = propIndex.Value +, + ShardsAcknowledged = propShardsAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SplitIndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropShardsAcknowledged, value.ShardsAcknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SplitIndexResponseConverter))] public sealed partial class SplitIndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("shards_acknowledged")] public bool ShardsAcknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs index 5b7fd8e987a..f8b320fe133 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/UpdateAliasesResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class UpdateAliasesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UpdateAliasesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateAliasesResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateAliasesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateAliasesResponseConverter))] public sealed partial class UpdateAliasesResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class UpdateAliasesResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs index 0f5e89c0d8b..f05f64f0563 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryRequest.g.cs @@ -147,6 +147,16 @@ public ValidateQueryRequest(Elastic.Clients.Elasticsearch.Indices? indices) : ba internal override string OperationName => "indices.validate_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs index 90f6de37d06..8e105c48ac8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexManagement/ValidateQueryResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ValidateQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropError = System.Text.Json.JsonEncodedText.Encode("error"); + private static readonly System.Text.Json.JsonEncodedText PropExplanations = System.Text.Json.JsonEncodedText.Encode("explanations"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropValid = System.Text.Json.JsonEncodedText.Encode("valid"); + + public override ValidateQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propError = default; + LocalJsonValue?> propExplanations = default; + LocalJsonValue propShards = default; + LocalJsonValue propValid = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propError.TryRead(ref reader, options, PropError)) + { + continue; + } + + if (propExplanations.TryRead(ref reader, options, PropExplanations)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propValid.TryRead(ref reader, options, PropValid)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateQueryResponse + { + Error = propError.Value +, + Explanations = propExplanations.Value +, + Shards = propShards.Value +, + Valid = propValid.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropError, value.Error); + writer.WriteProperty(options, PropExplanations, value.Explanations); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropValid, value.Valid); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateQueryResponseConverter))] public sealed partial class ValidateQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error")] public string? Error { get; init; } - [JsonInclude, JsonPropertyName("explanations")] public IReadOnlyCollection? Explanations { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics? Shards { get; init; } - [JsonInclude, JsonPropertyName("valid")] public bool Valid { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs index 2722f0c9b24..de0b6834c57 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexRequest.g.cs @@ -127,7 +127,7 @@ public sealed partial class IndexRequestParameters : RequestParameters /// If the target is an index and the document already exists, the request updates the document and increments its version. /// /// -public sealed partial class IndexRequest : PlainRequest, ISelfSerializable +public sealed partial class IndexRequest : PlainRequest, ISelfTwoWaySerializable { public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", index).Optional("id", id)) { @@ -145,6 +145,22 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r internal override string OperationName => "index"; + /// + /// + /// Unique identifier for the document. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + + /// + /// + /// Name of the data stream or index to target. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Only perform the operation if the document has this primary term. @@ -242,13 +258,17 @@ public IndexRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r => r /// [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } - [JsonIgnore] public TDocument Document { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { settings.SourceSerializer.Serialize(Document, writer); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Document = settings.SourceSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs index 289d66cf21d..171ed827096 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/IndexResponse.g.cs @@ -22,26 +22,124 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class IndexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override IndexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexResponseConverter))] public sealed partial class IndexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs index d8514b99866..5424f6bab4d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceRequest.g.cs @@ -70,6 +70,22 @@ public DeleteInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? internal override string OperationName => "inference.delete"; + /// + /// + /// The inference Id + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } + /// /// /// When true, the endpoint is not deleted, and a list of ingest processors which reference this endpoint is returned diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs index 2e7e80f69d3..fb82b4b55b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/DeleteInferenceResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Inference; +internal sealed partial class DeleteInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropPipelines = System.Text.Json.JsonEncodedText.Encode("pipelines"); + + public override DeleteInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue> propPipelines = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propPipelines.TryRead(ref reader, options, PropPipelines)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteInferenceResponse + { + Acknowledged = propAcknowledged.Value +, + Pipelines = propPipelines.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropPipelines, value.Pipelines); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteInferenceResponseConverter))] public sealed partial class DeleteInferenceResponse : ElasticsearchResponse { /// @@ -33,8 +79,6 @@ public sealed partial class DeleteInferenceResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("pipelines")] public IReadOnlyCollection Pipelines { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs index 40c96fe6b8d..e7b924832d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceRequest.g.cs @@ -60,6 +60,22 @@ public GetInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? tas internal override bool SupportsBody => false; internal override string OperationName => "inference.get"; + + /// + /// + /// The inference Id + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? InferenceId { get => P("inference_id"); set => PO("inference_id", value); } + + /// + /// + /// The task type + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs index 254b29ef133..21024b6a5e5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/GetInferenceResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Inference; +internal sealed partial class GetInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEndpoints = System.Text.Json.JsonEncodedText.Encode("endpoints"); + + public override GetInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propEndpoints = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEndpoints.TryRead(ref reader, options, PropEndpoints)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetInferenceResponse + { + Endpoints = propEndpoints.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEndpoints, value.Endpoints); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetInferenceResponseConverter))] public sealed partial class GetInferenceResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("endpoints")] public IReadOnlyCollection Endpoints { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs index 8c0ff5643b7..3ada08b3372 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceRequest.g.cs @@ -40,11 +40,65 @@ public sealed partial class InferenceRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } } +internal sealed partial class InferenceRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInput = System.Text.Json.JsonEncodedText.Encode("input"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropTaskSettings = System.Text.Json.JsonEncodedText.Encode("task_settings"); + + public override InferenceRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propInput = default; + LocalJsonValue propQuery = default; + LocalJsonValue propTaskSettings = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInput.TryRead(ref reader, options, PropInput, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propTaskSettings.TryRead(ref reader, options, PropTaskSettings)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceRequest + { + Input = propInput.Value + , + Query = propQuery.Value + , + TaskSettings = propTaskSettings.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInput, value.Input, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings); + writer.WriteEndObject(); + } +} + /// /// /// Perform inference on the service /// /// +[JsonConverter(typeof(InferenceRequestConverter))] public sealed partial class InferenceRequest : PlainRequest { public InferenceRequest(Elastic.Clients.Elasticsearch.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) @@ -63,12 +117,25 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy internal override string OperationName => "inference.inference"; + /// + /// + /// The inference Id + /// + /// + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } + /// /// /// Specifies the amount of time to wait for the inference request to complete. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -77,8 +144,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Either a string or an array of strings. /// /// - [JsonInclude, JsonPropertyName("input")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection Input { get; set; } /// @@ -87,7 +152,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Not required for other tasks. /// /// - [JsonInclude, JsonPropertyName("query")] public string? Query { get; set; } /// @@ -95,7 +159,6 @@ public InferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? taskTy /// Optional task settings /// /// - [JsonInclude, JsonPropertyName("task_settings")] public object? TaskSettings { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs index fb55c4afc55..3aa44c9b18e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/InferenceResponse.g.cs @@ -22,10 +22,34 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Inference; +internal sealed partial class InferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override InferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferenceResponseConverter))] public sealed partial class InferenceResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs index 2b49b107239..acd737bd581 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceRequest.g.cs @@ -49,7 +49,7 @@ public sealed partial class PutInferenceRequestParameters : RequestParameters /// However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs. /// /// -public sealed partial class PutInferenceRequest : PlainRequest, ISelfSerializable +public sealed partial class PutInferenceRequest : PlainRequest, ISelfTwoWaySerializable { public PutInferenceRequest(Elastic.Clients.Elasticsearch.Id inferenceId) : base(r => r.Required("inference_id", inferenceId)) { @@ -67,13 +67,32 @@ public PutInferenceRequest(Elastic.Clients.Elasticsearch.Inference.TaskType? tas internal override string OperationName => "inference.put"; + /// + /// + /// The inference Id + /// + /// [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id InferenceId { get => P("inference_id"); set => PR("inference_id", value); } + + /// + /// + /// The task type + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Inference.TaskType? TaskType { get => P("task_type"); set => PO("task_type", value); } public Elastic.Clients.Elasticsearch.Inference.InferenceEndpoint InferenceConfig { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, InferenceConfig, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + InferenceConfig = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs index dca82330fc2..6730b25ba7a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Inference/PutInferenceResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Inference; +internal sealed partial class PutInferenceResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInferenceId = System.Text.Json.JsonEncodedText.Encode("inference_id"); + private static readonly System.Text.Json.JsonEncodedText PropService = System.Text.Json.JsonEncodedText.Encode("service"); + private static readonly System.Text.Json.JsonEncodedText PropServiceSettings = System.Text.Json.JsonEncodedText.Encode("service_settings"); + private static readonly System.Text.Json.JsonEncodedText PropTaskSettings = System.Text.Json.JsonEncodedText.Encode("task_settings"); + private static readonly System.Text.Json.JsonEncodedText PropTaskType = System.Text.Json.JsonEncodedText.Encode("task_type"); + + public override PutInferenceResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propInferenceId = default; + LocalJsonValue propService = default; + LocalJsonValue propServiceSettings = default; + LocalJsonValue propTaskSettings = default; + LocalJsonValue propTaskType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceId.TryRead(ref reader, options, PropInferenceId)) + { + continue; + } + + if (propService.TryRead(ref reader, options, PropService)) + { + continue; + } + + if (propServiceSettings.TryRead(ref reader, options, PropServiceSettings)) + { + continue; + } + + if (propTaskSettings.TryRead(ref reader, options, PropTaskSettings)) + { + continue; + } + + if (propTaskType.TryRead(ref reader, options, PropTaskType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutInferenceResponse + { + InferenceId = propInferenceId.Value +, + Service = propService.Value +, + ServiceSettings = propServiceSettings.Value +, + TaskSettings = propTaskSettings.Value +, + TaskType = propTaskType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutInferenceResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInferenceId, value.InferenceId); + writer.WriteProperty(options, PropService, value.Service); + writer.WriteProperty(options, PropServiceSettings, value.ServiceSettings); + writer.WriteProperty(options, PropTaskSettings, value.TaskSettings); + writer.WriteProperty(options, PropTaskType, value.TaskType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutInferenceResponseConverter))] public sealed partial class PutInferenceResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The inference Id /// /// - [JsonInclude, JsonPropertyName("inference_id")] public string InferenceId { get; init; } /// @@ -41,7 +116,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The service type /// /// - [JsonInclude, JsonPropertyName("service")] public string Service { get; init; } /// @@ -49,7 +123,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// Settings specific to the service /// /// - [JsonInclude, JsonPropertyName("service_settings")] public object ServiceSettings { get; init; } /// @@ -57,7 +130,6 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// Task settings specific to the service and task type /// /// - [JsonInclude, JsonPropertyName("task_settings")] public object? TaskSettings { get; init; } /// @@ -65,6 +137,5 @@ public sealed partial class PutInferenceResponse : ElasticsearchResponse /// The task type /// /// - [JsonInclude, JsonPropertyName("task_type")] public Elastic.Clients.Elasticsearch.Inference.TaskType TaskType { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs index 0558e1d8735..339e2e4a049 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/InfoResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class InfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropClusterUuid = System.Text.Json.JsonEncodedText.Encode("cluster_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropTagline = System.Text.Json.JsonEncodedText.Encode("tagline"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override InfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue propClusterUuid = default; + LocalJsonValue propName = default; + LocalJsonValue propTagline = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propClusterUuid.TryRead(ref reader, options, PropClusterUuid)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propTagline.TryRead(ref reader, options, PropTagline)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InfoResponse + { + ClusterName = propClusterName.Value +, + ClusterUuid = propClusterUuid.Value +, + Name = propName.Value +, + Tagline = propTagline.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropClusterUuid, value.ClusterUuid); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropTagline, value.Tagline); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InfoResponseConverter))] public sealed partial class InfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("cluster_uuid")] public string ClusterUuid { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } - [JsonInclude, JsonPropertyName("tagline")] public string Tagline { get; init; } - [JsonInclude, JsonPropertyName("version")] public Elastic.Clients.Elasticsearch.ElasticsearchVersionInfo Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs index 26a49ab502d..2ce5ba876b0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseRequest.g.cs @@ -68,6 +68,14 @@ public DeleteGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : base(r internal override string OperationName => "ingest.delete_geoip_database"; + /// + /// + /// A comma-separated list of geoip database configurations to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs index dce6d2f572a..0b1f6ec0898 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteGeoipDatabaseResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class DeleteGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteGeoipDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteGeoipDatabaseResponseConverter))] public sealed partial class DeleteGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteGeoipDatabaseResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs index c59c95fc2ab..4a1d0dfee69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseRequest.g.cs @@ -70,6 +70,14 @@ public DeleteIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Ids id) : b internal override string OperationName => "ingest.delete_ip_location_database"; + /// + /// + /// A comma-separated list of IP location database configurations. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Id { get => P("id"); set => PR("id", value); } + /// /// /// The period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs index d221599c779..92263ebb36d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeleteIpLocationDatabaseResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class DeleteIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteIpLocationDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteIpLocationDatabaseResponseConverter))] public sealed partial class DeleteIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteIpLocationDatabaseResponse : ElasticsearchResp /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs index bae10014caa..2fcc8f71a6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineRequest.g.cs @@ -69,6 +69,15 @@ public DeletePipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override string OperationName => "ingest.delete_pipeline"; + /// + /// + /// Pipeline ID or wildcard expression of pipeline IDs used to limit the request. + /// To delete all ingest pipelines in a cluster, use a value of *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs index a56624fd181..63f925aef18 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/DeletePipelineResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class DeletePipelineResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeletePipelineResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeletePipelineResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeletePipelineResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeletePipelineResponseConverter))] public sealed partial class DeletePipelineResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeletePipelineResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs index dc229b51599..6554320c81c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GeoIpStatsResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class GeoIpStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + + public override GeoIpStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + LocalJsonValue propStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoIpStatsResponse + { + Nodes = propNodes.Value +, + Stats = propStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoIpStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoIpStatsResponseConverter))] public sealed partial class GeoIpStatsResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Downloaded GeoIP2 databases for each node. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class GeoIpStatsResponse : ElasticsearchResponse /// Download statistics for all GeoIP2 databases. /// /// - [JsonInclude, JsonPropertyName("stats")] public Elastic.Clients.Elasticsearch.Ingest.GeoIpDownloadStatistics Stats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs index b118dfd90f7..feb743569b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseRequest.g.cs @@ -65,6 +65,16 @@ public GetGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Ids? id) : base(r = internal override string OperationName => "ingest.get_geoip_database"; + /// + /// + /// Comma-separated list of database configuration IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all database configurations, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? Id { get => P("id"); set => PO("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs index e0310e524bc..3ca73aedf4d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetGeoipDatabaseResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class GetGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDatabases = System.Text.Json.JsonEncodedText.Encode("databases"); + + public override GetGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryRead(ref reader, options, PropDatabases)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetGeoipDatabaseResponse + { + Databases = propDatabases.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDatabases, value.Databases); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetGeoipDatabaseResponseConverter))] public sealed partial class GetGeoipDatabaseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("databases")] public IReadOnlyCollection Databases { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs index ebded8be3a5..32b674fdfce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseRequest.g.cs @@ -65,6 +65,16 @@ public GetIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Ids? id) : bas internal override string OperationName => "ingest.get_ip_location_database"; + /// + /// + /// Comma-separated list of database configuration IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all database configurations, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? Id { get => P("id"); set => PO("id", value); } + /// /// /// The period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs index 4e185a14181..f1296876bc5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetIpLocationDatabaseResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class GetIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDatabases = System.Text.Json.JsonEncodedText.Encode("databases"); + + public override GetIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDatabases = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDatabases.TryRead(ref reader, options, PropDatabases)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetIpLocationDatabaseResponse + { + Databases = propDatabases.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDatabases, value.Databases); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetIpLocationDatabaseResponseConverter))] public sealed partial class GetIpLocationDatabaseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("databases")] public IReadOnlyCollection Databases { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs index 39ca9bc7147..8956c79eb24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/GetPipelineRequest.g.cs @@ -73,6 +73,16 @@ public GetPipelineRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Op internal override string OperationName => "ingest.get_pipeline"; + /// + /// + /// Comma-separated list of pipeline IDs to retrieve. + /// Wildcard (*) expressions are supported. + /// To get all ingest pipelines, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs index 823c43ea0e4..990b9dc6a2c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/ProcessorGrokResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class ProcessorGrokResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPatterns = System.Text.Json.JsonEncodedText.Encode("patterns"); + + public override ProcessorGrokResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propPatterns = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPatterns.TryRead(ref reader, options, PropPatterns)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ProcessorGrokResponse + { + Patterns = propPatterns.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ProcessorGrokResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPatterns, value.Patterns); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ProcessorGrokResponseConverter))] public sealed partial class ProcessorGrokResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("patterns")] public IReadOnlyDictionary Patterns { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs index 8d0e30805a5..e86bade0fef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseRequest.g.cs @@ -68,6 +68,14 @@ public PutGeoipDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => internal override string OperationName => "ingest.put_geoip_database"; + /// + /// + /// ID of the database configuration to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs index 9fa354707d9..2bde4dd5795 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutGeoipDatabaseResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class PutGeoipDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutGeoipDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutGeoipDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutGeoipDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutGeoipDatabaseResponseConverter))] public sealed partial class PutGeoipDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutGeoipDatabaseResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs index 49a39028b0f..51289e8b0bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseRequest.g.cs @@ -56,7 +56,7 @@ public sealed partial class PutIpLocationDatabaseRequestParameters : RequestPara /// Create or update an IP geolocation database configuration. /// /// -public sealed partial class PutIpLocationDatabaseRequest : PlainRequest, ISelfSerializable +public sealed partial class PutIpLocationDatabaseRequest : PlainRequest, ISelfTwoWaySerializable { public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id)) { @@ -70,6 +70,14 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base( internal override string OperationName => "ingest.put_ip_location_database"; + /// + /// + /// The database configuration identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The period to wait for a connection to the master node. @@ -89,13 +97,17 @@ public PutIpLocationDatabaseRequest(Elastic.Clients.Elasticsearch.Id id) : base( /// [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Ingest.DatabaseConfiguration Configuration { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Configuration, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Configuration = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs index 3d865e894d1..411771ca1f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutIpLocationDatabaseResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class PutIpLocationDatabaseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutIpLocationDatabaseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutIpLocationDatabaseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutIpLocationDatabaseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutIpLocationDatabaseResponseConverter))] public sealed partial class PutIpLocationDatabaseResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutIpLocationDatabaseResponse : ElasticsearchRespons /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs index 2cf636c625b..d2cc1d16b66 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineRequest.g.cs @@ -74,6 +74,14 @@ public PutPipelineRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req internal override string OperationName => "ingest.put_pipeline"; + /// + /// + /// ID of the ingest pipeline to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Required version for optimistic concurrency control for pipeline updates diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs index e4f7017c4e6..050f7a3fba4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/PutPipelineResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class PutPipelineResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutPipelineResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutPipelineResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutPipelineResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutPipelineResponseConverter))] public sealed partial class PutPipelineResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutPipelineResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs index 945801158d6..a6b98685576 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateRequest.g.cs @@ -65,6 +65,15 @@ public SimulateRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Optio internal override string OperationName => "ingest.simulate"; + /// + /// + /// Pipeline to test. + /// If you don’t specify a pipeline in the request body, this parameter is required. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// If true, the response includes output data for each processor in the executed pipeline. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs index 557e500e320..9a8b9097f4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Ingest/SimulateResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class SimulateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override SimulateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimulateResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimulateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimulateResponseConverter))] public sealed partial class SimulateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs index 91e73fcccf5..c98ce7112c0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/DeleteLicenseResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class DeleteLicenseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteLicenseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteLicenseResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteLicenseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLicenseResponseConverter))] public sealed partial class DeleteLicenseResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteLicenseResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs index ec1e0cba8ff..31d112b2948 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetBasicStatusResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class GetBasicStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEligibleToStartBasic = System.Text.Json.JsonEncodedText.Encode("eligible_to_start_basic"); + + public override GetBasicStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propEligibleToStartBasic = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEligibleToStartBasic.TryRead(ref reader, options, PropEligibleToStartBasic)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBasicStatusResponse + { + EligibleToStartBasic = propEligibleToStartBasic.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBasicStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEligibleToStartBasic, value.EligibleToStartBasic); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBasicStatusResponseConverter))] public sealed partial class GetBasicStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("eligible_to_start_basic")] public bool EligibleToStartBasic { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs index fae9931e751..5137598815a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetLicenseResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class GetLicenseResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLicense = System.Text.Json.JsonEncodedText.Encode("license"); + + public override GetLicenseResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLicense = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLicense.TryRead(ref reader, options, PropLicense)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetLicenseResponse + { + License = propLicense.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetLicenseResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLicense, value.License); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetLicenseResponseConverter))] public sealed partial class GetLicenseResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseInformation License { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs index 0fa20962a0c..7526e45412b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/GetTrialStatusResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class GetTrialStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEligibleToStartTrial = System.Text.Json.JsonEncodedText.Encode("eligible_to_start_trial"); + + public override GetTrialStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propEligibleToStartTrial = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEligibleToStartTrial.TryRead(ref reader, options, PropEligibleToStartTrial)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrialStatusResponse + { + EligibleToStartTrial = propEligibleToStartTrial.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrialStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEligibleToStartTrial, value.EligibleToStartTrial); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrialStatusResponseConverter))] public sealed partial class GetTrialStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("eligible_to_start_trial")] public bool EligibleToStartTrial { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs index 1ba8f7e99c6..01371e64c82 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledge = System.Text.Json.JsonEncodedText.Encode("acknowledge"); + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropLicenseStatus = System.Text.Json.JsonEncodedText.Encode("license_status"); + + public override PostResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledge = default; + LocalJsonValue propAcknowledged = default; + LocalJsonValue propLicenseStatus = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledge.TryRead(ref reader, options, PropAcknowledge)) + { + continue; + } + + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propLicenseStatus.TryRead(ref reader, options, PropLicenseStatus)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostResponse + { + Acknowledge = propAcknowledge.Value +, + Acknowledged = propAcknowledged.Value +, + LicenseStatus = propLicenseStatus.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledge, value.Acknowledge); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropLicenseStatus, value.LicenseStatus); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostResponseConverter))] public sealed partial class PostResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledge")] public Elastic.Clients.Elasticsearch.LicenseManagement.Acknowledgement? Acknowledge { get; init; } - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("license_status")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseStatus LicenseStatus { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs index 9d33f61d74b..dae32ae5792 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartBasicResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostStartBasicResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledge = System.Text.Json.JsonEncodedText.Encode("acknowledge"); + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropBasicWasStarted = System.Text.Json.JsonEncodedText.Encode("basic_was_started"); + private static readonly System.Text.Json.JsonEncodedText PropErrorMessage = System.Text.Json.JsonEncodedText.Encode("error_message"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PostStartBasicResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>>?> propAcknowledge = default; + LocalJsonValue propAcknowledged = default; + LocalJsonValue propBasicWasStarted = default; + LocalJsonValue propErrorMessage = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledge.TryRead(ref reader, options, PropAcknowledge)) + { + continue; + } + + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propBasicWasStarted.TryRead(ref reader, options, PropBasicWasStarted)) + { + continue; + } + + if (propErrorMessage.TryRead(ref reader, options, PropErrorMessage)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostStartBasicResponse + { + Acknowledge = propAcknowledge.Value +, + Acknowledged = propAcknowledged.Value +, + BasicWasStarted = propBasicWasStarted.Value +, + ErrorMessage = propErrorMessage.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostStartBasicResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledge, value.Acknowledge); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropBasicWasStarted, value.BasicWasStarted); + writer.WriteProperty(options, PropErrorMessage, value.ErrorMessage); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostStartBasicResponseConverter))] public sealed partial class PostStartBasicResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledge")] public IReadOnlyDictionary>>? Acknowledge { get; init; } - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("basic_was_started")] public bool BasicWasStarted { get; init; } - [JsonInclude, JsonPropertyName("error_message")] public string? ErrorMessage { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseType? Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs index c95c366c974..aed5f807041 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/LicenseManagement/PostStartTrialResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.LicenseManagement; +internal sealed partial class PostStartTrialResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropErrorMessage = System.Text.Json.JsonEncodedText.Encode("error_message"); + private static readonly System.Text.Json.JsonEncodedText PropTrialWasStarted = System.Text.Json.JsonEncodedText.Encode("trial_was_started"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PostStartTrialResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propErrorMessage = default; + LocalJsonValue propTrialWasStarted = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propErrorMessage.TryRead(ref reader, options, PropErrorMessage)) + { + continue; + } + + if (propTrialWasStarted.TryRead(ref reader, options, PropTrialWasStarted)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostStartTrialResponse + { + Acknowledged = propAcknowledged.Value +, + ErrorMessage = propErrorMessage.Value +, + TrialWasStarted = propTrialWasStarted.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostStartTrialResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropErrorMessage, value.ErrorMessage); + writer.WriteProperty(options, PropTrialWasStarted, value.TrialWasStarted); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostStartTrialResponseConverter))] public sealed partial class PostStartTrialResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("error_message")] public string? ErrorMessage { get; init; } - [JsonInclude, JsonPropertyName("trial_was_started")] public bool TrialWasStarted { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.LicenseManagement.LicenseType? Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs index d0623e3f5cf..b949e929bdd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheRequest.g.cs @@ -56,6 +56,14 @@ public ClearTrainedModelDeploymentCacheRequest(Elastic.Clients.Elasticsearch.Id internal override bool SupportsBody => false; internal override string OperationName => "ml.clear_trained_model_deployment_cache"; + + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs index 8043e6d4bfa..3cdac4fe2b4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ClearTrainedModelDeploymentCacheResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ClearTrainedModelDeploymentCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCleared = System.Text.Json.JsonEncodedText.Encode("cleared"); + + public override ClearTrainedModelDeploymentCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCleared = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCleared.TryRead(ref reader, options, PropCleared)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearTrainedModelDeploymentCacheResponse + { + Cleared = propCleared.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearTrainedModelDeploymentCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCleared, value.Cleared); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearTrainedModelDeploymentCacheResponseConverter))] public sealed partial class ClearTrainedModelDeploymentCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cleared")] public bool Cleared { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs index 57ebbdb573f..3756595de42 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobRequest.g.cs @@ -57,6 +57,14 @@ public CloseJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.close_job"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a group name, or a wildcard expression. You can close multiple anomaly detection jobs in a single API request by using a group name, a comma-separated list of jobs, or a wildcard expression. You can close all jobs by using _all or by specifying * as the job identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs index 6548e5bf9b3..39678638b17 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/CloseJobResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class CloseJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + + public override CloseJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClosed = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClosed.TryRead(ref reader, options, PropClosed)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloseJobResponse + { + Closed = propClosed.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloseJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClosed, value.Closed); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloseJobResponseConverter))] public sealed partial class CloseJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("closed")] public bool Closed { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs index c1eee87a939..1779b742832 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventRequest.g.cs @@ -52,6 +52,23 @@ public DeleteCalendarEventRequest(Elastic.Clients.Elasticsearch.Id calendarId, E internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar_event"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// Identifier for the scheduled event. + /// You can obtain this identifier by using the get calendar events API. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id EventId { get => P("event_id"); set => PR("event_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs index 47d28a27405..a455993fa20 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarEventResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteCalendarEventResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteCalendarEventResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarEventResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarEventResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarEventResponseConverter))] public sealed partial class DeleteCalendarEventResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteCalendarEventResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs index c6365779a10..4d0e2a792f3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobRequest.g.cs @@ -52,6 +52,23 @@ public DeleteCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Ela internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar_job"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a + /// comma-separated list of jobs or groups. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids JobId { get => P("job_id"); set => PR("job_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs index f79e96e6c83..db3f15ada4b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarJobResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteCalendarJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override DeleteCalendarJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarJobResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarJobResponseConverter))] public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +103,5 @@ public sealed partial class DeleteCalendarJobResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs index e96d8a0c6fc..cc3fe620465 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarRequest.g.cs @@ -53,6 +53,14 @@ public DeleteCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_calendar"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs index f2439430e4c..c12014e38c3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteCalendarResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteCalendarResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteCalendarResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteCalendarResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteCalendarResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteCalendarResponseConverter))] public sealed partial class DeleteCalendarResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteCalendarResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs index 0d7176897c5..6edee0b88f9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsRequest.g.cs @@ -66,6 +66,14 @@ public DeleteDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "ml.delete_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// If true, it deletes a job that is not stopped; this method is quicker than stopping and deleting the job. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs index 78d91d8d7ff..6fb671c0dbb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDataFrameAnalyticsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDataFrameAnalyticsResponseConverter))] public sealed partial class DeleteDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteDataFrameAnalyticsResponse : ElasticsearchResp /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs index 9d4691e39ba..49b95019bc2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedRequest.g.cs @@ -60,6 +60,17 @@ public DeleteDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base internal override string OperationName => "ml.delete_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. This + /// identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It must start and end with alphanumeric + /// characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Use to forcefully delete a started datafeed; this method is quicker than diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs index 985d0ec763f..829c9bd8504 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteDatafeedResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteDatafeedResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteDatafeedResponseConverter))] public sealed partial class DeleteDatafeedResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteDatafeedResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs index 02f49150cf5..b4b2b47e16f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataRequest.g.cs @@ -65,6 +65,15 @@ public DeleteExpiredDataRequest(Elastic.Clients.Elasticsearch.Id? jobId) : base( internal override string OperationName => "ml.delete_expired_data"; + /// + /// + /// Identifier for an anomaly detection job. It can be a job identifier, a + /// group name, or a wildcard expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// The desired requests per second for the deletion processes. The default diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs index 2fa4f758f7d..c1d89e189cf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteExpiredDataResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteExpiredDataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + + public override DeleteExpiredDataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDeleted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteExpiredDataResponse + { + Deleted = propDeleted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteExpiredDataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteExpiredDataResponseConverter))] public sealed partial class DeleteExpiredDataResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("deleted")] public bool Deleted { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs index babccd97a41..8e8166a80df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterRequest.g.cs @@ -54,6 +54,14 @@ public DeleteFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_filter"; + + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs index 6d37a717058..02f3ddff61e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteFilterResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteFilterResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteFilterResponseConverter))] public sealed partial class DeleteFilterResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteFilterResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs index f6ccf14951c..40705110c5e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastRequest.g.cs @@ -79,6 +79,24 @@ public DeleteForecastRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic.Cli internal override string OperationName => "ml.delete_forecast"; + /// + /// + /// A comma-separated list of forecast identifiers. If you do not specify + /// this optional parameter or if you specify _all or * the API deletes + /// all forecasts from the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? ForecastId { get => P("forecast_id"); set => PO("forecast_id", value); } + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether an error occurs when there are no forecasts. In diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs index 00b3f7ab79e..dc5a9a6d809 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteForecastResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteForecastResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteForecastResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteForecastResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteForecastResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteForecastResponseConverter))] public sealed partial class DeleteForecastResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteForecastResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs index 68da0f7870a..36048de72e1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobRequest.g.cs @@ -83,6 +83,14 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re internal override string OperationName => "ml.delete_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether annotations that have been added by the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs index 94765430771..147fbfbee51 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteJobResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteJobResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteJobResponseConverter))] public sealed partial class DeleteJobResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteJobResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs index 60154991bb8..5cde99000a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotRequest.g.cs @@ -55,6 +55,22 @@ public DeleteModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_model_snapshot"; + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// Identifier for the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs index 658f9205a22..34e76b71306 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteModelSnapshotResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteModelSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteModelSnapshotResponseConverter))] public sealed partial class DeleteModelSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteModelSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs index a2802a0df4a..5d6147b30ac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasRequest.g.cs @@ -55,6 +55,22 @@ public DeleteTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, internal override bool SupportsBody => false; internal override string OperationName => "ml.delete_trained_model_alias"; + + /// + /// + /// The model alias to delete. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name ModelAlias { get => P("model_alias"); set => PR("model_alias", value); } + + /// + /// + /// The trained model ID to which the model alias refers. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs index 9d8644ff51e..1d47ad48670 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelAliasResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteTrainedModelAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTrainedModelAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTrainedModelAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTrainedModelAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelAliasResponseConverter))] public sealed partial class DeleteTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteTrainedModelAliasResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs index 11d60873725..3f1a1dd97e6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelRequest.g.cs @@ -60,6 +60,14 @@ public DeleteTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : bas internal override string OperationName => "ml.delete_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Forcefully deletes a trained model that is referenced by ingest pipelines or has a started deployment. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs index 2a0564f9050..9b3b6f9b71a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/DeleteTrainedModelResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DeleteTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTrainedModelResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTrainedModelResponseConverter))] public sealed partial class DeleteTrainedModelResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteTrainedModelResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs index c420b7ffc87..99459da4a75 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EstimateModelMemoryResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class EstimateModelMemoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryEstimate = System.Text.Json.JsonEncodedText.Encode("model_memory_estimate"); + + public override EstimateModelMemoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propModelMemoryEstimate = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModelMemoryEstimate.TryRead(ref reader, options, PropModelMemoryEstimate)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EstimateModelMemoryResponse + { + ModelMemoryEstimate = propModelMemoryEstimate.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EstimateModelMemoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropModelMemoryEstimate, value.ModelMemoryEstimate); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EstimateModelMemoryResponseConverter))] public sealed partial class EstimateModelMemoryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("model_memory_estimate")] public string ModelMemoryEstimate { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs index 8cad649908a..b8fdac23558 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/EvaluateDataFrameResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class EvaluateDataFrameResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText PropOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText PropRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + + public override EvaluateDataFrameResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClassification = default; + LocalJsonValue propOutlierDetection = default; + LocalJsonValue propRegression = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClassification.TryRead(ref reader, options, PropClassification)) + { + continue; + } + + if (propOutlierDetection.TryRead(ref reader, options, PropOutlierDetection)) + { + continue; + } + + if (propRegression.TryRead(ref reader, options, PropRegression)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EvaluateDataFrameResponse + { + Classification = propClassification.Value +, + OutlierDetection = propOutlierDetection.Value +, + Regression = propRegression.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EvaluateDataFrameResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClassification, value.Classification); + writer.WriteProperty(options, PropOutlierDetection, value.OutlierDetection); + writer.WriteProperty(options, PropRegression, value.Regression); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EvaluateDataFrameResponseConverter))] public sealed partial class EvaluateDataFrameResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("classification")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeClassificationSummary? Classification { get; init; } - [JsonInclude, JsonPropertyName("outlier_detection")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeOutlierDetectionSummary? OutlierDetection { get; init; } - [JsonInclude, JsonPropertyName("regression")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeRegressionSummary? Regression { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs index 86ef39e34da..6d16681a4e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsRequest.g.cs @@ -73,6 +73,16 @@ public ExplainDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.explain_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs index 9538fde34a2..11dd5e4b8ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ExplainDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ExplainDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFieldSelection = System.Text.Json.JsonEncodedText.Encode("field_selection"); + private static readonly System.Text.Json.JsonEncodedText PropMemoryEstimation = System.Text.Json.JsonEncodedText.Encode("memory_estimation"); + + public override ExplainDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propFieldSelection = default; + LocalJsonValue propMemoryEstimation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFieldSelection.TryRead(ref reader, options, PropFieldSelection)) + { + continue; + } + + if (propMemoryEstimation.TryRead(ref reader, options, PropMemoryEstimation)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainDataFrameAnalyticsResponse + { + FieldSelection = propFieldSelection.Value +, + MemoryEstimation = propMemoryEstimation.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFieldSelection, value.FieldSelection); + writer.WriteProperty(options, PropMemoryEstimation, value.MemoryEstimation); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExplainDataFrameAnalyticsResponseConverter))] public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that explain selection for each field, sorted by the field names. /// /// - [JsonInclude, JsonPropertyName("field_selection")] public IReadOnlyCollection FieldSelection { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class ExplainDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that explain selection for each field, sorted by the field names. /// /// - [JsonInclude, JsonPropertyName("memory_estimation")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsMemoryEstimation MemoryEstimation { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs index 7d2aad9a7b2..3453ed6a051 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobRequest.g.cs @@ -61,6 +61,14 @@ public FlushJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.flush_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the advance_time query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs index ad4776b1c49..190df61c87f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/FlushJobResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class FlushJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFlushed = System.Text.Json.JsonEncodedText.Encode("flushed"); + private static readonly System.Text.Json.JsonEncodedText PropLastFinalizedBucketEnd = System.Text.Json.JsonEncodedText.Encode("last_finalized_bucket_end"); + + public override FlushJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFlushed = default; + LocalJsonValue propLastFinalizedBucketEnd = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlushed.TryRead(ref reader, options, PropFlushed)) + { + continue; + } + + if (propLastFinalizedBucketEnd.TryRead(ref reader, options, PropLastFinalizedBucketEnd)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FlushJobResponse + { + Flushed = propFlushed.Value +, + LastFinalizedBucketEnd = propLastFinalizedBucketEnd.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FlushJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFlushed, value.Flushed); + writer.WriteProperty(options, PropLastFinalizedBucketEnd, value.LastFinalizedBucketEnd); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FlushJobResponseConverter))] public sealed partial class FlushJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("flushed")] public bool Flushed { get; init; } /// @@ -37,6 +82,5 @@ public sealed partial class FlushJobResponse : ElasticsearchResponse /// the last bucket that was processed. /// /// - [JsonInclude, JsonPropertyName("last_finalized_bucket_end")] public int? LastFinalizedBucketEnd { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs index bfbd4285a3c..67eea2a430b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastRequest.g.cs @@ -59,6 +59,15 @@ public ForecastRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.forecast"; + /// + /// + /// Identifier for the anomaly detection job. The job must be open when you + /// create a forecast; otherwise, an error occurs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the duration query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs index 90c4b0f3cb0..074beaf8f64 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ForecastResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ForecastResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropForecastId = System.Text.Json.JsonEncodedText.Encode("forecast_id"); + + public override ForecastResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propForecastId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propForecastId.TryRead(ref reader, options, PropForecastId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ForecastResponse + { + Acknowledged = propAcknowledged.Value +, + ForecastId = propForecastId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ForecastResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropForecastId, value.ForecastId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ForecastResponseConverter))] public sealed partial class ForecastResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("forecast_id")] public string ForecastId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs index e24e4432ff7..bde7164d48b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsRequest.g.cs @@ -71,6 +71,23 @@ public GetBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R internal override string OperationName => "ml.get_buckets"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// The timestamp of a single bucket result. If you do not specify this + /// parameter, the API returns information about all buckets. + /// + /// + [JsonIgnore] + public DateTimeOffset? Timestamp { get => P("timestamp"); set => PO("timestamp", value); } + /// /// /// Skips the specified number of buckets. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs index a4c60815b86..9ca9b7bc6e1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetBucketsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetBucketsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBuckets = System.Text.Json.JsonEncodedText.Encode("buckets"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetBucketsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propBuckets = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuckets.TryRead(ref reader, options, PropBuckets)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBucketsResponse + { + Buckets = propBuckets.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBucketsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBuckets, value.Buckets); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBucketsResponseConverter))] public sealed partial class GetBucketsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("buckets")] public IReadOnlyCollection Buckets { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs index 66a32155f0d..7a6a36b0fa0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsRequest.g.cs @@ -87,6 +87,14 @@ public GetCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : b internal override string OperationName => "ml.get_calendar_events"; + /// + /// + /// A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using _all or * or by omitting the calendar identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// Specifies to get events with timestamps earlier than this time. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs index a8e698977df..a82789aa669 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarEventsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetCalendarEventsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + + public override GetCalendarEventsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCalendarEventsResponse + { + Count = propCount.Value +, + Events = propEvents.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCalendarEventsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCalendarEventsResponseConverter))] public sealed partial class GetCalendarEventsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection Events { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs index a0ddc443b1e..98ac555e164 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsRequest.g.cs @@ -70,6 +70,14 @@ public GetCalendarsRequest(Elastic.Clients.Elasticsearch.Id? calendarId) : base( internal override string OperationName => "ml.get_calendars"; + /// + /// + /// A string that uniquely identifies a calendar. You can get information for multiple calendars by using a comma-separated list of ids or a wildcard expression. You can get information for all calendars by using _all or * or by omitting the calendar identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? CalendarId { get => P("calendar_id"); set => PO("calendar_id", value); } + /// /// /// Skips the specified number of calendars. This parameter is supported only when you omit the calendar identifier. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs index 4b098d1cd30..157bba7c387 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCalendarsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetCalendarsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendars = System.Text.Json.JsonEncodedText.Encode("calendars"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetCalendarsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propCalendars = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendars.TryRead(ref reader, options, PropCalendars)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCalendarsResponse + { + Calendars = propCalendars.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCalendarsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendars, value.Calendars); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCalendarsResponseConverter))] public sealed partial class GetCalendarsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("calendars")] public IReadOnlyCollection Calendars { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs index 00006ea2873..55042c044fb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesRequest.g.cs @@ -77,6 +77,26 @@ public GetCategoriesRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => internal override string OperationName => "ml.get_categories"; + /// + /// + /// Identifier for the category, which is unique in the job. If you specify + /// neither the category ID nor the partition_field_value, the API returns + /// information about all categories. If you specify only the + /// partition_field_value, it returns information about all categories for + /// the specified partition. + /// + /// + [JsonIgnore] + public string? CategoryId { get => P("category_id"); set => PO("category_id", value); } + + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Skips the specified number of categories. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs index 0a9fef54aeb..90cc1b2a1cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetCategoriesResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetCategoriesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCategories = System.Text.Json.JsonEncodedText.Encode("categories"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + + public override GetCategoriesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propCategories = default; + LocalJsonValue propCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCategories.TryRead(ref reader, options, PropCategories)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetCategoriesResponse + { + Categories = propCategories.Value +, + Count = propCount.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetCategoriesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCategories, value.Categories); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetCategoriesResponseConverter))] public sealed partial class GetCategoriesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("categories")] public IReadOnlyCollection Categories { get; init; } - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs index 0019cb46116..e0f88b0a8bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsRequest.g.cs @@ -113,6 +113,16 @@ public GetDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : base internal override string OperationName => "ml.get_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. If you do not specify this + /// option, the API returns information for the first hundred data frame + /// analytics jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs index da8f94fc4cb..d41d807e06f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrameAnalytics = System.Text.Json.JsonEncodedText.Encode("data_frame_analytics"); + + public override GetDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDataFrameAnalytics.TryRead(ref reader, options, PropDataFrameAnalytics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataFrameAnalyticsResponse + { + Count = propCount.Value +, + DataFrameAnalytics = propDataFrameAnalytics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsResponseConverter))] public sealed partial class GetDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class GetDataFrameAnalyticsResponse : ElasticsearchRespons /// An array of data frame analytics job resources, which are sorted by the id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("data_frame_analytics")] public IReadOnlyCollection DataFrameAnalytics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs index ee5420191c0..9e8fe878af9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsRequest.g.cs @@ -108,6 +108,16 @@ public GetDataFrameAnalyticsStatsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.get_data_frame_analytics_stats"; + /// + /// + /// Identifier for the data frame analytics job. If you do not specify this + /// option, the API returns information for the first hundred data frame + /// analytics jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs index fb6b005d405..9805664f2b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDataFrameAnalyticsStatsResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetDataFrameAnalyticsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrameAnalytics = System.Text.Json.JsonEncodedText.Encode("data_frame_analytics"); + + public override GetDataFrameAnalyticsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propDataFrameAnalytics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDataFrameAnalytics.TryRead(ref reader, options, PropDataFrameAnalytics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDataFrameAnalyticsStatsResponse + { + Count = propCount.Value +, + DataFrameAnalytics = propDataFrameAnalytics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDataFrameAnalyticsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDataFrameAnalytics, value.DataFrameAnalytics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDataFrameAnalyticsStatsResponseConverter))] public sealed partial class GetDataFrameAnalyticsStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class GetDataFrameAnalyticsStatsResponse : ElasticsearchRe /// An array of objects that contain usage information for data frame analytics jobs, which are sorted by the id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("data_frame_analytics")] public IReadOnlyCollection DataFrameAnalytics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs index 12d213290c1..65ffa61212f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsRequest.g.cs @@ -92,6 +92,16 @@ public GetDatafeedStatsRequest(Elastic.Clients.Elasticsearch.Ids? datafeedId) : internal override string OperationName => "ml.get_datafeed_stats"; + /// + /// + /// Identifier for the datafeed. It can be a datafeed identifier or a + /// wildcard expression. If you do not specify one of these options, the API + /// returns information about all datafeeds. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? DatafeedId { get => P("datafeed_id"); set => PO("datafeed_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs index 5b5b708f0f5..5f8c138c1ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetDatafeedStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeeds = System.Text.Json.JsonEncodedText.Encode("datafeeds"); + + public override GetDatafeedStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDatafeeds.TryRead(ref reader, options, PropDatafeeds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDatafeedStatsResponse + { + Count = propCount.Value +, + Datafeeds = propDatafeeds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDatafeedStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDatafeedStatsResponseConverter))] public sealed partial class GetDatafeedStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("datafeeds")] public IReadOnlyCollection Datafeeds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs index f4cef19baa3..349e23bedb5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsRequest.g.cs @@ -100,6 +100,16 @@ public GetDatafeedsRequest(Elastic.Clients.Elasticsearch.Ids? datafeedId) : base internal override string OperationName => "ml.get_datafeeds"; + /// + /// + /// Identifier for the datafeed. It can be a datafeed identifier or a + /// wildcard expression. If you do not specify one of these options, the API + /// returns information about all datafeeds. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? DatafeedId { get => P("datafeed_id"); set => PO("datafeed_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs index 080ae74ef84..56f53899af3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetDatafeedsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetDatafeedsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeeds = System.Text.Json.JsonEncodedText.Encode("datafeeds"); + + public override GetDatafeedsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propDatafeeds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propDatafeeds.TryRead(ref reader, options, PropDatafeeds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetDatafeedsResponse + { + Count = propCount.Value +, + Datafeeds = propDatafeeds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetDatafeedsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropDatafeeds, value.Datafeeds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetDatafeedsResponseConverter))] public sealed partial class GetDatafeedsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("datafeeds")] public IReadOnlyCollection Datafeeds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs index 0ae21abfdd6..21b9cc2f815 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersRequest.g.cs @@ -71,6 +71,14 @@ public GetFiltersRequest(Elastic.Clients.Elasticsearch.Ids? filterId) : base(r = internal override string OperationName => "ml.get_filters"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? FilterId { get => P("filter_id"); set => PO("filter_id", value); } + /// /// /// Skips the specified number of filters. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs index e7c60c8592c..2a7d92dc753 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetFiltersResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetFiltersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropFilters = System.Text.Json.JsonEncodedText.Encode("filters"); + + public override GetFiltersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propFilters = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propFilters.TryRead(ref reader, options, PropFilters)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetFiltersResponse + { + Count = propCount.Value +, + Filters = propFilters.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetFiltersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropFilters, value.Filters); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetFiltersResponseConverter))] public sealed partial class GetFiltersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("filters")] public IReadOnlyCollection Filters { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs index 5754873d0bd..f4a8f974055 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersRequest.g.cs @@ -117,6 +117,14 @@ public GetInfluencersRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => internal override string OperationName => "ml.get_influencers"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// If true, the results are sorted in descending order. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs index 188949c02d9..069501c8d15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetInfluencersResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetInfluencersResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropInfluencers = System.Text.Json.JsonEncodedText.Encode("influencers"); + + public override GetInfluencersResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propInfluencers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propInfluencers.TryRead(ref reader, options, PropInfluencers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetInfluencersResponse + { + Count = propCount.Value +, + Influencers = propInfluencers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetInfluencersResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropInfluencers, value.Influencers); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetInfluencersResponseConverter))] public sealed partial class GetInfluencersResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class GetInfluencersResponse : ElasticsearchResponse /// Array of influencer objects /// /// - [JsonInclude, JsonPropertyName("influencers")] public IReadOnlyCollection Influencers { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs index bea2d642d87..20815bd8821 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsRequest.g.cs @@ -86,6 +86,17 @@ public GetJobStatsRequest(Elastic.Clients.Elasticsearch.Id? jobId) : base(r => r internal override string OperationName => "ml.get_job_stats"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, a comma-separated list of jobs, or a wildcard expression. If + /// you do not specify one of these options, the API returns information for + /// all anomaly detection jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs index 190a243cb18..67ab331e8dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetJobStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropJobs = System.Text.Json.JsonEncodedText.Encode("jobs"); + + public override GetJobStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propJobs.TryRead(ref reader, options, PropJobs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetJobStatsResponse + { + Count = propCount.Value +, + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropJobs, value.Jobs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobStatsResponseConverter))] public sealed partial class GetJobStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs index 6d95ea6c52f..81bd87e52a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsRequest.g.cs @@ -99,6 +99,16 @@ public GetJobsRequest(Elastic.Clients.Elasticsearch.Ids? jobId) : base(r => r.Op internal override string OperationName => "ml.get_jobs"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, or a wildcard expression. If you do not specify one of these + /// options, the API returns information for all anomaly detection jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? JobId { get => P("job_id"); set => PO("job_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs index 419693e599b..ed2315e983e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetJobsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetJobsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropJobs = System.Text.Json.JsonEncodedText.Encode("jobs"); + + public override GetJobsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propJobs.TryRead(ref reader, options, PropJobs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetJobsResponse + { + Count = propCount.Value +, + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropJobs, value.Jobs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobsResponseConverter))] public sealed partial class GetJobsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs index 7c8a3d1f22d..130ee0102b4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsRequest.g.cs @@ -74,6 +74,15 @@ public GetMemoryStatsRequest(Elastic.Clients.Elasticsearch.Id? nodeId) : base(r internal override string OperationName => "ml.get_memory_stats"; + /// + /// + /// The names of particular nodes in the cluster to target. For example, nodeId1,nodeId2 or + /// ml:true + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs index ebfed58ba91..c208d1e7e92 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetMemoryStatsResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetMemoryStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStatistics = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override GetMemoryStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStatistics = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStatistics.TryRead(ref reader, options, PropNodeStatistics)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetMemoryStatsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStatistics = propNodeStatistics.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetMemoryStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStatistics, value.NodeStatistics); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetMemoryStatsResponseConverter))] public sealed partial class GetMemoryStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStatistics { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs index 2d88a9b0287..ffb225936bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsRequest.g.cs @@ -81,6 +81,24 @@ public GetModelSnapshotUpgradeStatsRequest(Elastic.Clients.Elasticsearch.Id jobI internal override string OperationName => "ml.get_model_snapshot_upgrade_stats"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + /// snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using _all, + /// by specifying * as the snapshot ID, or by omitting the snapshot ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs index 45fd57704ca..048b00fbb58 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotUpgradeStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetModelSnapshotUpgradeStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotUpgrades = System.Text.Json.JsonEncodedText.Encode("model_snapshot_upgrades"); + + public override GetModelSnapshotUpgradeStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propModelSnapshotUpgrades = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propModelSnapshotUpgrades.TryRead(ref reader, options, PropModelSnapshotUpgrades)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetModelSnapshotUpgradeStatsResponse + { + Count = propCount.Value +, + ModelSnapshotUpgrades = propModelSnapshotUpgrades.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetModelSnapshotUpgradeStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropModelSnapshotUpgrades, value.ModelSnapshotUpgrades); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetModelSnapshotUpgradeStatsResponseConverter))] public sealed partial class GetModelSnapshotUpgradeStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_upgrades")] public IReadOnlyCollection ModelSnapshotUpgrades { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs index 04ad8474205..0787ba56a32 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsRequest.g.cs @@ -70,6 +70,24 @@ public GetModelSnapshotsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r internal override string OperationName => "ml.get_model_snapshots"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. You can get information for multiple + /// snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using _all, + /// by specifying * as the snapshot ID, or by omitting the snapshot ID. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? SnapshotId { get => P("snapshot_id"); set => PO("snapshot_id", value); } + /// /// /// Skips the specified number of snapshots. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs index b56ff39f247..d68e9e589b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetModelSnapshotsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetModelSnapshotsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshots = System.Text.Json.JsonEncodedText.Encode("model_snapshots"); + + public override GetModelSnapshotsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propModelSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propModelSnapshots.TryRead(ref reader, options, PropModelSnapshots)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetModelSnapshotsResponse + { + Count = propCount.Value +, + ModelSnapshots = propModelSnapshots.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetModelSnapshotsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropModelSnapshots, value.ModelSnapshots); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetModelSnapshotsResponseConverter))] public sealed partial class GetModelSnapshotsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("model_snapshots")] public IReadOnlyCollection ModelSnapshots { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs index 46d90e46696..09edbff9786 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsRequest.g.cs @@ -73,6 +73,20 @@ public GetOverallBucketsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r internal override string OperationName => "ml.get_overall_buckets"; + /// + /// + /// Identifier for the anomaly detection job. It can be a job identifier, a + /// group name, a comma-separated list of jobs or groups, or a wildcard + /// expression. + /// + /// + /// You can summarize the bucket results for all anomaly detection jobs by + /// using _all or by specifying * as the <job_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs index 341db374b03..034150b8995 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetOverallBucketsResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetOverallBucketsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropOverallBuckets = System.Text.Json.JsonEncodedText.Encode("overall_buckets"); + + public override GetOverallBucketsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propOverallBuckets = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propOverallBuckets.TryRead(ref reader, options, PropOverallBuckets)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetOverallBucketsResponse + { + Count = propCount.Value +, + OverallBuckets = propOverallBuckets.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetOverallBucketsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropOverallBuckets, value.OverallBuckets); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetOverallBucketsResponseConverter))] public sealed partial class GetOverallBucketsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class GetOverallBucketsResponse : ElasticsearchResponse /// Array of overall bucket objects /// /// - [JsonInclude, JsonPropertyName("overall_buckets")] public IReadOnlyCollection OverallBuckets { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs index 1fd0c64b61b..449389fde90 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsRequest.g.cs @@ -76,6 +76,14 @@ public GetRecordsRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.R internal override string OperationName => "ml.get_records"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Skips the specified number of records. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs index 10805cbe3fe..43157f56f41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetRecordsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetRecordsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropRecords = System.Text.Json.JsonEncodedText.Encode("records"); + + public override GetRecordsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propRecords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propRecords.TryRead(ref reader, options, PropRecords)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRecordsResponse + { + Count = propCount.Value +, + Records = propRecords.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRecordsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropRecords, value.Records); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRecordsResponseConverter))] public sealed partial class GetRecordsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("records")] public IReadOnlyCollection Records { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs index 3800d44371d..938349468cb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsRequest.g.cs @@ -132,6 +132,19 @@ public GetTrainedModelsRequest(Elastic.Clients.Elasticsearch.Ids? modelId) : bas internal override string OperationName => "ml.get_trained_models"; + /// + /// + /// The unique identifier of the trained model or a model alias. + /// + /// + /// You can get information for multiple trained models in a single API + /// request by using a comma-separated list of model IDs or a wildcard + /// expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? ModelId { get => P("model_id"); set => PO("model_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs index ec971e39178..57d6f3a7c1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetTrainedModelsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTrainedModelConfigs = System.Text.Json.JsonEncodedText.Encode("trained_model_configs"); + + public override GetTrainedModelsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propTrainedModelConfigs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTrainedModelConfigs.TryRead(ref reader, options, PropTrainedModelConfigs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrainedModelsResponse + { + Count = propCount.Value +, + TrainedModelConfigs = propTrainedModelConfigs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrainedModelsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTrainedModelConfigs, value.TrainedModelConfigs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsResponseConverter))] public sealed partial class GetTrainedModelsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class GetTrainedModelsResponse : ElasticsearchResponse /// An array of trained model resources, which are sorted by the model_id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("trained_model_configs")] public IReadOnlyCollection TrainedModelConfigs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs index a66c834864c..f219e8039b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsRequest.g.cs @@ -100,6 +100,15 @@ public GetTrainedModelsStatsRequest(Elastic.Clients.Elasticsearch.Ids? modelId) internal override string OperationName => "ml.get_trained_models_stats"; + /// + /// + /// The unique identifier of the trained model or a model alias. It can be a + /// comma-separated list or a wildcard expression. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids? ModelId { get => P("model_id"); set => PO("model_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs index d49b5734363..7ce94533865 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/GetTrainedModelsStatsResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class GetTrainedModelsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTrainedModelStats = System.Text.Json.JsonEncodedText.Encode("trained_model_stats"); + + public override GetTrainedModelsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propTrainedModelStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTrainedModelStats.TryRead(ref reader, options, PropTrainedModelStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTrainedModelsStatsResponse + { + Count = propCount.Value +, + TrainedModelStats = propTrainedModelStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTrainedModelsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTrainedModelStats, value.TrainedModelStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTrainedModelsStatsResponseConverter))] public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchRespons /// The total number of trained model statistics that matched the requested ID patterns. Could be higher than the number of items in the trained_model_stats array as the size of the array is restricted by the supplied size parameter. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class GetTrainedModelsStatsResponse : ElasticsearchRespons /// An array of trained model statistics, which are sorted by the model_id value in ascending order. /// /// - [JsonInclude, JsonPropertyName("trained_model_stats")] public IReadOnlyCollection TrainedModelStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs index 79cf334a50c..ca2f3dad74d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelRequest.g.cs @@ -59,6 +59,14 @@ public InferTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base internal override string OperationName => "ml.infer_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Controls the amount of time to wait for inference results. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs index b9edc44911f..a7633a475bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/InferTrainedModelResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class InferTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInferenceResults = System.Text.Json.JsonEncodedText.Encode("inference_results"); + + public override InferTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propInferenceResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInferenceResults.TryRead(ref reader, options, PropInferenceResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferTrainedModelResponse + { + InferenceResults = propInferenceResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInferenceResults, value.InferenceResults); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferTrainedModelResponseConverter))] public sealed partial class InferTrainedModelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("inference_results")] public IReadOnlyCollection InferenceResults { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs index 7f86fd9da05..de266860803 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/MlInfoResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class MlInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefaults = System.Text.Json.JsonEncodedText.Encode("defaults"); + private static readonly System.Text.Json.JsonEncodedText PropLimits = System.Text.Json.JsonEncodedText.Encode("limits"); + private static readonly System.Text.Json.JsonEncodedText PropNativeCode = System.Text.Json.JsonEncodedText.Encode("native_code"); + private static readonly System.Text.Json.JsonEncodedText PropUpgradeMode = System.Text.Json.JsonEncodedText.Encode("upgrade_mode"); + + public override MlInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDefaults = default; + LocalJsonValue propLimits = default; + LocalJsonValue propNativeCode = default; + LocalJsonValue propUpgradeMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefaults.TryRead(ref reader, options, PropDefaults)) + { + continue; + } + + if (propLimits.TryRead(ref reader, options, PropLimits)) + { + continue; + } + + if (propNativeCode.TryRead(ref reader, options, PropNativeCode)) + { + continue; + } + + if (propUpgradeMode.TryRead(ref reader, options, PropUpgradeMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MlInfoResponse + { + Defaults = propDefaults.Value +, + Limits = propLimits.Value +, + NativeCode = propNativeCode.Value +, + UpgradeMode = propUpgradeMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MlInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefaults, value.Defaults); + writer.WriteProperty(options, PropLimits, value.Limits); + writer.WriteProperty(options, PropNativeCode, value.NativeCode); + writer.WriteProperty(options, PropUpgradeMode, value.UpgradeMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MlInfoResponseConverter))] public sealed partial class MlInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("defaults")] public Elastic.Clients.Elasticsearch.MachineLearning.Defaults Defaults { get; init; } - [JsonInclude, JsonPropertyName("limits")] public Elastic.Clients.Elasticsearch.MachineLearning.Limits Limits { get; init; } - [JsonInclude, JsonPropertyName("native_code")] public Elastic.Clients.Elasticsearch.MachineLearning.NativeCode NativeCode { get; init; } - [JsonInclude, JsonPropertyName("upgrade_mode")] public bool UpgradeMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs index b997be7d093..17ac814d620 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobRequest.g.cs @@ -59,6 +59,14 @@ public OpenJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Requ internal override string OperationName => "ml.open_job"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Refer to the description for the timeout query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs index af8427ee8e5..9ac134ec06b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/OpenJobResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class OpenJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropOpened = System.Text.Json.JsonEncodedText.Encode("opened"); + + public override OpenJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNode = default; + LocalJsonValue propOpened = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + if (propOpened.TryRead(ref reader, options, PropOpened)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenJobResponse + { + Node = propNode.Value +, + Opened = propOpened.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteProperty(options, PropOpened, value.Opened); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenJobResponseConverter))] public sealed partial class OpenJobResponse : ElasticsearchResponse { /// @@ -34,8 +80,6 @@ public sealed partial class OpenJobResponse : ElasticsearchResponse /// If the job is allowed to open lazily and has not yet been assigned to a node, this value is an empty string. /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } - [JsonInclude, JsonPropertyName("opened")] public bool Opened { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs index 254e2fb0204..8ad6be2c57a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsRequest.g.cs @@ -53,6 +53,14 @@ public PostCalendarEventsRequest(Elastic.Clients.Elasticsearch.Id calendarId) : internal override string OperationName => "ml.post_calendar_events"; + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// A list of one of more scheduled events. The event’s start and end times can be specified as integer milliseconds since the epoch or as a string in ISO 8601 format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs index e8742653958..1a73a116901 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PostCalendarEventsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PostCalendarEventsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + + public override PostCalendarEventsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propEvents = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PostCalendarEventsResponse + { + Events = propEvents.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PostCalendarEventsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PostCalendarEventsResponseConverter))] public sealed partial class PostCalendarEventsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection Events { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs index c59ce728794..a25c5aa4900 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsRequest.g.cs @@ -58,6 +58,14 @@ public PreviewDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id? id) : internal override string OperationName => "ml.preview_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + /// /// /// A data frame analytics config as described in create data frame analytics diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs index 3247772bece..bfec343daa6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PreviewDataFrameAnalyticsResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PreviewDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatureValues = System.Text.Json.JsonEncodedText.Encode("feature_values"); + + public override PreviewDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propFeatureValues = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureValues.TryRead(ref reader, options, PropFeatureValues)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PreviewDataFrameAnalyticsResponse + { + FeatureValues = propFeatureValues.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PreviewDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureValues, value.FeatureValues); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PreviewDataFrameAnalyticsResponseConverter))] public sealed partial class PreviewDataFrameAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PreviewDataFrameAnalyticsResponse : ElasticsearchRes /// An array of objects that contain feature name and value pairs. The features have been processed and indicate what will be sent to the model for training. /// /// - [JsonInclude, JsonPropertyName("feature_values")] public IReadOnlyCollection> FeatureValues { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs index d8286ceaee4..f3f7bd5b554 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobRequest.g.cs @@ -52,6 +52,22 @@ public PutCalendarJobRequest(Elastic.Clients.Elasticsearch.Id calendarId, Elasti internal override bool SupportsBody => false; internal override string OperationName => "ml.put_calendar_job"; + + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + + /// + /// + /// An identifier for the anomaly detection jobs. It can be a job identifier, a group name, or a comma-separated list of jobs or groups. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids JobId { get => P("job_id"); set => PR("job_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs index 6c5d6e9ec7c..b70cfe55cf7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarJobResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutCalendarJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override PutCalendarJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutCalendarJobResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutCalendarJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarJobResponseConverter))] public sealed partial class PutCalendarJobResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +103,5 @@ public sealed partial class PutCalendarJobResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs index d475637ee75..19b7a1960ad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarRequest.g.cs @@ -53,6 +53,14 @@ public PutCalendarRequest(Elastic.Clients.Elasticsearch.Id calendarId) : base(r internal override string OperationName => "ml.put_calendar"; + /// + /// + /// A string that uniquely identifies a calendar. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id CalendarId { get => P("calendar_id"); set => PR("calendar_id", value); } + /// /// /// A description of the calendar. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs index 191a67ad6f5..472b61b514b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutCalendarResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutCalendarResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarId = System.Text.Json.JsonEncodedText.Encode("calendar_id"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropJobIds = System.Text.Json.JsonEncodedText.Encode("job_ids"); + + public override PutCalendarResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCalendarId = default; + LocalJsonValue propDescription = default; + LocalJsonValue> propJobIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarId.TryRead(ref reader, options, PropCalendarId)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propJobIds.TryRead(ref reader, options, PropJobIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutCalendarResponse + { + CalendarId = propCalendarId.Value +, + Description = propDescription.Value +, + JobIds = propJobIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutCalendarResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarId, value.CalendarId); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropJobIds, value.JobIds, null, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutCalendarResponseConverter))] public sealed partial class PutCalendarResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A string that uniquely identifies a calendar. /// /// - [JsonInclude, JsonPropertyName("calendar_id")] public string CalendarId { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A description of the calendar. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -49,7 +103,5 @@ public sealed partial class PutCalendarResponse : ElasticsearchResponse /// A list of anomaly detection job identifiers or group names. /// /// - [JsonInclude, JsonPropertyName("job_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection JobIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs index f62f35e8c15..e439c83e365 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsRequest.g.cs @@ -55,6 +55,16 @@ public PutDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base( internal override string OperationName => "ml.put_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs index f09a4e42769..ffe81f53a78 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDataFrameAnalyticsResponse.g.cs @@ -22,36 +22,179 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyStart = System.Text.Json.JsonEncodedText.Encode("allow_lazy_start"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzedFields = System.Text.Json.JsonEncodedText.Encode("analyzed_fields"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNumThreads = System.Text.Json.JsonEncodedText.Encode("max_num_threads"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryLimit = System.Text.Json.JsonEncodedText.Encode("model_memory_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowLazyStart = default; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyzedFields = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propId = default; + LocalJsonValue propMaxNumThreads = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propModelMemoryLimit = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryRead(ref reader, options, PropAllowLazyStart)) + { + continue; + } + + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) + { + continue; + } + + if (propAnalyzedFields.TryRead(ref reader, options, PropAnalyzedFields)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propMaxNumThreads.TryRead(ref reader, options, PropMaxNumThreads)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propModelMemoryLimit.TryRead(ref reader, options, PropModelMemoryLimit)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDataFrameAnalyticsResponse + { + AllowLazyStart = propAllowLazyStart.Value +, + Analysis = propAnalysis.Value +, + AnalyzedFields = propAnalyzedFields.Value +, + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Id = propId.Value +, + MaxNumThreads = propMaxNumThreads.Value +, + Meta = propMeta.Value +, + ModelMemoryLimit = propModelMemoryLimit.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyStart, value.AllowLazyStart); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDataFrameAnalyticsResponseConverter))] public sealed partial class PutDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_start")] public bool AllowLazyStart { get; init; } - [JsonInclude, JsonPropertyName("analysis")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination Dest { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("max_num_threads")] public int MaxNumThreads { get; init; } - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } - [JsonInclude, JsonPropertyName("model_memory_limit")] public string ModelMemoryLimit { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource Source { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs index f73cd9f69fd..ca45ebc3003 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedRequest.g.cs @@ -56,194 +56,167 @@ public sealed partial class PutDatafeedRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } -internal sealed partial class PutDatafeedRequestConverter : JsonConverter +internal sealed partial class PutDatafeedRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override PutDatafeedRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropHeaders = System.Text.Json.JsonEncodedText.Encode("headers"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override PutDatafeedRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new PutDatafeedRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue>>?> propHeaders = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "headers") - { - variant.Headers = JsonSerializer.Deserialize>>?>(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, PutDatafeedRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propHeaders.TryRead(ref reader, options, PropHeaders)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Headers is not null) - { - writer.WritePropertyName("headers"); - JsonSerializer.Serialize(writer, value.Headers, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDatafeedRequest { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value + , + ChunkingConfig = propChunkingConfig.Value + , + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value + , + Frequency = propFrequency.Value + , + Headers = propHeaders.Value + , + Indices = propIndices.Value + , + IndicesOptions = propIndicesOptions.Value + , + JobId = propJobId.Value + , + MaxEmptySearches = propMaxEmptySearches.Value + , + Query = propQuery.Value + , + QueryDelay = propQueryDelay.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDatafeedRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropHeaders, value.Headers); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } @@ -281,13 +254,21 @@ public PutDatafeedRequest() internal override string OperationName => "ml.put_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. + /// This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + /// It must start and end with alphanumeric characters. + /// + /// + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// If true, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the _all /// string or when no indices are specified. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -296,7 +277,6 @@ public PutDatafeedRequest() /// whether wildcard expressions match hidden data streams. Supports comma-separated values. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -304,7 +284,6 @@ public PutDatafeedRequest() /// If true, unavailable indices (missing or closed) are ignored. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -313,7 +292,6 @@ public PutDatafeedRequest() /// Support for aggregations is limited and should be used only with low cardinality data. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -324,7 +302,6 @@ public PutDatafeedRequest() /// it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -336,7 +313,6 @@ public PutDatafeedRequest() /// This check runs only on real-time datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -348,9 +324,7 @@ public PutDatafeedRequest() /// aggregations, this value must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; set; } - [JsonInclude, JsonPropertyName("headers")] public IDictionary>>? Headers { get; set; } /// @@ -359,7 +333,6 @@ public PutDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -367,7 +340,6 @@ public PutDatafeedRequest() /// Specifies index expansion options that are used during search /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; set; } /// @@ -375,7 +347,6 @@ public PutDatafeedRequest() /// Identifier for the anomaly detection job. /// /// - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Id? JobId { get; set; } /// @@ -386,7 +357,6 @@ public PutDatafeedRequest() /// end time that sees no data remains started until it is explicitly stopped. By default, it is not set. /// /// - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; set; } /// @@ -396,7 +366,6 @@ public PutDatafeedRequest() /// object is passed verbatim to Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -407,7 +376,6 @@ public PutDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; set; } /// @@ -415,7 +383,6 @@ public PutDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -424,7 +391,6 @@ public PutDatafeedRequest() /// The detector configuration objects in a job can contain functions that use these script fields. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -433,7 +399,6 @@ public PutDatafeedRequest() /// The maximum value is the value of index.max_result_window, which is 10,000 by default. /// /// - [JsonInclude, JsonPropertyName("scroll_size")] public int? ScrollSize { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs index 0a02dd03b3c..08c1e4a446f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutDatafeedResponse.g.cs @@ -22,40 +22,201 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override PutDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutDatafeedResponse + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutDatafeedResponseConverter))] public sealed partial class PutDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration QueryDelay { get; init; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IReadOnlyDictionary? RuntimeMappings { get; init; } - [JsonInclude, JsonPropertyName("script_fields")] public IReadOnlyDictionary? ScriptFields { get; init; } - [JsonInclude, JsonPropertyName("scroll_size")] public int ScrollSize { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs index 6e235f21ab1..8bc624d30d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterRequest.g.cs @@ -55,6 +55,14 @@ public PutFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r => r internal override string OperationName => "ml.put_filter"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } + /// /// /// A description of the filter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs index 03d0bc4ab06..078118d156e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutFilterResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFilterId = System.Text.Json.JsonEncodedText.Encode("filter_id"); + private static readonly System.Text.Json.JsonEncodedText PropItems = System.Text.Json.JsonEncodedText.Encode("items"); + + public override PutFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDescription = default; + LocalJsonValue propFilterId = default; + LocalJsonValue> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFilterId.TryRead(ref reader, options, PropFilterId)) + { + continue; + } + + if (propItems.TryRead(ref reader, options, PropItems)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutFilterResponse + { + Description = propDescription.Value +, + FilterId = propFilterId.Value +, + Items = propItems.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFilterId, value.FilterId); + writer.WriteProperty(options, PropItems, value.Items); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutFilterResponseConverter))] public sealed partial class PutFilterResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("filter_id")] public string FilterId { get; init; } - [JsonInclude, JsonPropertyName("items")] public IReadOnlyCollection Items { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs index cd8cb1f1ccf..03e3123ec35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutJobResponse.g.cs @@ -22,50 +22,256 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyOpen = System.Text.Json.JsonEncodedText.Encode("allow_lazy_open"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisConfig = System.Text.Json.JsonEncodedText.Encode("analysis_config"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisLimits = System.Text.Json.JsonEncodedText.Encode("analysis_limits"); + private static readonly System.Text.Json.JsonEncodedText PropBackgroundPersistInterval = System.Text.Json.JsonEncodedText.Encode("background_persist_interval"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropCustomSettings = System.Text.Json.JsonEncodedText.Encode("custom_settings"); + private static readonly System.Text.Json.JsonEncodedText PropDailyModelSnapshotRetentionAfterDays = System.Text.Json.JsonEncodedText.Encode("daily_model_snapshot_retention_after_days"); + private static readonly System.Text.Json.JsonEncodedText PropDataDescription = System.Text.Json.JsonEncodedText.Encode("data_description"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedConfig = System.Text.Json.JsonEncodedText.Encode("datafeed_config"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropGroups = System.Text.Json.JsonEncodedText.Encode("groups"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropJobType = System.Text.Json.JsonEncodedText.Encode("job_type"); + private static readonly System.Text.Json.JsonEncodedText PropJobVersion = System.Text.Json.JsonEncodedText.Encode("job_version"); + private static readonly System.Text.Json.JsonEncodedText PropModelPlotConfig = System.Text.Json.JsonEncodedText.Encode("model_plot_config"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotId = System.Text.Json.JsonEncodedText.Encode("model_snapshot_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotRetentionDays = System.Text.Json.JsonEncodedText.Encode("model_snapshot_retention_days"); + private static readonly System.Text.Json.JsonEncodedText PropRenormalizationWindowDays = System.Text.Json.JsonEncodedText.Encode("renormalization_window_days"); + private static readonly System.Text.Json.JsonEncodedText PropResultsIndexName = System.Text.Json.JsonEncodedText.Encode("results_index_name"); + private static readonly System.Text.Json.JsonEncodedText PropResultsRetentionDays = System.Text.Json.JsonEncodedText.Encode("results_retention_days"); + + public override PutJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowLazyOpen = default; + LocalJsonValue propAnalysisConfig = default; + LocalJsonValue propAnalysisLimits = default; + LocalJsonValue propBackgroundPersistInterval = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propCustomSettings = default; + LocalJsonValue propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonValue propDataDescription = default; + LocalJsonValue propDatafeedConfig = default; + LocalJsonValue propDescription = default; + LocalJsonValue?> propGroups = default; + LocalJsonValue propJobId = default; + LocalJsonValue propJobType = default; + LocalJsonValue propJobVersion = default; + LocalJsonValue propModelPlotConfig = default; + LocalJsonValue propModelSnapshotId = default; + LocalJsonValue propModelSnapshotRetentionDays = default; + LocalJsonValue propRenormalizationWindowDays = default; + LocalJsonValue propResultsIndexName = default; + LocalJsonValue propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryRead(ref reader, options, PropAllowLazyOpen)) + { + continue; + } + + if (propAnalysisConfig.TryRead(ref reader, options, PropAnalysisConfig)) + { + continue; + } + + if (propAnalysisLimits.TryRead(ref reader, options, PropAnalysisLimits)) + { + continue; + } + + if (propBackgroundPersistInterval.TryRead(ref reader, options, PropBackgroundPersistInterval)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propCustomSettings.TryRead(ref reader, options, PropCustomSettings)) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryRead(ref reader, options, PropDailyModelSnapshotRetentionAfterDays)) + { + continue; + } + + if (propDataDescription.TryRead(ref reader, options, PropDataDescription)) + { + continue; + } + + if (propDatafeedConfig.TryRead(ref reader, options, PropDatafeedConfig)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propGroups.TryRead(ref reader, options, PropGroups)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propJobType.TryRead(ref reader, options, PropJobType)) + { + continue; + } + + if (propJobVersion.TryRead(ref reader, options, PropJobVersion)) + { + continue; + } + + if (propModelPlotConfig.TryRead(ref reader, options, PropModelPlotConfig)) + { + continue; + } + + if (propModelSnapshotId.TryRead(ref reader, options, PropModelSnapshotId)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryRead(ref reader, options, PropModelSnapshotRetentionDays)) + { + continue; + } + + if (propRenormalizationWindowDays.TryRead(ref reader, options, PropRenormalizationWindowDays)) + { + continue; + } + + if (propResultsIndexName.TryRead(ref reader, options, PropResultsIndexName)) + { + continue; + } + + if (propResultsRetentionDays.TryRead(ref reader, options, PropResultsRetentionDays)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutJobResponse + { + AllowLazyOpen = propAllowLazyOpen.Value +, + AnalysisConfig = propAnalysisConfig.Value +, + AnalysisLimits = propAnalysisLimits.Value +, + BackgroundPersistInterval = propBackgroundPersistInterval.Value +, + CreateTime = propCreateTime.Value +, + CustomSettings = propCustomSettings.Value +, + DailyModelSnapshotRetentionAfterDays = propDailyModelSnapshotRetentionAfterDays.Value +, + DataDescription = propDataDescription.Value +, + DatafeedConfig = propDatafeedConfig.Value +, + Description = propDescription.Value +, + Groups = propGroups.Value +, + JobId = propJobId.Value +, + JobType = propJobType.Value +, + JobVersion = propJobVersion.Value +, + ModelPlotConfig = propModelPlotConfig.Value +, + ModelSnapshotId = propModelSnapshotId.Value +, + ModelSnapshotRetentionDays = propModelSnapshotRetentionDays.Value +, + RenormalizationWindowDays = propRenormalizationWindowDays.Value +, + ResultsIndexName = propResultsIndexName.Value +, + ResultsRetentionDays = propResultsRetentionDays.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyOpen, value.AllowLazyOpen); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays); + writer.WriteProperty(options, PropDataDescription, value.DataDescription); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropGroups, value.Groups); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropJobType, value.JobType); + writer.WriteProperty(options, PropJobVersion, value.JobVersion); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutJobResponseConverter))] public sealed partial class PutJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_open")] public bool AllowLazyOpen { get; init; } - [JsonInclude, JsonPropertyName("analysis_config")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.Duration? BackgroundPersistInterval { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public DateTimeOffset CreateTime { get; init; } - [JsonInclude, JsonPropertyName("custom_settings")] public object? CustomSettings { get; init; } - [JsonInclude, JsonPropertyName("daily_model_snapshot_retention_after_days")] public long DailyModelSnapshotRetentionAfterDays { get; init; } - [JsonInclude, JsonPropertyName("data_description")] public Elastic.Clients.Elasticsearch.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.MachineLearning.Datafeed? DatafeedConfig { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("groups")] public IReadOnlyCollection? Groups { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("job_type")] public string JobType { get; init; } - [JsonInclude, JsonPropertyName("job_version")] public string JobVersion { get; init; } - [JsonInclude, JsonPropertyName("model_plot_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? ModelPlotConfig { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_id")] public string? ModelSnapshotId { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_retention_days")] public long ModelSnapshotRetentionDays { get; init; } - [JsonInclude, JsonPropertyName("renormalization_window_days")] public long? RenormalizationWindowDays { get; init; } - [JsonInclude, JsonPropertyName("results_index_name")] public string ResultsIndexName { get; init; } - [JsonInclude, JsonPropertyName("results_retention_days")] public long? ResultsRetentionDays { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs index c2a8fb886fc..630aadd9a13 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasRequest.g.cs @@ -77,6 +77,22 @@ public PutTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Id modelId, Ela internal override string OperationName => "ml.put_trained_model_alias"; + /// + /// + /// The alias to create or update. This value cannot end in numbers. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name ModelAlias { get => P("model_alias"); set => PR("model_alias", value); } + + /// + /// + /// The identifier for the trained model that the alias refers to. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Specifies whether the alias gets reassigned to the specified trained diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs index 0e3e893281e..595eb9116b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelAliasResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutTrainedModelAliasResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelAliasResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelAliasResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelAliasResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelAliasResponseConverter))] public sealed partial class PutTrainedModelAliasResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutTrainedModelAliasResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs index 949f8e5915c..c0e8f946a48 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartRequest.g.cs @@ -53,6 +53,23 @@ public PutTrainedModelDefinitionPartRequest(Elastic.Clients.Elasticsearch.Id mod internal override string OperationName => "ml.put_trained_model_definition_part"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + + /// + /// + /// The definition part number. When the definition is loaded for inference the definition parts are streamed in the + /// order of their part number. The first part must be 0 and the final part must be total_parts - 1. + /// + /// + [JsonIgnore] + public int Part { get => P("part"); set => PR("part", value); } + /// /// /// The definition part for the model. Must be a base64 encoded string. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs index 683d8780c23..cd7b5647e9d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelDefinitionPartResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutTrainedModelDefinitionPartResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelDefinitionPartResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelDefinitionPartResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelDefinitionPartResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelDefinitionPartResponseConverter))] public sealed partial class PutTrainedModelDefinitionPartResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutTrainedModelDefinitionPartResponse : Elasticsearc /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs index d5c5f91da95..ae3820e52ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelRequest.g.cs @@ -70,6 +70,14 @@ public PutTrainedModelRequest(Elastic.Clients.Elasticsearch.Id modelId) : base(r internal override string OperationName => "ml.put_trained_model"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// If set to true and a compressed_definition is provided, diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs index cb1d77cd15a..735ac142156 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelResponse.g.cs @@ -22,13 +22,238 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutTrainedModelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompressedDefinition = System.Text.Json.JsonEncodedText.Encode("compressed_definition"); + private static readonly System.Text.Json.JsonEncodedText PropCreatedBy = System.Text.Json.JsonEncodedText.Encode("created_by"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultFieldMap = System.Text.Json.JsonEncodedText.Encode("default_field_map"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropEstimatedHeapMemoryUsageBytes = System.Text.Json.JsonEncodedText.Encode("estimated_heap_memory_usage_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropEstimatedOperations = System.Text.Json.JsonEncodedText.Encode("estimated_operations"); + private static readonly System.Text.Json.JsonEncodedText PropFullyDefined = System.Text.Json.JsonEncodedText.Encode("fully_defined"); + private static readonly System.Text.Json.JsonEncodedText PropInferenceConfig = System.Text.Json.JsonEncodedText.Encode("inference_config"); + private static readonly System.Text.Json.JsonEncodedText PropInput = System.Text.Json.JsonEncodedText.Encode("input"); + private static readonly System.Text.Json.JsonEncodedText PropLicenseLevel = System.Text.Json.JsonEncodedText.Encode("license_level"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropModelId = System.Text.Json.JsonEncodedText.Encode("model_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelPackage = System.Text.Json.JsonEncodedText.Encode("model_package"); + private static readonly System.Text.Json.JsonEncodedText PropModelSizeBytes = System.Text.Json.JsonEncodedText.Encode("model_size_bytes"); + private static readonly System.Text.Json.JsonEncodedText PropModelType = System.Text.Json.JsonEncodedText.Encode("model_type"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixStrings = System.Text.Json.JsonEncodedText.Encode("prefix_strings"); + private static readonly System.Text.Json.JsonEncodedText PropTags = System.Text.Json.JsonEncodedText.Encode("tags"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PutTrainedModelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompressedDefinition = default; + LocalJsonValue propCreatedBy = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue?> propDefaultFieldMap = default; + LocalJsonValue propDescription = default; + LocalJsonValue propEstimatedHeapMemoryUsageBytes = default; + LocalJsonValue propEstimatedOperations = default; + LocalJsonValue propFullyDefined = default; + LocalJsonValue propInferenceConfig = default; + LocalJsonValue propInput = default; + LocalJsonValue propLicenseLevel = default; + LocalJsonValue propLocation = default; + LocalJsonValue propMetadata = default; + LocalJsonValue propModelId = default; + LocalJsonValue propModelPackage = default; + LocalJsonValue propModelSizeBytes = default; + LocalJsonValue propModelType = default; + LocalJsonValue propPrefixStrings = default; + LocalJsonValue> propTags = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompressedDefinition.TryRead(ref reader, options, PropCompressedDefinition)) + { + continue; + } + + if (propCreatedBy.TryRead(ref reader, options, PropCreatedBy)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDefaultFieldMap.TryRead(ref reader, options, PropDefaultFieldMap)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propEstimatedHeapMemoryUsageBytes.TryRead(ref reader, options, PropEstimatedHeapMemoryUsageBytes)) + { + continue; + } + + if (propEstimatedOperations.TryRead(ref reader, options, PropEstimatedOperations)) + { + continue; + } + + if (propFullyDefined.TryRead(ref reader, options, PropFullyDefined)) + { + continue; + } + + if (propInferenceConfig.TryRead(ref reader, options, PropInferenceConfig)) + { + continue; + } + + if (propInput.TryRead(ref reader, options, PropInput)) + { + continue; + } + + if (propLicenseLevel.TryRead(ref reader, options, PropLicenseLevel)) + { + continue; + } + + if (propLocation.TryRead(ref reader, options, PropLocation)) + { + continue; + } + + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + if (propModelId.TryRead(ref reader, options, PropModelId)) + { + continue; + } + + if (propModelPackage.TryRead(ref reader, options, PropModelPackage)) + { + continue; + } + + if (propModelSizeBytes.TryRead(ref reader, options, PropModelSizeBytes)) + { + continue; + } + + if (propModelType.TryRead(ref reader, options, PropModelType)) + { + continue; + } + + if (propPrefixStrings.TryRead(ref reader, options, PropPrefixStrings)) + { + continue; + } + + if (propTags.TryRead(ref reader, options, PropTags)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelResponse + { + CompressedDefinition = propCompressedDefinition.Value +, + CreatedBy = propCreatedBy.Value +, + CreateTime = propCreateTime.Value +, + DefaultFieldMap = propDefaultFieldMap.Value +, + Description = propDescription.Value +, + EstimatedHeapMemoryUsageBytes = propEstimatedHeapMemoryUsageBytes.Value +, + EstimatedOperations = propEstimatedOperations.Value +, + FullyDefined = propFullyDefined.Value +, + InferenceConfig = propInferenceConfig.Value +, + Input = propInput.Value +, + LicenseLevel = propLicenseLevel.Value +, + Location = propLocation.Value +, + Metadata = propMetadata.Value +, + ModelId = propModelId.Value +, + ModelPackage = propModelPackage.Value +, + ModelSizeBytes = propModelSizeBytes.Value +, + ModelType = propModelType.Value +, + PrefixStrings = propPrefixStrings.Value +, + Tags = propTags.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompressedDefinition, value.CompressedDefinition); + writer.WriteProperty(options, PropCreatedBy, value.CreatedBy); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDefaultFieldMap, value.DefaultFieldMap); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropEstimatedHeapMemoryUsageBytes, value.EstimatedHeapMemoryUsageBytes); + writer.WriteProperty(options, PropEstimatedOperations, value.EstimatedOperations); + writer.WriteProperty(options, PropFullyDefined, value.FullyDefined); + writer.WriteProperty(options, PropInferenceConfig, value.InferenceConfig); + writer.WriteProperty(options, PropInput, value.Input); + writer.WriteProperty(options, PropLicenseLevel, value.LicenseLevel); + writer.WriteProperty(options, PropLocation, value.Location); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteProperty(options, PropModelId, value.ModelId); + writer.WriteProperty(options, PropModelPackage, value.ModelPackage); + writer.WriteProperty(options, PropModelSizeBytes, value.ModelSizeBytes); + writer.WriteProperty(options, PropModelType, value.ModelType); + writer.WriteProperty(options, PropPrefixStrings, value.PrefixStrings); + writer.WriteProperty(options, PropTags, value.Tags); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelResponseConverter))] public sealed partial class PutTrainedModelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("compressed_definition")] public string? CompressedDefinition { get; init; } /// @@ -36,7 +261,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Information on the creator of the trained model. /// /// - [JsonInclude, JsonPropertyName("created_by")] public string? CreatedBy { get; init; } /// @@ -44,7 +268,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The time when the trained model was created. /// /// - [JsonInclude, JsonPropertyName("create_time")] public DateTimeOffset? CreateTime { get; init; } /// @@ -52,7 +275,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Any field map described in the inference configuration takes precedence. /// /// - [JsonInclude, JsonPropertyName("default_field_map")] public IReadOnlyDictionary? DefaultFieldMap { get; init; } /// @@ -60,7 +282,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The free-text description of the trained model. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } /// @@ -68,7 +289,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The estimated heap usage in bytes to keep the trained model in memory. /// /// - [JsonInclude, JsonPropertyName("estimated_heap_memory_usage_bytes")] public int? EstimatedHeapMemoryUsageBytes { get; init; } /// @@ -76,7 +296,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The estimated number of operations to use the trained model. /// /// - [JsonInclude, JsonPropertyName("estimated_operations")] public int? EstimatedOperations { get; init; } /// @@ -84,7 +303,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// True if the full model definition is present. /// /// - [JsonInclude, JsonPropertyName("fully_defined")] public bool? FullyDefined { get; init; } /// @@ -92,7 +310,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The default configuration for inference. This can be either a regression, classification, or one of the many NLP focused configurations. It must match the underlying definition.trained_model's target_type. For pre-packaged models such as ELSER the config is not required. /// /// - [JsonInclude, JsonPropertyName("inference_config")] public Elastic.Clients.Elasticsearch.MachineLearning.InferenceConfigCreate? InferenceConfig { get; init; } /// @@ -100,7 +317,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The input field names for the model definition. /// /// - [JsonInclude, JsonPropertyName("input")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelConfigInput Input { get; init; } /// @@ -108,9 +324,7 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The license level of the trained model. /// /// - [JsonInclude, JsonPropertyName("license_level")] public string? LicenseLevel { get; init; } - [JsonInclude, JsonPropertyName("location")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelLocation? Location { get; init; } /// @@ -118,7 +332,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// An object containing metadata about the trained model. For example, models created by data frame analytics contain analysis_config and input objects. /// /// - [JsonInclude, JsonPropertyName("metadata")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelConfigMetadata? Metadata { get; init; } /// @@ -126,11 +339,8 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// Identifier for the trained model. /// /// - [JsonInclude, JsonPropertyName("model_id")] public string ModelId { get; init; } - [JsonInclude, JsonPropertyName("model_package")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelPackageConfig? ModelPackage { get; init; } - [JsonInclude, JsonPropertyName("model_size_bytes")] public Elastic.Clients.Elasticsearch.ByteSize? ModelSizeBytes { get; init; } /// @@ -138,9 +348,7 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The model type /// /// - [JsonInclude, JsonPropertyName("model_type")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelType? ModelType { get; init; } - [JsonInclude, JsonPropertyName("prefix_strings")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelPrefixStrings? PrefixStrings { get; init; } /// @@ -148,7 +356,6 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// A comma delimited string of tags. A trained model can have many tags, or none. /// /// - [JsonInclude, JsonPropertyName("tags")] public IReadOnlyCollection Tags { get; init; } /// @@ -156,6 +363,5 @@ public sealed partial class PutTrainedModelResponse : ElasticsearchResponse /// The Elasticsearch version number in which the trained model was created. /// /// - [JsonInclude, JsonPropertyName("version")] public string? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs index 410059d8e85..cee079ebfd1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyRequest.g.cs @@ -55,6 +55,14 @@ public PutTrainedModelVocabularyRequest(Elastic.Clients.Elasticsearch.Id modelId internal override string OperationName => "ml.put_trained_model_vocabulary"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The optional model merges if required by the tokenizer. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs index ad429dd3de8..6f92151d6b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/PutTrainedModelVocabularyResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class PutTrainedModelVocabularyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTrainedModelVocabularyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTrainedModelVocabularyResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTrainedModelVocabularyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTrainedModelVocabularyResponseConverter))] public sealed partial class PutTrainedModelVocabularyResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutTrainedModelVocabularyResponse : ElasticsearchRes /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs index 22e01c4e863..30c32501865 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobRequest.g.cs @@ -73,6 +73,14 @@ public ResetJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Req internal override string OperationName => "ml.reset_job"; + /// + /// + /// The ID of the job to reset. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Specifies whether annotations that have been added by the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs index 1376dc1be33..0f3f15a9f43 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ResetJobResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ResetJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResetJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetJobResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetJobResponseConverter))] public sealed partial class ResetJobResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ResetJobResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs index fd5a431f6bc..1bfe3dea5a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotRequest.g.cs @@ -60,6 +60,24 @@ public RevertModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override string OperationName => "ml.revert_model_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// You can specify empty as the <snapshot_id>. Reverting to the empty + /// snapshot means the anomaly detection job starts learning a new model from + /// scratch when it is started. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Refer to the description for the delete_intervening_results query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs index 845e682de52..0035e552cc2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/RevertModelSnapshotResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class RevertModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropModel = System.Text.Json.JsonEncodedText.Encode("model"); + + public override RevertModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propModel.TryRead(ref reader, options, PropModel)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RevertModelSnapshotResponse + { + Model = propModel.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RevertModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropModel, value.Model); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RevertModelSnapshotResponseConverter))] public sealed partial class RevertModelSnapshotResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("model")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs index 2331ea78700..6c7b7f0239b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/SetUpgradeModeResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class SetUpgradeModeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override SetUpgradeModeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SetUpgradeModeResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SetUpgradeModeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SetUpgradeModeResponseConverter))] public sealed partial class SetUpgradeModeResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class SetUpgradeModeResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs index cd42cb41dfa..9214c5348c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsRequest.g.cs @@ -71,6 +71,16 @@ public StartDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : bas internal override string OperationName => "ml.start_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Controls the amount of time to wait until the data frame analytics job diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs index 2285b69b809..ae8bbbf81ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDataFrameAnalyticsResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StartDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + + public override StartDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartDataFrameAnalyticsResponse + { + Acknowledged = propAcknowledged.Value +, + Node = propNode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDataFrameAnalyticsResponseConverter))] public sealed partial class StartDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } /// @@ -40,6 +85,5 @@ public sealed partial class StartDataFrameAnalyticsResponse : ElasticsearchRespo /// node ID will be "serverless". /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs index 443127894dc..b90e150cf1b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedRequest.g.cs @@ -69,6 +69,16 @@ public StartDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base( internal override string OperationName => "ml.start_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. This identifier can contain lowercase + /// alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must start and end with alphanumeric + /// characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Refer to the description for the end query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs index a8ff65cd2ea..608ca5b4d72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartDatafeedResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StartDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override StartDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNode = default; + LocalJsonValue propStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNode.TryRead(ref reader, options, PropNode, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propStarted.TryRead(ref reader, options, PropStarted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartDatafeedResponse + { + Node = propNode.Value +, + Started = propStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNode, value.Node, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropStarted, value.Started); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartDatafeedResponseConverter))] public sealed partial class StartDatafeedResponse : ElasticsearchResponse { /// @@ -34,8 +80,6 @@ public sealed partial class StartDatafeedResponse : ElasticsearchResponse /// If the job is allowed to open lazily and has not yet been assigned to a node, this value is an empty string. /// /// - [JsonInclude, JsonPropertyName("node")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Node { get; init; } /// @@ -43,6 +87,5 @@ public sealed partial class StartDatafeedResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("started")] public bool Started { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs index 81f77f7f92a..2fa52710545 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentRequest.g.cs @@ -121,6 +121,14 @@ public StartTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id model internal override string OperationName => "ml.start_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. Currently, only PyTorch models are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The inference cache size (in memory outside the JVM heap) per node for the model. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs index de829f86d0b..c89e9818406 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StartTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StartTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAssignment = System.Text.Json.JsonEncodedText.Encode("assignment"); + + public override StartTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAssignment = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAssignment.TryRead(ref reader, options, PropAssignment)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartTrainedModelDeploymentResponse + { + Assignment = propAssignment.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAssignment, value.Assignment); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTrainedModelDeploymentResponseConverter))] public sealed partial class StartTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("assignment")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelAssignment Assignment { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs index 86f9bcb4d1e..fca2622f0e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsRequest.g.cs @@ -100,6 +100,16 @@ public StopDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : base internal override string OperationName => "ml.stop_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs index b367f3fd569..60b78add767 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDataFrameAnalyticsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StopDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopDataFrameAnalyticsResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopDataFrameAnalyticsResponseConverter))] public sealed partial class StopDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs index 1d8fe87c595..d8689dae317 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedRequest.g.cs @@ -55,6 +55,16 @@ public StopDatafeedRequest(Elastic.Clients.Elasticsearch.Id datafeedId) : base(r internal override string OperationName => "ml.stop_datafeed"; + /// + /// + /// Identifier for the datafeed. You can stop multiple datafeeds in a single API request by using a comma-separated + /// list of datafeeds or a wildcard expression. You can close all datafeeds by using _all or by specifying * as + /// the identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// Refer to the description for the allow_no_match query parameter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs index 984d91eafa8..e7dc69aaf3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopDatafeedResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StopDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopDatafeedResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopDatafeedResponseConverter))] public sealed partial class StopDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs index 998d7826948..96e599060c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentRequest.g.cs @@ -70,6 +70,14 @@ public StopTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id modelI internal override string OperationName => "ml.stop_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// Specifies what to do when the request: contains wildcard expressions and there are no deployments that match; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs index b7e839abf4f..90f20a38a0f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/StopTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class StopTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTrainedModelDeploymentResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTrainedModelDeploymentResponseConverter))] public sealed partial class StopTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs index 002350b9b66..88479030382 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsRequest.g.cs @@ -53,6 +53,16 @@ public UpdateDataFrameAnalyticsRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "ml.update_data_frame_analytics"; + /// + /// + /// Identifier for the data frame analytics job. This identifier can contain + /// lowercase alphanumeric characters (a-z and 0-9), hyphens, and + /// underscores. It must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Specifies whether this job can start when there is insufficient machine diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs index b1c66fc047e..41b50ed8d74 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDataFrameAnalyticsResponse.g.cs @@ -22,34 +22,168 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateDataFrameAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyStart = System.Text.Json.JsonEncodedText.Encode("allow_lazy_start"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzedFields = System.Text.Json.JsonEncodedText.Encode("analyzed_fields"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNumThreads = System.Text.Json.JsonEncodedText.Encode("max_num_threads"); + private static readonly System.Text.Json.JsonEncodedText PropModelMemoryLimit = System.Text.Json.JsonEncodedText.Encode("model_memory_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override UpdateDataFrameAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowLazyStart = default; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyzedFields = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propId = default; + LocalJsonValue propMaxNumThreads = default; + LocalJsonValue propModelMemoryLimit = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyStart.TryRead(ref reader, options, PropAllowLazyStart)) + { + continue; + } + + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) + { + continue; + } + + if (propAnalyzedFields.TryRead(ref reader, options, PropAnalyzedFields)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propMaxNumThreads.TryRead(ref reader, options, PropMaxNumThreads)) + { + continue; + } + + if (propModelMemoryLimit.TryRead(ref reader, options, PropModelMemoryLimit)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDataFrameAnalyticsResponse + { + AllowLazyStart = propAllowLazyStart.Value +, + Analysis = propAnalysis.Value +, + AnalyzedFields = propAnalyzedFields.Value +, + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Id = propId.Value +, + MaxNumThreads = propMaxNumThreads.Value +, + ModelMemoryLimit = propModelMemoryLimit.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDataFrameAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyStart, value.AllowLazyStart); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyzedFields, value.AnalyzedFields); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropMaxNumThreads, value.MaxNumThreads); + writer.WriteProperty(options, PropModelMemoryLimit, value.ModelMemoryLimit); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateDataFrameAnalyticsResponseConverter))] public sealed partial class UpdateDataFrameAnalyticsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_start")] public bool AllowLazyStart { get; init; } - [JsonInclude, JsonPropertyName("analysis")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysis Analysis { get; init; } - [JsonInclude, JsonPropertyName("analyzed_fields")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisAnalyzedFields? AnalyzedFields { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsDestination Dest { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("max_num_threads")] public int MaxNumThreads { get; init; } - [JsonInclude, JsonPropertyName("model_memory_limit")] public string ModelMemoryLimit { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalyticsSource Source { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs index b7116b1731f..bb29a88a575 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedRequest.g.cs @@ -83,182 +83,156 @@ public sealed partial class UpdateDatafeedRequestParameters : RequestParameters public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } } -internal sealed partial class UpdateDatafeedRequestConverter : JsonConverter +internal sealed partial class UpdateDatafeedRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override UpdateDatafeedRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override UpdateDatafeedRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new UpdateDatafeedRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations)) { - var property = reader.GetString(); - if (property == "aggregations") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, UpdateDatafeedRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDatafeedRequest { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value + , + ChunkingConfig = propChunkingConfig.Value + , + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value + , + Frequency = propFrequency.Value + , + Indices = propIndices.Value + , + IndicesOptions = propIndicesOptions.Value + , + JobId = propJobId.Value + , + MaxEmptySearches = propMaxEmptySearches.Value + , + Query = propQuery.Value + , + QueryDelay = propQueryDelay.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDatafeedRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } @@ -291,13 +265,21 @@ public UpdateDatafeedRequest() internal override string OperationName => "ml.update_datafeed"; + /// + /// + /// A numerical character string that uniquely identifies the datafeed. + /// This identifier can contain lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. + /// It must start and end with alphanumeric characters. + /// + /// + public Elastic.Clients.Elasticsearch.Id DatafeedId { get => P("datafeed_id"); set => PR("datafeed_id", value); } + /// /// /// If true, wildcard indices expressions that resolve into no concrete indices are ignored. This includes the /// _all string or when no indices are specified. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -333,7 +315,6 @@ public UpdateDatafeedRequest() /// /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -341,7 +322,6 @@ public UpdateDatafeedRequest() /// If true, unavailable indices (missing or closed) are ignored. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -350,7 +330,6 @@ public UpdateDatafeedRequest() /// with low cardinality data. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -360,7 +339,6 @@ public UpdateDatafeedRequest() /// these time chunks are calculated; it is an advanced configuration option. /// /// - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? ChunkingConfig { get; set; } /// @@ -372,7 +350,6 @@ public UpdateDatafeedRequest() /// datafeeds. /// /// - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; set; } /// @@ -384,7 +361,6 @@ public UpdateDatafeedRequest() /// must be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; set; } /// @@ -393,7 +369,6 @@ public UpdateDatafeedRequest() /// learning nodes must have the remote_cluster_client role. /// /// - [JsonInclude, JsonPropertyName("indices")] public ICollection? Indices { get; set; } /// @@ -401,9 +376,7 @@ public UpdateDatafeedRequest() /// Specifies index expansion options that are used during search. /// /// - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; set; } - [JsonInclude, JsonPropertyName("job_id")] public Elastic.Clients.Elasticsearch.Id? JobId { get; set; } /// @@ -414,7 +387,6 @@ public UpdateDatafeedRequest() /// end time that sees no data remains started until it is explicitly stopped. By default, it is not set. /// /// - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; set; } /// @@ -428,7 +400,6 @@ public UpdateDatafeedRequest() /// when you are satisfied with the results of the job. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -439,7 +410,6 @@ public UpdateDatafeedRequest() /// when there are multiple jobs running on the same node. /// /// - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration? QueryDelay { get; set; } /// @@ -447,7 +417,6 @@ public UpdateDatafeedRequest() /// Specifies runtime fields for the datafeed search. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -456,7 +425,6 @@ public UpdateDatafeedRequest() /// The detector configuration objects in a job can contain functions that use these script fields. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -465,7 +433,6 @@ public UpdateDatafeedRequest() /// The maximum value is the value of index.max_result_window. /// /// - [JsonInclude, JsonPropertyName("scroll_size")] public int? ScrollSize { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs index ebee97ee8e8..084fa92e957 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateDatafeedResponse.g.cs @@ -22,40 +22,201 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateDatafeedResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override UpdateDatafeedResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateDatafeedResponse + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateDatafeedResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateDatafeedResponseConverter))] public sealed partial class UpdateDatafeedResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.MachineLearning.DatafeedAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("chunking_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig ChunkingConfig { get; init; } - [JsonInclude, JsonPropertyName("datafeed_id")] public string DatafeedId { get; init; } - [JsonInclude, JsonPropertyName("delayed_data_check_config")] public Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig? DelayedDataCheckConfig { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("indices_options")] public Elastic.Clients.Elasticsearch.IndicesOptions? IndicesOptions { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("max_empty_searches")] public int? MaxEmptySearches { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query Query { get; init; } - [JsonInclude, JsonPropertyName("query_delay")] public Elastic.Clients.Elasticsearch.Duration QueryDelay { get; init; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IReadOnlyDictionary? RuntimeMappings { get; init; } - [JsonInclude, JsonPropertyName("script_fields")] public IReadOnlyDictionary? ScriptFields { get; init; } - [JsonInclude, JsonPropertyName("scroll_size")] public int ScrollSize { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs index 444d8a9d5a7..475dbc46dae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterRequest.g.cs @@ -54,6 +54,14 @@ public UpdateFilterRequest(Elastic.Clients.Elasticsearch.Id filterId) : base(r = internal override string OperationName => "ml.update_filter"; + /// + /// + /// A string that uniquely identifies a filter. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id FilterId { get => P("filter_id"); set => PR("filter_id", value); } + /// /// /// The items to add to the filter. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs index 7cbe0f06cbc..bc183e015c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateFilterResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateFilterResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFilterId = System.Text.Json.JsonEncodedText.Encode("filter_id"); + private static readonly System.Text.Json.JsonEncodedText PropItems = System.Text.Json.JsonEncodedText.Encode("items"); + + public override UpdateFilterResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDescription = default; + LocalJsonValue propFilterId = default; + LocalJsonValue> propItems = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFilterId.TryRead(ref reader, options, PropFilterId)) + { + continue; + } + + if (propItems.TryRead(ref reader, options, PropItems)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateFilterResponse + { + Description = propDescription.Value +, + FilterId = propFilterId.Value +, + Items = propItems.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateFilterResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFilterId, value.FilterId); + writer.WriteProperty(options, PropItems, value.Items); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateFilterResponseConverter))] public sealed partial class UpdateFilterResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("filter_id")] public string FilterId { get; init; } - [JsonInclude, JsonPropertyName("items")] public IReadOnlyCollection Items { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs index 83f7061f442..cf1155f931f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobRequest.g.cs @@ -54,6 +54,14 @@ public UpdateJobRequest(Elastic.Clients.Elasticsearch.Id jobId) : base(r => r.Re internal override string OperationName => "ml.update_job"; + /// + /// + /// Identifier for the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + /// /// /// Advanced configuration option. Specifies whether this job can open when diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs index 0fbf50d92cd..2d880b8a9d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateJobResponse.g.cs @@ -22,52 +22,267 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLazyOpen = System.Text.Json.JsonEncodedText.Encode("allow_lazy_open"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisConfig = System.Text.Json.JsonEncodedText.Encode("analysis_config"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysisLimits = System.Text.Json.JsonEncodedText.Encode("analysis_limits"); + private static readonly System.Text.Json.JsonEncodedText PropBackgroundPersistInterval = System.Text.Json.JsonEncodedText.Encode("background_persist_interval"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropCustomSettings = System.Text.Json.JsonEncodedText.Encode("custom_settings"); + private static readonly System.Text.Json.JsonEncodedText PropDailyModelSnapshotRetentionAfterDays = System.Text.Json.JsonEncodedText.Encode("daily_model_snapshot_retention_after_days"); + private static readonly System.Text.Json.JsonEncodedText PropDataDescription = System.Text.Json.JsonEncodedText.Encode("data_description"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedConfig = System.Text.Json.JsonEncodedText.Encode("datafeed_config"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFinishedTime = System.Text.Json.JsonEncodedText.Encode("finished_time"); + private static readonly System.Text.Json.JsonEncodedText PropGroups = System.Text.Json.JsonEncodedText.Encode("groups"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropJobType = System.Text.Json.JsonEncodedText.Encode("job_type"); + private static readonly System.Text.Json.JsonEncodedText PropJobVersion = System.Text.Json.JsonEncodedText.Encode("job_version"); + private static readonly System.Text.Json.JsonEncodedText PropModelPlotConfig = System.Text.Json.JsonEncodedText.Encode("model_plot_config"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotId = System.Text.Json.JsonEncodedText.Encode("model_snapshot_id"); + private static readonly System.Text.Json.JsonEncodedText PropModelSnapshotRetentionDays = System.Text.Json.JsonEncodedText.Encode("model_snapshot_retention_days"); + private static readonly System.Text.Json.JsonEncodedText PropRenormalizationWindowDays = System.Text.Json.JsonEncodedText.Encode("renormalization_window_days"); + private static readonly System.Text.Json.JsonEncodedText PropResultsIndexName = System.Text.Json.JsonEncodedText.Encode("results_index_name"); + private static readonly System.Text.Json.JsonEncodedText PropResultsRetentionDays = System.Text.Json.JsonEncodedText.Encode("results_retention_days"); + + public override UpdateJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowLazyOpen = default; + LocalJsonValue propAnalysisConfig = default; + LocalJsonValue propAnalysisLimits = default; + LocalJsonValue propBackgroundPersistInterval = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue?> propCustomSettings = default; + LocalJsonValue propDailyModelSnapshotRetentionAfterDays = default; + LocalJsonValue propDataDescription = default; + LocalJsonValue propDatafeedConfig = default; + LocalJsonValue propDescription = default; + LocalJsonValue propFinishedTime = default; + LocalJsonValue?> propGroups = default; + LocalJsonValue propJobId = default; + LocalJsonValue propJobType = default; + LocalJsonValue propJobVersion = default; + LocalJsonValue propModelPlotConfig = default; + LocalJsonValue propModelSnapshotId = default; + LocalJsonValue propModelSnapshotRetentionDays = default; + LocalJsonValue propRenormalizationWindowDays = default; + LocalJsonValue propResultsIndexName = default; + LocalJsonValue propResultsRetentionDays = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLazyOpen.TryRead(ref reader, options, PropAllowLazyOpen)) + { + continue; + } + + if (propAnalysisConfig.TryRead(ref reader, options, PropAnalysisConfig)) + { + continue; + } + + if (propAnalysisLimits.TryRead(ref reader, options, PropAnalysisLimits)) + { + continue; + } + + if (propBackgroundPersistInterval.TryRead(ref reader, options, PropBackgroundPersistInterval)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propCustomSettings.TryRead(ref reader, options, PropCustomSettings)) + { + continue; + } + + if (propDailyModelSnapshotRetentionAfterDays.TryRead(ref reader, options, PropDailyModelSnapshotRetentionAfterDays)) + { + continue; + } + + if (propDataDescription.TryRead(ref reader, options, PropDataDescription)) + { + continue; + } + + if (propDatafeedConfig.TryRead(ref reader, options, PropDatafeedConfig)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFinishedTime.TryRead(ref reader, options, PropFinishedTime)) + { + continue; + } + + if (propGroups.TryRead(ref reader, options, PropGroups)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propJobType.TryRead(ref reader, options, PropJobType)) + { + continue; + } + + if (propJobVersion.TryRead(ref reader, options, PropJobVersion)) + { + continue; + } + + if (propModelPlotConfig.TryRead(ref reader, options, PropModelPlotConfig)) + { + continue; + } + + if (propModelSnapshotId.TryRead(ref reader, options, PropModelSnapshotId)) + { + continue; + } + + if (propModelSnapshotRetentionDays.TryRead(ref reader, options, PropModelSnapshotRetentionDays)) + { + continue; + } + + if (propRenormalizationWindowDays.TryRead(ref reader, options, PropRenormalizationWindowDays)) + { + continue; + } + + if (propResultsIndexName.TryRead(ref reader, options, PropResultsIndexName)) + { + continue; + } + + if (propResultsRetentionDays.TryRead(ref reader, options, PropResultsRetentionDays)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateJobResponse + { + AllowLazyOpen = propAllowLazyOpen.Value +, + AnalysisConfig = propAnalysisConfig.Value +, + AnalysisLimits = propAnalysisLimits.Value +, + BackgroundPersistInterval = propBackgroundPersistInterval.Value +, + CreateTime = propCreateTime.Value +, + CustomSettings = propCustomSettings.Value +, + DailyModelSnapshotRetentionAfterDays = propDailyModelSnapshotRetentionAfterDays.Value +, + DataDescription = propDataDescription.Value +, + DatafeedConfig = propDatafeedConfig.Value +, + Description = propDescription.Value +, + FinishedTime = propFinishedTime.Value +, + Groups = propGroups.Value +, + JobId = propJobId.Value +, + JobType = propJobType.Value +, + JobVersion = propJobVersion.Value +, + ModelPlotConfig = propModelPlotConfig.Value +, + ModelSnapshotId = propModelSnapshotId.Value +, + ModelSnapshotRetentionDays = propModelSnapshotRetentionDays.Value +, + RenormalizationWindowDays = propRenormalizationWindowDays.Value +, + ResultsIndexName = propResultsIndexName.Value +, + ResultsRetentionDays = propResultsRetentionDays.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLazyOpen, value.AllowLazyOpen); + writer.WriteProperty(options, PropAnalysisConfig, value.AnalysisConfig); + writer.WriteProperty(options, PropAnalysisLimits, value.AnalysisLimits); + writer.WriteProperty(options, PropBackgroundPersistInterval, value.BackgroundPersistInterval); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropCustomSettings, value.CustomSettings); + writer.WriteProperty(options, PropDailyModelSnapshotRetentionAfterDays, value.DailyModelSnapshotRetentionAfterDays); + writer.WriteProperty(options, PropDataDescription, value.DataDescription); + writer.WriteProperty(options, PropDatafeedConfig, value.DatafeedConfig); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFinishedTime, value.FinishedTime); + writer.WriteProperty(options, PropGroups, value.Groups); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropJobType, value.JobType); + writer.WriteProperty(options, PropJobVersion, value.JobVersion); + writer.WriteProperty(options, PropModelPlotConfig, value.ModelPlotConfig); + writer.WriteProperty(options, PropModelSnapshotId, value.ModelSnapshotId); + writer.WriteProperty(options, PropModelSnapshotRetentionDays, value.ModelSnapshotRetentionDays); + writer.WriteProperty(options, PropRenormalizationWindowDays, value.RenormalizationWindowDays); + writer.WriteProperty(options, PropResultsIndexName, value.ResultsIndexName); + writer.WriteProperty(options, PropResultsRetentionDays, value.ResultsRetentionDays); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateJobResponseConverter))] public sealed partial class UpdateJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("allow_lazy_open")] public bool AllowLazyOpen { get; init; } - [JsonInclude, JsonPropertyName("analysis_config")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisConfigRead AnalysisConfig { get; init; } - [JsonInclude, JsonPropertyName("analysis_limits")] public Elastic.Clients.Elasticsearch.MachineLearning.AnalysisLimits AnalysisLimits { get; init; } - [JsonInclude, JsonPropertyName("background_persist_interval")] public Elastic.Clients.Elasticsearch.Duration? BackgroundPersistInterval { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("custom_settings")] public IReadOnlyDictionary? CustomSettings { get; init; } - [JsonInclude, JsonPropertyName("daily_model_snapshot_retention_after_days")] public long DailyModelSnapshotRetentionAfterDays { get; init; } - [JsonInclude, JsonPropertyName("data_description")] public Elastic.Clients.Elasticsearch.MachineLearning.DataDescription DataDescription { get; init; } - [JsonInclude, JsonPropertyName("datafeed_config")] public Elastic.Clients.Elasticsearch.MachineLearning.Datafeed? DatafeedConfig { get; init; } - [JsonInclude, JsonPropertyName("description")] public string? Description { get; init; } - [JsonInclude, JsonPropertyName("finished_time")] public long? FinishedTime { get; init; } - [JsonInclude, JsonPropertyName("groups")] public IReadOnlyCollection? Groups { get; init; } - [JsonInclude, JsonPropertyName("job_id")] public string JobId { get; init; } - [JsonInclude, JsonPropertyName("job_type")] public string JobType { get; init; } - [JsonInclude, JsonPropertyName("job_version")] public string JobVersion { get; init; } - [JsonInclude, JsonPropertyName("model_plot_config")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelPlotConfig? ModelPlotConfig { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_id")] public string? ModelSnapshotId { get; init; } - [JsonInclude, JsonPropertyName("model_snapshot_retention_days")] public long ModelSnapshotRetentionDays { get; init; } - [JsonInclude, JsonPropertyName("renormalization_window_days")] public long? RenormalizationWindowDays { get; init; } - [JsonInclude, JsonPropertyName("results_index_name")] public string ResultsIndexName { get; init; } - [JsonInclude, JsonPropertyName("results_retention_days")] public long? ResultsRetentionDays { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs index d8c88bacb00..6018d8b576d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotRequest.g.cs @@ -54,6 +54,22 @@ public UpdateModelSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elasti internal override string OperationName => "ml.update_model_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// Identifier for the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// A description of the model snapshot. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs index c5fb4fc4670..626af1a497d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateModelSnapshotResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateModelSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropModel = System.Text.Json.JsonEncodedText.Encode("model"); + + public override UpdateModelSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propModel = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propModel.TryRead(ref reader, options, PropModel)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateModelSnapshotResponse + { + Acknowledged = propAcknowledged.Value +, + Model = propModel.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateModelSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropModel, value.Model); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateModelSnapshotResponseConverter))] public sealed partial class UpdateModelSnapshotResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("model")] public Elastic.Clients.Elasticsearch.MachineLearning.ModelSnapshot Model { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs index fbbf728cec4..c1b04762c79 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentRequest.g.cs @@ -53,6 +53,14 @@ public UpdateTrainedModelDeploymentRequest(Elastic.Clients.Elasticsearch.Id mode internal override string OperationName => "ml.update_trained_model_deployment"; + /// + /// + /// The unique identifier of the trained model. Currently, only PyTorch models are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id ModelId { get => P("model_id"); set => PR("model_id", value); } + /// /// /// The number of model allocations on each node where the model is deployed. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs index 3ef93e48077..d83aa6a9938 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpdateTrainedModelDeploymentResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpdateTrainedModelDeploymentResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAssignment = System.Text.Json.JsonEncodedText.Encode("assignment"); + + public override UpdateTrainedModelDeploymentResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAssignment = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAssignment.TryRead(ref reader, options, PropAssignment)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateTrainedModelDeploymentResponse + { + Assignment = propAssignment.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateTrainedModelDeploymentResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAssignment, value.Assignment); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateTrainedModelDeploymentResponseConverter))] public sealed partial class UpdateTrainedModelDeploymentResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("assignment")] public Elastic.Clients.Elasticsearch.MachineLearning.TrainedModelAssignment Assignment { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs index 07886ed234a..1051301b35f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotRequest.g.cs @@ -76,6 +76,22 @@ public UpgradeJobSnapshotRequest(Elastic.Clients.Elasticsearch.Id jobId, Elastic internal override string OperationName => "ml.upgrade_job_snapshot"; + /// + /// + /// Identifier for the anomaly detection job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id JobId { get => P("job_id"); set => PR("job_id", value); } + + /// + /// + /// A numerical character string that uniquely identifies the model snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SnapshotId { get => P("snapshot_id"); set => PR("snapshot_id", value); } + /// /// /// Controls the time to wait for the request to complete. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs index 95e29dedea5..bb80a1cc120 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/UpgradeJobSnapshotResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class UpgradeJobSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompleted = System.Text.Json.JsonEncodedText.Encode("completed"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + + public override UpgradeJobSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompleted = default; + LocalJsonValue propNode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompleted.TryRead(ref reader, options, PropCompleted)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpgradeJobSnapshotResponse + { + Completed = propCompleted.Value +, + Node = propNode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpgradeJobSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompleted, value.Completed); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeJobSnapshotResponseConverter))] public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse /// When true, this means the task is complete. When false, it is still running. /// /// - [JsonInclude, JsonPropertyName("completed")] public bool Completed { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class UpgradeJobSnapshotResponse : ElasticsearchResponse /// The ID of the node that the upgrade task was started on if it is still running. In serverless this will be the "serverless". /// /// - [JsonInclude, JsonPropertyName("node")] public string Node { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs index 0d1a079f90b..b7bb500c1c3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorRequest.g.cs @@ -39,7 +39,7 @@ public sealed partial class ValidateDetectorRequestParameters : RequestParameter /// Validate an anomaly detection job. /// /// -public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfSerializable +public sealed partial class ValidateDetectorRequest : PlainRequest, ISelfTwoWaySerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningValidateDetector; @@ -49,13 +49,17 @@ public sealed partial class ValidateDetectorRequest : PlainRequest "ml.validate_detector"; - [JsonIgnore] public Elastic.Clients.Elasticsearch.MachineLearning.Detector Detector { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Detector, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Detector = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs index 3b016da7f28..e88027b66e0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateDetectorResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ValidateDetectorResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ValidateDetectorResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateDetectorResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateDetectorResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateDetectorResponseConverter))] public sealed partial class ValidateDetectorResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ValidateDetectorResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs index 09bd6cb03b7..4d7d918fd1c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MachineLearning/ValidateResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class ValidateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ValidateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ValidateResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValidateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ValidateResponseConverter))] public sealed partial class ValidateResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ValidateResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs index 192b345d954..6aad1c88a8b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetRequest.g.cs @@ -129,6 +129,14 @@ public MultiGetRequest(Elastic.Clients.Elasticsearch.IndexName? index) : base(r internal override string OperationName => "mget"; + /// + /// + /// Name of the index to retrieve documents from when ids are specified, or when a document in the docs array does not specify an index. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// Should this request force synthetic _source? diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs index 13199e2f0a7..bfecb4b1b71 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiGetResponse.g.cs @@ -22,12 +22,64 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class MultiGetResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override MultiGetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiGetResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiGetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiGetResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiGetResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiGetResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiGetResponseConverterFactory))] public sealed partial class MultiGetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection> Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs index 526b27fa61e..d12c3f60126 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchRequest.g.cs @@ -160,6 +160,14 @@ public MultiSearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base internal override string OperationName => "msearch"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases to search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs index a942a757900..5ed50b707e6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchResponse.g.cs @@ -22,14 +22,75 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class MultiSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override MultiSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propResponses = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchResponse + { + Responses = propResponses.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiSearchResponseConverterFactory))] public sealed partial class MultiSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection> Responses { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs index 2c558db006d..10c64b9d3d5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateRequest.g.cs @@ -95,6 +95,16 @@ public MultiSearchTemplateRequest(Elastic.Clients.Elasticsearch.Indices? indices internal override string OperationName => "msearch_template"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If true, network round-trips are minimized for cross-cluster search requests. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs index 061ee312555..06ed010ffd1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiSearchTemplateResponse.g.cs @@ -22,14 +22,75 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class MultiSearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override MultiSearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propResponses = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchTemplateResponse + { + Responses = propResponses.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchTemplateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchTemplateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiSearchTemplateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiSearchTemplateResponseConverterFactory))] public sealed partial class MultiSearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection> Responses { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs index 9a6c3ba7206..8ff3c2a973c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsRequest.g.cs @@ -141,6 +141,14 @@ public MultiTermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName? index) : internal override string OperationName => "mtermvectors"; + /// + /// + /// Name of the index that contains the documents. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName? Index { get => P("index"); set => PO("index", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in the statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs index 36c309f3cab..39b7710361c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/MultiTermVectorsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class MultiTermVectorsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override MultiTermVectorsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDocs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocs.TryRead(ref reader, options, PropDocs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermVectorsResponse + { + Docs = propDocs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermVectorsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocs, value.Docs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermVectorsResponseConverter))] public sealed partial class MultiTermVectorsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("docs")] public IReadOnlyCollection Docs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs index bd81ff113e0..a59ec27bd19 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveRequest.g.cs @@ -53,6 +53,23 @@ public ClearRepositoriesMeteringArchiveRequest(Elastic.Clients.Elasticsearch.Nod internal override bool SupportsBody => false; internal override string OperationName => "nodes.clear_repositories_metering_archive"; + + /// + /// + /// Specifies the maximum archive_version to be cleared from the archive. + /// + /// + [JsonIgnore] + public long MaxArchiveVersion { get => P("max_archive_version"); set => PR("max_archive_version", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// All the nodes selective options are explained here. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds NodeId { get => P("node_id"); set => PR("node_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs index 5b20e33dca1..a7a97420a3e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ClearRepositoriesMeteringArchiveResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class ClearRepositoriesMeteringArchiveResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearRepositoriesMeteringArchiveResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearRepositoriesMeteringArchiveResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearRepositoriesMeteringArchiveResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearRepositoriesMeteringArchiveResponseConverter))] public sealed partial class ClearRepositoriesMeteringArchiveResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Name of the cluster. Based on the Cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Contains repositories metering information for the nodes selected by the request. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class ClearRepositoriesMeteringArchiveResponse : Elasticse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs index 58ce8fee68b..62f4b18d076 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoRequest.g.cs @@ -55,6 +55,15 @@ public GetRepositoriesMeteringInfoRequest(Elastic.Clients.Elasticsearch.NodeIds internal override bool SupportsBody => false; internal override string OperationName => "nodes.get_repositories_metering_info"; + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// All the nodes selective options are explained here. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds NodeId { get => P("node_id"); set => PR("node_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs index 5699dc4d2fb..9c9e5180258 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/GetRepositoriesMeteringInfoResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class GetRepositoriesMeteringInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override GetRepositoriesMeteringInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRepositoriesMeteringInfoResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRepositoriesMeteringInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRepositoriesMeteringInfoResponseConverter))] public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Name of the cluster. Based on the Cluster name setting. /// /// - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Contains repositories metering information for the nodes selected by the request. /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class GetRepositoriesMeteringInfoResponse : ElasticsearchR /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs index 0f6987065fc..5e5e3ae28d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsRequest.g.cs @@ -118,6 +118,14 @@ public HotThreadsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base(r internal override string OperationName => "nodes.hot_threads"; + /// + /// + /// List of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// If true, known idle threads (e.g. waiting in a socket select, or to get diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs index f1677d7d5c5..7f8d4fe5232 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/HotThreadsResponse.g.cs @@ -22,10 +22,34 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class HotThreadsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override HotThreadsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HotThreadsResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HotThreadsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HotThreadsResponseConverter))] public sealed partial class HotThreadsResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs index 104b1f5333f..5a43617a4b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoRequest.g.cs @@ -86,6 +86,22 @@ public NodesInfoRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic.C internal override string OperationName => "nodes.info"; + /// + /// + /// Limits the information returned to the specific metrics. Supports a comma-separated list, such as http,ingest. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// If true, returns settings in flat format. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs index 5ca252fad2f..e7e91572e39 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesInfoResponse.g.cs @@ -22,15 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodesInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesInfoResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesInfoResponseConverter))] public sealed partial class NodesInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +92,5 @@ public sealed partial class NodesInfoResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs index 47a0483057f..e4383c652d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsRequest.g.cs @@ -144,6 +144,30 @@ public NodesStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic. internal override string OperationName => "nodes.stats"; + /// + /// + /// Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? IndexMetric { get => P("index_metric"); set => PO("index_metric", value); } + + /// + /// + /// Limit the information returned to the specified metrics + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// Comma-separated list of node IDs or names used to limit returned information. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs index cb917ccc1c0..e4c6f84a4da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesStatsResponse.g.cs @@ -22,15 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodesStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesStatsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesStatsResponseConverter))] public sealed partial class NodesStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string? ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +92,5 @@ public sealed partial class NodesStatsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs index 28adaf7a654..c3e8176fb67 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageRequest.g.cs @@ -72,6 +72,23 @@ public NodesUsageRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId, Elastic. internal override string OperationName => "nodes.usage"; + /// + /// + /// Limits the information returned to the specific metrics. + /// A comma-separated list of the following options: _all, rest_actions. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Metrics? Metric { get => P("metric"); set => PO("metric", value); } + + /// + /// + /// A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you're connecting to, leave empty to get information from all nodes + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs index daaa410f471..42407b5be50 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/NodesUsageResponse.g.cs @@ -22,15 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodesUsageResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override NodesUsageResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodesUsageResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodesUsageResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodesUsageResponseConverter))] public sealed partial class NodesUsageResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +92,5 @@ public sealed partial class NodesUsageResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs index 5e944e764a9..5ab99699274 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsRequest.g.cs @@ -74,6 +74,14 @@ public ReloadSecureSettingsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId internal override string OperationName => "nodes.reload_secure_settings"; + /// + /// + /// The names of particular nodes in the cluster to target. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs index 0ad2ae88554..c0afcceabeb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Nodes/ReloadSecureSettingsResponse.g.cs @@ -22,15 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class ReloadSecureSettingsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ReloadSecureSettingsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReloadSecureSettingsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReloadSecureSettingsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReloadSecureSettingsResponseConverter))] public sealed partial class ReloadSecureSettingsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } /// @@ -38,6 +92,5 @@ public sealed partial class ReloadSecureSettingsResponse : ElasticsearchResponse /// Contains statistics about the number of nodes selected by the request’s node filters. /// /// - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics? NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs index 4741472e4d9..ce14f16f30d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeRequest.g.cs @@ -110,6 +110,14 @@ public OpenPointInTimeRequest(Elastic.Clients.Elasticsearch.Indices indices) : b internal override string OperationName => "open_point_in_time"; + /// + /// + /// A comma-separated list of index names to open point in time; use _all or empty string to perform the operation on all indices + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, creating a point in time request when a shard is missing or unavailable will throw an exception. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs index 1dd4dd1105d..a31815df081 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/OpenPointInTimeResponse.g.cs @@ -22,13 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class OpenPointInTimeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + + public override OpenPointInTimeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propId = default; + LocalJsonValue propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new OpenPointInTimeResponse + { + Id = propId.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, OpenPointInTimeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(OpenPointInTimeResponseConverter))] public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -36,6 +81,5 @@ public sealed partial class OpenPointInTimeResponse : ElasticsearchResponse /// Shards used to create the PIT /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs index 91d6b99e3cf..2d0e062330c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptRequest.g.cs @@ -73,6 +73,24 @@ public PutScriptRequest(Elastic.Clients.Elasticsearch.Id id, Elastic.Clients.Ela internal override string OperationName => "put_script"; + /// + /// + /// Context in which the script or search template should run. + /// To prevent errors, the API immediately compiles the script or template in this context. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Context { get => P("context"); set => PO("context", value); } + + /// + /// + /// Identifier for the stored script or search template. + /// Must be unique within the cluster. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs index 7b863a48caa..404ed2bb8cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/PutScriptResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class PutScriptResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutScriptResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutScriptResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutScriptResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutScriptResponseConverter))] public sealed partial class PutScriptResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutScriptResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs index 5db5e648058..66cef3a2f1c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleRequest.g.cs @@ -53,6 +53,22 @@ public DeleteRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Cli internal override bool SupportsBody => false; internal override string OperationName => "query_rules.delete_rule"; + + /// + /// + /// The unique identifier of the query rule within the specified ruleset to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs index cd36153036e..bb55ccafc1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRuleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class DeleteRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRuleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRuleResponseConverter))] public sealed partial class DeleteRuleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteRuleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs index c9ff402c290..7c269bd4c4f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetRequest.g.cs @@ -52,6 +52,14 @@ public DeleteRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r internal override bool SupportsBody => false; internal override string OperationName => "query_rules.delete_ruleset"; + + /// + /// + /// The unique identifier of the query ruleset to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs index eb6ccc13ee9..b68af52b995 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/DeleteRulesetResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class DeleteRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRulesetResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRulesetResponseConverter))] public sealed partial class DeleteRulesetResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteRulesetResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs index 947016c599d..65347eac640 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleRequest.g.cs @@ -53,6 +53,22 @@ public GetRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Client internal override bool SupportsBody => false; internal override string OperationName => "query_rules.get_rule"; + + /// + /// + /// The unique identifier of the query rule within the specified ruleset to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs index 014f75a2f0f..77c230d8f7e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRuleResponse.g.cs @@ -22,21 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class GetRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropRuleId = System.Text.Json.JsonEncodedText.Encode("rule_id"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GetRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propRuleId = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propRuleId.TryRead(ref reader, options, PropRuleId)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRuleResponse + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + RuleId = propRuleId.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropRuleId, value.RuleId); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRuleResponseConverter))] public sealed partial class GetRuleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; init; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public IReadOnlyCollection Criteria { get; init; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; init; } - [JsonInclude, JsonPropertyName("rule_id")] public string RuleId { get; init; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs index 2241fbfbab8..2922ffcc0af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetRequest.g.cs @@ -53,6 +53,14 @@ public GetRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => internal override bool SupportsBody => false; internal override string OperationName => "query_rules.get_ruleset"; + + /// + /// + /// The unique identifier of the query ruleset + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs index c0fef19badb..d15afc47f55 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/GetRulesetResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class GetRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + private static readonly System.Text.Json.JsonEncodedText PropRulesetId = System.Text.Json.JsonEncodedText.Encode("ruleset_id"); + + public override GetRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propRules = default; + LocalJsonValue propRulesetId = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryRead(ref reader, options, PropRules)) + { + continue; + } + + if (propRulesetId.TryRead(ref reader, options, PropRulesetId)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetRulesetResponse + { + Rules = propRules.Value +, + RulesetId = propRulesetId.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRules, value.Rules); + writer.WriteProperty(options, PropRulesetId, value.RulesetId); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetRulesetResponseConverter))] public sealed partial class GetRulesetResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// Rules associated with the query ruleset /// /// - [JsonInclude, JsonPropertyName("rules")] public IReadOnlyCollection Rules { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class GetRulesetResponse : ElasticsearchResponse /// Query Ruleset unique identifier /// /// - [JsonInclude, JsonPropertyName("ruleset_id")] public string RulesetId { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs index dc7e677080a..0f19cb852b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/ListRulesetsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class ListRulesetsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override ListRulesetsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListRulesetsResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListRulesetsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListRulesetsResponseConverter))] public sealed partial class ListRulesetsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("results")] public IReadOnlyCollection Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs index b9287c5cda7..349deac8ca9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleRequest.g.cs @@ -34,12 +34,76 @@ public sealed partial class PutRuleRequestParameters : RequestParameters { } +internal sealed partial class PutRuleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PutRuleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRuleRequest + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRuleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query rule. /// Create or update a query rule within a query ruleset. /// /// +[JsonConverter(typeof(PutRuleRequestConverter))] public sealed partial class PutRuleRequest : PlainRequest { public PutRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Clients.Elasticsearch.Id ruleId) : base(r => r.Required("ruleset_id", rulesetId).Required("rule_id", ruleId)) @@ -54,14 +118,22 @@ public PutRuleRequest(Elastic.Clients.Elasticsearch.Id rulesetId, Elastic.Client internal override string OperationName => "query_rules.put_rule"; - [JsonInclude, JsonPropertyName("actions")] + /// + /// + /// The unique identifier of the query rule within the specified ruleset to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The unique identifier of the query ruleset containing the rule to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; set; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs index b0df637361d..8f5aae110cb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRuleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class PutRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRuleResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRuleResponseConverter))] public sealed partial class PutRuleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs index 3d91b4e2890..06fa57b7e02 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetRequest.g.cs @@ -34,11 +34,45 @@ public sealed partial class PutRulesetRequestParameters : RequestParameters { } +internal sealed partial class PutRulesetRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + + public override PutRulesetRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRules.TryRead(ref reader, options, PropRules, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRule>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRulesetRequest + { + Rules = propRules.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRulesetRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRules, value.Rules, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRule>)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a query ruleset. /// /// +[JsonConverter(typeof(PutRulesetRequestConverter))] public sealed partial class PutRulesetRequest : PlainRequest { public PutRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => r.Required("ruleset_id", rulesetId)) @@ -53,8 +87,12 @@ public PutRulesetRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => internal override string OperationName => "query_rules.put_ruleset"; - [JsonInclude, JsonPropertyName("rules")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRule))] + /// + /// + /// The unique identifier of the query ruleset to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } public ICollection Rules { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs index 23c35068711..6b2db3c9198 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/PutRulesetResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class PutRulesetResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutRulesetResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRulesetResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRulesetResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRulesetResponseConverter))] public sealed partial class PutRulesetResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs index 973d126cfdb..19f5bc2f7de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestRequest.g.cs @@ -54,6 +54,13 @@ public TestRequest(Elastic.Clients.Elasticsearch.Id rulesetId) : base(r => r.Req internal override string OperationName => "query_rules.test"; + /// + /// + /// The unique identifier of the query ruleset to be created or updated + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RulesetId { get => P("ruleset_id"); set => PR("ruleset_id", value); } [JsonInclude, JsonPropertyName("match_criteria")] public IDictionary MatchCriteria { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs index 6afa8a862e7..7883c9bed0b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/QueryRules/TestResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class TestResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMatchedRules = System.Text.Json.JsonEncodedText.Encode("matched_rules"); + private static readonly System.Text.Json.JsonEncodedText PropTotalMatchedRules = System.Text.Json.JsonEncodedText.Encode("total_matched_rules"); + + public override TestResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propMatchedRules = default; + LocalJsonValue propTotalMatchedRules = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatchedRules.TryRead(ref reader, options, PropMatchedRules)) + { + continue; + } + + if (propTotalMatchedRules.TryRead(ref reader, options, PropTotalMatchedRules)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TestResponse + { + MatchedRules = propMatchedRules.Value +, + TotalMatchedRules = propTotalMatchedRules.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TestResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMatchedRules, value.MatchedRules); + writer.WriteProperty(options, PropTotalMatchedRules, value.TotalMatchedRules); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TestResponseConverter))] public sealed partial class TestResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("matched_rules")] public IReadOnlyCollection MatchedRules { get; init; } - [JsonInclude, JsonPropertyName("total_matched_rules")] public int TotalMatchedRules { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs index c42ede2ec90..f781d5970ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalRequest.g.cs @@ -87,6 +87,15 @@ public RankEvalRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r internal override string OperationName => "rank_eval"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases used to limit the request. Wildcard (*) expressions are supported. + /// To target all data streams and indices in a cluster, omit this parameter or use _all or *. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs index c8fffdd414c..4c94f8c05ee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RankEvalResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class RankEvalResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDetails = System.Text.Json.JsonEncodedText.Encode("details"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropMetricScore = System.Text.Json.JsonEncodedText.Encode("metric_score"); + + public override RankEvalResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propDetails = default; + LocalJsonValue> propFailures = default; + LocalJsonValue propMetricScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetails.TryRead(ref reader, options, PropDetails)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propMetricScore.TryRead(ref reader, options, PropMetricScore)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RankEvalResponse + { + Details = propDetails.Value +, + Failures = propFailures.Value +, + MetricScore = propMetricScore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RankEvalResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetails, value.Details); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropMetricScore, value.MetricScore); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalResponseConverter))] public sealed partial class RankEvalResponse : ElasticsearchResponse { /// @@ -33,9 +89,7 @@ public sealed partial class RankEvalResponse : ElasticsearchResponse /// The details section contains one entry for every query in the original requests section, keyed by the search request id /// /// - [JsonInclude, JsonPropertyName("details")] public IReadOnlyDictionary Details { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyDictionary Failures { get; init; } /// @@ -43,6 +97,5 @@ public sealed partial class RankEvalResponse : ElasticsearchResponse /// The overall evaluation quality calculated by the defined metric /// /// - [JsonInclude, JsonPropertyName("metric_score")] public double MetricScore { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs index 615f5821c06..8c401f4ccd9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexResponse.g.cs @@ -22,42 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ReindexResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropSliceId = System.Text.Json.JsonEncodedText.Encode("slice_id"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override ReindexResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBatches = default; + LocalJsonValue propCreated = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propSliceId = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propUpdated = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propSliceId.TryRead(ref reader, options, PropSliceId)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReindexResponse + { + Batches = propBatches.Value +, + Created = propCreated.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + SliceId = propSliceId.Value +, + Task = propTask.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + Updated = propUpdated.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReindexResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropSliceId, value.SliceId); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReindexResponseConverter))] public sealed partial class ReindexResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("created")] public long? Created { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("slice_id")] public int? SliceId { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("updated")] public long? Updated { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs index 88bf92f8d80..1ffd8c479ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleRequest.g.cs @@ -62,6 +62,14 @@ public ReindexRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : base( internal override string OperationName => "reindex_rethrottle"; + /// + /// + /// Identifier for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs index eb0a0d689a5..cd35a220dd6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ReindexRethrottleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ReindexRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override ReindexRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReindexRethrottleResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReindexRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ReindexRethrottleResponseConverter))] public sealed partial class ReindexRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs index 26361bc0ec5..de6996e74cb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateRequest.g.cs @@ -60,6 +60,14 @@ public RenderSearchTemplateRequest(Elastic.Clients.Elasticsearch.Id? id) : base( internal override string OperationName => "render_search_template"; + /// + /// + /// ID of the search template to render. + /// If no source is specified, this or the id request body parameter is required. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } [JsonInclude, JsonPropertyName("file")] public string? File { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs index 9fba7ed830c..2fcd10dede0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/RenderSearchTemplateResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class RenderSearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropTemplateOutput = System.Text.Json.JsonEncodedText.Encode("template_output"); + + public override RenderSearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propTemplateOutput = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propTemplateOutput.TryRead(ref reader, options, PropTemplateOutput)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RenderSearchTemplateResponse + { + TemplateOutput = propTemplateOutput.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RenderSearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropTemplateOutput, value.TemplateOutput); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RenderSearchTemplateResponseConverter))] public sealed partial class RenderSearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("template_output")] public IReadOnlyDictionary TemplateOutput { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs index aa025a5e23b..a807c9030c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobRequest.g.cs @@ -76,6 +76,14 @@ public DeleteJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requi internal override bool SupportsBody => false; internal override string OperationName => "rollup.delete_job"; + + /// + /// + /// Identifier for the job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs index ecf093b6b08..6f40ea46e7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/DeleteJobResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class DeleteJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + + public override DeleteJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue?> propTaskFailures = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propTaskFailures.TryRead(ref reader, options, PropTaskFailures)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteJobResponse + { + Acknowledged = propAcknowledged.Value +, + TaskFailures = propTaskFailures.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteJobResponseConverter))] public sealed partial class DeleteJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs index fdf23d38c7e..af8830eedee 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsRequest.g.cs @@ -62,6 +62,15 @@ public GetJobsRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Option internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_jobs"; + + /// + /// + /// Identifier for the rollup job. + /// If it is _all or omitted, the API returns all rollup jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs index 94884fe565a..b99ec1c7d9b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetJobsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class GetJobsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropJobs = System.Text.Json.JsonEncodedText.Encode("jobs"); + + public override GetJobsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propJobs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propJobs.TryRead(ref reader, options, PropJobs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetJobsResponse + { + Jobs = propJobs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetJobsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropJobs, value.Jobs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetJobsResponseConverter))] public sealed partial class GetJobsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("jobs")] public IReadOnlyCollection Jobs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs index 7da32db36d5..5a6f93201d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupCapsRequest.g.cs @@ -74,6 +74,15 @@ public GetRollupCapsRequest(Elastic.Clients.Elasticsearch.Id? id) : base(r => r. internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_rollup_caps"; + + /// + /// + /// Index, indices or index-pattern to return rollup capabilities for. + /// _all may be used to fetch rollup capabilities from all jobs. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs index f9e818a1e27..29931af8e87 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/GetRollupIndexCapsRequest.g.cs @@ -66,6 +66,15 @@ public GetRollupIndexCapsRequest(Elastic.Clients.Elasticsearch.Ids index) : base internal override bool SupportsBody => false; internal override string OperationName => "rollup.get_rollup_index_caps"; + + /// + /// + /// Data stream or index to check for rollup capabilities. + /// Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Index { get => P("index"); set => PR("index", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs index 32ac6dc9b6b..cd305ff441c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobRequest.g.cs @@ -65,6 +65,18 @@ public PutJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required internal override string OperationName => "rollup.put_job"; + /// + /// + /// Identifier for the rollup job. This can be any alphanumeric string and uniquely identifies the + /// data that is associated with the rollup job. The ID is persistent; it is stored with the rolled + /// up data. If you create a job, let it run for a while, then delete the job, the data that the job + /// rolled up is still be associated with this job ID. You cannot create a new job with the same ID + /// since that could lead to problems with mismatched job configurations. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// A cron string which defines the intervals when the rollup job should be executed. When the interval diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs index 4182c776136..ffa90306b03 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/PutJobResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class PutJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutJobResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutJobResponseConverter))] public sealed partial class PutJobResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutJobResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs index 983b3bbff95..30249909328 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchRequest.g.cs @@ -47,62 +47,56 @@ public sealed partial class RollupSearchRequestParameters : RequestParameters public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } } -internal sealed partial class RollupSearchRequestConverter : JsonConverter +internal sealed partial class RollupSearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override RollupSearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override RollupSearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new RollupSearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, RollupSearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Size.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RollupSearchRequest { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + Aggregations = propAggregations.Value + , + Query = propQuery.Value + , + Size = propSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, RollupSearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSize, value.Size); writer.WriteEndObject(); } } @@ -133,12 +127,18 @@ public RollupSearchRequest() internal override string OperationName => "rollup.rollup_search"; + /// + /// + /// Enables searching rolled-up data using the standard Query DSL. + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// Indicates whether hits.total should be rendered as an integer or an object in the rest search response /// /// - [JsonIgnore] public bool? RestTotalHitsAsInt { get => Q("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); } /// @@ -146,7 +146,6 @@ public RollupSearchRequest() /// Specify whether aggregation and suggester names should be prefixed by their respective types in the response /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -154,7 +153,6 @@ public RollupSearchRequest() /// Specifies aggregations. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -162,7 +160,6 @@ public RollupSearchRequest() /// Specifies a DSL query. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -170,7 +167,6 @@ public RollupSearchRequest() /// Must be zero if set, as rollups work on pre-aggregated data. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs index 16d3e49bdad..1ec3eddf262 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/RollupSearchResponse.g.cs @@ -22,22 +22,119 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class RollupSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override RollupSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue> propHits = default; + LocalJsonValue propShards = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RollupSearchResponse + { + Aggregations = propAggregations.Value +, + Hits = propHits.Value +, + Shards = propShards.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RollupSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class RollupSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(RollupSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(RollupSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(RollupSearchResponseConverterFactory))] public sealed partial class RollupSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata Hits { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs index d5cfcc92559..ef9a926c8b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobRequest.g.cs @@ -54,6 +54,14 @@ public StartJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir internal override bool SupportsBody => false; internal override string OperationName => "rollup.start_job"; + + /// + /// + /// Identifier for the rollup job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs index 1d6d05f4ff7..27d4aa17e12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StartJobResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class StartJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override StartJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStarted = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStarted.TryRead(ref reader, options, PropStarted)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartJobResponse + { + Started = propStarted.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStarted, value.Started); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartJobResponseConverter))] public sealed partial class StartJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("started")] public bool Started { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs index f4129512b7e..9eabbbaaf36 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobRequest.g.cs @@ -70,6 +70,14 @@ public StopJobRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Require internal override string OperationName => "rollup.stop_job"; + /// + /// + /// Identifier for the rollup job. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// If wait_for_completion is true, the API blocks for (at maximum) the specified duration while waiting for the job to stop. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs index 9f696d586bc..db836ac8bfd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Rollup/StopJobResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class StopJobResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + + public override StopJobResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStopped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopped.TryRead(ref reader, options, PropStopped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopJobResponse + { + Stopped = propStopped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopJobResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopped, value.Stopped); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopJobResponseConverter))] public sealed partial class StopJobResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stopped")] public bool Stopped { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs index d2c5569f64c..5fae7684fd1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScriptsPainlessExecuteResponse.g.cs @@ -22,13 +22,64 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ScriptsPainlessExecuteResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override ScriptsPainlessExecuteResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScriptsPainlessExecuteResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScriptsPainlessExecuteResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result, null, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class ScriptsPainlessExecuteResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ScriptsPainlessExecuteResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(ScriptsPainlessExecuteResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(ScriptsPainlessExecuteResponseConverterFactory))] public sealed partial class ScriptsPainlessExecuteResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] - [SourceConverter] public TResult Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs index 056d1985d46..47e0804014a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/ScrollResponse.g.cs @@ -22,38 +22,207 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ScrollResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override ScrollResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScrollResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScrollResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class ScrollResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(ScrollResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(ScrollResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(ScrollResponseConverterFactory))] public sealed partial class ScrollResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs index 0821769f39a..99f941dc913 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsRequest.g.cs @@ -53,6 +53,14 @@ public DeleteBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) internal override bool SupportsBody => false; internal override string OperationName => "search_application.delete_behavioral_analytics"; + + /// + /// + /// The name of the analytics collection to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs index 815097e6f70..6223aa1ea24 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteBehavioralAnalyticsResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class DeleteBehavioralAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteBehavioralAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteBehavioralAnalyticsResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteBehavioralAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteBehavioralAnalyticsResponseConverter))] public sealed partial class DeleteBehavioralAnalyticsResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteBehavioralAnalyticsResponse : ElasticsearchRes /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs index 3683272e428..b51b276aea1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationRequest.g.cs @@ -53,6 +53,14 @@ public DeleteSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "search_application.delete"; + + /// + /// + /// The name of the search application to delete + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs index 25ab747e186..36c4c0643e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/DeleteSearchApplicationResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class DeleteSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSearchApplicationResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSearchApplicationResponseConverter))] public sealed partial class DeleteSearchApplicationResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteSearchApplicationResponse : ElasticsearchRespo /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs index 3032d656690..92e2408dfa1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetBehavioralAnalyticsRequest.g.cs @@ -56,6 +56,14 @@ public GetBehavioralAnalyticsRequest(IReadOnlyCollection false; internal override string OperationName => "search_application.get_behavioral_analytics"; + + /// + /// + /// A list of analytics collections to limit the returned information + /// + /// + [JsonIgnore] + public ICollection? Name { get => P?>("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs index e7342f567b8..203f3a89869 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationRequest.g.cs @@ -52,6 +52,14 @@ public GetSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override bool SupportsBody => false; internal override string OperationName => "search_application.get"; + + /// + /// + /// The name of the search application + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs index e8dfe37f8c5..408e1396199 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/GetSearchApplicationResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class GetSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyticsCollectionName = System.Text.Json.JsonEncodedText.Encode("analytics_collection_name"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + private static readonly System.Text.Json.JsonEncodedText PropUpdatedAtMillis = System.Text.Json.JsonEncodedText.Encode("updated_at_millis"); + + public override GetSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyticsCollectionName = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propName = default; + LocalJsonValue propTemplate = default; + LocalJsonValue propUpdatedAtMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyticsCollectionName.TryRead(ref reader, options, PropAnalyticsCollectionName)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + if (propUpdatedAtMillis.TryRead(ref reader, options, PropUpdatedAtMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSearchApplicationResponse + { + AnalyticsCollectionName = propAnalyticsCollectionName.Value +, + Indices = propIndices.Value +, + Name = propName.Value +, + Template = propTemplate.Value +, + UpdatedAtMillis = propUpdatedAtMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyticsCollectionName, value.AnalyticsCollectionName); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteProperty(options, PropUpdatedAtMillis, value.UpdatedAtMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSearchApplicationResponseConverter))] public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Analytics collection associated to the Search Application. /// /// - [JsonInclude, JsonPropertyName("analytics_collection_name")] public string? AnalyticsCollectionName { get; init; } /// @@ -41,7 +116,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Indices that are part of the Search Application. /// /// - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } /// @@ -49,7 +123,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Search Application name /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } /// @@ -57,7 +130,6 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Search template to use on search operations. /// /// - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationTemplate? Template { get; init; } /// @@ -65,6 +137,5 @@ public sealed partial class GetSearchApplicationResponse : ElasticsearchResponse /// Last time the Search Application was updated. /// /// - [JsonInclude, JsonPropertyName("updated_at_millis")] public long UpdatedAtMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs index c1945b4a695..2cf111b69bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/ListResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class ListResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override ListResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListResponseConverter))] public sealed partial class ListResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("results")] public IReadOnlyCollection Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs index 9b13e1d8a6a..6156b3f932f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsRequest.g.cs @@ -52,6 +52,14 @@ public PutBehavioralAnalyticsRequest(Elastic.Clients.Elasticsearch.Name name) : internal override bool SupportsBody => false; internal override string OperationName => "search_application.put_behavioral_analytics"; + + /// + /// + /// The name of the analytics collection to be created or updated. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs index 9ef176986b8..b827c177f8e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutBehavioralAnalyticsResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class PutBehavioralAnalyticsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override PutBehavioralAnalyticsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutBehavioralAnalyticsResponse + { + Acknowledged = propAcknowledged.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutBehavioralAnalyticsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutBehavioralAnalyticsResponseConverter))] public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchRespon /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class PutBehavioralAnalyticsResponse : ElasticsearchRespon /// The name of the analytics collection created or updated /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs index 09736ffa1d9..045700ea37b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationRequest.g.cs @@ -45,7 +45,7 @@ public sealed partial class PutSearchApplicationRequestParameters : RequestParam /// Create or update a search application. /// /// -public sealed partial class PutSearchApplicationRequest : PlainRequest, ISelfSerializable +public sealed partial class PutSearchApplicationRequest : PlainRequest, ISelfTwoWaySerializable { public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name)) { @@ -59,6 +59,14 @@ public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba internal override string OperationName => "search_application.put"; + /// + /// + /// The name of the search application to be created or updated. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true, this request cannot replace or update existing Search Applications. @@ -66,13 +74,17 @@ public PutSearchApplicationRequest(Elastic.Clients.Elasticsearch.Name name) : ba /// [JsonIgnore] public bool? Create { get => Q("create"); set => Q("create", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchApplication.SearchApplicationParameters SearchApplication { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, SearchApplication, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + SearchApplication = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs index 142ce716eb0..dec97608943 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/PutSearchApplicationResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class PutSearchApplicationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSearchApplicationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSearchApplicationResponse + { + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSearchApplicationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSearchApplicationResponseConverter))] public sealed partial class PutSearchApplicationResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs index 173d6962b99..d819286d75a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchRequest.g.cs @@ -61,6 +61,14 @@ public SearchApplicationSearchRequest(Elastic.Clients.Elasticsearch.Name name) : internal override string OperationName => "search_application.search"; + /// + /// + /// The name of the search application to be searched. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// Determines whether aggregation names are prefixed by their respective types in the response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs index 65205873d88..7f29b4a4839 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchApplication/SearchApplicationSearchResponse.g.cs @@ -22,38 +22,207 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchApplication; +internal sealed partial class SearchApplicationSearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override SearchApplicationSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchApplicationSearchResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchApplicationSearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchApplicationSearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchApplicationSearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SearchApplicationSearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SearchApplicationSearchResponseConverterFactory))] public sealed partial class SearchApplicationSearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs index 2863e257262..e3256630ce9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchMvtRequest.g.cs @@ -34,6 +34,169 @@ public sealed partial class SearchMvtRequestParameters : RequestParameters { } +internal sealed partial class SearchMvtRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggs = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropBuffer = System.Text.Json.JsonEncodedText.Encode("buffer"); + private static readonly System.Text.Json.JsonEncodedText PropExactBounds = System.Text.Json.JsonEncodedText.Encode("exact_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropExtent = System.Text.Json.JsonEncodedText.Encode("extent"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropGridAgg = System.Text.Json.JsonEncodedText.Encode("grid_agg"); + private static readonly System.Text.Json.JsonEncodedText PropGridPrecision = System.Text.Json.JsonEncodedText.Encode("grid_precision"); + private static readonly System.Text.Json.JsonEncodedText PropGridType = System.Text.Json.JsonEncodedText.Encode("grid_type"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropWithLabels = System.Text.Json.JsonEncodedText.Encode("with_labels"); + + public override SearchMvtRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggs = default; + LocalJsonValue propBuffer = default; + LocalJsonValue propExactBounds = default; + LocalJsonValue propExtent = default; + LocalJsonValue propFields = default; + LocalJsonValue propGridAgg = default; + LocalJsonValue propGridPrecision = default; + LocalJsonValue propGridType = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propWithLabels = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggs.TryRead(ref reader, options, PropAggs)) + { + continue; + } + + if (propBuffer.TryRead(ref reader, options, PropBuffer)) + { + continue; + } + + if (propExactBounds.TryRead(ref reader, options, PropExactBounds)) + { + continue; + } + + if (propExtent.TryRead(ref reader, options, PropExtent)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propGridAgg.TryRead(ref reader, options, PropGridAgg)) + { + continue; + } + + if (propGridPrecision.TryRead(ref reader, options, PropGridPrecision)) + { + continue; + } + + if (propGridType.TryRead(ref reader, options, PropGridType)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } + + if (propWithLabels.TryRead(ref reader, options, PropWithLabels)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchMvtRequest + { + Aggs = propAggs.Value +, + Buffer = propBuffer.Value +, + ExactBounds = propExactBounds.Value +, + Extent = propExtent.Value +, + Fields = propFields.Value +, + GridAgg = propGridAgg.Value +, + GridPrecision = propGridPrecision.Value +, + GridType = propGridType.Value +, + Query = propQuery.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + TrackTotalHits = propTrackTotalHits.Value +, + WithLabels = propWithLabels.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchMvtRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggs, value.Aggs); + writer.WriteProperty(options, PropBuffer, value.Buffer); + writer.WriteProperty(options, PropExactBounds, value.ExactBounds); + writer.WriteProperty(options, PropExtent, value.Extent); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropGridAgg, value.GridAgg); + writer.WriteProperty(options, PropGridPrecision, value.GridPrecision); + writer.WriteProperty(options, PropGridType, value.GridType); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropWithLabels, value.WithLabels); + writer.WriteEndObject(); + } +} + /// /// /// Search a vector tile. @@ -42,6 +205,7 @@ public sealed partial class SearchMvtRequestParameters : RequestParameters /// Search a vector tile for geospatial values. /// /// +[JsonConverter(typeof(SearchMvtRequestConverter))] public sealed partial class SearchMvtRequest : PlainRequest { public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.Clients.Elasticsearch.Field field, int zoom, int x, int y) : base(r => r.Required("index", indices).Required("field", field).Required("zoom", zoom).Required("x", x).Required("y", y)) @@ -56,6 +220,41 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C internal override string OperationName => "search_mvt"; + /// + /// + /// Field containing geospatial data to return + /// + /// + public Elastic.Clients.Elasticsearch.Field Field { get => P("field"); set => PR("field", value); } + + /// + /// + /// Comma-separated list of data streams, indices, or aliases to search + /// + /// + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + + /// + /// + /// X coordinate for the vector tile to search + /// + /// + public int x { get => P("x"); set => PR("x", value); } + + /// + /// + /// Y coordinate for the vector tile to search + /// + /// + public int y { get => P("y"); set => PR("y", value); } + + /// + /// + /// Zoom level for the vector tile to search + /// + /// + public int Zoom { get => P("zoom"); set => PR("zoom", value); } + /// /// /// Sub-aggregations for the geotile_grid. @@ -91,7 +290,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// /// /// - [JsonInclude, JsonPropertyName("aggs")] public IDictionary? Aggs { get; set; } /// @@ -100,7 +298,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// to avoid outline artifacts from geometries that extend past the extent of the tile. /// /// - [JsonInclude, JsonPropertyName("buffer")] public int? Buffer { get; set; } /// @@ -112,7 +309,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// bounding box may be larger than the vector tile. /// /// - [JsonInclude, JsonPropertyName("exact_bounds")] public bool? ExactBounds { get; set; } /// @@ -120,7 +316,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// Size, in pixels, of a side of the tile. Vector tiles are square with equal sides. /// /// - [JsonInclude, JsonPropertyName("extent")] public int? Extent { get; set; } /// @@ -130,8 +325,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// values may return inconsistent results. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -139,7 +332,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// Aggregation used to create a grid for the field. /// /// - [JsonInclude, JsonPropertyName("grid_agg")] public Elastic.Clients.Elasticsearch.Core.SearchMvt.GridAggregationType? GridAgg { get; set; } /// @@ -149,7 +341,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// don’t include the aggs layer. /// /// - [JsonInclude, JsonPropertyName("grid_precision")] public int? GridPrecision { get; set; } /// @@ -160,7 +351,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// of the cell. /// /// - [JsonInclude, JsonPropertyName("grid_type")] public Elastic.Clients.Elasticsearch.Core.SearchMvt.GridType? GridType { get; set; } /// @@ -168,7 +358,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// Query DSL used to filter documents for the search. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -177,7 +366,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -186,7 +374,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// If 0, results don’t include the hits layer. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -196,8 +383,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// from longest to shortest. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -207,7 +392,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -216,7 +400,6 @@ public SearchMvtRequest(Elastic.Clients.Elasticsearch.Indices indices, Elastic.C /// suggested label positions for the original features. /// /// - [JsonInclude, JsonPropertyName("with_labels")] public bool? WithLabels { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs index 7c11901438f..0833166ee17 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs @@ -273,434 +273,366 @@ public sealed partial class SearchRequestParameters : RequestParameters public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } } -internal sealed partial class SearchRequestConverter : JsonConverter +internal sealed partial class SearchRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override SearchRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SearchRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRank = System.Text.Json.JsonEncodedText.Encode("rank"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRetriever = System.Text.Json.JsonEncodedText.Encode("retriever"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SearchRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue propRank = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue propRetriever = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rank") - { - variant.Rank = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "retriever") - { - variant.Retriever = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slice") - { - variant.Slice = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rank is not null) - { - writer.WritePropertyName("rank"); - JsonSerializer.Serialize(writer, value.Rank, options); - } + if (propRank.TryRead(ref reader, options, PropRank)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>))) + { + continue; + } - if (value.Retriever is not null) - { - writer.WritePropertyName("retriever"); - JsonSerializer.Serialize(writer, value.Retriever, options); - } + if (propRetriever.TryRead(ref reader, options, PropRetriever)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Slice is not null) - { - writer.WritePropertyName("slice"); - JsonSerializer.Serialize(writer, value.Slice, options); - } + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchRequest + { + Aggregations = propAggregations.Value + , + Collapse = propCollapse.Value + , + DocvalueFields = propDocvalueFields.Value + , + Explain = propExplain.Value + , + Ext = propExt.Value + , + Fields = propFields.Value + , + From = propFrom.Value + , + Highlight = propHighlight.Value + , + IndicesBoost = propIndicesBoost.Value + , + Knn = propKnn.Value + , + MinScore = propMinScore.Value + , + Pit = propPit.Value + , + PostFilter = propPostFilter.Value + , + Profile = propProfile.Value + , + Query = propQuery.Value + , + Rank = propRank.Value + , + Rescore = propRescore.Value + , + Retriever = propRetriever.Value + , + RuntimeMappings = propRuntimeMappings.Value + , + ScriptFields = propScriptFields.Value + , + SearchAfter = propSearchAfter.Value + , + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value + , + Size = propSize.Value + , + Slice = propSlice.Value + , + Sort = propSort.Value + , + Source = propSource.Value + , + Stats = propStats.Value + , + StoredFields = propStoredFields.Value + , + Suggest = propSuggest.Value + , + TerminateAfter = propTerminateAfter.Value + , + Timeout = propTimeout.Value + , + TrackScores = propTrackScores.Value + , + TrackTotalHits = propTrackTotalHits.Value + , + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRank, value.Rank); + writer.WriteProperty(options, PropRescore, value.Rescore, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRetriever, value.Retriever); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } @@ -734,6 +666,15 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => internal override string OperationName => "search"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams and indices, omit this parameter or use * or _all. + /// + /// + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. @@ -741,7 +682,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonIgnore] public bool? AllowNoIndices { get => Q("allow_no_indices"); set => Q("allow_no_indices", value); } /// @@ -749,7 +689,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, returns partial results if there are shard request timeouts or shard failures. If false, returns an error with no partial results. /// /// - [JsonIgnore] public bool? AllowPartialSearchResults { get => Q("allow_partial_search_results"); set => Q("allow_partial_search_results", value); } /// @@ -758,7 +697,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public string? Analyzer { get => Q("analyzer"); set => Q("analyzer", value); } /// @@ -767,7 +705,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public bool? AnalyzeWildcard { get => Q("analyze_wildcard"); set => Q("analyze_wildcard", value); } /// @@ -776,7 +713,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. /// /// - [JsonIgnore] public long? BatchedReduceSize { get => Q("batched_reduce_size"); set => Q("batched_reduce_size", value); } /// @@ -784,7 +720,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. /// /// - [JsonIgnore] public bool? CcsMinimizeRoundtrips { get => Q("ccs_minimize_roundtrips"); set => Q("ccs_minimize_roundtrips", value); } /// @@ -793,7 +728,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get => Q("default_operator"); set => Q("default_operator", value); } /// @@ -802,7 +736,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public string? Df { get => Q("df"); set => Q("df", value); } /// @@ -812,7 +745,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Supports comma-separated values, such as open,hidden. /// /// - [JsonIgnore] public ICollection? ExpandWildcards { get => Q?>("expand_wildcards"); set => Q("expand_wildcards", value); } /// @@ -822,7 +754,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Fetches with this enabled will be slower the enabling synthetic source natively in the index. /// /// - [JsonIgnore] public bool? ForceSyntheticSource { get => Q("force_synthetic_source"); set => Q("force_synthetic_source", value); } /// @@ -830,7 +761,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, concrete, expanded or aliased indices will be ignored when frozen. /// /// - [JsonIgnore] public bool? IgnoreThrottled { get => Q("ignore_throttled"); set => Q("ignore_throttled", value); } /// @@ -838,7 +768,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If false, the request returns an error if it targets a missing or closed index. /// /// - [JsonIgnore] public bool? IgnoreUnavailable { get => Q("ignore_unavailable"); set => Q("ignore_unavailable", value); } /// @@ -847,7 +776,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the q query string parameter is specified. /// /// - [JsonIgnore] public bool? Lenient { get => Q("lenient"); set => Q("lenient", value); } /// @@ -856,7 +784,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests. /// /// - [JsonIgnore] public long? MaxConcurrentShardRequests { get => Q("max_concurrent_shard_requests"); set => Q("max_concurrent_shard_requests", value); } /// @@ -871,7 +798,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// <custom-string> (any string that does not start with _) to route searches with the same <custom-string> to the same shards in the same order. /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -884,7 +810,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// the primary sort of the query targets an indexed field. /// /// - [JsonIgnore] public long? PreFilterShardSize { get => Q("pre_filter_shard_size"); set => Q("pre_filter_shard_size", value); } /// @@ -893,7 +818,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Query parameter searches do not support the full Elasticsearch Query DSL but are handy for testing. /// /// - [JsonIgnore] public string? QueryLuceneSyntax { get => Q("q"); set => Q("q", value); } /// @@ -902,7 +826,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defaults to index level settings. /// /// - [JsonIgnore] public bool? RequestCache { get => Q("request_cache"); set => Q("request_cache", value); } /// @@ -910,7 +833,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Indicates whether hits.total should be rendered as an integer or an object in the rest search response. /// /// - [JsonIgnore] public bool? RestTotalHitsAsInt { get => Q("rest_total_hits_as_int"); set => Q("rest_total_hits_as_int", value); } /// @@ -918,7 +840,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -928,7 +849,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// You can change this limit using the search.max_keep_alive cluster-level setting. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Scroll { get => Q("scroll"); set => Q("scroll", value); } /// @@ -936,7 +856,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// How distributed term frequencies are calculated for relevance scoring. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get => Q("search_type"); set => Q("search_type", value); } /// @@ -946,7 +865,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -957,7 +875,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If the _source parameter is false, this parameter is ignored. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -965,7 +882,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Specifies which field to use for suggestions. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Field? SuggestField { get => Q("suggest_field"); set => Q("suggest_field", value); } /// @@ -974,7 +890,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.SuggestMode? SuggestMode { get => Q("suggest_mode"); set => Q("suggest_mode", value); } /// @@ -983,7 +898,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public long? SuggestSize { get => Q("suggest_size"); set => Q("suggest_size", value); } /// @@ -992,7 +906,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// This parameter can only be used when the suggest_field and suggest_text query string parameters are specified. /// /// - [JsonIgnore] public string? SuggestText { get => Q("suggest_text"); set => Q("suggest_text", value); } /// @@ -1000,7 +913,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, aggregation and suggester names are be prefixed by their respective types in the response. /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -1008,7 +920,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the aggregations that are run as part of the search request. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -1016,7 +927,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Collapses search results the values of the specified field. /// /// - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -1025,7 +935,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// The request returns doc values for field names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -1033,7 +942,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -1041,7 +949,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Configuration of search extensions defined by Elasticsearch plugins. /// /// - [JsonInclude, JsonPropertyName("ext")] public IDictionary? Ext { get; set; } /// @@ -1050,7 +957,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// The request returns values for field names matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -1061,7 +967,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -1069,7 +974,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in your search results. /// /// - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } /// @@ -1077,7 +981,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Boosts the _score of documents from specified indices. /// /// - [JsonInclude, JsonPropertyName("indices_boost")] public ICollection>? IndicesBoost { get; set; } /// @@ -1085,8 +988,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the approximate kNN search to run. /// /// - [JsonInclude, JsonPropertyName("knn")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.KnnSearch))] public ICollection? Knn { get; set; } /// @@ -1095,7 +996,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Documents with a lower _score are not included in the search results. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -1104,7 +1004,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If you provide a PIT, you cannot specify an <index> in the request path. /// /// - [JsonInclude, JsonPropertyName("pit")] public Elastic.Clients.Elasticsearch.Core.Search.PointInTimeReference? Pit { get; set; } /// @@ -1114,7 +1013,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// A post filter has no impact on the aggregation results. /// /// - [JsonInclude, JsonPropertyName("post_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? PostFilter { get; set; } /// @@ -1123,7 +1021,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// NOTE: This is a debugging tool and adds significant overhead to search execution. /// /// - [JsonInclude, JsonPropertyName("profile")] public bool? Profile { get; set; } /// @@ -1131,7 +1028,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the search definition using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -1139,7 +1035,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines the Reciprocal Rank Fusion (RRF) to use. /// /// - [JsonInclude, JsonPropertyName("rank")] public Elastic.Clients.Elasticsearch.Rank? Rank { get; set; } /// @@ -1147,8 +1042,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Can be used to improve precision by reordering just the top (for example 100 - 500) documents returned by the query and post_filter phases. /// /// - [JsonInclude, JsonPropertyName("rescore")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.Rescore))] public ICollection? Rescore { get; set; } /// @@ -1156,7 +1049,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// A retriever is a specification to describe top documents returned from a search. A retriever replaces other elements of the search API that also return top documents such as query and knn. /// /// - [JsonInclude, JsonPropertyName("retriever")] public Elastic.Clients.Elasticsearch.Retriever? Retriever { get; set; } /// @@ -1165,7 +1057,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// These fields take precedence over mapped fields with the same name. /// /// - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -1173,7 +1064,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Retrieve a script evaluation (based on different fields) for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -1181,7 +1071,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Used to retrieve the next page of hits using a set of sort values from the previous page. /// /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -1189,7 +1078,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, returns sequence number and primary term of the last modification of each hit. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -1199,7 +1087,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -1207,7 +1094,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Can be used to split a scrolled search into multiple slices that can be consumed independently. /// /// - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.SlicedScroll? Slice { get; set; } /// @@ -1215,8 +1101,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// A comma-separated list of <field>:<direction> pairs. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -1225,7 +1109,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// These fields are returned in the hits._source property of the search response. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -1235,7 +1118,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// You can retrieve these stats using the indices stats API. /// /// - [JsonInclude, JsonPropertyName("stats")] public ICollection? Stats { get; set; } /// @@ -1246,8 +1128,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// You can pass _source: true to return both source fields and stored fields in the search response. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } /// @@ -1255,7 +1135,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defines a suggester that provides similar looking terms based on a provided text. /// /// - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.Suggester? Suggest { get; set; } /// @@ -1270,7 +1149,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If set to 0 (default), the query does not terminate early. /// /// - [JsonInclude, JsonPropertyName("terminate_after")] public long? TerminateAfter { get; set; } /// @@ -1280,7 +1158,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// Defaults to no timeout. /// /// - [JsonInclude, JsonPropertyName("timeout")] public string? Timeout { get; set; } /// @@ -1288,7 +1165,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, calculate and return document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -1298,7 +1174,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If false, the response does not include the total number of hits matching the query. /// /// - [JsonInclude, JsonPropertyName("track_total_hits")] public Elastic.Clients.Elasticsearch.Core.Search.TrackHits? TrackTotalHits { get; set; } /// @@ -1306,7 +1181,6 @@ public SearchRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base(r => /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs index 2d2eba622c5..bbc97c29f5c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchResponse.g.cs @@ -22,38 +22,207 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class SearchResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override SearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SearchResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SearchResponseConverterFactory))] public sealed partial class SearchResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs index 9e3baa8588e..0efc5c82e7c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsRequest.g.cs @@ -109,6 +109,14 @@ public SearchShardsRequest(Elastic.Clients.Elasticsearch.Indices? indices) : bas internal override string OperationName => "search_shards"; + /// + /// + /// Returns the indices and shards that a search request would be executed against. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs index 2914a6a88f7..d1ad06c4b1c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchShardsResponse.g.cs @@ -22,17 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class SearchShardsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("shards"); + + public override SearchShardsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + LocalJsonValue> propNodes = default; + LocalJsonValue>> propShards = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchShardsResponse + { + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + Shards = propShards.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchShardsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchShardsResponseConverter))] public sealed partial class SearchShardsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("indices")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Core.SearchShards.ShardStoreIndex))] public IReadOnlyDictionary Indices { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("shards")] public IReadOnlyCollection> Shards { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs index 79f27aa0434..69ee8fad022 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateRequest.g.cs @@ -140,6 +140,15 @@ public SearchTemplateRequest(Elastic.Clients.Elasticsearch.Indices? indices) : b internal override string OperationName => "search_template"; + /// + /// + /// Comma-separated list of data streams, indices, + /// and aliases to search. Supports wildcards (*). + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs index 051c600694e..105face06c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchTemplateResponse.g.cs @@ -22,38 +22,207 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class SearchTemplateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override SearchTemplateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHits = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchTemplateResponse + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + Hits = propHits.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchTemplateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class SearchTemplateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SearchTemplateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SearchTemplateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(SearchTemplateResponseConverterFactory))] public sealed partial class SearchTemplateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata Hits { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs index e7abfbbbe1c..6d221dadaed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsRequest.g.cs @@ -59,6 +59,13 @@ public CacheStatsRequest(Elastic.Clients.Elasticsearch.NodeIds? nodeId) : base(r internal override string OperationName => "searchable_snapshots.cache_stats"; + /// + /// + /// A comma-separated list of node IDs or names to limit the returned information; use _local to return information from the node you're connecting to, leave empty to get information from all nodes + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.NodeIds? NodeId { get => P("node_id"); set => PO("node_id", value); } [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? MasterTimeout { get => Q("master_timeout"); set => Q("master_timeout", value); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs index 6b810e01d41..6dc05965f99 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/CacheStatsResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class CacheStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override CacheStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CacheStatsResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CacheStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CacheStatsResponseConverter))] public sealed partial class CacheStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs index 92a8547f9d3..d71875c69db 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/ClearCacheRequest.g.cs @@ -78,6 +78,14 @@ public ClearCacheRequest(Elastic.Clients.Elasticsearch.Indices? indices) : base( internal override string OperationName => "searchable_snapshots.clear_cache"; + /// + /// + /// A comma-separated list of index names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs index fd393b4da9f..391b4f12e22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountRequest.g.cs @@ -76,6 +76,22 @@ public MountRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Clien internal override string OperationName => "searchable_snapshots.mount"; + /// + /// + /// The name of the repository containing the snapshot of the index to mount + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// The name of the snapshot of the index to mount + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs index 9ae28a8c3cf..94e92d014b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/MountResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class MountResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override MountResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshot.TryRead(ref reader, options, PropSnapshot)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MountResponse + { + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MountResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshot, value.Snapshot); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MountResponseConverter))] public sealed partial class MountResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.SearchableSnapshots.MountedSnapshot Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs index 24db2126902..9b45609d272 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsRequest.g.cs @@ -63,6 +63,14 @@ public SearchableSnapshotsStatsRequest(Elastic.Clients.Elasticsearch.Indices? in internal override string OperationName => "searchable_snapshots.stats"; + /// + /// + /// A comma-separated list of index names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices? Indices { get => P("index"); set => PO("index", value); } + /// /// /// Return stats aggregated at cluster, index or shard level diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs index fc66cfe509e..fe825e74058 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchableSnapshots/SearchableSnapshotsStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SearchableSnapshots; +internal sealed partial class SearchableSnapshotsStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override SearchableSnapshotsStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propStats = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchableSnapshotsStatsResponse + { + Stats = propStats.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchableSnapshotsStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchableSnapshotsStatsResponseConverter))] public sealed partial class SearchableSnapshotsStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("stats")] public object Stats { get; init; } - [JsonInclude, JsonPropertyName("total")] public object Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs index e3935e35022..2fb6f7328ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ActivateUserProfileResponse.g.cs @@ -22,24 +22,113 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ActivateUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("_doc"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropLabels = System.Text.Json.JsonEncodedText.Encode("labels"); + private static readonly System.Text.Json.JsonEncodedText PropLastSynchronized = System.Text.Json.JsonEncodedText.Encode("last_synchronized"); + private static readonly System.Text.Json.JsonEncodedText PropUid = System.Text.Json.JsonEncodedText.Encode("uid"); + private static readonly System.Text.Json.JsonEncodedText PropUser = System.Text.Json.JsonEncodedText.Encode("user"); + + public override ActivateUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propData = default; + LocalJsonValue propDoc = default; + LocalJsonValue propEnabled = default; + LocalJsonValue> propLabels = default; + LocalJsonValue propLastSynchronized = default; + LocalJsonValue propUid = default; + LocalJsonValue propUser = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData)) + { + continue; + } + + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propLabels.TryRead(ref reader, options, PropLabels)) + { + continue; + } + + if (propLastSynchronized.TryRead(ref reader, options, PropLastSynchronized)) + { + continue; + } + + if (propUid.TryRead(ref reader, options, PropUid)) + { + continue; + } + + if (propUser.TryRead(ref reader, options, PropUser)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ActivateUserProfileResponse + { + Data = propData.Value +, + Doc = propDoc.Value +, + Enabled = propEnabled.Value +, + Labels = propLabels.Value +, + LastSynchronized = propLastSynchronized.Value +, + Uid = propUid.Value +, + User = propUser.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ActivateUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropLabels, value.Labels); + writer.WriteProperty(options, PropLastSynchronized, value.LastSynchronized); + writer.WriteProperty(options, PropUid, value.Uid); + writer.WriteProperty(options, PropUser, value.User); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ActivateUserProfileResponseConverter))] public sealed partial class ActivateUserProfileResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("data")] public IReadOnlyDictionary Data { get; init; } - [JsonInclude, JsonPropertyName("_doc")] public Elastic.Clients.Elasticsearch.Security.UserProfileHitMetadata Doc { get; init; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; init; } - [JsonInclude, JsonPropertyName("labels")] public IReadOnlyDictionary Labels { get; init; } - [JsonInclude, JsonPropertyName("last_synchronized")] public long LastSynchronized { get; init; } - [JsonInclude, JsonPropertyName("uid")] public string Uid { get; init; } - [JsonInclude, JsonPropertyName("user")] public Elastic.Clients.Elasticsearch.Security.UserProfileUser User { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs index 0ce01ead1df..074c8c4fd46 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/AuthenticateResponse.g.cs @@ -22,32 +22,157 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class AuthenticateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropAuthenticationRealm = System.Text.Json.JsonEncodedText.Encode("authentication_realm"); + private static readonly System.Text.Json.JsonEncodedText PropAuthenticationType = System.Text.Json.JsonEncodedText.Encode("authentication_type"); + private static readonly System.Text.Json.JsonEncodedText PropEmail = System.Text.Json.JsonEncodedText.Encode("email"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFullName = System.Text.Json.JsonEncodedText.Encode("full_name"); + private static readonly System.Text.Json.JsonEncodedText PropLookupRealm = System.Text.Json.JsonEncodedText.Encode("lookup_realm"); + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override AuthenticateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propApiKey = default; + LocalJsonValue propAuthenticationRealm = default; + LocalJsonValue propAuthenticationType = default; + LocalJsonValue propEmail = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFullName = default; + LocalJsonValue propLookupRealm = default; + LocalJsonValue> propMetadata = default; + LocalJsonValue> propRoles = default; + LocalJsonValue propToken = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propAuthenticationRealm.TryRead(ref reader, options, PropAuthenticationRealm)) + { + continue; + } + + if (propAuthenticationType.TryRead(ref reader, options, PropAuthenticationType)) + { + continue; + } + + if (propEmail.TryRead(ref reader, options, PropEmail)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFullName.TryRead(ref reader, options, PropFullName)) + { + continue; + } + + if (propLookupRealm.TryRead(ref reader, options, PropLookupRealm)) + { + continue; + } + + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AuthenticateResponse + { + ApiKey = propApiKey.Value +, + AuthenticationRealm = propAuthenticationRealm.Value +, + AuthenticationType = propAuthenticationType.Value +, + Email = propEmail.Value +, + Enabled = propEnabled.Value +, + FullName = propFullName.Value +, + LookupRealm = propLookupRealm.Value +, + Metadata = propMetadata.Value +, + Roles = propRoles.Value +, + Token = propToken.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AuthenticateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropAuthenticationRealm, value.AuthenticationRealm); + writer.WriteProperty(options, PropAuthenticationType, value.AuthenticationType); + writer.WriteProperty(options, PropEmail, value.Email); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFullName, value.FullName); + writer.WriteProperty(options, PropLookupRealm, value.LookupRealm); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AuthenticateResponseConverter))] public sealed partial class AuthenticateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_key")] public Elastic.Clients.Elasticsearch.Security.AuthenticateApiKey? ApiKey { get; init; } - [JsonInclude, JsonPropertyName("authentication_realm")] public Elastic.Clients.Elasticsearch.Security.RealmInfo AuthenticationRealm { get; init; } - [JsonInclude, JsonPropertyName("authentication_type")] public string AuthenticationType { get; init; } - [JsonInclude, JsonPropertyName("email")] public string? Email { get; init; } - [JsonInclude, JsonPropertyName("enabled")] public bool Enabled { get; init; } - [JsonInclude, JsonPropertyName("full_name")] public string? FullName { get; init; } - [JsonInclude, JsonPropertyName("lookup_realm")] public Elastic.Clients.Elasticsearch.Security.RealmInfo LookupRealm { get; init; } - [JsonInclude, JsonPropertyName("metadata")] public IReadOnlyDictionary Metadata { get; init; } - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection Roles { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Security.AuthenticateToken? Token { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs index c09c14e8c35..a64f15e8911 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkDeleteRoleResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class BulkDeleteRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropNotFound = System.Text.Json.JsonEncodedText.Encode("not_found"); + + public override BulkDeleteRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propDeleted = default; + LocalJsonValue propErrors = default; + LocalJsonValue?> propNotFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propNotFound.TryRead(ref reader, options, PropNotFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkDeleteRoleResponse + { + Deleted = propDeleted.Value +, + Errors = propErrors.Value +, + NotFound = propNotFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkDeleteRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropNotFound, value.NotFound); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkDeleteRoleResponseConverter))] public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Array of deleted roles /// /// - [JsonInclude, JsonPropertyName("deleted")] public IReadOnlyCollection? Deleted { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Present if any deletes resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.BulkError? Errors { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class BulkDeleteRoleResponse : ElasticsearchResponse /// Array of roles that could not be found /// /// - [JsonInclude, JsonPropertyName("not_found")] public IReadOnlyCollection? NotFound { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs index 82e4e4312b5..ce600f09fa1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/BulkPutRoleResponse.g.cs @@ -22,10 +22,76 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class BulkPutRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropNoop = System.Text.Json.JsonEncodedText.Encode("noop"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override BulkPutRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propCreated = default; + LocalJsonValue propErrors = default; + LocalJsonValue?> propNoop = default; + LocalJsonValue?> propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propNoop.TryRead(ref reader, options, PropNoop)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulkPutRoleResponse + { + Created = propCreated.Value +, + Errors = propErrors.Value +, + Noop = propNoop.Value +, + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulkPutRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropNoop, value.Noop); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulkPutRoleResponseConverter))] public sealed partial class BulkPutRoleResponse : ElasticsearchResponse { /// @@ -33,7 +99,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of created roles /// /// - [JsonInclude, JsonPropertyName("created")] public IReadOnlyCollection? Created { get; init; } /// @@ -41,7 +106,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Present if any updates resulted in errors /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.BulkError? Errors { get; init; } /// @@ -49,7 +113,6 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of role names without any changes /// /// - [JsonInclude, JsonPropertyName("noop")] public IReadOnlyCollection? Noop { get; init; } /// @@ -57,6 +120,5 @@ public sealed partial class BulkPutRoleResponse : ElasticsearchResponse /// Array of updated roles /// /// - [JsonInclude, JsonPropertyName("updated")] public IReadOnlyCollection? Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs index 4c483138389..67081e8db72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordRequest.g.cs @@ -66,6 +66,15 @@ public ChangePasswordRequest(Elastic.Clients.Elasticsearch.Username? username) : internal override string OperationName => "security.change_password"; + /// + /// + /// The user whose password you want to change. If you do not specify this + /// parameter, the password is changed for the current user. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username? Username { get => P("username"); set => PO("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs index 00c66d00ff6..aaf0c53d982 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ChangePasswordResponse.g.cs @@ -22,10 +22,34 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ChangePasswordResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override ChangePasswordResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChangePasswordResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChangePasswordResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ChangePasswordResponseConverter))] public sealed partial class ChangePasswordResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs index 48b0f598878..ba98f9fa76c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheRequest.g.cs @@ -56,6 +56,16 @@ public ClearApiKeyCacheRequest(Elastic.Clients.Elasticsearch.Ids ids) : base(r = internal override bool SupportsBody => false; internal override string OperationName => "security.clear_api_key_cache"; + + /// + /// + /// Comma-separated list of API key IDs to evict from the API key cache. + /// To evict all API keys, use *. + /// Does not support other wildcard patterns. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Ids Ids { get => P("ids"); set => PR("ids", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs index 65cdf04e9b0..8964bdd44e9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearApiKeyCacheResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ClearApiKeyCacheResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearApiKeyCacheResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearApiKeyCacheResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearApiKeyCacheResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearApiKeyCacheResponseConverter))] public sealed partial class ClearApiKeyCacheResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs index 19bedb531d5..43c4a5537af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesRequest.g.cs @@ -56,6 +56,14 @@ public ClearCachedPrivilegesRequest(Elastic.Clients.Elasticsearch.Name applicati internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_privileges"; + + /// + /// + /// A comma-separated list of application names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Application { get => P("application"); set => PR("application", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs index d912eaa3cfd..28f0a080115 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedPrivilegesResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ClearCachedPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedPrivilegesResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedPrivilegesResponseConverter))] public sealed partial class ClearCachedPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs index 0687c5d5d41..215ecdb8d72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsRequest.g.cs @@ -62,6 +62,14 @@ public ClearCachedRealmsRequest(Elastic.Clients.Elasticsearch.Names realms) : ba internal override string OperationName => "security.clear_cached_realms"; + /// + /// + /// Comma-separated list of realms to clear + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Realms { get => P("realms"); set => PR("realms", value); } + /// /// /// Comma-separated list of usernames to clear from the cache diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs index 7f2e195891e..cba71fbda19 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRealmsResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ClearCachedRealmsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedRealmsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedRealmsResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedRealmsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedRealmsResponseConverter))] public sealed partial class ClearCachedRealmsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs index 1b630f2adff..237afba5336 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesRequest.g.cs @@ -55,6 +55,14 @@ public ClearCachedRolesRequest(Elastic.Clients.Elasticsearch.Names name) : base( internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_roles"; + + /// + /// + /// Role name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs index 5257f5d7b69..f72b8d28cc0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedRolesResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ClearCachedRolesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedRolesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedRolesResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedRolesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedRolesResponseConverter))] public sealed partial class ClearCachedRolesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs index a018b729fd4..9fbe669c855 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensRequest.g.cs @@ -55,6 +55,30 @@ public ClearCachedServiceTokensRequest(string ns, string service, Elastic.Client internal override bool SupportsBody => false; internal override string OperationName => "security.clear_cached_service_tokens"; + + /// + /// + /// A comma-separated list of service token names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs index b1b33e09cf9..31b4cb2a566 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/ClearCachedServiceTokensResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class ClearCachedServiceTokensResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropClusterName = System.Text.Json.JsonEncodedText.Encode("cluster_name"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropNodeStats = System.Text.Json.JsonEncodedText.Encode("_nodes"); + + public override ClearCachedServiceTokensResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propClusterName = default; + LocalJsonValue> propNodes = default; + LocalJsonValue propNodeStats = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propClusterName.TryRead(ref reader, options, PropClusterName)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propNodeStats.TryRead(ref reader, options, PropNodeStats)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCachedServiceTokensResponse + { + ClusterName = propClusterName.Value +, + Nodes = propNodes.Value +, + NodeStats = propNodeStats.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCachedServiceTokensResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropClusterName, value.ClusterName); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropNodeStats, value.NodeStats); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCachedServiceTokensResponseConverter))] public sealed partial class ClearCachedServiceTokensResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster_name")] public string ClusterName { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } - [JsonInclude, JsonPropertyName("_nodes")] public Elastic.Clients.Elasticsearch.NodeStatistics NodeStats { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs index 440179df1b5..b4c7be35d05 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateApiKeyResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class CreateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropEncoded = System.Text.Json.JsonEncodedText.Encode("encoded"); + private static readonly System.Text.Json.JsonEncodedText PropExpiration = System.Text.Json.JsonEncodedText.Encode("expiration"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override CreateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propEncoded.TryRead(ref reader, options, PropEncoded)) + { + continue; + } + + if (propExpiration.TryRead(ref reader, options, PropExpiration)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropEncoded, value.Encoded); + writer.WriteProperty(options, PropExpiration, value.Expiration); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateApiKeyResponseConverter))] public sealed partial class CreateApiKeyResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Generated API key. /// /// - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } /// @@ -43,7 +118,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// by a colon (:). /// /// - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } /// @@ -51,7 +125,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Expiration in milliseconds for the API key. /// /// - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } /// @@ -59,7 +132,6 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Unique ID for this API key. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -67,6 +139,5 @@ public sealed partial class CreateApiKeyResponse : ElasticsearchResponse /// Specifies the name for this API key. /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs index 3dcac6531a1..76fd1f40842 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateCrossClusterApiKeyResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class CreateCrossClusterApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropEncoded = System.Text.Json.JsonEncodedText.Encode("encoded"); + private static readonly System.Text.Json.JsonEncodedText PropExpiration = System.Text.Json.JsonEncodedText.Encode("expiration"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override CreateCrossClusterApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propEncoded.TryRead(ref reader, options, PropEncoded)) + { + continue; + } + + if (propExpiration.TryRead(ref reader, options, PropExpiration)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateCrossClusterApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateCrossClusterApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropEncoded, value.Encoded); + writer.WriteProperty(options, PropExpiration, value.Expiration); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateCrossClusterApiKeyResponseConverter))] public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Generated API key. /// /// - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } /// @@ -43,7 +118,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// by a colon (:). /// /// - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } /// @@ -51,7 +125,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Expiration in milliseconds for the API key. /// /// - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } /// @@ -59,7 +132,6 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Unique ID for this API key. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -67,6 +139,5 @@ public sealed partial class CreateCrossClusterApiKeyResponse : ElasticsearchResp /// Specifies the name for this API key. /// /// - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs index 6b8dd3f4062..75d42beaf31 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenRequest.g.cs @@ -66,6 +66,30 @@ public CreateServiceTokenRequest(string ns, string service) : base(r => r.Requir internal override string OperationName => "security.create_service_token"; + /// + /// + /// An identifier for the token name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Name { get => P("name"); set => PO("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } + /// /// /// If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs index 925204e9e00..d2a9f682380 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/CreateServiceTokenResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class CreateServiceTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + + public override CreateServiceTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreated = default; + LocalJsonValue propToken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateServiceTokenResponse + { + Created = propCreated.Value +, + Token = propToken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateServiceTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateServiceTokenResponseConverter))] public sealed partial class CreateServiceTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool Created { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Security.ServiceToken Token { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs index 320489f1431..3e34f9d53b0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeletePrivilegesRequest.g.cs @@ -59,6 +59,22 @@ public DeletePrivilegesRequest(Elastic.Clients.Elasticsearch.Name application, E internal override string OperationName => "security.delete_privileges"; + /// + /// + /// Application name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Application { get => P("application"); set => PR("application", value); } + + /// + /// + /// Privilege name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs index 2421e540477..999a2d9c58c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingRequest.g.cs @@ -59,6 +59,14 @@ public DeleteRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base( internal override string OperationName => "security.delete_role_mapping"; + /// + /// + /// Role-mapping name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs index ba9829eeecf..c625645a920 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleMappingResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DeleteRoleMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteRoleMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRoleMappingResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRoleMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRoleMappingResponseConverter))] public sealed partial class DeleteRoleMappingResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs index fd976f508f4..ce828516e1f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleRequest.g.cs @@ -62,6 +62,14 @@ public DeleteRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r. internal override string OperationName => "security.delete_role"; + /// + /// + /// Role name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs index 8733410e218..6e0685568df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteRoleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DeleteRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRoleResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRoleResponseConverter))] public sealed partial class DeleteRoleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs index 94441f708bb..79694223147 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenRequest.g.cs @@ -62,6 +62,30 @@ public DeleteServiceTokenRequest(string ns, string service, Elastic.Clients.Elas internal override string OperationName => "security.delete_service_token"; + /// + /// + /// An identifier for the token name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + + /// + /// + /// An identifier for the namespace + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// An identifier for the service name + /// + /// + [JsonIgnore] + public string Service { get => P("service"); set => PR("service", value); } + /// /// /// If true then refresh the affected shards to make this operation visible to search, if wait_for (the default) then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs index a9ad6329929..9ad5720e1fa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteServiceTokenResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DeleteServiceTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteServiceTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteServiceTokenResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteServiceTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteServiceTokenResponseConverter))] public sealed partial class DeleteServiceTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs index 90e38b47654..653c9207eb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserRequest.g.cs @@ -62,6 +62,14 @@ public DeleteUserRequest(Elastic.Clients.Elasticsearch.Username username) : base internal override string OperationName => "security.delete_user"; + /// + /// + /// username + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs index 3ccd3bafba1..193bc3b35c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DeleteUserResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DeleteUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + + public override DeleteUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteUserResponse + { + Found = propFound.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteUserResponseConverter))] public sealed partial class DeleteUserResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs index ee4991e79cf..818e0bda3e8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileRequest.g.cs @@ -64,6 +64,14 @@ public DisableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) internal override string OperationName => "security.disable_user_profile"; + /// + /// + /// Unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// If 'true', Elasticsearch refreshes the affected shards to make this operation diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs index b6a983cec33..268b4cffcf1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserProfileResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DisableUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DisableUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DisableUserProfileResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DisableUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DisableUserProfileResponseConverter))] public sealed partial class DisableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DisableUserProfileResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs index e8f286a5a80..070bb1168ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserRequest.g.cs @@ -62,6 +62,14 @@ public DisableUserRequest(Elastic.Clients.Elasticsearch.Username username) : bas internal override string OperationName => "security.disable_user"; + /// + /// + /// The username of the user to disable + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs index 91cd0736f94..3042e0f8eb2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/DisableUserResponse.g.cs @@ -22,10 +22,34 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class DisableUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override DisableUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DisableUserResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DisableUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DisableUserResponseConverter))] public sealed partial class DisableUserResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs index 725a5665805..4fc0855c4bb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileRequest.g.cs @@ -64,6 +64,14 @@ public EnableUserProfileRequest(string uid) : base(r => r.Required("uid", uid)) internal override string OperationName => "security.enable_user_profile"; + /// + /// + /// Unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// If 'true', Elasticsearch refreshes the affected shards to make this operation diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs index 01d90498655..acfd753e04c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserProfileResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnableUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override EnableUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnableUserProfileResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnableUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnableUserProfileResponseConverter))] public sealed partial class EnableUserProfileResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class EnableUserProfileResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs index 4758880e9f4..3f13102f1d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserRequest.g.cs @@ -62,6 +62,14 @@ public EnableUserRequest(Elastic.Clients.Elasticsearch.Username username) : base internal override string OperationName => "security.enable_user"; + /// + /// + /// The username of the user to enable + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Username Username { get => P("username"); set => PR("username", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs index e839c5abf6f..3018ed2d484 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnableUserResponse.g.cs @@ -22,10 +22,34 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnableUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + public override EnableUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnableUserResponse { }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnableUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnableUserResponseConverter))] public sealed partial class EnableUserResponse : ElasticsearchResponse { } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs index 79907207140..3b9323c3a35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollKibanaResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnrollKibanaResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHttpCa = System.Text.Json.JsonEncodedText.Encode("http_ca"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + + public override EnrollKibanaResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propHttpCa = default; + LocalJsonValue propToken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHttpCa.TryRead(ref reader, options, PropHttpCa)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrollKibanaResponse + { + HttpCa = propHttpCa.Value +, + Token = propToken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrollKibanaResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHttpCa, value.HttpCa); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrollKibanaResponseConverter))] public sealed partial class EnrollKibanaResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("http_ca")] public string HttpCa { get; init; } - [JsonInclude, JsonPropertyName("token")] public Elastic.Clients.Elasticsearch.Security.KibanaToken Token { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs index 5d34b09a546..9e7b242c345 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/EnrollNodeResponse.g.cs @@ -22,22 +22,102 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class EnrollNodeResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHttpCaCert = System.Text.Json.JsonEncodedText.Encode("http_ca_cert"); + private static readonly System.Text.Json.JsonEncodedText PropHttpCaKey = System.Text.Json.JsonEncodedText.Encode("http_ca_key"); + private static readonly System.Text.Json.JsonEncodedText PropNodesAddresses = System.Text.Json.JsonEncodedText.Encode("nodes_addresses"); + private static readonly System.Text.Json.JsonEncodedText PropTransportCaCert = System.Text.Json.JsonEncodedText.Encode("transport_ca_cert"); + private static readonly System.Text.Json.JsonEncodedText PropTransportCert = System.Text.Json.JsonEncodedText.Encode("transport_cert"); + private static readonly System.Text.Json.JsonEncodedText PropTransportKey = System.Text.Json.JsonEncodedText.Encode("transport_key"); + + public override EnrollNodeResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propHttpCaCert = default; + LocalJsonValue propHttpCaKey = default; + LocalJsonValue> propNodesAddresses = default; + LocalJsonValue propTransportCaCert = default; + LocalJsonValue propTransportCert = default; + LocalJsonValue propTransportKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHttpCaCert.TryRead(ref reader, options, PropHttpCaCert)) + { + continue; + } + + if (propHttpCaKey.TryRead(ref reader, options, PropHttpCaKey)) + { + continue; + } + + if (propNodesAddresses.TryRead(ref reader, options, PropNodesAddresses)) + { + continue; + } + + if (propTransportCaCert.TryRead(ref reader, options, PropTransportCaCert)) + { + continue; + } + + if (propTransportCert.TryRead(ref reader, options, PropTransportCert)) + { + continue; + } + + if (propTransportKey.TryRead(ref reader, options, PropTransportKey)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrollNodeResponse + { + HttpCaCert = propHttpCaCert.Value +, + HttpCaKey = propHttpCaKey.Value +, + NodesAddresses = propNodesAddresses.Value +, + TransportCaCert = propTransportCaCert.Value +, + TransportCert = propTransportCert.Value +, + TransportKey = propTransportKey.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrollNodeResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHttpCaCert, value.HttpCaCert); + writer.WriteProperty(options, PropHttpCaKey, value.HttpCaKey); + writer.WriteProperty(options, PropNodesAddresses, value.NodesAddresses); + writer.WriteProperty(options, PropTransportCaCert, value.TransportCaCert); + writer.WriteProperty(options, PropTransportCert, value.TransportCert); + writer.WriteProperty(options, PropTransportKey, value.TransportKey); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrollNodeResponseConverter))] public sealed partial class EnrollNodeResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("http_ca_cert")] public string HttpCaCert { get; init; } - [JsonInclude, JsonPropertyName("http_ca_key")] public string HttpCaKey { get; init; } - [JsonInclude, JsonPropertyName("nodes_addresses")] public IReadOnlyCollection NodesAddresses { get; init; } - [JsonInclude, JsonPropertyName("transport_ca_cert")] public string TransportCaCert { get; init; } - [JsonInclude, JsonPropertyName("transport_cert")] public string TransportCert { get; init; } - [JsonInclude, JsonPropertyName("transport_key")] public string TransportKey { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs index 39e7a09e307..097feb968b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetApiKeyResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKeys = System.Text.Json.JsonEncodedText.Encode("api_keys"); + + public override GetApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKeys.TryRead(ref reader, options, PropApiKeys)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetApiKeyResponse + { + ApiKeys = propApiKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKeys, value.ApiKeys); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetApiKeyResponseConverter))] public sealed partial class GetApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_keys")] public IReadOnlyCollection ApiKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs index 2410a2d7776..4e3541f5990 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetBuiltinPrivilegesResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetBuiltinPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropRemoteCluster = System.Text.Json.JsonEncodedText.Encode("remote_cluster"); + + public override GetBuiltinPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propCluster = default; + LocalJsonValue> propIndex = default; + LocalJsonValue> propRemoteCluster = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propRemoteCluster.TryRead(ref reader, options, PropRemoteCluster)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetBuiltinPrivilegesResponse + { + Cluster = propCluster.Value +, + Index = propIndex.Value +, + RemoteCluster = propRemoteCluster.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetBuiltinPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropRemoteCluster, value.RemoteCluster); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetBuiltinPrivilegesResponseConverter))] public sealed partial class GetBuiltinPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyCollection Cluster { get; init; } - [JsonInclude, JsonPropertyName("index")] public IReadOnlyCollection Index { get; init; } - [JsonInclude, JsonPropertyName("remote_cluster")] public IReadOnlyCollection RemoteCluster { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs index 54604deb0ad..53852444124 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetPrivilegesRequest.g.cs @@ -60,6 +60,22 @@ public GetPrivilegesRequest(Elastic.Clients.Elasticsearch.Name? application, Ela internal override bool SupportsBody => false; internal override string OperationName => "security.get_privileges"; + + /// + /// + /// Application name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Application { get => P("application"); set => PO("application", value); } + + /// + /// + /// Privilege name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs index 8a4c6a97c43..4856c5cf8de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleMappingRequest.g.cs @@ -61,6 +61,14 @@ public GetRoleMappingRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r internal override bool SupportsBody => false; internal override string OperationName => "security.get_role_mapping"; + + /// + /// + /// The distinct name that identifies the role mapping. The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way. You can specify multiple mapping names as a comma-separated list. If you do not specify this parameter, the API returns information about all role mappings. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs index 9269177ee80..ead569004f2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetRoleRequest.g.cs @@ -59,6 +59,14 @@ public GetRoleRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r => r.O internal override bool SupportsBody => false; internal override string OperationName => "security.get_role"; + + /// + /// + /// The name of the role. You can specify multiple roles as a comma-separated list. If you do not specify this parameter, the API returns information about all roles. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("name"); set => PO("name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs index 921b203f237..ca25155cf07 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceAccountsRequest.g.cs @@ -63,6 +63,22 @@ public GetServiceAccountsRequest(string? ns) : base(r => r.Optional("namespace", internal override bool SupportsBody => false; internal override string OperationName => "security.get_service_accounts"; + + /// + /// + /// Name of the namespace. Omit this parameter to retrieve information about all service accounts. If you omit this parameter, you must also omit the service parameter. + /// + /// + [JsonIgnore] + public string? Namespace { get => P("namespace"); set => PO("namespace", value); } + + /// + /// + /// Name of the service name. Omit this parameter to retrieve information about all service accounts that belong to the specified namespace. + /// + /// + [JsonIgnore] + public string? Service { get => P("service"); set => PO("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs index a1a5d627f24..a6789a89f6d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsRequest.g.cs @@ -52,6 +52,22 @@ public GetServiceCredentialsRequest(string ns, Elastic.Clients.Elasticsearch.Nam internal override bool SupportsBody => false; internal override string OperationName => "security.get_service_credentials"; + + /// + /// + /// Name of the namespace. + /// + /// + [JsonIgnore] + public string Namespace { get => P("namespace"); set => PR("namespace", value); } + + /// + /// + /// Name of the service name. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Service { get => P("service"); set => PR("service", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs index 7fa558776e9..e2a09eca538 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetServiceCredentialsResponse.g.cs @@ -22,13 +22,78 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetServiceCredentialsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropNodesCredentials = System.Text.Json.JsonEncodedText.Encode("nodes_credentials"); + private static readonly System.Text.Json.JsonEncodedText PropServiceAccount = System.Text.Json.JsonEncodedText.Encode("service_account"); + private static readonly System.Text.Json.JsonEncodedText PropTokens = System.Text.Json.JsonEncodedText.Encode("tokens"); + + public override GetServiceCredentialsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue propNodesCredentials = default; + LocalJsonValue propServiceAccount = default; + LocalJsonValue>> propTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propNodesCredentials.TryRead(ref reader, options, PropNodesCredentials)) + { + continue; + } + + if (propServiceAccount.TryRead(ref reader, options, PropServiceAccount)) + { + continue; + } + + if (propTokens.TryRead(ref reader, options, PropTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetServiceCredentialsResponse + { + Count = propCount.Value +, + NodesCredentials = propNodesCredentials.Value +, + ServiceAccount = propServiceAccount.Value +, + Tokens = propTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetServiceCredentialsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropNodesCredentials, value.NodesCredentials); + writer.WriteProperty(options, PropServiceAccount, value.ServiceAccount); + writer.WriteProperty(options, PropTokens, value.Tokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetServiceCredentialsResponseConverter))] public sealed partial class GetServiceCredentialsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -36,10 +101,7 @@ public sealed partial class GetServiceCredentialsResponse : ElasticsearchRespons /// Contains service account credentials collected from all nodes of the cluster /// /// - [JsonInclude, JsonPropertyName("nodes_credentials")] public Elastic.Clients.Elasticsearch.Security.NodesCredentials NodesCredentials { get; init; } - [JsonInclude, JsonPropertyName("service_account")] public string ServiceAccount { get; init; } - [JsonInclude, JsonPropertyName("tokens")] public IReadOnlyDictionary> Tokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs index 07fd75ec184..653089b2c2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetTokenResponse.g.cs @@ -22,24 +22,113 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + private static readonly System.Text.Json.JsonEncodedText PropAuthentication = System.Text.Json.JsonEncodedText.Encode("authentication"); + private static readonly System.Text.Json.JsonEncodedText PropExpiresIn = System.Text.Json.JsonEncodedText.Encode("expires_in"); + private static readonly System.Text.Json.JsonEncodedText PropKerberosAuthenticationResponseToken = System.Text.Json.JsonEncodedText.Encode("kerberos_authentication_response_token"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText PropScope = System.Text.Json.JsonEncodedText.Encode("scope"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GetTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAccessToken = default; + LocalJsonValue propAuthentication = default; + LocalJsonValue propExpiresIn = default; + LocalJsonValue propKerberosAuthenticationResponseToken = default; + LocalJsonValue propRefreshToken = default; + LocalJsonValue propScope = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryRead(ref reader, options, PropAccessToken)) + { + continue; + } + + if (propAuthentication.TryRead(ref reader, options, PropAuthentication)) + { + continue; + } + + if (propExpiresIn.TryRead(ref reader, options, PropExpiresIn)) + { + continue; + } + + if (propKerberosAuthenticationResponseToken.TryRead(ref reader, options, PropKerberosAuthenticationResponseToken)) + { + continue; + } + + if (propRefreshToken.TryRead(ref reader, options, PropRefreshToken)) + { + continue; + } + + if (propScope.TryRead(ref reader, options, PropScope)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTokenResponse + { + AccessToken = propAccessToken.Value +, + Authentication = propAuthentication.Value +, + ExpiresIn = propExpiresIn.Value +, + KerberosAuthenticationResponseToken = propKerberosAuthenticationResponseToken.Value +, + RefreshToken = propRefreshToken.Value +, + Scope = propScope.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccessToken, value.AccessToken); + writer.WriteProperty(options, PropAuthentication, value.Authentication); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn); + writer.WriteProperty(options, PropKerberosAuthenticationResponseToken, value.KerberosAuthenticationResponseToken); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken); + writer.WriteProperty(options, PropScope, value.Scope); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTokenResponseConverter))] public sealed partial class GetTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("access_token")] public string AccessToken { get; init; } - [JsonInclude, JsonPropertyName("authentication")] public Elastic.Clients.Elasticsearch.Security.AuthenticatedUser Authentication { get; init; } - [JsonInclude, JsonPropertyName("expires_in")] public long ExpiresIn { get; init; } - [JsonInclude, JsonPropertyName("kerberos_authentication_response_token")] public string? KerberosAuthenticationResponseToken { get; init; } - [JsonInclude, JsonPropertyName("refresh_token")] public string? RefreshToken { get; init; } - [JsonInclude, JsonPropertyName("scope")] public string? Scope { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs index 521ec2a00f5..cc411f036f6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserPrivilegesResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetUserPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApplications = System.Text.Json.JsonEncodedText.Encode("applications"); + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropRunAs = System.Text.Json.JsonEncodedText.Encode("run_as"); + + public override GetUserPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propApplications = default; + LocalJsonValue> propCluster = default; + LocalJsonValue> propGlobal = default; + LocalJsonValue> propIndices = default; + LocalJsonValue> propRunAs = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplications.TryRead(ref reader, options, PropApplications)) + { + continue; + } + + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propGlobal.TryRead(ref reader, options, PropGlobal)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propRunAs.TryRead(ref reader, options, PropRunAs)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetUserPrivilegesResponse + { + Applications = propApplications.Value +, + Cluster = propCluster.Value +, + Global = propGlobal.Value +, + Indices = propIndices.Value +, + RunAs = propRunAs.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetUserPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApplications, value.Applications); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropGlobal, value.Global); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropRunAs, value.RunAs); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetUserPrivilegesResponseConverter))] public sealed partial class GetUserPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("applications")] public IReadOnlyCollection Applications { get; init; } - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyCollection Cluster { get; init; } - [JsonInclude, JsonPropertyName("global")] public IReadOnlyCollection Global { get; init; } - [JsonInclude, JsonPropertyName("indices")] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("run_as")] public IReadOnlyCollection RunAs { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs index fa92cf1108f..45426cfc9d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileRequest.g.cs @@ -65,6 +65,14 @@ public GetUserProfileRequest(IReadOnlyCollection uid) : base(r => r.Requ internal override string OperationName => "security.get_user_profile"; + /// + /// + /// A unique identifier for the user profile. + /// + /// + [JsonIgnore] + public ICollection Uid { get => P>("uid"); set => PR("uid", value); } + /// /// /// List of filters for the data field of the profile document. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs index 71e2118cb2b..aa5e08d1e3b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserProfileResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GetUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropProfiles = System.Text.Json.JsonEncodedText.Encode("profiles"); + + public override GetUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propErrors = default; + LocalJsonValue> propProfiles = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propProfiles.TryRead(ref reader, options, PropProfiles)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetUserProfileResponse + { + Errors = propErrors.Value +, + Profiles = propProfiles.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropProfiles, value.Profiles); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetUserProfileResponseConverter))] public sealed partial class GetUserProfileResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.GetUserProfileErrors? Errors { get; init; } - [JsonInclude, JsonPropertyName("profiles")] public IReadOnlyCollection Profiles { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs index 9c77e91e3f6..66d4b9cd07f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GetUserRequest.g.cs @@ -66,6 +66,14 @@ public GetUserRequest(IReadOnlyCollection "security.get_user"; + /// + /// + /// An identifier for the user. You can specify multiple usernames as a comma-separated list. If you omit this parameter, the API retrieves information about all users. + /// + /// + [JsonIgnore] + public ICollection? Username { get => P?>("username"); set => PO("username", value); } + /// /// /// If true will return the User Profile ID for a user, if any. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs index 9644b9b2a5a..a9df30d88aa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/GrantApiKeyResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class GrantApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApiKey = System.Text.Json.JsonEncodedText.Encode("api_key"); + private static readonly System.Text.Json.JsonEncodedText PropEncoded = System.Text.Json.JsonEncodedText.Encode("encoded"); + private static readonly System.Text.Json.JsonEncodedText PropExpiration = System.Text.Json.JsonEncodedText.Encode("expiration"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override GrantApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propApiKey = default; + LocalJsonValue propEncoded = default; + LocalJsonValue propExpiration = default; + LocalJsonValue propId = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApiKey.TryRead(ref reader, options, PropApiKey)) + { + continue; + } + + if (propEncoded.TryRead(ref reader, options, PropEncoded)) + { + continue; + } + + if (propExpiration.TryRead(ref reader, options, PropExpiration)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GrantApiKeyResponse + { + ApiKey = propApiKey.Value +, + Encoded = propEncoded.Value +, + Expiration = propExpiration.Value +, + Id = propId.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GrantApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApiKey, value.ApiKey); + writer.WriteProperty(options, PropEncoded, value.Encoded); + writer.WriteProperty(options, PropExpiration, value.Expiration); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GrantApiKeyResponseConverter))] public sealed partial class GrantApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("api_key")] public string ApiKey { get; init; } - [JsonInclude, JsonPropertyName("encoded")] public string Encoded { get; init; } - [JsonInclude, JsonPropertyName("expiration")] public long? Expiration { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs index 623c868da87..913b9a5f00f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesRequest.g.cs @@ -60,6 +60,13 @@ public HasPrivilegesRequest(Elastic.Clients.Elasticsearch.Name? user) : base(r = internal override string OperationName => "security.has_privileges"; + /// + /// + /// Username + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? User { get => P("user"); set => PO("user", value); } [JsonInclude, JsonPropertyName("application")] public ICollection? Application { get; set; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs index 024488da85d..86e6c3f1859 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesResponse.g.cs @@ -22,21 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class HasPrivilegesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropApplication = System.Text.Json.JsonEncodedText.Encode("application"); + private static readonly System.Text.Json.JsonEncodedText PropCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + private static readonly System.Text.Json.JsonEncodedText PropHasAllRequested = System.Text.Json.JsonEncodedText.Encode("has_all_requested"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override HasPrivilegesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>>> propApplication = default; + LocalJsonValue> propCluster = default; + LocalJsonValue propHasAllRequested = default; + LocalJsonValue>> propIndex = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propApplication.TryRead(ref reader, options, PropApplication)) + { + continue; + } + + if (propCluster.TryRead(ref reader, options, PropCluster)) + { + continue; + } + + if (propHasAllRequested.TryRead(ref reader, options, PropHasAllRequested)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HasPrivilegesResponse + { + Application = propApplication.Value +, + Cluster = propCluster.Value +, + HasAllRequested = propHasAllRequested.Value +, + Index = propIndex.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HasPrivilegesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropApplication, value.Application); + writer.WriteProperty(options, PropCluster, value.Cluster); + writer.WriteProperty(options, PropHasAllRequested, value.HasAllRequested); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HasPrivilegesResponseConverter))] public sealed partial class HasPrivilegesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("application")] public IReadOnlyDictionary>> Application { get; init; } - [JsonInclude, JsonPropertyName("cluster")] public IReadOnlyDictionary Cluster { get; init; } - [JsonInclude, JsonPropertyName("has_all_requested")] public bool HasAllRequested { get; init; } - [JsonInclude, JsonPropertyName("index")] - [ReadOnlyIndexNameDictionaryConverter(typeof(IReadOnlyDictionary))] public IReadOnlyDictionary> Index { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs index 04b7b2fd847..2ce0394de76 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/HasPrivilegesUserProfileResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class HasPrivilegesUserProfileResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrors = System.Text.Json.JsonEncodedText.Encode("errors"); + private static readonly System.Text.Json.JsonEncodedText PropHasPrivilegeUids = System.Text.Json.JsonEncodedText.Encode("has_privilege_uids"); + + public override HasPrivilegesUserProfileResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propErrors = default; + LocalJsonValue> propHasPrivilegeUids = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrors.TryRead(ref reader, options, PropErrors)) + { + continue; + } + + if (propHasPrivilegeUids.TryRead(ref reader, options, PropHasPrivilegeUids)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HasPrivilegesUserProfileResponse + { + Errors = propErrors.Value +, + HasPrivilegeUids = propHasPrivilegeUids.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HasPrivilegesUserProfileResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrors, value.Errors); + writer.WriteProperty(options, PropHasPrivilegeUids, value.HasPrivilegeUids); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HasPrivilegesUserProfileResponseConverter))] public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResponse { /// @@ -36,7 +82,6 @@ public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResp /// requested privileges. This field is absent if empty. /// /// - [JsonInclude, JsonPropertyName("errors")] public Elastic.Clients.Elasticsearch.Security.HasPrivilegesUserProfileErrors? Errors { get; init; } /// @@ -45,6 +90,5 @@ public sealed partial class HasPrivilegesUserProfileResponse : ElasticsearchResp /// have all the requested privileges. /// /// - [JsonInclude, JsonPropertyName("has_privilege_uids")] public IReadOnlyCollection HasPrivilegeUids { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs index c46e96aaf8b..48571c7a4fb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateApiKeyResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class InvalidateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrorCount = System.Text.Json.JsonEncodedText.Encode("error_count"); + private static readonly System.Text.Json.JsonEncodedText PropErrorDetails = System.Text.Json.JsonEncodedText.Encode("error_details"); + private static readonly System.Text.Json.JsonEncodedText PropInvalidatedApiKeys = System.Text.Json.JsonEncodedText.Encode("invalidated_api_keys"); + private static readonly System.Text.Json.JsonEncodedText PropPreviouslyInvalidatedApiKeys = System.Text.Json.JsonEncodedText.Encode("previously_invalidated_api_keys"); + + public override InvalidateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propErrorCount = default; + LocalJsonValue?> propErrorDetails = default; + LocalJsonValue> propInvalidatedApiKeys = default; + LocalJsonValue> propPreviouslyInvalidatedApiKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryRead(ref reader, options, PropErrorCount)) + { + continue; + } + + if (propErrorDetails.TryRead(ref reader, options, PropErrorDetails)) + { + continue; + } + + if (propInvalidatedApiKeys.TryRead(ref reader, options, PropInvalidatedApiKeys)) + { + continue; + } + + if (propPreviouslyInvalidatedApiKeys.TryRead(ref reader, options, PropPreviouslyInvalidatedApiKeys)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InvalidateApiKeyResponse + { + ErrorCount = propErrorCount.Value +, + ErrorDetails = propErrorDetails.Value +, + InvalidatedApiKeys = propInvalidatedApiKeys.Value +, + PreviouslyInvalidatedApiKeys = propPreviouslyInvalidatedApiKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InvalidateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrorCount, value.ErrorCount); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails); + writer.WriteProperty(options, PropInvalidatedApiKeys, value.InvalidatedApiKeys); + writer.WriteProperty(options, PropPreviouslyInvalidatedApiKeys, value.PreviouslyInvalidatedApiKeys); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InvalidateApiKeyResponseConverter))] public sealed partial class InvalidateApiKeyResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error_count")] public int ErrorCount { get; init; } - [JsonInclude, JsonPropertyName("error_details")] public IReadOnlyCollection? ErrorDetails { get; init; } - [JsonInclude, JsonPropertyName("invalidated_api_keys")] public IReadOnlyCollection InvalidatedApiKeys { get; init; } - [JsonInclude, JsonPropertyName("previously_invalidated_api_keys")] public IReadOnlyCollection PreviouslyInvalidatedApiKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs index d014871850b..78c3cd6cdd0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/InvalidateTokenResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class InvalidateTokenResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropErrorCount = System.Text.Json.JsonEncodedText.Encode("error_count"); + private static readonly System.Text.Json.JsonEncodedText PropErrorDetails = System.Text.Json.JsonEncodedText.Encode("error_details"); + private static readonly System.Text.Json.JsonEncodedText PropInvalidatedTokens = System.Text.Json.JsonEncodedText.Encode("invalidated_tokens"); + private static readonly System.Text.Json.JsonEncodedText PropPreviouslyInvalidatedTokens = System.Text.Json.JsonEncodedText.Encode("previously_invalidated_tokens"); + + public override InvalidateTokenResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propErrorCount = default; + LocalJsonValue?> propErrorDetails = default; + LocalJsonValue propInvalidatedTokens = default; + LocalJsonValue propPreviouslyInvalidatedTokens = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propErrorCount.TryRead(ref reader, options, PropErrorCount)) + { + continue; + } + + if (propErrorDetails.TryRead(ref reader, options, PropErrorDetails)) + { + continue; + } + + if (propInvalidatedTokens.TryRead(ref reader, options, PropInvalidatedTokens)) + { + continue; + } + + if (propPreviouslyInvalidatedTokens.TryRead(ref reader, options, PropPreviouslyInvalidatedTokens)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InvalidateTokenResponse + { + ErrorCount = propErrorCount.Value +, + ErrorDetails = propErrorDetails.Value +, + InvalidatedTokens = propInvalidatedTokens.Value +, + PreviouslyInvalidatedTokens = propPreviouslyInvalidatedTokens.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InvalidateTokenResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropErrorCount, value.ErrorCount); + writer.WriteProperty(options, PropErrorDetails, value.ErrorDetails); + writer.WriteProperty(options, PropInvalidatedTokens, value.InvalidatedTokens); + writer.WriteProperty(options, PropPreviouslyInvalidatedTokens, value.PreviouslyInvalidatedTokens); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InvalidateTokenResponseConverter))] public sealed partial class InvalidateTokenResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("error_count")] public long ErrorCount { get; init; } - [JsonInclude, JsonPropertyName("error_details")] public IReadOnlyCollection? ErrorDetails { get; init; } - [JsonInclude, JsonPropertyName("invalidated_tokens")] public long InvalidatedTokens { get; init; } - [JsonInclude, JsonPropertyName("previously_invalidated_tokens")] public long PreviouslyInvalidatedTokens { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs index 9ba02c01239..190e41375a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutPrivilegesRequest.g.cs @@ -47,7 +47,7 @@ public sealed partial class PutPrivilegesRequestParameters : RequestParameters /// Create or update application privileges. /// /// -public sealed partial class PutPrivilegesRequest : PlainRequest, ISelfSerializable +public sealed partial class PutPrivilegesRequest : PlainRequest, ISelfTwoWaySerializable { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityPutPrivileges; @@ -66,10 +66,15 @@ public sealed partial class PutPrivilegesRequest : PlainRequest Q("refresh"); set => Q("refresh", value); } public Dictionary> Privileges { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Privileges, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Privileges = settings.RequestResponseSerializer.Deserialize>>(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs index e0713523d9f..492d827c55c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingRequest.g.cs @@ -68,6 +68,14 @@ public PutRoleMappingRequest(Elastic.Clients.Elasticsearch.Name name) : base(r = internal override string OperationName => "security.put_role_mapping"; + /// + /// + /// Role-mapping name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs index c3a0d4a12ce..a31c0046e5f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleMappingResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class PutRoleMappingResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + private static readonly System.Text.Json.JsonEncodedText PropRoleMapping = System.Text.Json.JsonEncodedText.Encode("role_mapping"); + + public override PutRoleMappingResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreated = default; + LocalJsonValue propRoleMapping = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + if (propRoleMapping.TryRead(ref reader, options, PropRoleMapping)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRoleMappingResponse + { + Created = propCreated.Value +, + RoleMapping = propRoleMapping.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRoleMappingResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteProperty(options, PropRoleMapping, value.RoleMapping); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRoleMappingResponseConverter))] public sealed partial class PutRoleMappingResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool? Created { get; init; } - [JsonInclude, JsonPropertyName("role_mapping")] public Elastic.Clients.Elasticsearch.Security.CreatedStatus RoleMapping { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs index 300912ec21c..b23064f00af 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleRequest.g.cs @@ -64,6 +64,14 @@ public PutRoleRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Req internal override string OperationName => "security.put_role"; + /// + /// + /// The name of the role that is being created or updated. On Elasticsearch Serverless, the role name must begin with a letter or digit and can only contain letters, digits and the characters '_', '-', and '.'. Each role must have a unique name, as this will serve as the identifier for that role. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("name"); set => PR("name", value); } + /// /// /// If true (the default) then refresh the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false then do nothing with refreshes. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs index 6c6b329cdb4..b0ce66de9d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutRoleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class PutRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRole = System.Text.Json.JsonEncodedText.Encode("role"); + + public override PutRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propRole = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRole.TryRead(ref reader, options, PropRole)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutRoleResponse + { + Role = propRole.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRole, value.Role); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutRoleResponseConverter))] public sealed partial class PutRoleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("role")] public Elastic.Clients.Elasticsearch.Security.CreatedStatus Role { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs index 5941437d1cc..b57d473d690 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/PutUserResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class PutUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreated = System.Text.Json.JsonEncodedText.Encode("created"); + + public override PutUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreated.TryRead(ref reader, options, PropCreated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutUserResponse + { + Created = propCreated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreated, value.Created); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutUserResponseConverter))] public sealed partial class PutUserResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("created")] public bool Created { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs index fdd42b6136d..33e90a24d00 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysRequest.g.cs @@ -55,98 +55,86 @@ public sealed partial class QueryApiKeysRequestParameters : RequestParameters public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } } -internal sealed partial class QueryApiKeysRequestConverter : JsonConverter +internal sealed partial class QueryApiKeysRequestConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryApiKeysRequest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryApiKeysRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new QueryApiKeysRequest(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, QueryApiKeysRequest value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Sort is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryApiKeysRequest { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + Aggregations = propAggregations.Value + , + From = propFrom.Value + , + Query = propQuery.Value + , + SearchAfter = propSearchAfter.Value + , + Size = propSize.Value + , + Sort = propSort.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryApiKeysRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); writer.WriteEndObject(); } } @@ -179,7 +167,6 @@ public QueryApiKeysRequest() /// Determines whether aggregation names are prefixed by their respective types in the response. /// /// - [JsonIgnore] public bool? TypedKeys { get => Q("typed_keys"); set => Q("typed_keys", value); } /// @@ -188,7 +175,6 @@ public QueryApiKeysRequest() /// An API key's actual permission is the intersection of its assigned role descriptors and the owner user's role descriptors. /// /// - [JsonIgnore] public bool? WithLimitedBy { get => Q("with_limited_by"); set => Q("with_limited_by", value); } /// @@ -196,7 +182,6 @@ public QueryApiKeysRequest() /// Determines whether to also retrieve the profile uid, for the API key owner principal, if it exists. /// /// - [JsonIgnore] public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } /// @@ -208,7 +193,6 @@ public QueryApiKeysRequest() /// Additionally, aggregations only run over the same subset of fields that query works with. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public IDictionary? Aggregations { get; set; } /// @@ -218,7 +202,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -231,7 +214,6 @@ public QueryApiKeysRequest() /// creation, expiration, invalidated, invalidation, username, realm, and metadata. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.ApiKeyQuery? Query { get; set; } /// @@ -239,7 +221,6 @@ public QueryApiKeysRequest() /// Search after definition /// /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -249,7 +230,6 @@ public QueryApiKeysRequest() /// To page through more hits, use the search_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -258,8 +238,6 @@ public QueryApiKeysRequest() /// In addition, sort can also be applied to the _doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs index 89b4746dbc8..37e4c1400f1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryApiKeysResponse.g.cs @@ -22,10 +22,76 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class QueryApiKeysResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropApiKeys = System.Text.Json.JsonEncodedText.Encode("api_keys"); + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override QueryApiKeysResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue> propApiKeys = default; + LocalJsonValue propCount = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propApiKeys.TryRead(ref reader, options, PropApiKeys)) + { + continue; + } + + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryApiKeysResponse + { + Aggregations = propAggregations.Value +, + ApiKeys = propApiKeys.Value +, + Count = propCount.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryApiKeysResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropApiKeys, value.ApiKeys); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryApiKeysResponseConverter))] public sealed partial class QueryApiKeysResponse : ElasticsearchResponse { /// @@ -33,7 +99,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The aggregations result, if requested. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } /// @@ -41,7 +106,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// A list of API key information. /// /// - [JsonInclude, JsonPropertyName("api_keys")] public IReadOnlyCollection ApiKeys { get; init; } /// @@ -49,7 +113,6 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The number of API keys returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -57,6 +120,5 @@ public sealed partial class QueryApiKeysResponse : ElasticsearchResponse /// The total number of API keys found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs index e55732256d7..ef600a8c4ca 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleRequest.g.cs @@ -34,6 +34,79 @@ public sealed partial class QueryRoleRequestParameters : RequestParameters { } +internal sealed partial class QueryRoleRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryRoleRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRoleRequest + { + From = propFrom.Value +, + Query = propQuery.Value +, + SearchAfter = propSearchAfter.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRoleRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteEndObject(); + } +} + /// /// /// Find roles with a query. @@ -42,6 +115,7 @@ public sealed partial class QueryRoleRequestParameters : RequestParameters /// Get roles in a paginated manner. You can optionally filter the results with a query. /// /// +[JsonConverter(typeof(QueryRoleRequestConverter))] public sealed partial class QueryRoleRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryRole; @@ -59,7 +133,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -72,7 +145,6 @@ public sealed partial class QueryRoleRequest : PlainRequestapplications.application, applications.privileges, applications.resources. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.RoleQuery? Query { get; set; } /// @@ -80,7 +152,6 @@ public sealed partial class QueryRoleRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -90,7 +161,6 @@ public sealed partial class QueryRoleRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -99,8 +169,6 @@ public sealed partial class QueryRoleRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs index dab72c52d73..1a456ba5225 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryRoleResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class QueryRoleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override QueryRoleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propRoles = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRoleResponse + { + Count = propCount.Value +, + Roles = propRoles.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRoleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRoleResponseConverter))] public sealed partial class QueryRoleResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The number of roles returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The list of roles. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection Roles { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class QueryRoleResponse : ElasticsearchResponse /// The total number of roles found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs index c5d98d22452..4153bd092d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserRequest.g.cs @@ -40,6 +40,79 @@ public sealed partial class QueryUserRequestParameters : RequestParameters public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } } +internal sealed partial class QueryUserRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override QueryUserRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFrom = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryUserRequest + { + From = propFrom.Value + , + Query = propQuery.Value + , + SearchAfter = propSearchAfter.Value + , + Size = propSize.Value + , + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryUserRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteEndObject(); + } +} + /// /// /// Find users with a query. @@ -49,6 +122,7 @@ public sealed partial class QueryUserRequestParameters : RequestParameters /// You can optionally filter the results with a query. /// /// +[JsonConverter(typeof(QueryUserRequestConverter))] public sealed partial class QueryUserRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityQueryUser; @@ -64,7 +138,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonIgnore] public bool? WithProfileUid { get => Q("with_profile_uid"); set => Q("with_profile_uid", value); } /// @@ -74,7 +147,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -86,7 +158,6 @@ public sealed partial class QueryUserRequest : PlainRequestusername, roles, enabled /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.Security.UserQuery? Query { get; set; } /// @@ -94,7 +165,6 @@ public sealed partial class QueryUserRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("search_after")] public ICollection? SearchAfter { get; set; } /// @@ -104,7 +174,6 @@ public sealed partial class QueryUserRequest : PlainRequestsearch_after parameter. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -113,8 +182,6 @@ public sealed partial class QueryUserRequest : PlainRequest_doc field to sort by index order. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs index 36090081fc3..9d36ab22377 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/QueryUserResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class QueryUserResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUsers = System.Text.Json.JsonEncodedText.Encode("users"); + + public override QueryUserResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue propTotal = default; + LocalJsonValue> propUsers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUsers.TryRead(ref reader, options, PropUsers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryUserResponse + { + Count = propCount.Value +, + Total = propTotal.Value +, + Users = propUsers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryUserResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUsers, value.Users); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryUserResponseConverter))] public sealed partial class QueryUserResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// The number of users returned in the response. /// /// - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// The total number of users found. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class QueryUserResponse : ElasticsearchResponse /// A list of user information. /// /// - [JsonInclude, JsonPropertyName("users")] public IReadOnlyCollection Users { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs index 563c505d691..676a54fd9ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlAuthenticateResponse.g.cs @@ -22,20 +22,91 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SamlAuthenticateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + private static readonly System.Text.Json.JsonEncodedText PropExpiresIn = System.Text.Json.JsonEncodedText.Encode("expires_in"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText PropUsername = System.Text.Json.JsonEncodedText.Encode("username"); + + public override SamlAuthenticateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAccessToken = default; + LocalJsonValue propExpiresIn = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRefreshToken = default; + LocalJsonValue propUsername = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccessToken.TryRead(ref reader, options, PropAccessToken)) + { + continue; + } + + if (propExpiresIn.TryRead(ref reader, options, PropExpiresIn)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRefreshToken.TryRead(ref reader, options, PropRefreshToken)) + { + continue; + } + + if (propUsername.TryRead(ref reader, options, PropUsername)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlAuthenticateResponse + { + AccessToken = propAccessToken.Value +, + ExpiresIn = propExpiresIn.Value +, + Realm = propRealm.Value +, + RefreshToken = propRefreshToken.Value +, + Username = propUsername.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlAuthenticateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccessToken, value.AccessToken); + writer.WriteProperty(options, PropExpiresIn, value.ExpiresIn); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRefreshToken, value.RefreshToken); + writer.WriteProperty(options, PropUsername, value.Username); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlAuthenticateResponseConverter))] public sealed partial class SamlAuthenticateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("access_token")] public string AccessToken { get; init; } - [JsonInclude, JsonPropertyName("expires_in")] public int ExpiresIn { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("refresh_token")] public string RefreshToken { get; init; } - [JsonInclude, JsonPropertyName("username")] public string Username { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs index afb8237ad22..63aa874e8b9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlInvalidateResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SamlInvalidateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropInvalidated = System.Text.Json.JsonEncodedText.Encode("invalidated"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlInvalidateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propInvalidated = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propInvalidated.TryRead(ref reader, options, PropInvalidated)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlInvalidateResponse + { + Invalidated = propInvalidated.Value +, + Realm = propRealm.Value +, + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlInvalidateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropInvalidated, value.Invalidated); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlInvalidateResponseConverter))] public sealed partial class SamlInvalidateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("invalidated")] public int Invalidated { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs index 07e111b2a2b..3708cb78faa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlLogoutResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SamlLogoutResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlLogoutResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlLogoutResponse + { + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlLogoutResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlLogoutResponseConverter))] public sealed partial class SamlLogoutResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs index dd6dd3b5d56..c32cd791fe5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlPrepareAuthenticationResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SamlPrepareAuthenticationResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropRealm = System.Text.Json.JsonEncodedText.Encode("realm"); + private static readonly System.Text.Json.JsonEncodedText PropRedirect = System.Text.Json.JsonEncodedText.Encode("redirect"); + + public override SamlPrepareAuthenticationResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propId = default; + LocalJsonValue propRealm = default; + LocalJsonValue propRedirect = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propRealm.TryRead(ref reader, options, PropRealm)) + { + continue; + } + + if (propRedirect.TryRead(ref reader, options, PropRedirect)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlPrepareAuthenticationResponse + { + Id = propId.Value +, + Realm = propRealm.Value +, + Redirect = propRedirect.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlPrepareAuthenticationResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropRealm, value.Realm); + writer.WriteProperty(options, PropRedirect, value.Redirect); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlPrepareAuthenticationResponseConverter))] public sealed partial class SamlPrepareAuthenticationResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("realm")] public string Realm { get; init; } - [JsonInclude, JsonPropertyName("redirect")] public string Redirect { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs index 009395c49bc..aa4135849a5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataRequest.g.cs @@ -55,6 +55,14 @@ public SamlServiceProviderMetadataRequest(Elastic.Clients.Elasticsearch.Name rea internal override bool SupportsBody => false; internal override string OperationName => "security.saml_service_provider_metadata"; + + /// + /// + /// The name of the SAML realm in Elasticsearch. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name RealmName { get => P("realm_name"); set => PR("realm_name", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs index b64c8776d95..08c3d78127e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SamlServiceProviderMetadataResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SamlServiceProviderMetadataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + + public override SamlServiceProviderMetadataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propMetadata = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMetadata.TryRead(ref reader, options, PropMetadata)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamlServiceProviderMetadataResponse + { + Metadata = propMetadata.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamlServiceProviderMetadataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMetadata, value.Metadata); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SamlServiceProviderMetadataResponseConverter))] public sealed partial class SamlServiceProviderMetadataResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("metadata")] public string Metadata { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs index c6596d47ecb..3f2c637bfad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesRequest.g.cs @@ -34,6 +34,69 @@ public sealed partial class SuggestUserProfilesRequestParameters : RequestParame { } +internal sealed partial class SuggestUserProfilesRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropHint = System.Text.Json.JsonEncodedText.Encode("hint"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override SuggestUserProfilesRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propData = default; + LocalJsonValue propHint = default; + LocalJsonValue propName = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propHint.TryRead(ref reader, options, PropHint)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SuggestUserProfilesRequest + { + Data = propData.Value +, + Hint = propHint.Value +, + Name = propName.Value +, + Size = propSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestUserProfilesRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropHint, value.Hint); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteEndObject(); + } +} + /// /// /// Suggest a user profile. @@ -42,6 +105,7 @@ public sealed partial class SuggestUserProfilesRequestParameters : RequestParame /// Get suggestions for user profiles that match specified search criteria. /// /// +[JsonConverter(typeof(SuggestUserProfilesRequestConverter))] public sealed partial class SuggestUserProfilesRequest : PlainRequest { internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySuggestUserProfiles; @@ -60,8 +124,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestdata content. /// /// - [JsonInclude, JsonPropertyName("data")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Data { get; set; } /// @@ -72,7 +134,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestname field query. /// /// - [JsonInclude, JsonPropertyName("hint")] public Elastic.Clients.Elasticsearch.Security.Hint? Hint { get; set; } /// @@ -81,7 +142,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequestusername, full_name, and email. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; set; } /// @@ -89,7 +149,6 @@ public sealed partial class SuggestUserProfilesRequest : PlainRequest /// - [JsonInclude, JsonPropertyName("size")] public long? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs index 9ab634abb11..3a0bf0847ac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/SuggestUserProfilesResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class SuggestUserProfilesResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropProfiles = System.Text.Json.JsonEncodedText.Encode("profiles"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override SuggestUserProfilesResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propProfiles = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propProfiles.TryRead(ref reader, options, PropProfiles)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SuggestUserProfilesResponse + { + Profiles = propProfiles.Value +, + Took = propTook.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestUserProfilesResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropProfiles, value.Profiles); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SuggestUserProfilesResponseConverter))] public sealed partial class SuggestUserProfilesResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("profiles")] public IReadOnlyCollection Profiles { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public Elastic.Clients.Elasticsearch.Security.TotalUserProfiles Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs index 15a488a199c..d3810404ba0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyRequest.g.cs @@ -68,6 +68,14 @@ public UpdateApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Re internal override string OperationName => "security.update_api_key"; + /// + /// + /// The ID of the API key to update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Expiration time for the API key. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs index ceeb922e33e..afed9d7d4dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateApiKeyResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class UpdateApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpdateApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateApiKeyResponse + { + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateApiKeyResponseConverter))] public sealed partial class UpdateApiKeyResponse : ElasticsearchResponse { /// @@ -34,6 +70,5 @@ public sealed partial class UpdateApiKeyResponse : ElasticsearchResponse /// If false, the API key didn’t change because no change was detected. /// /// - [JsonInclude, JsonPropertyName("updated")] public bool Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs index c93f01a473e..35b33d0b71f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyRequest.g.cs @@ -56,6 +56,14 @@ public UpdateCrossClusterApiKeyRequest(Elastic.Clients.Elasticsearch.Id id) : ba internal override string OperationName => "security.update_cross_cluster_api_key"; + /// + /// + /// The ID of the cross-cluster API key to update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The access to be granted to this API key. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs index d884f62166e..c557f01fdd6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateCrossClusterApiKeyResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class UpdateCrossClusterApiKeyResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpdateCrossClusterApiKeyResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateCrossClusterApiKeyResponse + { + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateCrossClusterApiKeyResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateCrossClusterApiKeyResponseConverter))] public sealed partial class UpdateCrossClusterApiKeyResponse : ElasticsearchResponse { /// @@ -34,6 +70,5 @@ public sealed partial class UpdateCrossClusterApiKeyResponse : ElasticsearchResp /// If false, the API key didn’t change because no change was detected. /// /// - [JsonInclude, JsonPropertyName("updated")] public bool Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs index 98048ccd890..d23dce832e2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataRequest.g.cs @@ -78,6 +78,14 @@ public UpdateUserProfileDataRequest(string uid) : base(r => r.Required("uid", ui internal override string OperationName => "security.update_user_profile_data"; + /// + /// + /// A unique identifier for the user profile. + /// + /// + [JsonIgnore] + public string Uid { get => P("uid"); set => PR("uid", value); } + /// /// /// Only perform the operation if the document has this primary term. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs index 1d47f41e31d..69198d28041 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Security/UpdateUserProfileDataResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Security; +internal sealed partial class UpdateUserProfileDataResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override UpdateUserProfileDataResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateUserProfileDataResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateUserProfileDataResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateUserProfileDataResponseConverter))] public sealed partial class UpdateUserProfileDataResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class UpdateUserProfileDataResponse : ElasticsearchRespons /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs index 3f7be7b5baa..3f5cac74727 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryRequest.g.cs @@ -67,6 +67,14 @@ public CleanupRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base( internal override string OperationName => "snapshot.cleanup_repository"; + /// + /// + /// Snapshot repository to clean up. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Period to wait for a connection to the master node. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs index 7a5a0dd0e26..e29082df520 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CleanupRepositoryResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class CleanupRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override CleanupRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CleanupRepositoryResponse + { + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CleanupRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CleanupRepositoryResponseConverter))] public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class CleanupRepositoryResponse : ElasticsearchResponse /// Statistics for cleanup operations. /// /// - [JsonInclude, JsonPropertyName("results")] public Elastic.Clients.Elasticsearch.Snapshot.CleanupRepositoryResults Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs index 69c10ac78c7..418a97087ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotRequest.g.cs @@ -61,6 +61,30 @@ public CloneSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elast internal override string OperationName => "snapshot.clone"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// The name of the snapshot to clone from + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + + /// + /// + /// The name of the cloned snapshot to create + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name TargetSnapshot { get => P("target_snapshot"); set => PR("target_snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs index 28a6abe2a04..7faf42a8139 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CloneSnapshotResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class CloneSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CloneSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CloneSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CloneSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CloneSnapshotResponseConverter))] public sealed partial class CloneSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class CloneSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs index bba5de0492f..e4ffc285006 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryRequest.g.cs @@ -62,7 +62,7 @@ public sealed partial class CreateRepositoryRequestParameters : RequestParameter /// Ensure there are no cluster blocks (for example, cluster.blocks.read_only and clsuter.blocks.read_only_allow_delete settings) that prevent write access. /// /// -public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfSerializable +public sealed partial class CreateRepositoryRequest : PlainRequest, ISelfTwoWaySerializable { public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("repository", name)) { @@ -76,6 +76,14 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "snapshot.create_repository"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node @@ -99,13 +107,17 @@ public CreateRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r /// [JsonIgnore] public bool? Verify { get => Q("verify"); set => Q("verify", value); } - [JsonIgnore] public Elastic.Clients.Elasticsearch.Snapshot.IRepository Repository { get; set; } - void ISelfSerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) + void ISelfTwoWaySerializable.Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings) { JsonSerializer.Serialize(writer, Repository, options); } + + void ISelfTwoWaySerializable.Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options, IElasticsearchClientSettings settings) + { + Repository = settings.RequestResponseSerializer.Deserialize(ref reader); + } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs index cfe979a738f..7a3785d146d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateRepositoryResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class CreateRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override CreateRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateRepositoryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateRepositoryResponseConverter))] public sealed partial class CreateRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class CreateRepositoryResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs index 974b6350300..1f92f9dbd90 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotRequest.g.cs @@ -67,6 +67,22 @@ public CreateSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas internal override string OperationName => "snapshot.create"; + /// + /// + /// Repository for the snapshot. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// Name of the snapshot. Must be unique in the repository. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs index 3afcb6e1a68..83a4d56552c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/CreateSnapshotResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class CreateSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccepted = System.Text.Json.JsonEncodedText.Encode("accepted"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override CreateSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAccepted = default; + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryRead(ref reader, options, PropAccepted)) + { + continue; + } + + if (propSnapshot.TryRead(ref reader, options, PropSnapshot)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CreateSnapshotResponse + { + Accepted = propAccepted.Value +, + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CreateSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccepted, value.Accepted); + writer.WriteProperty(options, PropSnapshot, value.Snapshot); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CreateSnapshotResponseConverter))] public sealed partial class CreateSnapshotResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class CreateSnapshotResponse : ElasticsearchResponse /// Equals true if the snapshot was accepted. Present when the request had wait_for_completion set to false /// /// - [JsonInclude, JsonPropertyName("accepted")] public bool? Accepted { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class CreateSnapshotResponse : ElasticsearchResponse /// Snapshot information. Present when the request had wait_for_completion set to true /// /// - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.Snapshot.SnapshotInfo? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs index bda787380fe..01db15725dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryRequest.g.cs @@ -68,6 +68,14 @@ public DeleteRepositoryRequest(Elastic.Clients.Elasticsearch.Names name) : base( internal override string OperationName => "snapshot.delete_repository"; + /// + /// + /// Name of the snapshot repository to unregister. Wildcard (*) patterns are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs index 0c043369220..ea58ff7e3c8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteRepositoryResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class DeleteRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteRepositoryResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteRepositoryResponseConverter))] public sealed partial class DeleteRepositoryResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteRepositoryResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs index 6b478e4cbff..49e6dc0963e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotRequest.g.cs @@ -59,6 +59,22 @@ public DeleteSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elas internal override string OperationName => "snapshot.delete"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// A comma-separated list of snapshot names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs index e1a69227318..470ea8ab12e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/DeleteSnapshotResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class DeleteSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSnapshotResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSnapshotResponseConverter))] public sealed partial class DeleteSnapshotResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteSnapshotResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs index a6279cf9d40..430c176983b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetRepositoryRequest.g.cs @@ -70,6 +70,14 @@ public GetRepositoryRequest(Elastic.Clients.Elasticsearch.Names? name) : base(r internal override string OperationName => "snapshot.get_repository"; + /// + /// + /// A comma-separated list of repository names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Name { get => P("repository"); set => PO("repository", value); } + /// /// /// Return local information, do not retrieve the state from master node (default: false) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs index a920c821cac..ea772fcd26f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotRequest.g.cs @@ -143,6 +143,34 @@ public GetSnapshotRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic internal override string OperationName => "snapshot.get"; + /// + /// + /// Comma-separated list of snapshot repository names used to limit the request. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// Comma-separated list of snapshot names to retrieve. Also accepts wildcards (*). + /// + /// + /// + /// + /// To get information about all snapshots in a registered repository, use a wildcard (*) or _all. + /// + /// + /// + /// + /// To get information about any snapshots that are currently running, use _current. + /// + /// + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Offset identifier to start pagination from as returned by the next field in the response body. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs index 929c06311cc..d9b77885564 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/GetSnapshotResponse.g.cs @@ -22,10 +22,76 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class GetSnapshotResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropRemaining = System.Text.Json.JsonEncodedText.Encode("remaining"); + private static readonly System.Text.Json.JsonEncodedText PropResponses = System.Text.Json.JsonEncodedText.Encode("responses"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshots = System.Text.Json.JsonEncodedText.Encode("snapshots"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override GetSnapshotResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propRemaining = default; + LocalJsonValue?> propResponses = default; + LocalJsonValue?> propSnapshots = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propRemaining.TryRead(ref reader, options, PropRemaining)) + { + continue; + } + + if (propResponses.TryRead(ref reader, options, PropResponses)) + { + continue; + } + + if (propSnapshots.TryRead(ref reader, options, PropSnapshots)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSnapshotResponse + { + Remaining = propRemaining.Value +, + Responses = propResponses.Value +, + Snapshots = propSnapshots.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSnapshotResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropRemaining, value.Remaining); + writer.WriteProperty(options, PropResponses, value.Responses); + writer.WriteProperty(options, PropSnapshots, value.Snapshots); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSnapshotResponseConverter))] public sealed partial class GetSnapshotResponse : ElasticsearchResponse { /// @@ -33,11 +99,8 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// The number of remaining snapshots that were not returned due to size limits and that can be fetched by additional requests using the next field value. /// /// - [JsonInclude, JsonPropertyName("remaining")] public int Remaining { get; init; } - [JsonInclude, JsonPropertyName("responses")] public IReadOnlyCollection? Responses { get; init; } - [JsonInclude, JsonPropertyName("snapshots")] public IReadOnlyCollection? Snapshots { get; init; } /// @@ -45,6 +108,5 @@ public sealed partial class GetSnapshotResponse : ElasticsearchResponse /// The total number of snapshots that match the request when ignoring size limit or after query parameter. /// /// - [JsonInclude, JsonPropertyName("total")] public int Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs index f48895454de..030e927f1de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RepositoryVerifyIntegrityRequest.g.cs @@ -163,6 +163,14 @@ public RepositoryVerifyIntegrityRequest(Elastic.Clients.Elasticsearch.Names name internal override string OperationName => "snapshot.repository_verify_integrity"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Number of threads to use for reading blob contents diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs index 73de6d5abec..cdc645d843c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreRequest.g.cs @@ -87,6 +87,22 @@ public RestoreRequest(Elastic.Clients.Elasticsearch.Name repository, Elastic.Cli internal override string OperationName => "snapshot.restore"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Repository { get => P("repository"); set => PR("repository", value); } + + /// + /// + /// A snapshot name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Snapshot { get => P("snapshot"); set => PR("snapshot", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs index 1bf5db7079d..8a8e1a9a448 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/RestoreResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class RestoreResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAccepted = System.Text.Json.JsonEncodedText.Encode("accepted"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshot = System.Text.Json.JsonEncodedText.Encode("snapshot"); + + public override RestoreResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAccepted = default; + LocalJsonValue propSnapshot = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAccepted.TryRead(ref reader, options, PropAccepted)) + { + continue; + } + + if (propSnapshot.TryRead(ref reader, options, PropSnapshot)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RestoreResponse + { + Accepted = propAccepted.Value +, + Snapshot = propSnapshot.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RestoreResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAccepted, value.Accepted); + writer.WriteProperty(options, PropSnapshot, value.Snapshot); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RestoreResponseConverter))] public sealed partial class RestoreResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("accepted")] public bool? Accepted { get; init; } - [JsonInclude, JsonPropertyName("snapshot")] public Elastic.Clients.Elasticsearch.Snapshot.SnapshotRestore? Snapshot { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs index 11e6df51119..507d3bfb21f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusRequest.g.cs @@ -86,6 +86,22 @@ public SnapshotStatusRequest(Elastic.Clients.Elasticsearch.Name? repository, Ela internal override string OperationName => "snapshot.status"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name? Repository { get => P("repository"); set => PO("repository", value); } + + /// + /// + /// A comma-separated list of snapshot names + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? Snapshot { get => P("snapshot"); set => PO("snapshot", value); } + /// /// /// Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs index e77aa967106..4ca9fd85965 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/SnapshotStatusResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class SnapshotStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshots = System.Text.Json.JsonEncodedText.Encode("snapshots"); + + public override SnapshotStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propSnapshots = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshots.TryRead(ref reader, options, PropSnapshots)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SnapshotStatusResponse + { + Snapshots = propSnapshots.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshots, value.Snapshots); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SnapshotStatusResponseConverter))] public sealed partial class SnapshotStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshots")] public IReadOnlyCollection Snapshots { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs index e6100f9e2f9..a35a4836803 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryRequest.g.cs @@ -67,6 +67,14 @@ public VerifyRepositoryRequest(Elastic.Clients.Elasticsearch.Name name) : base(r internal override string OperationName => "snapshot.verify_repository"; + /// + /// + /// A repository name + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name Name { get => P("repository"); set => PR("repository", value); } + /// /// /// Explicit operation timeout for connection to master node diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs index 8ebe48523d7..0f372b69e21 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Snapshot/VerifyRepositoryResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Snapshot; +internal sealed partial class VerifyRepositoryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override VerifyRepositoryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VerifyRepositoryResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, VerifyRepositoryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VerifyRepositoryResponseConverter))] public sealed partial class VerifyRepositoryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs index e50ac965692..e9fc3fb6022 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleRequest.g.cs @@ -54,6 +54,14 @@ public DeleteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : bas internal override bool SupportsBody => false; internal override string OperationName => "slm.delete_lifecycle"; + + /// + /// + /// The id of the snapshot lifecycle policy to remove + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs index ca9286d517a..04637ef1401 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/DeleteLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class DeleteLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteLifecycleResponseConverter))] public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs index 46c763acd3a..2f6088e9068 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleRequest.g.cs @@ -54,6 +54,14 @@ public ExecuteLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : ba internal override bool SupportsBody => false; internal override string OperationName => "slm.execute_lifecycle"; + + /// + /// + /// The id of the snapshot lifecycle policy to be executed + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs index ef39b567457..2993e31c40a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteLifecycleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class ExecuteLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSnapshotName = System.Text.Json.JsonEncodedText.Encode("snapshot_name"); + + public override ExecuteLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propSnapshotName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSnapshotName.TryRead(ref reader, options, PropSnapshotName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecuteLifecycleResponse + { + SnapshotName = propSnapshotName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecuteLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSnapshotName, value.SnapshotName); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecuteLifecycleResponseConverter))] public sealed partial class ExecuteLifecycleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("snapshot_name")] public string SnapshotName { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs index 42e6e3e5727..45dfaf7d13e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/ExecuteRetentionResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class ExecuteRetentionResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ExecuteRetentionResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExecuteRetentionResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExecuteRetentionResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ExecuteRetentionResponseConverter))] public sealed partial class ExecuteRetentionResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ExecuteRetentionResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs index e647bd33bb8..c9c04429606 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetLifecycleRequest.g.cs @@ -57,6 +57,14 @@ public GetLifecycleRequest(Elastic.Clients.Elasticsearch.Names? policyId) : base internal override bool SupportsBody => false; internal override string OperationName => "slm.get_lifecycle"; + + /// + /// + /// Comma-separated list of snapshot lifecycle policies to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? PolicyId { get => P("policy_id"); set => PO("policy_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs index c2cc6418284..60ca1126a74 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetSlmStatusResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class GetSlmStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropOperationMode = System.Text.Json.JsonEncodedText.Encode("operation_mode"); + + public override GetSlmStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propOperationMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propOperationMode.TryRead(ref reader, options, PropOperationMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSlmStatusResponse + { + OperationMode = propOperationMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSlmStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropOperationMode, value.OperationMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSlmStatusResponseConverter))] public sealed partial class GetSlmStatusResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("operation_mode")] public Elastic.Clients.Elasticsearch.LifecycleOperationMode OperationMode { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs index 7174da48a8a..dff9f132dd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/GetStatsResponse.g.cs @@ -22,30 +22,146 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class GetStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropPolicyStats = System.Text.Json.JsonEncodedText.Encode("policy_stats"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionDeletionTime = System.Text.Json.JsonEncodedText.Encode("retention_deletion_time"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionDeletionTimeMillis = System.Text.Json.JsonEncodedText.Encode("retention_deletion_time_millis"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionFailed = System.Text.Json.JsonEncodedText.Encode("retention_failed"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionRuns = System.Text.Json.JsonEncodedText.Encode("retention_runs"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionTimedOut = System.Text.Json.JsonEncodedText.Encode("retention_timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotDeletionFailures = System.Text.Json.JsonEncodedText.Encode("total_snapshot_deletion_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsDeleted = System.Text.Json.JsonEncodedText.Encode("total_snapshots_deleted"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsFailed = System.Text.Json.JsonEncodedText.Encode("total_snapshots_failed"); + private static readonly System.Text.Json.JsonEncodedText PropTotalSnapshotsTaken = System.Text.Json.JsonEncodedText.Encode("total_snapshots_taken"); + + public override GetStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propPolicyStats = default; + LocalJsonValue propRetentionDeletionTime = default; + LocalJsonValue propRetentionDeletionTimeMillis = default; + LocalJsonValue propRetentionFailed = default; + LocalJsonValue propRetentionRuns = default; + LocalJsonValue propRetentionTimedOut = default; + LocalJsonValue propTotalSnapshotDeletionFailures = default; + LocalJsonValue propTotalSnapshotsDeleted = default; + LocalJsonValue propTotalSnapshotsFailed = default; + LocalJsonValue propTotalSnapshotsTaken = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propPolicyStats.TryRead(ref reader, options, PropPolicyStats)) + { + continue; + } + + if (propRetentionDeletionTime.TryRead(ref reader, options, PropRetentionDeletionTime)) + { + continue; + } + + if (propRetentionDeletionTimeMillis.TryRead(ref reader, options, PropRetentionDeletionTimeMillis)) + { + continue; + } + + if (propRetentionFailed.TryRead(ref reader, options, PropRetentionFailed)) + { + continue; + } + + if (propRetentionRuns.TryRead(ref reader, options, PropRetentionRuns)) + { + continue; + } + + if (propRetentionTimedOut.TryRead(ref reader, options, PropRetentionTimedOut)) + { + continue; + } + + if (propTotalSnapshotDeletionFailures.TryRead(ref reader, options, PropTotalSnapshotDeletionFailures)) + { + continue; + } + + if (propTotalSnapshotsDeleted.TryRead(ref reader, options, PropTotalSnapshotsDeleted)) + { + continue; + } + + if (propTotalSnapshotsFailed.TryRead(ref reader, options, PropTotalSnapshotsFailed)) + { + continue; + } + + if (propTotalSnapshotsTaken.TryRead(ref reader, options, PropTotalSnapshotsTaken)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetStatsResponse + { + PolicyStats = propPolicyStats.Value +, + RetentionDeletionTime = propRetentionDeletionTime.Value +, + RetentionDeletionTimeMillis = propRetentionDeletionTimeMillis.Value +, + RetentionFailed = propRetentionFailed.Value +, + RetentionRuns = propRetentionRuns.Value +, + RetentionTimedOut = propRetentionTimedOut.Value +, + TotalSnapshotDeletionFailures = propTotalSnapshotDeletionFailures.Value +, + TotalSnapshotsDeleted = propTotalSnapshotsDeleted.Value +, + TotalSnapshotsFailed = propTotalSnapshotsFailed.Value +, + TotalSnapshotsTaken = propTotalSnapshotsTaken.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropPolicyStats, value.PolicyStats); + writer.WriteProperty(options, PropRetentionDeletionTime, value.RetentionDeletionTime); + writer.WriteProperty(options, PropRetentionDeletionTimeMillis, value.RetentionDeletionTimeMillis); + writer.WriteProperty(options, PropRetentionFailed, value.RetentionFailed); + writer.WriteProperty(options, PropRetentionRuns, value.RetentionRuns); + writer.WriteProperty(options, PropRetentionTimedOut, value.RetentionTimedOut); + writer.WriteProperty(options, PropTotalSnapshotDeletionFailures, value.TotalSnapshotDeletionFailures); + writer.WriteProperty(options, PropTotalSnapshotsDeleted, value.TotalSnapshotsDeleted); + writer.WriteProperty(options, PropTotalSnapshotsFailed, value.TotalSnapshotsFailed); + writer.WriteProperty(options, PropTotalSnapshotsTaken, value.TotalSnapshotsTaken); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetStatsResponseConverter))] public sealed partial class GetStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("policy_stats")] public IReadOnlyCollection PolicyStats { get; init; } - [JsonInclude, JsonPropertyName("retention_deletion_time")] public Elastic.Clients.Elasticsearch.Duration RetentionDeletionTime { get; init; } - [JsonInclude, JsonPropertyName("retention_deletion_time_millis")] public long RetentionDeletionTimeMillis { get; init; } - [JsonInclude, JsonPropertyName("retention_failed")] public long RetentionFailed { get; init; } - [JsonInclude, JsonPropertyName("retention_runs")] public long RetentionRuns { get; init; } - [JsonInclude, JsonPropertyName("retention_timed_out")] public long RetentionTimedOut { get; init; } - [JsonInclude, JsonPropertyName("total_snapshot_deletion_failures")] public long TotalSnapshotDeletionFailures { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_deleted")] public long TotalSnapshotsDeleted { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_failed")] public long TotalSnapshotsFailed { get; init; } - [JsonInclude, JsonPropertyName("total_snapshots_taken")] public long TotalSnapshotsTaken { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs index 865a2baf563..6b26fb13f40 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleRequest.g.cs @@ -69,6 +69,14 @@ public PutLifecycleRequest(Elastic.Clients.Elasticsearch.Name policyId) : base(r internal override string OperationName => "slm.put_lifecycle"; + /// + /// + /// The identifier for the snapshot lifecycle policy you want to create or update. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name PolicyId { get => P("policy_id"); set => PR("policy_id", value); } + /// /// /// Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs index e9eaecf826f..9d7732e21c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/PutLifecycleResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class PutLifecycleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutLifecycleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutLifecycleResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutLifecycleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutLifecycleResponseConverter))] public sealed partial class PutLifecycleResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutLifecycleResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs index 8ebc963e7ac..4757d16131b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StartSlmResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class StartSlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartSlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartSlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartSlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartSlmResponseConverter))] public sealed partial class StartSlmResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StartSlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs index c7f3fd2cc66..b39ef6a48e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SnapshotLifecycleManagement/StopSlmResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.SnapshotLifecycleManagement; +internal sealed partial class StopSlmResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopSlmResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopSlmResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopSlmResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopSlmResponseConverter))] public sealed partial class StopSlmResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StopSlmResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs index a57592eeeb5..c0c5de1a775 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/ClearCursorResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class ClearCursorResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSucceeded = System.Text.Json.JsonEncodedText.Encode("succeeded"); + + public override ClearCursorResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propSucceeded = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSucceeded.TryRead(ref reader, options, PropSucceeded)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ClearCursorResponse + { + Succeeded = propSucceeded.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClearCursorResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSucceeded, value.Succeeded); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ClearCursorResponseConverter))] public sealed partial class ClearCursorResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("succeeded")] public bool Succeeded { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs index d306d8916d2..8dfe3236b17 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncRequest.g.cs @@ -54,6 +54,14 @@ public DeleteAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Req internal override bool SupportsBody => false; internal override string OperationName => "sql.delete_async"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs index 29fa3e3e14d..6fe8f34db9a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/DeleteAsyncResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class DeleteAsyncResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteAsyncResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteAsyncResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAsyncResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteAsyncResponseConverter))] public sealed partial class DeleteAsyncResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteAsyncResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs index a725dcd4bd3..5f74f32156b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncRequest.g.cs @@ -84,6 +84,14 @@ public GetAsyncRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requir internal override string OperationName => "sql.get_async"; + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Separator for CSV results. The API only supports this parameter for CSV responses. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs index 9762bd7bd96..f2a2cc9abb5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class GetAsyncResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropColumns = System.Text.Json.JsonEncodedText.Encode("columns"); + private static readonly System.Text.Json.JsonEncodedText PropCursor = System.Text.Json.JsonEncodedText.Encode("cursor"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + + public override GetAsyncResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propColumns = default; + LocalJsonValue propCursor = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryRead(ref reader, options, PropColumns)) + { + continue; + } + + if (propCursor.TryRead(ref reader, options, PropCursor)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncResponse + { + Columns = propColumns.Value +, + Cursor = propCursor.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropColumns, value.Columns); + writer.WriteProperty(options, PropCursor, value.Cursor); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncResponseConverter))] public sealed partial class GetAsyncResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// Column headings for the search results. Each object is a column. /// /// - [JsonInclude, JsonPropertyName("columns")] public IReadOnlyCollection? Columns { get; init; } /// @@ -42,7 +117,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// TXT responses, this value is returned in the Cursor HTTP header. /// /// - [JsonInclude, JsonPropertyName("cursor")] public string? Cursor { get; init; } /// @@ -52,7 +126,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -64,7 +137,6 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// For CSV, TSV, and TXT responses, this value is returned in the Async-partial HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -75,6 +147,5 @@ public sealed partial class GetAsyncResponse : ElasticsearchResponse /// HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs index cd754c0e812..7ac55eca13c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusRequest.g.cs @@ -53,6 +53,14 @@ public GetAsyncStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r. internal override bool SupportsBody => false; internal override string OperationName => "sql.get_async_status"; + + /// + /// + /// Identifier for the search. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs index 8dd9a09e22b..b59c156f57a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/GetAsyncStatusResponse.g.cs @@ -22,10 +22,96 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class GetAsyncStatusResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status"); + private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + + public override GetAsyncStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompletionStatus = default; + LocalJsonValue propExpirationTimeInMillis = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + LocalJsonValue propStartTimeInMillis = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus)) + { + continue; + } + + if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetAsyncStatusResponse + { + CompletionStatus = propCompletionStatus.Value +, + ExpirationTimeInMillis = propExpirationTimeInMillis.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value +, + StartTimeInMillis = propStartTimeInMillis.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetAsyncStatusResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus); + writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetAsyncStatusResponseConverter))] public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse { /// @@ -33,7 +119,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// HTTP status code for the search. The API only returns this property for completed searches. /// /// - [JsonInclude, JsonPropertyName("completion_status")] public int? CompletionStatus { get; init; } /// @@ -42,7 +127,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// the search and its results, even if the search is still running. /// /// - [JsonInclude, JsonPropertyName("expiration_time_in_millis")] public long ExpirationTimeInMillis { get; init; } /// @@ -50,7 +134,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// Identifier for the search. /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -61,7 +144,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// timeout. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool IsPartial { get; init; } /// @@ -69,7 +151,6 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// If true, the search is still running. If false, the search has finished. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool IsRunning { get; init; } /// @@ -78,6 +159,5 @@ public sealed partial class GetAsyncStatusResponse : ElasticsearchResponse /// The API only returns this property for running searches. /// /// - [JsonInclude, JsonPropertyName("start_time_in_millis")] public long StartTimeInMillis { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs index 68a8c3c72ca..802575f87f2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/QueryResponse.g.cs @@ -22,10 +22,86 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class QueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropColumns = System.Text.Json.JsonEncodedText.Encode("columns"); + private static readonly System.Text.Json.JsonEncodedText PropCursor = System.Text.Json.JsonEncodedText.Encode("cursor"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial"); + private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running"); + + public override QueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propColumns = default; + LocalJsonValue propCursor = default; + LocalJsonValue propId = default; + LocalJsonValue propIsPartial = default; + LocalJsonValue propIsRunning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propColumns.TryRead(ref reader, options, PropColumns)) + { + continue; + } + + if (propCursor.TryRead(ref reader, options, PropCursor)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIsPartial.TryRead(ref reader, options, PropIsPartial)) + { + continue; + } + + if (propIsRunning.TryRead(ref reader, options, PropIsRunning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryResponse + { + Columns = propColumns.Value +, + Cursor = propCursor.Value +, + Id = propId.Value +, + IsPartial = propIsPartial.Value +, + IsRunning = propIsRunning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropColumns, value.Columns); + writer.WriteProperty(options, PropCursor, value.Cursor); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIsPartial, value.IsPartial); + writer.WriteProperty(options, PropIsRunning, value.IsRunning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryResponseConverter))] public sealed partial class QueryResponse : ElasticsearchResponse { /// @@ -33,7 +109,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// Column headings for the search results. Each object is a column. /// /// - [JsonInclude, JsonPropertyName("columns")] public IReadOnlyCollection? Columns { get; init; } /// @@ -42,7 +117,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// TXT responses, this value is returned in the Cursor HTTP header. /// /// - [JsonInclude, JsonPropertyName("cursor")] public string? Cursor { get; init; } /// @@ -52,7 +126,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// in the Async-ID HTTP header. /// /// - [JsonInclude, JsonPropertyName("id")] public string? Id { get; init; } /// @@ -64,7 +137,6 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// For CSV, TSV, and TXT responses, this value is returned in the Async-partial HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_partial")] public bool? IsPartial { get; init; } /// @@ -75,6 +147,5 @@ public sealed partial class QueryResponse : ElasticsearchResponse /// HTTP header. /// /// - [JsonInclude, JsonPropertyName("is_running")] public bool? IsRunning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs index 583441e33fb..478b51051a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Sql/TranslateResponse.g.cs @@ -22,23 +22,102 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Sql; +internal sealed partial class TranslateResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override TranslateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TranslateResponse + { + Aggregations = propAggregations.Value +, + Fields = propFields.Value +, + Query = propQuery.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TranslateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TranslateResponseConverter))] public sealed partial class TranslateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregations")] public IReadOnlyDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyCollection? Fields { get; init; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; init; } - [JsonInclude, JsonPropertyName("size")] public long? Size { get; init; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public IReadOnlyCollection? Sort { get; init; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs index 8468d27085d..76e7d8d7ccc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRequest.g.cs @@ -52,6 +52,14 @@ public DeleteSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.R internal override bool SupportsBody => false; internal override string OperationName => "synonyms.delete_synonym"; + + /// + /// + /// The id of the synonyms set to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs index 484ef271a05..cdac7820786 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class DeleteSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSynonymResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymResponseConverter))] public sealed partial class DeleteSynonymResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteSynonymResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs index 9bc1264b7ef..64e1e4745c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleRequest.g.cs @@ -53,6 +53,22 @@ public DeleteSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic. internal override bool SupportsBody => false; internal override string OperationName => "synonyms.delete_synonym_rule"; + + /// + /// + /// The id of the synonym rule to be deleted + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to be updated + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs index 7a128cafa53..0818e1a6885 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/DeleteSynonymRuleResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class DeleteSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override DeleteSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteSynonymRuleResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteSynonymRuleResponseConverter))] public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +80,6 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +87,5 @@ public sealed partial class DeleteSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs index 4a03450e469..dbd1be6e524 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRequest.g.cs @@ -66,6 +66,14 @@ public GetSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requ internal override string OperationName => "synonyms.get_synonym"; + /// + /// + /// "The id of the synonyms set to be retrieved + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// Starting offset for query rules to be retrieved diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs index e61b17766d2..63e65839198 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class GetSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropSynonymsSet = System.Text.Json.JsonEncodedText.Encode("synonyms_set"); + + public override GetSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propSynonymsSet.TryRead(ref reader, options, PropSynonymsSet)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymResponse + { + Count = propCount.Value +, + SynonymsSet = propSynonymsSet.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropSynonymsSet, value.SynonymsSet); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymResponseConverter))] public sealed partial class GetSynonymResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } - [JsonInclude, JsonPropertyName("synonyms_set")] public IReadOnlyCollection SynonymsSet { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs index 55894c24e13..8cb1f5b6333 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleRequest.g.cs @@ -53,6 +53,22 @@ public GetSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli internal override bool SupportsBody => false; internal override string OperationName => "synonyms.get_synonym_rule"; + + /// + /// + /// The id of the synonym rule to retrieve + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to retrieve the synonym rule from + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs index a6fc0854ce0..bbc558e00ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymRuleResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class GetSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropSynonyms = System.Text.Json.JsonEncodedText.Encode("synonyms"); + + public override GetSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propId = default; + LocalJsonValue propSynonyms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propSynonyms.TryRead(ref reader, options, PropSynonyms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymRuleResponse + { + Id = propId.Value +, + Synonyms = propSynonyms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropSynonyms, value.Synonyms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymRuleResponseConverter))] public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse { /// @@ -33,7 +79,6 @@ public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse /// Synonym Rule identifier /// /// - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } /// @@ -41,6 +86,5 @@ public sealed partial class GetSynonymRuleResponse : ElasticsearchResponse /// Synonyms, in Solr format, that conform the synonym rule. See https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-synonym-graph-tokenfilter.html#_solr_synonyms_2 /// /// - [JsonInclude, JsonPropertyName("synonyms")] public string Synonyms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs index 62143e3725b..9028ca23db5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/GetSynonymsSetsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class GetSynonymsSetsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropResults = System.Text.Json.JsonEncodedText.Encode("results"); + + public override GetSynonymsSetsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propResults = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propResults.TryRead(ref reader, options, PropResults)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetSynonymsSetsResponse + { + Count = propCount.Value +, + Results = propResults.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetSynonymsSetsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropResults, value.Results); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetSynonymsSetsResponseConverter))] public sealed partial class GetSynonymsSetsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public int Count { get; init; } - [JsonInclude, JsonPropertyName("results")] public IReadOnlyCollection Results { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs index ebde087aa42..e3339db8751 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRequest.g.cs @@ -34,6 +34,39 @@ public sealed partial class PutSynonymRequestParameters : RequestParameters { } +internal sealed partial class PutSynonymRequestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropSynonymsSet = System.Text.Json.JsonEncodedText.Encode("synonyms_set"); + + public override PutSynonymRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propSynonymsSet = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propSynonymsSet.TryRead(ref reader, options, PropSynonymsSet, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Synonyms.SynonymRule>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymRequest + { + SynonymsSet = propSynonymsSet.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropSynonymsSet, value.SynonymsSet, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Synonyms.SynonymRule>)); + writer.WriteEndObject(); + } +} + /// /// /// Create or update a synonym set. @@ -41,6 +74,7 @@ public sealed partial class PutSynonymRequestParameters : RequestParameters /// If you need to manage more synonym rules, you can create multiple synonym sets. /// /// +[JsonConverter(typeof(PutSynonymRequestConverter))] public sealed partial class PutSynonymRequest : PlainRequest { public PutSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("id", id)) @@ -55,13 +89,18 @@ public PutSynonymRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.Requ internal override string OperationName => "synonyms.put_synonym"; + /// + /// + /// The id of the synonyms set to be created or updated + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + /// /// /// The synonym set information to update /// /// - [JsonInclude, JsonPropertyName("synonyms_set")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Synonyms.SynonymRule))] public ICollection SynonymsSet { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs index 21b5b6c1093..b7a8bc93d04 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class PutSynonymResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSynonymResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymResponseConverter))] public sealed partial class PutSynonymResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs index 30b670af3d5..1025dae6a0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleRequest.g.cs @@ -54,6 +54,21 @@ public PutSynonymRuleRequest(Elastic.Clients.Elasticsearch.Id setId, Elastic.Cli internal override string OperationName => "synonyms.put_synonym_rule"; + /// + /// + /// The id of the synonym rule to be updated or created + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id RuleId { get => P("rule_id"); set => PR("rule_id", value); } + + /// + /// + /// The id of the synonym set to be updated with the synonym rule + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id SetId { get => P("set_id"); set => PR("set_id", value); } [JsonInclude, JsonPropertyName("synonyms")] public string Synonyms { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs index 652aebc8333..d0818807025 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Synonyms/PutSynonymRuleResponse.g.cs @@ -22,10 +22,56 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Synonyms; +internal sealed partial class PutSynonymRuleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropReloadAnalyzersDetails = System.Text.Json.JsonEncodedText.Encode("reload_analyzers_details"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + + public override PutSynonymRuleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propReloadAnalyzersDetails = default; + LocalJsonValue propResult = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propReloadAnalyzersDetails.TryRead(ref reader, options, PropReloadAnalyzersDetails)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutSynonymRuleResponse + { + ReloadAnalyzersDetails = propReloadAnalyzersDetails.Value +, + Result = propResult.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutSynonymRuleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropReloadAnalyzersDetails, value.ReloadAnalyzersDetails); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutSynonymRuleResponseConverter))] public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse { /// @@ -34,7 +80,6 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// This is the analyzers reloading result /// /// - [JsonInclude, JsonPropertyName("reload_analyzers_details")] public Elastic.Clients.Elasticsearch.IndexManagement.ReloadResult ReloadAnalyzersDetails { get; init; } /// @@ -42,6 +87,5 @@ public sealed partial class PutSynonymRuleResponse : ElasticsearchResponse /// Update operation result /// /// - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs index ecf9f2c38c1..ade170064f5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelRequest.g.cs @@ -92,6 +92,14 @@ public CancelRequest(Elastic.Clients.Elasticsearch.TaskId? taskId) : base(r => r internal override string OperationName => "tasks.cancel"; + /// + /// + /// ID of the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.TaskId? TaskId { get => P("task_id"); set => PO("task_id", value); } + /// /// /// Comma-separated list or wildcard expression of actions used to limit the request. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs index 42734dac9ee..4efc3a9b024 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/CancelResponse.g.cs @@ -22,13 +22,78 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class CancelResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodeFailures = System.Text.Json.JsonEncodedText.Encode("node_failures"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override CancelResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryRead(ref reader, options, PropNodeFailures)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propTaskFailures.TryRead(ref reader, options, PropTaskFailures)) + { + continue; + } + + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CancelResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CancelResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CancelResponseConverter))] public sealed partial class CancelResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +101,7 @@ public sealed partial class CancelResponse : ElasticsearchResponse /// Task information grouped by node, if group_by was set to node (the default). /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary? Nodes { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } /// @@ -47,6 +110,5 @@ public sealed partial class CancelResponse : ElasticsearchResponse /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs index 543a2fadcd0..e4d24a0bfc8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksRequest.g.cs @@ -68,6 +68,14 @@ public GetTasksRequest(Elastic.Clients.Elasticsearch.Id taskId) : base(r => r.Re internal override string OperationName => "tasks.get"; + /// + /// + /// ID of the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// Period to wait for a response. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs index cd9c953e47f..81d6dc2445e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/GetTasksResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class GetTasksResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCompleted = System.Text.Json.JsonEncodedText.Encode("completed"); + private static readonly System.Text.Json.JsonEncodedText PropError = System.Text.Json.JsonEncodedText.Encode("error"); + private static readonly System.Text.Json.JsonEncodedText PropResponse = System.Text.Json.JsonEncodedText.Encode("response"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + + public override GetTasksResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCompleted = default; + LocalJsonValue propError = default; + LocalJsonValue propResponse = default; + LocalJsonValue propTask = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCompleted.TryRead(ref reader, options, PropCompleted)) + { + continue; + } + + if (propError.TryRead(ref reader, options, PropError)) + { + continue; + } + + if (propResponse.TryRead(ref reader, options, PropResponse)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTasksResponse + { + Completed = propCompleted.Value +, + Error = propError.Value +, + Response = propResponse.Value +, + Task = propTask.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTasksResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCompleted, value.Completed); + writer.WriteProperty(options, PropError, value.Error); + writer.WriteProperty(options, PropResponse, value.Response); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTasksResponseConverter))] public sealed partial class GetTasksResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("completed")] public bool Completed { get; init; } - [JsonInclude, JsonPropertyName("error")] public Elastic.Clients.Elasticsearch.ErrorCause? Error { get; init; } - [JsonInclude, JsonPropertyName("response")] public object? Response { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfo Task { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs index 6eec10fe844..56cbced4ec6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Tasks/ListResponse.g.cs @@ -22,13 +22,78 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Tasks; +internal sealed partial class ListResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodeFailures = System.Text.Json.JsonEncodedText.Encode("node_failures"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropTaskFailures = System.Text.Json.JsonEncodedText.Encode("task_failures"); + private static readonly System.Text.Json.JsonEncodedText PropTasks = System.Text.Json.JsonEncodedText.Encode("tasks"); + + public override ListResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propNodeFailures = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propTaskFailures = default; + LocalJsonValue propTasks = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodeFailures.TryRead(ref reader, options, PropNodeFailures)) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propTaskFailures.TryRead(ref reader, options, PropTaskFailures)) + { + continue; + } + + if (propTasks.TryRead(ref reader, options, PropTasks)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ListResponse + { + NodeFailures = propNodeFailures.Value +, + Nodes = propNodes.Value +, + TaskFailures = propTaskFailures.Value +, + Tasks = propTasks.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ListResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodeFailures, value.NodeFailures); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropTaskFailures, value.TaskFailures); + writer.WriteProperty(options, PropTasks, value.Tasks); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ListResponseConverter))] public sealed partial class ListResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("node_failures")] public IReadOnlyCollection? NodeFailures { get; init; } /// @@ -36,9 +101,7 @@ public sealed partial class ListResponse : ElasticsearchResponse /// Task information grouped by node, if group_by was set to node (the default). /// /// - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary? Nodes { get; init; } - [JsonInclude, JsonPropertyName("task_failures")] public IReadOnlyCollection? TaskFailures { get; init; } /// @@ -47,6 +110,5 @@ public sealed partial class ListResponse : ElasticsearchResponse /// group_by was set to parents. /// /// - [JsonInclude, JsonPropertyName("tasks")] public Elastic.Clients.Elasticsearch.Tasks.TaskInfos? Tasks { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs index f9052ff3303..38ee6a2857a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsRequest.g.cs @@ -112,6 +112,76 @@ public sealed partial class TermVectorsRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } } +internal sealed partial class TermVectorsRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropPerFieldAnalyzer = System.Text.Json.JsonEncodedText.Encode("per_field_analyzer"); + + public override TermVectorsRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDoc = default; + LocalJsonValue propFilter = default; + LocalJsonValue?> propPerFieldAnalyzer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc, typeof(SourceMarker))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propPerFieldAnalyzer.TryRead(ref reader, options, PropPerFieldAnalyzer)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermVectorsRequest + { + Doc = propDoc.Value + , + Filter = propFilter.Value + , + PerFieldAnalyzer = propPerFieldAnalyzer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorsRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropPerFieldAnalyzer, value.PerFieldAnalyzer); + writer.WriteEndObject(); + } +} + +internal sealed partial class TermVectorsRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(TermVectorsRequest<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(TermVectorsRequestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Get term vector information. @@ -120,6 +190,7 @@ public sealed partial class TermVectorsRequestParameters : RequestParameters /// Get information and statistics about terms in the fields of a particular document. /// /// +[JsonConverter(typeof(TermVectorsRequestConverterFactory))] public sealed partial class TermVectorsRequest : PlainRequest { public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id? id) : base(r => r.Required("index", index).Optional("id", id)) @@ -138,13 +209,26 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( internal override string OperationName => "termvectors"; + /// + /// + /// Unique identifier of the document. + /// + /// + public Elastic.Clients.Elasticsearch.Id? Id { get => P("id"); set => PO("id", value); } + + /// + /// + /// Name of the index that contains the document. + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Comma-separated list or wildcard expressions of fields to include in the statistics. /// Used as the default list unless a specific field list is provided in the completion_fields or fielddata_fields parameters. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? Fields { get => Q("fields"); set => Q("fields", value); } /// @@ -152,7 +236,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes the document count, sum of document frequencies, and sum of total term frequencies. /// /// - [JsonIgnore] public bool? FieldStatistics { get => Q("field_statistics"); set => Q("field_statistics", value); } /// @@ -160,7 +243,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term offsets. /// /// - [JsonIgnore] public bool? Offsets { get => Q("offsets"); set => Q("offsets", value); } /// @@ -168,7 +250,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term payloads. /// /// - [JsonIgnore] public bool? Payloads { get => Q("payloads"); set => Q("payloads", value); } /// @@ -176,7 +257,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term positions. /// /// - [JsonIgnore] public bool? Positions { get => Q("positions"); set => Q("positions", value); } /// @@ -185,7 +265,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Random by default. /// /// - [JsonIgnore] public string? Preference { get => Q("preference"); set => Q("preference", value); } /// @@ -193,7 +272,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the request is real-time as opposed to near-real-time. /// /// - [JsonIgnore] public bool? Realtime { get => Q("realtime"); set => Q("realtime", value); } /// @@ -201,7 +279,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -209,7 +286,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, the response includes term frequency and document frequency. /// /// - [JsonIgnore] public bool? TermStatistics { get => Q("term_statistics"); set => Q("term_statistics", value); } /// @@ -217,7 +293,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// If true, returns the document version as part of a hit. /// /// - [JsonIgnore] public long? Version { get => Q("version"); set => Q("version", value); } /// @@ -225,7 +300,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Specific version type. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get => Q("version_type"); set => Q("version_type", value); } /// @@ -233,8 +307,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// An artificial document (a document not present in the index) for which you want to retrieve term vectors. /// /// - [JsonInclude, JsonPropertyName("doc")] - [SourceConverter] public TDocument? Doc { get; set; } /// @@ -242,7 +314,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Core.TermVectors.Filter? Filter { get; set; } /// @@ -250,7 +321,6 @@ public TermVectorsRequest(Elastic.Clients.Elasticsearch.IndexName index) : base( /// Overrides the default per-field analyzer. /// /// - [JsonInclude, JsonPropertyName("per_field_analyzer")] public IDictionary? PerFieldAnalyzer { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs index 530b3a6d741..5324bd9a3ba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermVectorsResponse.g.cs @@ -22,23 +22,102 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class TermVectorsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropTermVectors = System.Text.Json.JsonEncodedText.Encode("term_vectors"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override TermVectorsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propTermVectors = default; + LocalJsonValue propTook = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propTermVectors.TryRead(ref reader, options, PropTermVectors)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermVectorsResponse + { + Found = propFound.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + TermVectors = propTermVectors.Value +, + Took = propTook.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropTermVectors, value.TermVectors); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermVectorsResponseConverter))] public sealed partial class TermVectorsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("term_vectors")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Core.TermVectors.TermVector))] public IReadOnlyDictionary? TermVectors { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs index 60b90b70370..c22fb3754b5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumRequest.g.cs @@ -64,6 +64,14 @@ public TermsEnumRequest(Elastic.Clients.Elasticsearch.IndexName index) : base(r internal override string OperationName => "terms_enum"; + /// + /// + /// Comma-separated list of data streams, indices, and index aliases to search. Wildcard (*) expressions are supported. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// When true the provided search string is matched against index terms without case sensitivity. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs index 0c18094311e..d754077288e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TermsEnumResponse.g.cs @@ -22,16 +22,69 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class TermsEnumResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropComplete = System.Text.Json.JsonEncodedText.Encode("complete"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override TermsEnumResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propComplete = default; + LocalJsonValue propShards = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propComplete.TryRead(ref reader, options, PropComplete)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsEnumResponse + { + Complete = propComplete.Value +, + Shards = propShards.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsEnumResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropComplete, value.Complete); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropTerms, value.Terms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsEnumResponseConverter))] public sealed partial class TermsEnumResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("complete")] public bool Complete { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("terms")] public IReadOnlyCollection Terms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs index 432ca254f96..0ce873cd3a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindFieldStructureResponse.g.cs @@ -22,41 +22,201 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TextStructure; +internal sealed partial class FindFieldStructureResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharset = System.Text.Json.JsonEncodedText.Encode("charset"); + private static readonly System.Text.Json.JsonEncodedText PropEcsCompatibility = System.Text.Json.JsonEncodedText.Encode("ecs_compatibility"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStats = System.Text.Json.JsonEncodedText.Encode("field_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGrokPattern = System.Text.Json.JsonEncodedText.Encode("grok_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropIngestPipeline = System.Text.Json.JsonEncodedText.Encode("ingest_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropJavaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("java_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropJodaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("joda_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropMultilineStartPattern = System.Text.Json.JsonEncodedText.Encode("multiline_start_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropNeedClientTimezone = System.Text.Json.JsonEncodedText.Encode("need_client_timezone"); + private static readonly System.Text.Json.JsonEncodedText PropNumLinesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_lines_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropNumMessagesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_messages_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropSampleStart = System.Text.Json.JsonEncodedText.Encode("sample_start"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override FindFieldStructureResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCharset = default; + LocalJsonValue propEcsCompatibility = default; + LocalJsonValue> propFieldStats = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGrokPattern = default; + LocalJsonValue propIngestPipeline = default; + LocalJsonValue?> propJavaTimestampFormats = default; + LocalJsonValue?> propJodaTimestampFormats = default; + LocalJsonValue propMappings = default; + LocalJsonValue propMultilineStartPattern = default; + LocalJsonValue propNeedClientTimezone = default; + LocalJsonValue propNumLinesAnalyzed = default; + LocalJsonValue propNumMessagesAnalyzed = default; + LocalJsonValue propSampleStart = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharset.TryRead(ref reader, options, PropCharset)) + { + continue; + } + + if (propEcsCompatibility.TryRead(ref reader, options, PropEcsCompatibility)) + { + continue; + } + + if (propFieldStats.TryRead(ref reader, options, PropFieldStats)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propGrokPattern.TryRead(ref reader, options, PropGrokPattern)) + { + continue; + } + + if (propIngestPipeline.TryRead(ref reader, options, PropIngestPipeline)) + { + continue; + } + + if (propJavaTimestampFormats.TryRead(ref reader, options, PropJavaTimestampFormats)) + { + continue; + } + + if (propJodaTimestampFormats.TryRead(ref reader, options, PropJodaTimestampFormats)) + { + continue; + } + + if (propMappings.TryRead(ref reader, options, PropMappings)) + { + continue; + } + + if (propMultilineStartPattern.TryRead(ref reader, options, PropMultilineStartPattern)) + { + continue; + } + + if (propNeedClientTimezone.TryRead(ref reader, options, PropNeedClientTimezone)) + { + continue; + } + + if (propNumLinesAnalyzed.TryRead(ref reader, options, PropNumLinesAnalyzed)) + { + continue; + } + + if (propNumMessagesAnalyzed.TryRead(ref reader, options, PropNumMessagesAnalyzed)) + { + continue; + } + + if (propSampleStart.TryRead(ref reader, options, PropSampleStart)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FindFieldStructureResponse + { + Charset = propCharset.Value +, + EcsCompatibility = propEcsCompatibility.Value +, + FieldStats = propFieldStats.Value +, + Format = propFormat.Value +, + GrokPattern = propGrokPattern.Value +, + IngestPipeline = propIngestPipeline.Value +, + JavaTimestampFormats = propJavaTimestampFormats.Value +, + JodaTimestampFormats = propJodaTimestampFormats.Value +, + Mappings = propMappings.Value +, + MultilineStartPattern = propMultilineStartPattern.Value +, + NeedClientTimezone = propNeedClientTimezone.Value +, + NumLinesAnalyzed = propNumLinesAnalyzed.Value +, + NumMessagesAnalyzed = propNumMessagesAnalyzed.Value +, + SampleStart = propSampleStart.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FindFieldStructureResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharset, value.Charset); + writer.WriteProperty(options, PropEcsCompatibility, value.EcsCompatibility); + writer.WriteProperty(options, PropFieldStats, value.FieldStats); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGrokPattern, value.GrokPattern); + writer.WriteProperty(options, PropIngestPipeline, value.IngestPipeline); + writer.WriteProperty(options, PropJavaTimestampFormats, value.JavaTimestampFormats); + writer.WriteProperty(options, PropJodaTimestampFormats, value.JodaTimestampFormats); + writer.WriteProperty(options, PropMappings, value.Mappings); + writer.WriteProperty(options, PropMultilineStartPattern, value.MultilineStartPattern); + writer.WriteProperty(options, PropNeedClientTimezone, value.NeedClientTimezone); + writer.WriteProperty(options, PropNumLinesAnalyzed, value.NumLinesAnalyzed); + writer.WriteProperty(options, PropNumMessagesAnalyzed, value.NumMessagesAnalyzed); + writer.WriteProperty(options, PropSampleStart, value.SampleStart); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FindFieldStructureResponseConverter))] public sealed partial class FindFieldStructureResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("charset")] public string Charset { get; init; } - [JsonInclude, JsonPropertyName("ecs_compatibility")] public Elastic.Clients.Elasticsearch.TextStructure.EcsCompatibilityType? EcsCompatibility { get; init; } - [JsonInclude, JsonPropertyName("field_stats")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.TextStructure.FieldStat))] public IReadOnlyDictionary FieldStats { get; init; } - [JsonInclude, JsonPropertyName("format")] public Elastic.Clients.Elasticsearch.TextStructure.FormatType Format { get; init; } - [JsonInclude, JsonPropertyName("grok_pattern")] public string? GrokPattern { get; init; } - [JsonInclude, JsonPropertyName("ingest_pipeline")] public Elastic.Clients.Elasticsearch.Ingest.PipelineConfig IngestPipeline { get; init; } - [JsonInclude, JsonPropertyName("java_timestamp_formats")] public IReadOnlyCollection? JavaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("joda_timestamp_formats")] public IReadOnlyCollection? JodaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } - [JsonInclude, JsonPropertyName("multiline_start_pattern")] public string? MultilineStartPattern { get; init; } - [JsonInclude, JsonPropertyName("need_client_timezone")] public bool NeedClientTimezone { get; init; } - [JsonInclude, JsonPropertyName("num_lines_analyzed")] public int NumLinesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("num_messages_analyzed")] public int NumMessagesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("sample_start")] public string SampleStart { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string? TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs index 922ef596371..6382dd97508 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/FindMessageStructureResponse.g.cs @@ -22,41 +22,201 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TextStructure; +internal sealed partial class FindMessageStructureResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharset = System.Text.Json.JsonEncodedText.Encode("charset"); + private static readonly System.Text.Json.JsonEncodedText PropEcsCompatibility = System.Text.Json.JsonEncodedText.Encode("ecs_compatibility"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStats = System.Text.Json.JsonEncodedText.Encode("field_stats"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGrokPattern = System.Text.Json.JsonEncodedText.Encode("grok_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropIngestPipeline = System.Text.Json.JsonEncodedText.Encode("ingest_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropJavaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("java_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropJodaTimestampFormats = System.Text.Json.JsonEncodedText.Encode("joda_timestamp_formats"); + private static readonly System.Text.Json.JsonEncodedText PropMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText PropMultilineStartPattern = System.Text.Json.JsonEncodedText.Encode("multiline_start_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropNeedClientTimezone = System.Text.Json.JsonEncodedText.Encode("need_client_timezone"); + private static readonly System.Text.Json.JsonEncodedText PropNumLinesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_lines_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropNumMessagesAnalyzed = System.Text.Json.JsonEncodedText.Encode("num_messages_analyzed"); + private static readonly System.Text.Json.JsonEncodedText PropSampleStart = System.Text.Json.JsonEncodedText.Encode("sample_start"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override FindMessageStructureResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCharset = default; + LocalJsonValue propEcsCompatibility = default; + LocalJsonValue> propFieldStats = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGrokPattern = default; + LocalJsonValue propIngestPipeline = default; + LocalJsonValue?> propJavaTimestampFormats = default; + LocalJsonValue?> propJodaTimestampFormats = default; + LocalJsonValue propMappings = default; + LocalJsonValue propMultilineStartPattern = default; + LocalJsonValue propNeedClientTimezone = default; + LocalJsonValue propNumLinesAnalyzed = default; + LocalJsonValue propNumMessagesAnalyzed = default; + LocalJsonValue propSampleStart = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharset.TryRead(ref reader, options, PropCharset)) + { + continue; + } + + if (propEcsCompatibility.TryRead(ref reader, options, PropEcsCompatibility)) + { + continue; + } + + if (propFieldStats.TryRead(ref reader, options, PropFieldStats)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propGrokPattern.TryRead(ref reader, options, PropGrokPattern)) + { + continue; + } + + if (propIngestPipeline.TryRead(ref reader, options, PropIngestPipeline)) + { + continue; + } + + if (propJavaTimestampFormats.TryRead(ref reader, options, PropJavaTimestampFormats)) + { + continue; + } + + if (propJodaTimestampFormats.TryRead(ref reader, options, PropJodaTimestampFormats)) + { + continue; + } + + if (propMappings.TryRead(ref reader, options, PropMappings)) + { + continue; + } + + if (propMultilineStartPattern.TryRead(ref reader, options, PropMultilineStartPattern)) + { + continue; + } + + if (propNeedClientTimezone.TryRead(ref reader, options, PropNeedClientTimezone)) + { + continue; + } + + if (propNumLinesAnalyzed.TryRead(ref reader, options, PropNumLinesAnalyzed)) + { + continue; + } + + if (propNumMessagesAnalyzed.TryRead(ref reader, options, PropNumMessagesAnalyzed)) + { + continue; + } + + if (propSampleStart.TryRead(ref reader, options, PropSampleStart)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FindMessageStructureResponse + { + Charset = propCharset.Value +, + EcsCompatibility = propEcsCompatibility.Value +, + FieldStats = propFieldStats.Value +, + Format = propFormat.Value +, + GrokPattern = propGrokPattern.Value +, + IngestPipeline = propIngestPipeline.Value +, + JavaTimestampFormats = propJavaTimestampFormats.Value +, + JodaTimestampFormats = propJodaTimestampFormats.Value +, + Mappings = propMappings.Value +, + MultilineStartPattern = propMultilineStartPattern.Value +, + NeedClientTimezone = propNeedClientTimezone.Value +, + NumLinesAnalyzed = propNumLinesAnalyzed.Value +, + NumMessagesAnalyzed = propNumMessagesAnalyzed.Value +, + SampleStart = propSampleStart.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FindMessageStructureResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharset, value.Charset); + writer.WriteProperty(options, PropEcsCompatibility, value.EcsCompatibility); + writer.WriteProperty(options, PropFieldStats, value.FieldStats); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGrokPattern, value.GrokPattern); + writer.WriteProperty(options, PropIngestPipeline, value.IngestPipeline); + writer.WriteProperty(options, PropJavaTimestampFormats, value.JavaTimestampFormats); + writer.WriteProperty(options, PropJodaTimestampFormats, value.JodaTimestampFormats); + writer.WriteProperty(options, PropMappings, value.Mappings); + writer.WriteProperty(options, PropMultilineStartPattern, value.MultilineStartPattern); + writer.WriteProperty(options, PropNeedClientTimezone, value.NeedClientTimezone); + writer.WriteProperty(options, PropNumLinesAnalyzed, value.NumLinesAnalyzed); + writer.WriteProperty(options, PropNumMessagesAnalyzed, value.NumMessagesAnalyzed); + writer.WriteProperty(options, PropSampleStart, value.SampleStart); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FindMessageStructureResponseConverter))] public sealed partial class FindMessageStructureResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("charset")] public string Charset { get; init; } - [JsonInclude, JsonPropertyName("ecs_compatibility")] public Elastic.Clients.Elasticsearch.TextStructure.EcsCompatibilityType? EcsCompatibility { get; init; } - [JsonInclude, JsonPropertyName("field_stats")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.TextStructure.FieldStat))] public IReadOnlyDictionary FieldStats { get; init; } - [JsonInclude, JsonPropertyName("format")] public Elastic.Clients.Elasticsearch.TextStructure.FormatType Format { get; init; } - [JsonInclude, JsonPropertyName("grok_pattern")] public string? GrokPattern { get; init; } - [JsonInclude, JsonPropertyName("ingest_pipeline")] public Elastic.Clients.Elasticsearch.Ingest.PipelineConfig IngestPipeline { get; init; } - [JsonInclude, JsonPropertyName("java_timestamp_formats")] public IReadOnlyCollection? JavaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("joda_timestamp_formats")] public IReadOnlyCollection? JodaTimestampFormats { get; init; } - [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } - [JsonInclude, JsonPropertyName("multiline_start_pattern")] public string? MultilineStartPattern { get; init; } - [JsonInclude, JsonPropertyName("need_client_timezone")] public bool NeedClientTimezone { get; init; } - [JsonInclude, JsonPropertyName("num_lines_analyzed")] public int NumLinesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("num_messages_analyzed")] public int NumMessagesAnalyzed { get; init; } - [JsonInclude, JsonPropertyName("sample_start")] public string SampleStart { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string? TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs index 50646b97f83..de3219b396f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TextStructure/TestGrokPatternResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TextStructure; +internal sealed partial class TestGrokPatternResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMatches = System.Text.Json.JsonEncodedText.Encode("matches"); + + public override TestGrokPatternResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propMatches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMatches.TryRead(ref reader, options, PropMatches)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TestGrokPatternResponse + { + Matches = propMatches.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TestGrokPatternResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMatches, value.Matches); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TestGrokPatternResponseConverter))] public sealed partial class TestGrokPatternResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("matches")] public IReadOnlyCollection Matches { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs index 4c99c8484f9..b9c0ed6f2ed 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformRequest.g.cs @@ -76,6 +76,14 @@ public DeleteTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba internal override string OperationName => "transform.delete_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// If this value is true, the destination index is deleted together with the transform. If false, the destination diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs index afcb0daed68..e398fa50f70 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/DeleteTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class DeleteTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override DeleteTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DeleteTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DeleteTransformResponseConverter))] public sealed partial class DeleteTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class DeleteTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs index c5d4152ca6b..62ee0940b32 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformRequest.g.cs @@ -108,6 +108,17 @@ public GetTransformRequest(Elastic.Clients.Elasticsearch.Names? transformId) : b internal override string OperationName => "transform.get_transform"; + /// + /// + /// Identifier for the transform. It can be a transform identifier or a + /// wildcard expression. You can get information for all transforms by using + /// _all, by specifying * as the <transform_id>, or by omitting the + /// <transform_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names? TransformId { get => P("transform_id"); set => PO("transform_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs index a9ade3c0e06..fb779eb0aff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class GetTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTransforms = System.Text.Json.JsonEncodedText.Encode("transforms"); + + public override GetTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTransforms.TryRead(ref reader, options, PropTransforms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTransformResponse + { + Count = propCount.Value +, + Transforms = propTransforms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTransforms, value.Transforms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTransformResponseConverter))] public sealed partial class GetTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("transforms")] public IReadOnlyCollection Transforms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs index bfd538ede2c..ee7283d7c59 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsRequest.g.cs @@ -102,6 +102,17 @@ public GetTransformStatsRequest(Elastic.Clients.Elasticsearch.Names transformId) internal override string OperationName => "transform.get_transform_stats"; + /// + /// + /// Identifier for the transform. It can be a transform identifier or a + /// wildcard expression. You can get information for all transforms by using + /// _all, by specifying * as the <transform_id>, or by omitting the + /// <transform_id>. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Names TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Specifies what to do when the request: diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs index 463e3808c08..6d37d60ce98 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/GetTransformStatsResponse.g.cs @@ -22,14 +22,58 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class GetTransformStatsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCount = System.Text.Json.JsonEncodedText.Encode("count"); + private static readonly System.Text.Json.JsonEncodedText PropTransforms = System.Text.Json.JsonEncodedText.Encode("transforms"); + + public override GetTransformStatsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCount = default; + LocalJsonValue> propTransforms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCount.TryRead(ref reader, options, PropCount)) + { + continue; + } + + if (propTransforms.TryRead(ref reader, options, PropTransforms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetTransformStatsResponse + { + Count = propCount.Value +, + Transforms = propTransforms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetTransformStatsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCount, value.Count); + writer.WriteProperty(options, PropTransforms, value.Transforms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GetTransformStatsResponseConverter))] public sealed partial class GetTransformStatsResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } - [JsonInclude, JsonPropertyName("transforms")] public IReadOnlyCollection Transforms { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs index c9dd9773b16..5ab7aea2b2b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformRequest.g.cs @@ -70,6 +70,15 @@ public PreviewTransformRequest(Elastic.Clients.Elasticsearch.Id? transformId) : internal override string OperationName => "transform.preview_transform"; + /// + /// + /// Identifier for the transform to preview. If you specify this path parameter, you cannot provide transform + /// configuration details in the request body. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id? TransformId { get => P("transform_id"); set => PO("transform_id", value); } + /// /// /// Period to wait for a response. If no response is received before the diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs index 3deeb3c40ce..cc7ccae85ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PreviewTransformResponse.g.cs @@ -22,14 +22,75 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class PreviewTransformResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropGeneratedDestIndex = System.Text.Json.JsonEncodedText.Encode("generated_dest_index"); + private static readonly System.Text.Json.JsonEncodedText PropPreview = System.Text.Json.JsonEncodedText.Encode("preview"); + + public override PreviewTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propGeneratedDestIndex = default; + LocalJsonValue> propPreview = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propGeneratedDestIndex.TryRead(ref reader, options, PropGeneratedDestIndex)) + { + continue; + } + + if (propPreview.TryRead(ref reader, options, PropPreview)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PreviewTransformResponse + { + GeneratedDestIndex = propGeneratedDestIndex.Value +, + Preview = propPreview.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PreviewTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropGeneratedDestIndex, value.GeneratedDestIndex); + writer.WriteProperty(options, PropPreview, value.Preview); + writer.WriteEndObject(); + } +} + +internal sealed partial class PreviewTransformResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(PreviewTransformResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(PreviewTransformResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(PreviewTransformResponseConverterFactory))] public sealed partial class PreviewTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("generated_dest_index")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexState GeneratedDestIndex { get; init; } - [JsonInclude, JsonPropertyName("preview")] public IReadOnlyCollection Preview { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs index 7572393a22f..c8e67ffa417 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformRequest.g.cs @@ -95,6 +95,15 @@ public PutTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : base( internal override string OperationName => "transform.put_transform"; + /// + /// + /// Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// When the transform is created, a series of validations occur to ensure its success. For example, there is a diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs index 10f7f7ec4f7..42e492cd873 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/PutTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class PutTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override PutTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PutTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PutTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PutTransformResponseConverter))] public sealed partial class PutTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class PutTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs index bbe3236f756..d672167f1c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformRequest.g.cs @@ -63,6 +63,15 @@ public ResetTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas internal override string OperationName => "transform.reset_transform"; + /// + /// + /// Identifier for the transform. This identifier can contain lowercase alphanumeric characters (a-z and 0-9), + /// hyphens, and underscores. It has a 64 character limit and must start and end with alphanumeric characters. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// If this value is true, the transform is reset regardless of its current state. If it's false, the transform diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs index fa10ee989c7..7eb1ab5e08e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ResetTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class ResetTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ResetTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResetTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResetTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResetTransformResponseConverter))] public sealed partial class ResetTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ResetTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs index b77da029d31..95768284d67 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformRequest.g.cs @@ -66,6 +66,14 @@ public ScheduleNowTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) internal override string OperationName => "transform.schedule_now_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Controls the time to wait for the scheduling to take place diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs index 93f527a6b0c..31502a304b0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/ScheduleNowTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class ScheduleNowTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override ScheduleNowTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScheduleNowTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScheduleNowTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ScheduleNowTransformResponseConverter))] public sealed partial class ScheduleNowTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class ScheduleNowTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs index c13718c4ae6..e41528c0ef2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformRequest.g.cs @@ -84,6 +84,14 @@ public StartTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : bas internal override string OperationName => "transform.start_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Restricts the set of transformed entities to those changed after this time. Relative times like now-30d are supported. Only applicable for continuous transforms. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs index 04f75c1be41..36a10702d88 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StartTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class StartTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StartTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StartTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StartTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StartTransformResponseConverter))] public sealed partial class StartTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StartTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs index 83c77465a31..89eace6e770 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformRequest.g.cs @@ -101,6 +101,15 @@ public StopTransformRequest(Elastic.Clients.Elasticsearch.Name transformId) : ba internal override string OperationName => "transform.stop_transform"; + /// + /// + /// Identifier for the transform. To stop multiple transforms, use a comma-separated list or a wildcard expression. + /// To stop all transforms, use _all or * as the identifier. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Name TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs index 05fbc4e6609..2112b44ffd6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/StopTransformResponse.g.cs @@ -22,10 +22,46 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class StopTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged"); + + public override StopTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAcknowledged = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTransformResponse + { + Acknowledged = propAcknowledged.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAcknowledged, value.Acknowledged); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTransformResponseConverter))] public sealed partial class StopTransformResponse : ElasticsearchResponse { /// @@ -33,6 +69,5 @@ public sealed partial class StopTransformResponse : ElasticsearchResponse /// For a successful response, this value is always true. On failure, an exception is returned instead. /// /// - [JsonInclude, JsonPropertyName("acknowledged")] public bool Acknowledged { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs index bc612418057..74197d79b3e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformRequest.g.cs @@ -77,6 +77,14 @@ public UpdateTransformRequest(Elastic.Clients.Elasticsearch.Id transformId) : ba internal override string OperationName => "transform.update_transform"; + /// + /// + /// Identifier for the transform. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TransformId { get => P("transform_id"); set => PR("transform_id", value); } + /// /// /// When true, deferrable validations are not run. This behavior may be diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs index 0dda6e4d96f..18f5fbf322d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpdateTransformResponse.g.cs @@ -22,38 +22,190 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class UpdateTransformResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropCreateTime = System.Text.Json.JsonEncodedText.Encode("create_time"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDest = System.Text.Json.JsonEncodedText.Encode("dest"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id"); + private static readonly System.Text.Json.JsonEncodedText PropLatest = System.Text.Json.JsonEncodedText.Encode("latest"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropPivot = System.Text.Json.JsonEncodedText.Encode("pivot"); + private static readonly System.Text.Json.JsonEncodedText PropRetentionPolicy = System.Text.Json.JsonEncodedText.Encode("retention_policy"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("source"); + private static readonly System.Text.Json.JsonEncodedText PropSync = System.Text.Json.JsonEncodedText.Encode("sync"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override UpdateTransformResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAuthorization = default; + LocalJsonValue propCreateTime = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDest = default; + LocalJsonValue propFrequency = default; + LocalJsonValue propId = default; + LocalJsonValue propLatest = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPivot = default; + LocalJsonValue propRetentionPolicy = default; + LocalJsonValue propSettings = default; + LocalJsonValue propSource = default; + LocalJsonValue propSync = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propCreateTime.TryRead(ref reader, options, PropCreateTime)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDest.TryRead(ref reader, options, PropDest)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propLatest.TryRead(ref reader, options, PropLatest)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPivot.TryRead(ref reader, options, PropPivot)) + { + continue; + } + + if (propRetentionPolicy.TryRead(ref reader, options, PropRetentionPolicy)) + { + continue; + } + + if (propSettings.TryRead(ref reader, options, PropSettings)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propSync.TryRead(ref reader, options, PropSync)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateTransformResponse + { + Authorization = propAuthorization.Value +, + CreateTime = propCreateTime.Value +, + Description = propDescription.Value +, + Dest = propDest.Value +, + Frequency = propFrequency.Value +, + Id = propId.Value +, + Latest = propLatest.Value +, + Meta = propMeta.Value +, + Pivot = propPivot.Value +, + RetentionPolicy = propRetentionPolicy.Value +, + Settings = propSettings.Value +, + Source = propSource.Value +, + Sync = propSync.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateTransformResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropCreateTime, value.CreateTime); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDest, value.Dest); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropLatest, value.Latest); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPivot, value.Pivot); + writer.WriteProperty(options, PropRetentionPolicy, value.RetentionPolicy); + writer.WriteProperty(options, PropSettings, value.Settings); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropSync, value.Sync); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateTransformResponseConverter))] public sealed partial class UpdateTransformResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("authorization")] public Elastic.Clients.Elasticsearch.MachineLearning.TransformAuthorization? Authorization { get; init; } - [JsonInclude, JsonPropertyName("create_time")] public long CreateTime { get; init; } - [JsonInclude, JsonPropertyName("description")] public string Description { get; init; } - [JsonInclude, JsonPropertyName("dest")] public Elastic.Clients.Elasticsearch.Core.Reindex.Destination Dest { get; init; } - [JsonInclude, JsonPropertyName("frequency")] public Elastic.Clients.Elasticsearch.Duration? Frequency { get; init; } - [JsonInclude, JsonPropertyName("id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("latest")] public Elastic.Clients.Elasticsearch.TransformManagement.Latest? Latest { get; init; } - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } - [JsonInclude, JsonPropertyName("pivot")] public Elastic.Clients.Elasticsearch.TransformManagement.Pivot? Pivot { get; init; } - [JsonInclude, JsonPropertyName("retention_policy")] public Elastic.Clients.Elasticsearch.TransformManagement.RetentionPolicy? RetentionPolicy { get; init; } - [JsonInclude, JsonPropertyName("settings")] public Elastic.Clients.Elasticsearch.TransformManagement.Settings Settings { get; init; } - [JsonInclude, JsonPropertyName("source")] public Elastic.Clients.Elasticsearch.Core.Reindex.Source Source { get; init; } - [JsonInclude, JsonPropertyName("sync")] public Elastic.Clients.Elasticsearch.TransformManagement.Sync? Sync { get; init; } - [JsonInclude, JsonPropertyName("version")] public string Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs index d2e39135530..08b3bea5d99 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/TransformManagement/UpgradeTransformsResponse.g.cs @@ -22,10 +22,66 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.TransformManagement; +internal sealed partial class UpgradeTransformsResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNeedsUpdate = System.Text.Json.JsonEncodedText.Encode("needs_update"); + private static readonly System.Text.Json.JsonEncodedText PropNoAction = System.Text.Json.JsonEncodedText.Encode("no_action"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + + public override UpgradeTransformsResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNeedsUpdate = default; + LocalJsonValue propNoAction = default; + LocalJsonValue propUpdated = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNeedsUpdate.TryRead(ref reader, options, PropNeedsUpdate)) + { + continue; + } + + if (propNoAction.TryRead(ref reader, options, PropNoAction)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpgradeTransformsResponse + { + NeedsUpdate = propNeedsUpdate.Value +, + NoAction = propNoAction.Value +, + Updated = propUpdated.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpgradeTransformsResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNeedsUpdate, value.NeedsUpdate); + writer.WriteProperty(options, PropNoAction, value.NoAction); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpgradeTransformsResponseConverter))] public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse { /// @@ -33,7 +89,6 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that need to be upgraded. /// /// - [JsonInclude, JsonPropertyName("needs_update")] public int NeedsUpdate { get; init; } /// @@ -41,7 +96,6 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that don’t require upgrading. /// /// - [JsonInclude, JsonPropertyName("no_action")] public int NoAction { get; init; } /// @@ -49,6 +103,5 @@ public sealed partial class UpgradeTransformsResponse : ElasticsearchResponse /// The number of transforms that have been upgraded. /// /// - [JsonInclude, JsonPropertyName("updated")] public int Updated { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs index 26842bb705f..ea9e399e521 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRequest.g.cs @@ -272,6 +272,16 @@ public UpdateByQueryRequest(Elastic.Clients.Elasticsearch.Indices indices) : bas internal override string OperationName => "update_by_query"; + /// + /// + /// Comma-separated list of data streams, indices, and aliases to search. + /// Supports wildcards (*). + /// To search all data streams or indices, omit this parameter or use * or _all. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Indices Indices { get => P("index"); set => PR("index", value); } + /// /// /// If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs index c08f04aa435..6fa9e5671f9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryResponse.g.cs @@ -22,42 +22,212 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class UpdateByQueryResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBatches = System.Text.Json.JsonEncodedText.Encode("batches"); + private static readonly System.Text.Json.JsonEncodedText PropDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText PropFailures = System.Text.Json.JsonEncodedText.Encode("failures"); + private static readonly System.Text.Json.JsonEncodedText PropNoops = System.Text.Json.JsonEncodedText.Encode("noops"); + private static readonly System.Text.Json.JsonEncodedText PropRequestsPerSecond = System.Text.Json.JsonEncodedText.Encode("requests_per_second"); + private static readonly System.Text.Json.JsonEncodedText PropRetries = System.Text.Json.JsonEncodedText.Encode("retries"); + private static readonly System.Text.Json.JsonEncodedText PropTask = System.Text.Json.JsonEncodedText.Encode("task"); + private static readonly System.Text.Json.JsonEncodedText PropThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledMillis = System.Text.Json.JsonEncodedText.Encode("throttled_millis"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntil = System.Text.Json.JsonEncodedText.Encode("throttled_until"); + private static readonly System.Text.Json.JsonEncodedText PropThrottledUntilMillis = System.Text.Json.JsonEncodedText.Encode("throttled_until_millis"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText PropUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText PropVersionConflicts = System.Text.Json.JsonEncodedText.Encode("version_conflicts"); + + public override UpdateByQueryResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBatches = default; + LocalJsonValue propDeleted = default; + LocalJsonValue?> propFailures = default; + LocalJsonValue propNoops = default; + LocalJsonValue propRequestsPerSecond = default; + LocalJsonValue propRetries = default; + LocalJsonValue propTask = default; + LocalJsonValue propThrottled = default; + LocalJsonValue propThrottledMillis = default; + LocalJsonValue propThrottledUntil = default; + LocalJsonValue propThrottledUntilMillis = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + LocalJsonValue propTotal = default; + LocalJsonValue propUpdated = default; + LocalJsonValue propVersionConflicts = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBatches.TryRead(ref reader, options, PropBatches)) + { + continue; + } + + if (propDeleted.TryRead(ref reader, options, PropDeleted)) + { + continue; + } + + if (propFailures.TryRead(ref reader, options, PropFailures)) + { + continue; + } + + if (propNoops.TryRead(ref reader, options, PropNoops)) + { + continue; + } + + if (propRequestsPerSecond.TryRead(ref reader, options, PropRequestsPerSecond)) + { + continue; + } + + if (propRetries.TryRead(ref reader, options, PropRetries)) + { + continue; + } + + if (propTask.TryRead(ref reader, options, PropTask)) + { + continue; + } + + if (propThrottled.TryRead(ref reader, options, PropThrottled)) + { + continue; + } + + if (propThrottledMillis.TryRead(ref reader, options, PropThrottledMillis)) + { + continue; + } + + if (propThrottledUntil.TryRead(ref reader, options, PropThrottledUntil)) + { + continue; + } + + if (propThrottledUntilMillis.TryRead(ref reader, options, PropThrottledUntilMillis)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + if (propUpdated.TryRead(ref reader, options, PropUpdated)) + { + continue; + } + + if (propVersionConflicts.TryRead(ref reader, options, PropVersionConflicts)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateByQueryResponse + { + Batches = propBatches.Value +, + Deleted = propDeleted.Value +, + Failures = propFailures.Value +, + Noops = propNoops.Value +, + RequestsPerSecond = propRequestsPerSecond.Value +, + Retries = propRetries.Value +, + Task = propTask.Value +, + Throttled = propThrottled.Value +, + ThrottledMillis = propThrottledMillis.Value +, + ThrottledUntil = propThrottledUntil.Value +, + ThrottledUntilMillis = propThrottledUntilMillis.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value +, + Total = propTotal.Value +, + Updated = propUpdated.Value +, + VersionConflicts = propVersionConflicts.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateByQueryResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBatches, value.Batches); + writer.WriteProperty(options, PropDeleted, value.Deleted); + writer.WriteProperty(options, PropFailures, value.Failures); + writer.WriteProperty(options, PropNoops, value.Noops); + writer.WriteProperty(options, PropRequestsPerSecond, value.RequestsPerSecond); + writer.WriteProperty(options, PropRetries, value.Retries); + writer.WriteProperty(options, PropTask, value.Task); + writer.WriteProperty(options, PropThrottled, value.Throttled); + writer.WriteProperty(options, PropThrottledMillis, value.ThrottledMillis); + writer.WriteProperty(options, PropThrottledUntil, value.ThrottledUntil); + writer.WriteProperty(options, PropThrottledUntilMillis, value.ThrottledUntilMillis); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteProperty(options, PropUpdated, value.Updated); + writer.WriteProperty(options, PropVersionConflicts, value.VersionConflicts); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateByQueryResponseConverter))] public sealed partial class UpdateByQueryResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("batches")] public long? Batches { get; init; } - [JsonInclude, JsonPropertyName("deleted")] public long? Deleted { get; init; } - [JsonInclude, JsonPropertyName("failures")] public IReadOnlyCollection? Failures { get; init; } - [JsonInclude, JsonPropertyName("noops")] public long? Noops { get; init; } - [JsonInclude, JsonPropertyName("requests_per_second")] public float? RequestsPerSecond { get; init; } - [JsonInclude, JsonPropertyName("retries")] public Elastic.Clients.Elasticsearch.Retries? Retries { get; init; } - [JsonInclude, JsonPropertyName("task")] public Elastic.Clients.Elasticsearch.TaskId? Task { get; init; } - [JsonInclude, JsonPropertyName("throttled")] public Elastic.Clients.Elasticsearch.Duration? Throttled { get; init; } - [JsonInclude, JsonPropertyName("throttled_millis")] public long? ThrottledMillis { get; init; } - [JsonInclude, JsonPropertyName("throttled_until")] public Elastic.Clients.Elasticsearch.Duration? ThrottledUntil { get; init; } - [JsonInclude, JsonPropertyName("throttled_until_millis")] public long? ThrottledUntilMillis { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool? TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } - [JsonInclude, JsonPropertyName("total")] public long? Total { get; init; } - [JsonInclude, JsonPropertyName("updated")] public long? Updated { get; init; } - [JsonInclude, JsonPropertyName("version_conflicts")] public long? VersionConflicts { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs index 6ee3ca87ed4..57cf83ac1c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleRequest.g.cs @@ -63,6 +63,14 @@ public UpdateByQueryRethrottleRequest(Elastic.Clients.Elasticsearch.Id taskId) : internal override string OperationName => "update_by_query_rethrottle"; + /// + /// + /// The ID for the task. + /// + /// + [JsonIgnore] + public Elastic.Clients.Elasticsearch.Id TaskId { get => P("task_id"); set => PR("task_id", value); } + /// /// /// The throttle for this request in sub-requests per second. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs index ed940ed3d73..d772cc913f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateByQueryRethrottleResponse.g.cs @@ -22,12 +22,47 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class UpdateByQueryRethrottleResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override UpdateByQueryRethrottleResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propNodes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateByQueryRethrottleResponse + { + Nodes = propNodes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateByQueryRethrottleResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UpdateByQueryRethrottleResponseConverter))] public sealed partial class UpdateByQueryRethrottleResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyDictionary Nodes { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs index 2b7fb9ce352..e7f5cc775a6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateRequest.g.cs @@ -116,12 +116,123 @@ public sealed partial class UpdateRequestParameters : RequestParameters public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } } +internal sealed partial class UpdateRequestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDetectNoop = System.Text.Json.JsonEncodedText.Encode("detect_noop"); + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropDocAsUpsert = System.Text.Json.JsonEncodedText.Encode("doc_as_upsert"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptedUpsert = System.Text.Json.JsonEncodedText.Encode("scripted_upsert"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropUpsert = System.Text.Json.JsonEncodedText.Encode("upsert"); + + public override UpdateRequest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDetectNoop = default; + LocalJsonValue propDoc = default; + LocalJsonValue propDocAsUpsert = default; + LocalJsonValue propScript = default; + LocalJsonValue propScriptedUpsert = default; + LocalJsonValue propSource = default; + LocalJsonValue propUpsert = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDetectNoop.TryRead(ref reader, options, PropDetectNoop)) + { + continue; + } + + if (propDoc.TryRead(ref reader, options, PropDoc, typeof(SourceMarker))) + { + continue; + } + + if (propDocAsUpsert.TryRead(ref reader, options, PropDocAsUpsert)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptedUpsert.TryRead(ref reader, options, PropScriptedUpsert)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propUpsert.TryRead(ref reader, options, PropUpsert, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateRequest + { + DetectNoop = propDetectNoop.Value + , + Doc = propDoc.Value + , + DocAsUpsert = propDocAsUpsert.Value + , + Script = propScript.Value + , + ScriptedUpsert = propScriptedUpsert.Value + , + Source = propSource.Value + , + Upsert = propUpsert.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateRequest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDetectNoop, value.DetectNoop); + writer.WriteProperty(options, PropDoc, value.Doc, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropDocAsUpsert, value.DocAsUpsert); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptedUpsert, value.ScriptedUpsert); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropUpsert, value.Upsert, null, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class UpdateRequestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(UpdateRequest<,>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(UpdateRequestConverter<,>).MakeGenericType(args[0], args[1]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + /// /// /// Update a document. /// Updates a document by running a script or passing a partial document. /// /// +[JsonConverter(typeof(UpdateRequestConverterFactory))] public sealed partial class UpdateRequest : PlainRequest { public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clients.Elasticsearch.Id id) : base(r => r.Required("index", index).Required("id", id)) @@ -136,12 +247,25 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie internal override string OperationName => "update"; + /// + /// + /// Document ID + /// + /// + public Elastic.Clients.Elasticsearch.Id Id { get => P("id"); set => PR("id", value); } + + /// + /// + /// The name of the index + /// + /// + public Elastic.Clients.Elasticsearch.IndexName Index { get => P("index"); set => PR("index", value); } + /// /// /// Only perform the operation if the document has this primary term. /// /// - [JsonIgnore] public long? IfPrimaryTerm { get => Q("if_primary_term"); set => Q("if_primary_term", value); } /// @@ -149,7 +273,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Only perform the operation if the document has this sequence number. /// /// - [JsonIgnore] public long? IfSeqNo { get => Q("if_seq_no"); set => Q("if_seq_no", value); } /// @@ -157,7 +280,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// The script language. /// /// - [JsonIgnore] public string? Lang { get => Q("lang"); set => Q("lang", value); } /// @@ -167,7 +289,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// visible to search, if 'false' do nothing with refreshes. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } /// @@ -175,7 +296,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// If true, the destination must be an index alias. /// /// - [JsonIgnore] public bool? RequireAlias { get => Q("require_alias"); set => Q("require_alias", value); } /// @@ -183,7 +303,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specify how many times should the operation be retried when a conflict occurs. /// /// - [JsonIgnore] public int? RetryOnConflict { get => Q("retry_on_conflict"); set => Q("retry_on_conflict", value); } /// @@ -191,7 +310,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Custom value used to route operations to a specific shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Routing? Routing { get => Q("routing"); set => Q("routing", value); } /// @@ -199,7 +317,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specify the source fields you want to exclude. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceExcludes { get => Q("_source_excludes"); set => Q("_source_excludes", value); } /// @@ -207,7 +324,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Specify the source fields you want to retrieve. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Fields? SourceIncludes { get => Q("_source_includes"); set => Q("_source_includes", value); } /// @@ -217,7 +333,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// The actual wait time could be longer, particularly when multiple waits occur. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.Duration? Timeout { get => Q("timeout"); set => Q("timeout", value); } /// @@ -227,7 +342,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// (number_of_replicas+1). Defaults to 1 meaning the primary shard. /// /// - [JsonIgnore] public Elastic.Clients.Elasticsearch.WaitForActiveShards? WaitForActiveShards { get => Q("wait_for_active_shards"); set => Q("wait_for_active_shards", value); } /// @@ -236,7 +350,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// to 'noop' if no change to the document occurred. /// /// - [JsonInclude, JsonPropertyName("detect_noop")] public bool? DetectNoop { get; set; } /// @@ -244,8 +357,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// A partial update to an existing document. /// /// - [JsonInclude, JsonPropertyName("doc")] - [SourceConverter] public TPartialDocument? Doc { get; set; } /// @@ -253,7 +364,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Set to true to use the contents of 'doc' as the value of 'upsert' /// /// - [JsonInclude, JsonPropertyName("doc_as_upsert")] public bool? DocAsUpsert { get; set; } /// @@ -261,7 +371,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Script to execute to update the document. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -269,7 +378,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// Set to true to execute the script whether or not the document exists. /// /// - [JsonInclude, JsonPropertyName("scripted_upsert")] public bool? ScriptedUpsert { get; set; } /// @@ -278,7 +386,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// list of the fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -287,8 +394,6 @@ public UpdateRequest(Elastic.Clients.Elasticsearch.IndexName index, Elastic.Clie /// new document. If the document exists, the 'script' is executed. /// /// - [JsonInclude, JsonPropertyName("upsert")] - [SourceConverter] public TDocument? Upsert { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs index fb1f7195afe..255ea4fdd58 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/UpdateResponse.g.cs @@ -22,28 +22,152 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch; +internal sealed partial class UpdateResponseConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropForcedRefresh = System.Text.Json.JsonEncodedText.Encode("forced_refresh"); + private static readonly System.Text.Json.JsonEncodedText PropGet = System.Text.Json.JsonEncodedText.Encode("get"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropResult = System.Text.Json.JsonEncodedText.Encode("result"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override UpdateResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propForcedRefresh = default; + LocalJsonValue?> propGet = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propResult = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShards = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propForcedRefresh.TryRead(ref reader, options, PropForcedRefresh)) + { + continue; + } + + if (propGet.TryRead(ref reader, options, PropGet)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propResult.TryRead(ref reader, options, PropResult)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UpdateResponse + { + ForcedRefresh = propForcedRefresh.Value +, + Get = propGet.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Result = propResult.Value +, + SeqNo = propSeqNo.Value +, + Shards = propShards.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UpdateResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropForcedRefresh, value.ForcedRefresh); + writer.WriteProperty(options, PropGet, value.Get); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropResult, value.Result); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class UpdateResponseConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(UpdateResponse<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(UpdateResponseConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(UpdateResponseConverterFactory))] public sealed partial class UpdateResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("forced_refresh")] public bool? ForcedRefresh { get; init; } - [JsonInclude, JsonPropertyName("get")] public Elastic.Clients.Elasticsearch.InlineGet? Get { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("result")] public Elastic.Clients.Elasticsearch.Result Result { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs index 6b636e1191f..326fb8ba574 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackInfoResponse.g.cs @@ -22,18 +22,80 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Xpack; +internal sealed partial class XpackInfoResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBuild = System.Text.Json.JsonEncodedText.Encode("build"); + private static readonly System.Text.Json.JsonEncodedText PropFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + private static readonly System.Text.Json.JsonEncodedText PropLicense = System.Text.Json.JsonEncodedText.Encode("license"); + private static readonly System.Text.Json.JsonEncodedText PropTagline = System.Text.Json.JsonEncodedText.Encode("tagline"); + + public override XpackInfoResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBuild = default; + LocalJsonValue propFeatures = default; + LocalJsonValue propLicense = default; + LocalJsonValue propTagline = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBuild.TryRead(ref reader, options, PropBuild)) + { + continue; + } + + if (propFeatures.TryRead(ref reader, options, PropFeatures)) + { + continue; + } + + if (propLicense.TryRead(ref reader, options, PropLicense)) + { + continue; + } + + if (propTagline.TryRead(ref reader, options, PropTagline)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new XpackInfoResponse + { + Build = propBuild.Value +, + Features = propFeatures.Value +, + License = propLicense.Value +, + Tagline = propTagline.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, XpackInfoResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBuild, value.Build); + writer.WriteProperty(options, PropFeatures, value.Features); + writer.WriteProperty(options, PropLicense, value.License); + writer.WriteProperty(options, PropTagline, value.Tagline); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackInfoResponseConverter))] public sealed partial class XpackInfoResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("build")] public Elastic.Clients.Elasticsearch.Xpack.BuildInformation Build { get; init; } - [JsonInclude, JsonPropertyName("features")] public Elastic.Clients.Elasticsearch.Xpack.Features Features { get; init; } - [JsonInclude, JsonPropertyName("license")] public Elastic.Clients.Elasticsearch.Xpack.MinimalLicenseInformation License { get; init; } - [JsonInclude, JsonPropertyName("tagline")] public string Tagline { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs index 347789ed115..44e0761e608 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/Xpack/XpackUsageResponse.g.cs @@ -22,68 +22,355 @@ using Elastic.Transport.Products.Elasticsearch; using System; using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; using System.Text.Json.Serialization; namespace Elastic.Clients.Elasticsearch.Xpack; +internal sealed partial class XpackUsageResponseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregateMetric = System.Text.Json.JsonEncodedText.Encode("aggregate_metric"); + private static readonly System.Text.Json.JsonEncodedText PropAnalytics = System.Text.Json.JsonEncodedText.Encode("analytics"); + private static readonly System.Text.Json.JsonEncodedText PropArchive = System.Text.Json.JsonEncodedText.Encode("archive"); + private static readonly System.Text.Json.JsonEncodedText PropCcr = System.Text.Json.JsonEncodedText.Encode("ccr"); + private static readonly System.Text.Json.JsonEncodedText PropDataFrame = System.Text.Json.JsonEncodedText.Encode("data_frame"); + private static readonly System.Text.Json.JsonEncodedText PropDataScience = System.Text.Json.JsonEncodedText.Encode("data_science"); + private static readonly System.Text.Json.JsonEncodedText PropDataStreams = System.Text.Json.JsonEncodedText.Encode("data_streams"); + private static readonly System.Text.Json.JsonEncodedText PropDataTiers = System.Text.Json.JsonEncodedText.Encode("data_tiers"); + private static readonly System.Text.Json.JsonEncodedText PropEnrich = System.Text.Json.JsonEncodedText.Encode("enrich"); + private static readonly System.Text.Json.JsonEncodedText PropEql = System.Text.Json.JsonEncodedText.Encode("eql"); + private static readonly System.Text.Json.JsonEncodedText PropFlattened = System.Text.Json.JsonEncodedText.Encode("flattened"); + private static readonly System.Text.Json.JsonEncodedText PropFrozenIndices = System.Text.Json.JsonEncodedText.Encode("frozen_indices"); + private static readonly System.Text.Json.JsonEncodedText PropGraph = System.Text.Json.JsonEncodedText.Encode("graph"); + private static readonly System.Text.Json.JsonEncodedText PropHealthApi = System.Text.Json.JsonEncodedText.Encode("health_api"); + private static readonly System.Text.Json.JsonEncodedText PropIlm = System.Text.Json.JsonEncodedText.Encode("ilm"); + private static readonly System.Text.Json.JsonEncodedText PropLogstash = System.Text.Json.JsonEncodedText.Encode("logstash"); + private static readonly System.Text.Json.JsonEncodedText PropMl = System.Text.Json.JsonEncodedText.Encode("ml"); + private static readonly System.Text.Json.JsonEncodedText PropMonitoring = System.Text.Json.JsonEncodedText.Encode("monitoring"); + private static readonly System.Text.Json.JsonEncodedText PropRollup = System.Text.Json.JsonEncodedText.Encode("rollup"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeFields = System.Text.Json.JsonEncodedText.Encode("runtime_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchableSnapshots = System.Text.Json.JsonEncodedText.Encode("searchable_snapshots"); + private static readonly System.Text.Json.JsonEncodedText PropSecurity = System.Text.Json.JsonEncodedText.Encode("security"); + private static readonly System.Text.Json.JsonEncodedText PropSlm = System.Text.Json.JsonEncodedText.Encode("slm"); + private static readonly System.Text.Json.JsonEncodedText PropSpatial = System.Text.Json.JsonEncodedText.Encode("spatial"); + private static readonly System.Text.Json.JsonEncodedText PropSql = System.Text.Json.JsonEncodedText.Encode("sql"); + private static readonly System.Text.Json.JsonEncodedText PropTransform = System.Text.Json.JsonEncodedText.Encode("transform"); + private static readonly System.Text.Json.JsonEncodedText PropVectors = System.Text.Json.JsonEncodedText.Encode("vectors"); + private static readonly System.Text.Json.JsonEncodedText PropVotingOnly = System.Text.Json.JsonEncodedText.Encode("voting_only"); + private static readonly System.Text.Json.JsonEncodedText PropWatcher = System.Text.Json.JsonEncodedText.Encode("watcher"); + + public override XpackUsageResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregateMetric = default; + LocalJsonValue propAnalytics = default; + LocalJsonValue propArchive = default; + LocalJsonValue propCcr = default; + LocalJsonValue propDataFrame = default; + LocalJsonValue propDataScience = default; + LocalJsonValue propDataStreams = default; + LocalJsonValue propDataTiers = default; + LocalJsonValue propEnrich = default; + LocalJsonValue propEql = default; + LocalJsonValue propFlattened = default; + LocalJsonValue propFrozenIndices = default; + LocalJsonValue propGraph = default; + LocalJsonValue propHealthApi = default; + LocalJsonValue propIlm = default; + LocalJsonValue propLogstash = default; + LocalJsonValue propMl = default; + LocalJsonValue propMonitoring = default; + LocalJsonValue propRollup = default; + LocalJsonValue propRuntimeFields = default; + LocalJsonValue propSearchableSnapshots = default; + LocalJsonValue propSecurity = default; + LocalJsonValue propSlm = default; + LocalJsonValue propSpatial = default; + LocalJsonValue propSql = default; + LocalJsonValue propTransform = default; + LocalJsonValue propVectors = default; + LocalJsonValue propVotingOnly = default; + LocalJsonValue propWatcher = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregateMetric.TryRead(ref reader, options, PropAggregateMetric)) + { + continue; + } + + if (propAnalytics.TryRead(ref reader, options, PropAnalytics)) + { + continue; + } + + if (propArchive.TryRead(ref reader, options, PropArchive)) + { + continue; + } + + if (propCcr.TryRead(ref reader, options, PropCcr)) + { + continue; + } + + if (propDataFrame.TryRead(ref reader, options, PropDataFrame)) + { + continue; + } + + if (propDataScience.TryRead(ref reader, options, PropDataScience)) + { + continue; + } + + if (propDataStreams.TryRead(ref reader, options, PropDataStreams)) + { + continue; + } + + if (propDataTiers.TryRead(ref reader, options, PropDataTiers)) + { + continue; + } + + if (propEnrich.TryRead(ref reader, options, PropEnrich)) + { + continue; + } + + if (propEql.TryRead(ref reader, options, PropEql)) + { + continue; + } + + if (propFlattened.TryRead(ref reader, options, PropFlattened)) + { + continue; + } + + if (propFrozenIndices.TryRead(ref reader, options, PropFrozenIndices)) + { + continue; + } + + if (propGraph.TryRead(ref reader, options, PropGraph)) + { + continue; + } + + if (propHealthApi.TryRead(ref reader, options, PropHealthApi)) + { + continue; + } + + if (propIlm.TryRead(ref reader, options, PropIlm)) + { + continue; + } + + if (propLogstash.TryRead(ref reader, options, PropLogstash)) + { + continue; + } + + if (propMl.TryRead(ref reader, options, PropMl)) + { + continue; + } + + if (propMonitoring.TryRead(ref reader, options, PropMonitoring)) + { + continue; + } + + if (propRollup.TryRead(ref reader, options, PropRollup)) + { + continue; + } + + if (propRuntimeFields.TryRead(ref reader, options, PropRuntimeFields)) + { + continue; + } + + if (propSearchableSnapshots.TryRead(ref reader, options, PropSearchableSnapshots)) + { + continue; + } + + if (propSecurity.TryRead(ref reader, options, PropSecurity)) + { + continue; + } + + if (propSlm.TryRead(ref reader, options, PropSlm)) + { + continue; + } + + if (propSpatial.TryRead(ref reader, options, PropSpatial)) + { + continue; + } + + if (propSql.TryRead(ref reader, options, PropSql)) + { + continue; + } + + if (propTransform.TryRead(ref reader, options, PropTransform)) + { + continue; + } + + if (propVectors.TryRead(ref reader, options, PropVectors)) + { + continue; + } + + if (propVotingOnly.TryRead(ref reader, options, PropVotingOnly)) + { + continue; + } + + if (propWatcher.TryRead(ref reader, options, PropWatcher)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new XpackUsageResponse + { + AggregateMetric = propAggregateMetric.Value +, + Analytics = propAnalytics.Value +, + Archive = propArchive.Value +, + Ccr = propCcr.Value +, + DataFrame = propDataFrame.Value +, + DataScience = propDataScience.Value +, + DataStreams = propDataStreams.Value +, + DataTiers = propDataTiers.Value +, + Enrich = propEnrich.Value +, + Eql = propEql.Value +, + Flattened = propFlattened.Value +, + FrozenIndices = propFrozenIndices.Value +, + Graph = propGraph.Value +, + HealthApi = propHealthApi.Value +, + Ilm = propIlm.Value +, + Logstash = propLogstash.Value +, + Ml = propMl.Value +, + Monitoring = propMonitoring.Value +, + Rollup = propRollup.Value +, + RuntimeFields = propRuntimeFields.Value +, + SearchableSnapshots = propSearchableSnapshots.Value +, + Security = propSecurity.Value +, + Slm = propSlm.Value +, + Spatial = propSpatial.Value +, + Sql = propSql.Value +, + Transform = propTransform.Value +, + Vectors = propVectors.Value +, + VotingOnly = propVotingOnly.Value +, + Watcher = propWatcher.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, XpackUsageResponse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregateMetric, value.AggregateMetric); + writer.WriteProperty(options, PropAnalytics, value.Analytics); + writer.WriteProperty(options, PropArchive, value.Archive); + writer.WriteProperty(options, PropCcr, value.Ccr); + writer.WriteProperty(options, PropDataFrame, value.DataFrame); + writer.WriteProperty(options, PropDataScience, value.DataScience); + writer.WriteProperty(options, PropDataStreams, value.DataStreams); + writer.WriteProperty(options, PropDataTiers, value.DataTiers); + writer.WriteProperty(options, PropEnrich, value.Enrich); + writer.WriteProperty(options, PropEql, value.Eql); + writer.WriteProperty(options, PropFlattened, value.Flattened); + writer.WriteProperty(options, PropFrozenIndices, value.FrozenIndices); + writer.WriteProperty(options, PropGraph, value.Graph); + writer.WriteProperty(options, PropHealthApi, value.HealthApi); + writer.WriteProperty(options, PropIlm, value.Ilm); + writer.WriteProperty(options, PropLogstash, value.Logstash); + writer.WriteProperty(options, PropMl, value.Ml); + writer.WriteProperty(options, PropMonitoring, value.Monitoring); + writer.WriteProperty(options, PropRollup, value.Rollup); + writer.WriteProperty(options, PropRuntimeFields, value.RuntimeFields); + writer.WriteProperty(options, PropSearchableSnapshots, value.SearchableSnapshots); + writer.WriteProperty(options, PropSecurity, value.Security); + writer.WriteProperty(options, PropSlm, value.Slm); + writer.WriteProperty(options, PropSpatial, value.Spatial); + writer.WriteProperty(options, PropSql, value.Sql); + writer.WriteProperty(options, PropTransform, value.Transform); + writer.WriteProperty(options, PropVectors, value.Vectors); + writer.WriteProperty(options, PropVotingOnly, value.VotingOnly); + writer.WriteProperty(options, PropWatcher, value.Watcher); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(XpackUsageResponseConverter))] public sealed partial class XpackUsageResponse : ElasticsearchResponse { - [JsonInclude, JsonPropertyName("aggregate_metric")] public Elastic.Clients.Elasticsearch.Xpack.Base AggregateMetric { get; init; } - [JsonInclude, JsonPropertyName("analytics")] public Elastic.Clients.Elasticsearch.Xpack.Analytics Analytics { get; init; } - [JsonInclude, JsonPropertyName("archive")] public Elastic.Clients.Elasticsearch.Xpack.Archive Archive { get; init; } - [JsonInclude, JsonPropertyName("ccr")] public Elastic.Clients.Elasticsearch.Xpack.Ccr Ccr { get; init; } - [JsonInclude, JsonPropertyName("data_frame")] public Elastic.Clients.Elasticsearch.Xpack.Base? DataFrame { get; init; } - [JsonInclude, JsonPropertyName("data_science")] public Elastic.Clients.Elasticsearch.Xpack.Base? DataScience { get; init; } - [JsonInclude, JsonPropertyName("data_streams")] public Elastic.Clients.Elasticsearch.Xpack.DataStreams? DataStreams { get; init; } - [JsonInclude, JsonPropertyName("data_tiers")] public Elastic.Clients.Elasticsearch.Xpack.DataTiers DataTiers { get; init; } - [JsonInclude, JsonPropertyName("enrich")] public Elastic.Clients.Elasticsearch.Xpack.Base? Enrich { get; init; } - [JsonInclude, JsonPropertyName("eql")] public Elastic.Clients.Elasticsearch.Xpack.Eql Eql { get; init; } - [JsonInclude, JsonPropertyName("flattened")] public Elastic.Clients.Elasticsearch.Xpack.Flattened? Flattened { get; init; } - [JsonInclude, JsonPropertyName("frozen_indices")] public Elastic.Clients.Elasticsearch.Xpack.FrozenIndices FrozenIndices { get; init; } - [JsonInclude, JsonPropertyName("graph")] public Elastic.Clients.Elasticsearch.Xpack.Base Graph { get; init; } - [JsonInclude, JsonPropertyName("health_api")] public Elastic.Clients.Elasticsearch.Xpack.HealthStatistics? HealthApi { get; init; } - [JsonInclude, JsonPropertyName("ilm")] public Elastic.Clients.Elasticsearch.Xpack.Ilm Ilm { get; init; } - [JsonInclude, JsonPropertyName("logstash")] public Elastic.Clients.Elasticsearch.Xpack.Base Logstash { get; init; } - [JsonInclude, JsonPropertyName("ml")] public Elastic.Clients.Elasticsearch.Xpack.MachineLearning Ml { get; init; } - [JsonInclude, JsonPropertyName("monitoring")] public Elastic.Clients.Elasticsearch.Xpack.Monitoring Monitoring { get; init; } - [JsonInclude, JsonPropertyName("rollup")] public Elastic.Clients.Elasticsearch.Xpack.Base Rollup { get; init; } - [JsonInclude, JsonPropertyName("runtime_fields")] public Elastic.Clients.Elasticsearch.Xpack.RuntimeFieldTypes? RuntimeFields { get; init; } - [JsonInclude, JsonPropertyName("searchable_snapshots")] public Elastic.Clients.Elasticsearch.Xpack.SearchableSnapshots SearchableSnapshots { get; init; } - [JsonInclude, JsonPropertyName("security")] public Elastic.Clients.Elasticsearch.Xpack.Security Security { get; init; } - [JsonInclude, JsonPropertyName("slm")] public Elastic.Clients.Elasticsearch.Xpack.Slm Slm { get; init; } - [JsonInclude, JsonPropertyName("spatial")] public Elastic.Clients.Elasticsearch.Xpack.Base Spatial { get; init; } - [JsonInclude, JsonPropertyName("sql")] public Elastic.Clients.Elasticsearch.Xpack.Sql Sql { get; init; } - [JsonInclude, JsonPropertyName("transform")] public Elastic.Clients.Elasticsearch.Xpack.Base Transform { get; init; } - [JsonInclude, JsonPropertyName("vectors")] public Elastic.Clients.Elasticsearch.Xpack.Vector? Vectors { get; init; } - [JsonInclude, JsonPropertyName("voting_only")] public Elastic.Clients.Elasticsearch.Xpack.Base VotingOnly { get; init; } - [JsonInclude, JsonPropertyName("watcher")] public Elastic.Clients.Elasticsearch.Xpack.Watcher Watcher { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs index 5b0e0007e35..a2965704b6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class AdjacencyMatrixAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "adjacency_matrix"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs index f238c0e248c..c690740b1bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AdjacencyMatrixBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class AdjacencyMatrixBucketConverter : JsonConverter +internal sealed partial class AdjacencyMatrixBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override AdjacencyMatrixBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override AdjacencyMatrixBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new AdjacencyMatrixBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AdjacencyMatrixBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, AdjacencyMatrixBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AdjacencyMatrixBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'AdjacencyMatrixBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs index 6198ae808d5..92093684aab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AggregateDictionary.g.cs @@ -33,6 +33,7 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; public partial interface IAggregate { + public string? Type { get; } } [JsonConverter(typeof(AggregateDictionaryConverter))] @@ -115,530 +116,338 @@ public AggregateDictionary(IReadOnlyDictionary backingDictio private T? TryGet(string key) where T : class, IAggregate => BackingDictionary.TryGetValue(key, out var value) ? value as T : null; } -internal sealed partial class AggregateDictionaryConverter : JsonConverter +internal sealed partial class AggregateDictionaryConverter : System.Text.Json.Serialization.JsonConverter { - public override AggregateDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override AggregateDictionary Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var dictionary = new Dictionary(); - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var dictionary = new System.Collections.Generic.Dictionary(); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); - var name = reader.GetString(); - reader.Read(); - ReadItem(ref reader, options, dictionary, name); + ReadItem(ref reader, options, out string name, out IAggregate value); + dictionary[name] = value; } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); return new AggregateDictionary(dictionary); } - public override void Write(Utf8JsonWriter writer, AggregateDictionary value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AggregateDictionary value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'AggregateDictionary' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + foreach (var pair in value) + { + WriteItem(writer, options, pair.Key, pair.Value); + } + + writer.WriteEndObject(); } - public static void ReadItem(ref Utf8JsonReader reader, JsonSerializerOptions options, Dictionary dictionary, string name) + internal static void ReadItem(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, out string name, out IAggregate value) { - var nameParts = name.Split('#'); - if (nameParts.Length != 2) - throw new JsonException($"Unable to parse typed-key '{name}'."); - var type = nameParts[0]; - switch (type) + var key = reader.ReadPropertyName(options); + reader.Read(); + var parts = key.Split('#'); + if (parts.Length != 2) { - case "adjacency_matrix": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "auto_date_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "avg": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "boxplot": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "bucket_metric_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "cardinality": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "children": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "composite": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "simple_long_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "date_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "date_range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "derivative": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "dterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "extended_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "extended_stats_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "filter": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "filters": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "frequent_item_sets": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_bounds": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_centroid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_distance": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geohash_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geohex_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geo_line": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "geotile_grid": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "global": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "hdr_percentile_ranks": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "hdr_percentiles": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "inference": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "ip_prefix": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "ip_range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "lrareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "lterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "matrix_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "max": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "median_absolute_deviation": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "min": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "missing": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "multi_terms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "nested": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "parent": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "percentiles_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "range": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "rate": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "reverse_nested": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sampler": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "scripted_metric": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "siglterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sigsterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "simple_value": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "stats_bucket": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "srareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "string_stats": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "sum": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "tdigest_percentile_ranks": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "tdigest_percentiles": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "time_series": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "top_hits": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "top_metrics": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "t_test": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umrareterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "unmapped_sampler": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umsigterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "umterms": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "value_count": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "variable_width_histogram": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + throw new System.Text.Json.JsonException($"Unable to parse typed-key '{key}' for variant '{nameof(IAggregate)}'."); + } - case "weighted_avg": - { - var item = JsonSerializer.Deserialize(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + var discriminator = parts[0]; + name = parts[1]; + value = discriminator switch + { + "adjacency_matrix" => reader.ReadValue(options), + "auto_date_histogram" => reader.ReadValue(options), + "avg" => reader.ReadValue(options), + "boxplot" => reader.ReadValue(options), + "bucket_metric_value" => reader.ReadValue(options), + "cardinality" => reader.ReadValue(options), + "children" => reader.ReadValue(options), + "composite" => reader.ReadValue(options), + "simple_long_value" => reader.ReadValue(options), + "date_histogram" => reader.ReadValue(options), + "date_range" => reader.ReadValue(options), + "derivative" => reader.ReadValue(options), + "dterms" => reader.ReadValue(options), + "extended_stats" => reader.ReadValue(options), + "extended_stats_bucket" => reader.ReadValue(options), + "filter" => reader.ReadValue(options), + "filters" => reader.ReadValue(options), + "frequent_item_sets" => reader.ReadValue(options), + "geo_bounds" => reader.ReadValue(options), + "geo_centroid" => reader.ReadValue(options), + "geo_distance" => reader.ReadValue(options), + "geohash_grid" => reader.ReadValue(options), + "geohex_grid" => reader.ReadValue(options), + "geo_line" => reader.ReadValue(options), + "geotile_grid" => reader.ReadValue(options), + "global" => reader.ReadValue(options), + "hdr_percentile_ranks" => reader.ReadValue(options), + "hdr_percentiles" => reader.ReadValue(options), + "histogram" => reader.ReadValue(options), + "inference" => reader.ReadValue(options), + "ip_prefix" => reader.ReadValue(options), + "ip_range" => reader.ReadValue(options), + "lrareterms" => reader.ReadValue(options), + "lterms" => reader.ReadValue(options), + "matrix_stats" => reader.ReadValue(options), + "max" => reader.ReadValue(options), + "median_absolute_deviation" => reader.ReadValue(options), + "min" => reader.ReadValue(options), + "missing" => reader.ReadValue(options), + "multi_terms" => reader.ReadValue(options), + "nested" => reader.ReadValue(options), + "parent" => reader.ReadValue(options), + "percentiles_bucket" => reader.ReadValue(options), + "range" => reader.ReadValue(options), + "rate" => reader.ReadValue(options), + "reverse_nested" => reader.ReadValue(options), + "sampler" => reader.ReadValue(options), + "scripted_metric" => reader.ReadValue(options), + "siglterms" => reader.ReadValue(options), + "sigsterms" => reader.ReadValue(options), + "simple_value" => reader.ReadValue(options), + "stats" => reader.ReadValue(options), + "stats_bucket" => reader.ReadValue(options), + "srareterms" => reader.ReadValue(options), + "string_stats" => reader.ReadValue(options), + "sterms" => reader.ReadValue(options), + "sum" => reader.ReadValue(options), + "tdigest_percentile_ranks" => reader.ReadValue(options), + "tdigest_percentiles" => reader.ReadValue(options), + "time_series" => reader.ReadValue(options), + "top_hits" => reader.ReadValue(options), + "top_metrics" => reader.ReadValue(options), + "t_test" => reader.ReadValue(options), + "umrareterms" => reader.ReadValue(options), + "unmapped_sampler" => reader.ReadValue(options), + "umsigterms" => reader.ReadValue(options), + "umterms" => reader.ReadValue(options), + "value_count" => reader.ReadValue(options), + "variable_width_histogram" => reader.ReadValue(options), + "weighted_avg" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IAggregate)}'.") + }; + } + internal static void WriteItem(System.Text.Json.Utf8JsonWriter writer, System.Text.Json.JsonSerializerOptions options, string name, IAggregate value) + { + var key = value.Type + '#' + name; + switch (value) + { + case Elastic.Clients.Elasticsearch.Aggregations.AdjacencyMatrixAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.AverageAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.BucketMetricValueAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.DoubleTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FilterAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HdrPercentileRanksAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HdrPercentilesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.LongRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.LongTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MaxAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MinAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MissingAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.NestedAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ParentAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.RangeAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.RateAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SignificantLongTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SignificantStringTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SimpleValueAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.StringTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.SumAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentileRanksAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentilesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.TTestAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedRareTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedSamplerAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedSignificantTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.UnmappedTermsAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregate v: + writer.WriteProperty(options, key, v); + break; + case Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregate v: + writer.WriteProperty(options, key, v); + break; default: - throw new NotSupportedException($"The tagged variant '{type}' is currently not supported."); + throw new System.Text.Json.JsonException($"Variant '{0}' is not supported for type '{nameof(IAggregate)}'."); } } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs index 3ce7c7ac1d7..0c4ba4ec26e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/Aggregation.g.cs @@ -39,12 +39,16 @@ internal Aggregation(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Aggregation() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Aggregation AdjacencyMatrix(Elastic.Clients.Elasticsearch.Aggregations.AdjacencyMatrixAggregation adjacencyMatrixAggregation) => new Aggregation("adjacency_matrix", adjacencyMatrixAggregation); public static Aggregation AutoDateHistogram(Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation autoDateHistogramAggregation) => new Aggregation("auto_date_histogram", autoDateHistogramAggregation); @@ -148,847 +152,982 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class AggregationConverter : JsonConverter +internal sealed partial class AggregationConverter : System.Text.Json.Serialization.JsonConverter { - public override Aggregation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText VariantAdjacencyMatrix = System.Text.Json.JsonEncodedText.Encode("adjacency_matrix"); + private static readonly System.Text.Json.JsonEncodedText VariantAutoDateHistogram = System.Text.Json.JsonEncodedText.Encode("auto_date_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + private static readonly System.Text.Json.JsonEncodedText VariantAvgBucket = System.Text.Json.JsonEncodedText.Encode("avg_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantBoxplot = System.Text.Json.JsonEncodedText.Encode("boxplot"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketCorrelation = System.Text.Json.JsonEncodedText.Encode("bucket_correlation"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketCountKsTest = System.Text.Json.JsonEncodedText.Encode("bucket_count_ks_test"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketScript = System.Text.Json.JsonEncodedText.Encode("bucket_script"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketSelector = System.Text.Json.JsonEncodedText.Encode("bucket_selector"); + private static readonly System.Text.Json.JsonEncodedText VariantBucketSort = System.Text.Json.JsonEncodedText.Encode("bucket_sort"); + private static readonly System.Text.Json.JsonEncodedText VariantCardinality = System.Text.Json.JsonEncodedText.Encode("cardinality"); + private static readonly System.Text.Json.JsonEncodedText VariantCategorizeText = System.Text.Json.JsonEncodedText.Encode("categorize_text"); + private static readonly System.Text.Json.JsonEncodedText VariantChildren = System.Text.Json.JsonEncodedText.Encode("children"); + private static readonly System.Text.Json.JsonEncodedText VariantComposite = System.Text.Json.JsonEncodedText.Encode("composite"); + private static readonly System.Text.Json.JsonEncodedText VariantCumulativeCardinality = System.Text.Json.JsonEncodedText.Encode("cumulative_cardinality"); + private static readonly System.Text.Json.JsonEncodedText VariantCumulativeSum = System.Text.Json.JsonEncodedText.Encode("cumulative_sum"); + private static readonly System.Text.Json.JsonEncodedText VariantDateHistogram = System.Text.Json.JsonEncodedText.Encode("date_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantDateRange = System.Text.Json.JsonEncodedText.Encode("date_range"); + private static readonly System.Text.Json.JsonEncodedText VariantDerivative = System.Text.Json.JsonEncodedText.Encode("derivative"); + private static readonly System.Text.Json.JsonEncodedText VariantDiversifiedSampler = System.Text.Json.JsonEncodedText.Encode("diversified_sampler"); + private static readonly System.Text.Json.JsonEncodedText VariantExtendedStats = System.Text.Json.JsonEncodedText.Encode("extended_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantExtendedStatsBucket = System.Text.Json.JsonEncodedText.Encode("extended_stats_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText VariantFilters = System.Text.Json.JsonEncodedText.Encode("filters"); + private static readonly System.Text.Json.JsonEncodedText VariantFrequentItemSets = System.Text.Json.JsonEncodedText.Encode("frequent_item_sets"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoBounds = System.Text.Json.JsonEncodedText.Encode("geo_bounds"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoCentroid = System.Text.Json.JsonEncodedText.Encode("geo_centroid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoDistance = System.Text.Json.JsonEncodedText.Encode("geo_distance"); + private static readonly System.Text.Json.JsonEncodedText VariantGeohashGrid = System.Text.Json.JsonEncodedText.Encode("geohash_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeohexGrid = System.Text.Json.JsonEncodedText.Encode("geohex_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoLine = System.Text.Json.JsonEncodedText.Encode("geo_line"); + private static readonly System.Text.Json.JsonEncodedText VariantGeotileGrid = System.Text.Json.JsonEncodedText.Encode("geotile_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText VariantHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantInference = System.Text.Json.JsonEncodedText.Encode("inference"); + private static readonly System.Text.Json.JsonEncodedText VariantIpPrefix = System.Text.Json.JsonEncodedText.Encode("ip_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantIpRange = System.Text.Json.JsonEncodedText.Encode("ip_range"); + private static readonly System.Text.Json.JsonEncodedText VariantLine = System.Text.Json.JsonEncodedText.Encode("line"); + private static readonly System.Text.Json.JsonEncodedText VariantMatrixStats = System.Text.Json.JsonEncodedText.Encode("matrix_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxBucket = System.Text.Json.JsonEncodedText.Encode("max_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantMedianAbsoluteDeviation = System.Text.Json.JsonEncodedText.Encode("median_absolute_deviation"); + private static readonly System.Text.Json.JsonEncodedText VariantMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText VariantMinBucket = System.Text.Json.JsonEncodedText.Encode("min_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText VariantMovingFn = System.Text.Json.JsonEncodedText.Encode("moving_fn"); + private static readonly System.Text.Json.JsonEncodedText VariantMovingPercentiles = System.Text.Json.JsonEncodedText.Encode("moving_percentiles"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiTerms = System.Text.Json.JsonEncodedText.Encode("multi_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText VariantNormalize = System.Text.Json.JsonEncodedText.Encode("normalize"); + private static readonly System.Text.Json.JsonEncodedText VariantParent = System.Text.Json.JsonEncodedText.Encode("parent"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentileRanks = System.Text.Json.JsonEncodedText.Encode("percentile_ranks"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentiles = System.Text.Json.JsonEncodedText.Encode("percentiles"); + private static readonly System.Text.Json.JsonEncodedText VariantPercentilesBucket = System.Text.Json.JsonEncodedText.Encode("percentiles_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantRandomSampler = System.Text.Json.JsonEncodedText.Encode("random_sampler"); + private static readonly System.Text.Json.JsonEncodedText VariantRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText VariantRareTerms = System.Text.Json.JsonEncodedText.Encode("rare_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantRate = System.Text.Json.JsonEncodedText.Encode("rate"); + private static readonly System.Text.Json.JsonEncodedText VariantReverseNested = System.Text.Json.JsonEncodedText.Encode("reverse_nested"); + private static readonly System.Text.Json.JsonEncodedText VariantSampler = System.Text.Json.JsonEncodedText.Encode("sampler"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptedMetric = System.Text.Json.JsonEncodedText.Encode("scripted_metric"); + private static readonly System.Text.Json.JsonEncodedText VariantSerialDiff = System.Text.Json.JsonEncodedText.Encode("serial_diff"); + private static readonly System.Text.Json.JsonEncodedText VariantSignificantTerms = System.Text.Json.JsonEncodedText.Encode("significant_terms"); + private static readonly System.Text.Json.JsonEncodedText VariantSignificantText = System.Text.Json.JsonEncodedText.Encode("significant_text"); + private static readonly System.Text.Json.JsonEncodedText VariantStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText VariantStatsBucket = System.Text.Json.JsonEncodedText.Encode("stats_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantStringStats = System.Text.Json.JsonEncodedText.Encode("string_stats"); + private static readonly System.Text.Json.JsonEncodedText VariantSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText VariantSumBucket = System.Text.Json.JsonEncodedText.Encode("sum_bucket"); + private static readonly System.Text.Json.JsonEncodedText VariantTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText VariantTimeSeries = System.Text.Json.JsonEncodedText.Encode("time_series"); + private static readonly System.Text.Json.JsonEncodedText VariantTopHits = System.Text.Json.JsonEncodedText.Encode("top_hits"); + private static readonly System.Text.Json.JsonEncodedText VariantTopMetrics = System.Text.Json.JsonEncodedText.Encode("top_metrics"); + private static readonly System.Text.Json.JsonEncodedText VariantTTest = System.Text.Json.JsonEncodedText.Encode("t_test"); + private static readonly System.Text.Json.JsonEncodedText VariantValueCount = System.Text.Json.JsonEncodedText.Encode("value_count"); + private static readonly System.Text.Json.JsonEncodedText VariantVariableWidthHistogram = System.Text.Json.JsonEncodedText.Encode("variable_width_histogram"); + private static readonly System.Text.Json.JsonEncodedText VariantWeightedAvg = System.Text.Json.JsonEncodedText.Encode("weighted_avg"); + + public override Aggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - IDictionary? aggregationsValue = default; - IDictionary? metaValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue?> propMeta = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "aggregations") + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - aggregationsValue = JsonSerializer.Deserialize?>(ref reader, options); continue; } - if (propertyName == "meta") + if (propMeta.TryRead(ref reader, options, PropMeta)) { - metaValue = JsonSerializer.Deserialize?>(ref reader, options); continue; } - if (propertyName == "adjacency_matrix") + if (reader.ValueTextEquals(VariantAdjacencyMatrix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAdjacencyMatrix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "auto_date_histogram") + if (reader.ValueTextEquals(VariantAutoDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAutoDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "avg") + if (reader.ValueTextEquals(VariantAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvg.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "avg_bucket") + if (reader.ValueTextEquals(VariantAvgBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAvgBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "boxplot") + if (reader.ValueTextEquals(VariantBoxplot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoxplot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_correlation") + if (reader.ValueTextEquals(VariantBucketCorrelation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketCorrelation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_count_ks_test") + if (reader.ValueTextEquals(VariantBucketCountKsTest)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketCountKsTest.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_script") + if (reader.ValueTextEquals(VariantBucketScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_selector") + if (reader.ValueTextEquals(VariantBucketSelector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSelector.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bucket_sort") + if (reader.ValueTextEquals(VariantBucketSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBucketSort.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cardinality") + if (reader.ValueTextEquals(VariantCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "categorize_text") + if (reader.ValueTextEquals(VariantCategorizeText)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCategorizeText.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "children") + if (reader.ValueTextEquals(VariantChildren)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantChildren.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "composite") + if (reader.ValueTextEquals(VariantComposite)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantComposite.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cumulative_cardinality") + if (reader.ValueTextEquals(VariantCumulativeCardinality)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeCardinality.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "cumulative_sum") + if (reader.ValueTextEquals(VariantCumulativeSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCumulativeSum.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_histogram") + if (reader.ValueTextEquals(VariantDateHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_range") + if (reader.ValueTextEquals(VariantDateRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "derivative") + if (reader.ValueTextEquals(VariantDerivative)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDerivative.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "diversified_sampler") + if (reader.ValueTextEquals(VariantDiversifiedSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDiversifiedSampler.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "extended_stats") + if (reader.ValueTextEquals(VariantExtendedStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "extended_stats_bucket") + if (reader.ValueTextEquals(VariantExtendedStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExtendedStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "filter") + if (reader.ValueTextEquals(VariantFilter)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilter.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "filters") + if (reader.ValueTextEquals(VariantFilters)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFilters.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "frequent_item_sets") + if (reader.ValueTextEquals(VariantFrequentItemSets)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequentItemSets.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_bounds") + if (reader.ValueTextEquals(VariantGeoBounds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBounds.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_centroid") + if (reader.ValueTextEquals(VariantGeoCentroid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoCentroid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geohash_grid") + if (reader.ValueTextEquals(VariantGeohashGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohashGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geohex_grid") + if (reader.ValueTextEquals(VariantGeohexGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeohexGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_line") + if (reader.ValueTextEquals(VariantGeoLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoLine.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geotile_grid") + if (reader.ValueTextEquals(VariantGeotileGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeotileGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "global") + if (reader.ValueTextEquals(VariantGlobal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGlobal.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "histogram") + if (reader.ValueTextEquals(VariantHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_prefix") + if (reader.ValueTextEquals(VariantIpPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_range") + if (reader.ValueTextEquals(VariantIpRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "line") + if (reader.ValueTextEquals(VariantLine)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLine.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "matrix_stats") + if (reader.ValueTextEquals(VariantMatrixStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatrixStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "max") + if (reader.ValueTextEquals(VariantMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMax.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "max_bucket") + if (reader.ValueTextEquals(VariantMaxBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "median_absolute_deviation") + if (reader.ValueTextEquals(VariantMedianAbsoluteDeviation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMedianAbsoluteDeviation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "min") + if (reader.ValueTextEquals(VariantMin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "min_bucket") + if (reader.ValueTextEquals(VariantMinBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMinBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "missing") + if (reader.ValueTextEquals(VariantMissing)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMissing.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "moving_fn") + if (reader.ValueTextEquals(VariantMovingFn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingFn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "moving_percentiles") + if (reader.ValueTextEquals(VariantMovingPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMovingPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_terms") + if (reader.ValueTextEquals(VariantMultiTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "normalize") + if (reader.ValueTextEquals(VariantNormalize)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNormalize.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "parent") + if (reader.ValueTextEquals(VariantParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentile_ranks") + if (reader.ValueTextEquals(VariantPercentileRanks)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentileRanks.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentiles") + if (reader.ValueTextEquals(VariantPercentiles)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentiles.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percentiles_bucket") + if (reader.ValueTextEquals(VariantPercentilesBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercentilesBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "random_sampler") + if (reader.ValueTextEquals(VariantRandomSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRandomSampler.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rare_terms") + if (reader.ValueTextEquals(VariantRareTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRareTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rate") + if (reader.ValueTextEquals(VariantRate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "reverse_nested") + if (reader.ValueTextEquals(VariantReverseNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReverseNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sampler") + if (reader.ValueTextEquals(VariantSampler)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSampler.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "scripted_metric") + if (reader.ValueTextEquals(VariantScriptedMetric)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptedMetric.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "serial_diff") + if (reader.ValueTextEquals(VariantSerialDiff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSerialDiff.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "significant_terms") + if (reader.ValueTextEquals(VariantSignificantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "significant_text") + if (reader.ValueTextEquals(VariantSignificantText)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSignificantText.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stats") + if (reader.ValueTextEquals(VariantStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stats_bucket") + if (reader.ValueTextEquals(VariantStatsBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStatsBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "string_stats") + if (reader.ValueTextEquals(VariantStringStats)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStringStats.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sum") + if (reader.ValueTextEquals(VariantSum)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSum.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sum_bucket") + if (reader.ValueTextEquals(VariantSumBucket)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSumBucket.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "time_series") + if (reader.ValueTextEquals(VariantTimeSeries)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTimeSeries.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "top_hits") + if (reader.ValueTextEquals(VariantTopHits)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopHits.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "top_metrics") + if (reader.ValueTextEquals(VariantTopMetrics)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTopMetrics.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "t_test") + if (reader.ValueTextEquals(VariantTTest)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTTest.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "value_count") + if (reader.ValueTextEquals(VariantValueCount)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantValueCount.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "variable_width_histogram") + if (reader.ValueTextEquals(VariantVariableWidthHistogram)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantVariableWidthHistogram.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "weighted_avg") + if (reader.ValueTextEquals(VariantWeightedAvg)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeightedAvg.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Aggregation' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Aggregation(variantNameValue, variantValue); - result.Aggregations = aggregationsValue; - result.Meta = metaValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Aggregation + { + VariantType = variantType, + Variant = variant, + Aggregations = propAggregations.Value + , + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, Aggregation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Aggregation value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - - if (value.Meta is not null) + switch (value.VariantType) { - writer.WritePropertyName("meta"); - JsonSerializer.Serialize(writer, value.Meta, options); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "adjacency_matrix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AdjacencyMatrixAggregation)value.Variant, options); - break; - case "auto_date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation)value.Variant, options); - break; - case "avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AverageAggregation)value.Variant, options); - break; - case "avg_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.AverageBucketAggregation)value.Variant, options); - break; - case "boxplot": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregation)value.Variant, options); - break; - case "bucket_correlation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationAggregation)value.Variant, options); - break; - case "bucket_count_ks_test": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketKsAggregation)value.Variant, options); - break; - case "bucket_script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketScriptAggregation)value.Variant, options); - break; - case "bucket_selector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketSelectorAggregation)value.Variant, options); - break; - case "bucket_sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.BucketSortAggregation)value.Variant, options); - break; - case "cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregation)value.Variant, options); - break; - case "categorize_text": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CategorizeTextAggregation)value.Variant, options); - break; - case "children": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregation)value.Variant, options); - break; - case "composite": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregation)value.Variant, options); - break; - case "cumulative_cardinality": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregation)value.Variant, options); - break; - case "cumulative_sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeSumAggregation)value.Variant, options); - break; - case "date_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregation)value.Variant, options); - break; - case "date_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation)value.Variant, options); - break; - case "derivative": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregation)value.Variant, options); - break; - case "diversified_sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.DiversifiedSamplerAggregation)value.Variant, options); - break; - case "extended_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregation)value.Variant, options); - break; - case "extended_stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregation)value.Variant, options); - break; - case "filter": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Query)value.Variant, options); - break; - case "filters": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregation)value.Variant, options); - break; - case "frequent_item_sets": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregation)value.Variant, options); - break; - case "geo_bounds": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregation)value.Variant, options); - break; - case "geo_centroid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregation)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregation)value.Variant, options); - break; - case "geohash_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregation)value.Variant, options); - break; - case "geohex_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregation)value.Variant, options); - break; - case "geo_line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "geotile_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregation)value.Variant, options); - break; - case "global": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregation)value.Variant, options); - break; - case "histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregation)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregation)value.Variant, options); - break; - case "ip_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregation)value.Variant, options); - break; - case "ip_range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregation)value.Variant, options); - break; - case "line": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation)value.Variant, options); - break; - case "matrix_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation)value.Variant, options); - break; - case "max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MaxAggregation)value.Variant, options); - break; - case "max_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MaxBucketAggregation)value.Variant, options); - break; - case "median_absolute_deviation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregation)value.Variant, options); - break; - case "min": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MinAggregation)value.Variant, options); - break; - case "min_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MinBucketAggregation)value.Variant, options); - break; - case "missing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MissingAggregation)value.Variant, options); - break; - case "moving_fn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MovingFunctionAggregation)value.Variant, options); - break; - case "moving_percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MovingPercentilesAggregation)value.Variant, options); - break; - case "multi_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregation)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.NestedAggregation)value.Variant, options); - break; - case "normalize": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.NormalizeAggregation)value.Variant, options); - break; - case "parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ParentAggregation)value.Variant, options); - break; - case "percentile_ranks": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentileRanksAggregation)value.Variant, options); - break; - case "percentiles": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesAggregation)value.Variant, options); - break; - case "percentiles_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregation)value.Variant, options); - break; - case "random_sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RandomSamplerAggregation)value.Variant, options); - break; - case "range": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RangeAggregation)value.Variant, options); - break; - case "rare_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RareTermsAggregation)value.Variant, options); - break; - case "rate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.RateAggregation)value.Variant, options); - break; - case "reverse_nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregation)value.Variant, options); - break; - case "sampler": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregation)value.Variant, options); - break; - case "scripted_metric": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregation)value.Variant, options); - break; - case "serial_diff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SerialDifferencingAggregation)value.Variant, options); - break; - case "significant_terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTermsAggregation)value.Variant, options); - break; - case "significant_text": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTextAggregation)value.Variant, options); - break; - case "stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StatsAggregation)value.Variant, options); - break; - case "stats_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregation)value.Variant, options); - break; - case "string_stats": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregation)value.Variant, options); - break; - case "sum": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SumAggregation)value.Variant, options); - break; - case "sum_bucket": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.SumBucketAggregation)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TermsAggregation)value.Variant, options); - break; - case "time_series": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregation)value.Variant, options); - break; - case "top_hits": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregation)value.Variant, options); - break; - case "top_metrics": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregation)value.Variant, options); - break; - case "t_test": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.TTestAggregation)value.Variant, options); - break; - case "value_count": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregation)value.Variant, options); - break; - case "variable_width_histogram": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregation)value.Variant, options); - break; - case "weighted_avg": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation)value.Variant, options); - break; - } + case "": + break; + case "adjacency_matrix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AdjacencyMatrixAggregation?)value.Variant); + break; + case "auto_date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AutoDateHistogramAggregation?)value.Variant); + break; + case "avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AverageAggregation?)value.Variant); + break; + case "avg_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.AverageBucketAggregation?)value.Variant); + break; + case "boxplot": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BoxplotAggregation?)value.Variant); + break; + case "bucket_correlation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketCorrelationAggregation?)value.Variant); + break; + case "bucket_count_ks_test": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketKsAggregation?)value.Variant); + break; + case "bucket_script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketScriptAggregation?)value.Variant); + break; + case "bucket_selector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketSelectorAggregation?)value.Variant); + break; + case "bucket_sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.BucketSortAggregation?)value.Variant); + break; + case "cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CardinalityAggregation?)value.Variant); + break; + case "categorize_text": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CategorizeTextAggregation?)value.Variant); + break; + case "children": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ChildrenAggregation?)value.Variant); + break; + case "composite": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CompositeAggregation?)value.Variant); + break; + case "cumulative_cardinality": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeCardinalityAggregation?)value.Variant); + break; + case "cumulative_sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.CumulativeSumAggregation?)value.Variant); + break; + case "date_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DateHistogramAggregation?)value.Variant); + break; + case "date_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DateRangeAggregation?)value.Variant); + break; + case "derivative": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DerivativeAggregation?)value.Variant); + break; + case "diversified_sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.DiversifiedSamplerAggregation?)value.Variant); + break; + case "extended_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsAggregation?)value.Variant); + break; + case "extended_stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ExtendedStatsBucketAggregation?)value.Variant); + break; + case "filter": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Query?)value.Variant); + break; + case "filters": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.FiltersAggregation?)value.Variant); + break; + case "frequent_item_sets": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.FrequentItemSetsAggregation?)value.Variant); + break; + case "geo_bounds": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoBoundsAggregation?)value.Variant); + break; + case "geo_centroid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoCentroidAggregation?)value.Variant); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoDistanceAggregation?)value.Variant); + break; + case "geohash_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeohashGridAggregation?)value.Variant); + break; + case "geohex_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeohexGridAggregation?)value.Variant); + break; + case "geo_line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation?)value.Variant); + break; + case "geotile_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeotileGridAggregation?)value.Variant); + break; + case "global": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GlobalAggregation?)value.Variant); + break; + case "histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.HistogramAggregation?)value.Variant); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.InferenceAggregation?)value.Variant); + break; + case "ip_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.IpPrefixAggregation?)value.Variant); + break; + case "ip_range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.IpRangeAggregation?)value.Variant); + break; + case "line": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.GeoLineAggregation?)value.Variant); + break; + case "matrix_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MatrixStatsAggregation?)value.Variant); + break; + case "max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MaxAggregation?)value.Variant); + break; + case "max_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MaxBucketAggregation?)value.Variant); + break; + case "median_absolute_deviation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MedianAbsoluteDeviationAggregation?)value.Variant); + break; + case "min": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MinAggregation?)value.Variant); + break; + case "min_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MinBucketAggregation?)value.Variant); + break; + case "missing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MissingAggregation?)value.Variant); + break; + case "moving_fn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MovingFunctionAggregation?)value.Variant); + break; + case "moving_percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MovingPercentilesAggregation?)value.Variant); + break; + case "multi_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.MultiTermsAggregation?)value.Variant); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.NestedAggregation?)value.Variant); + break; + case "normalize": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.NormalizeAggregation?)value.Variant); + break; + case "parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ParentAggregation?)value.Variant); + break; + case "percentile_ranks": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentileRanksAggregation?)value.Variant); + break; + case "percentiles": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesAggregation?)value.Variant); + break; + case "percentiles_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.PercentilesBucketAggregation?)value.Variant); + break; + case "random_sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RandomSamplerAggregation?)value.Variant); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RangeAggregation?)value.Variant); + break; + case "rare_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RareTermsAggregation?)value.Variant); + break; + case "rate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.RateAggregation?)value.Variant); + break; + case "reverse_nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ReverseNestedAggregation?)value.Variant); + break; + case "sampler": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SamplerAggregation?)value.Variant); + break; + case "scripted_metric": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ScriptedMetricAggregation?)value.Variant); + break; + case "serial_diff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SerialDifferencingAggregation?)value.Variant); + break; + case "significant_terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTermsAggregation?)value.Variant); + break; + case "significant_text": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SignificantTextAggregation?)value.Variant); + break; + case "stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StatsAggregation?)value.Variant); + break; + case "stats_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StatsBucketAggregation?)value.Variant); + break; + case "string_stats": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.StringStatsAggregation?)value.Variant); + break; + case "sum": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SumAggregation?)value.Variant); + break; + case "sum_bucket": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.SumBucketAggregation?)value.Variant); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TermsAggregation?)value.Variant); + break; + case "time_series": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TimeSeriesAggregation?)value.Variant); + break; + case "top_hits": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TopHitsAggregation?)value.Variant); + break; + case "top_metrics": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TopMetricsAggregation?)value.Variant); + break; + case "t_test": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.TTestAggregation?)value.Variant); + break; + case "value_count": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.ValueCountAggregation?)value.Variant); + break; + case "variable_width_histogram": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.VariableWidthHistogramAggregation?)value.Variant); + break; + case "weighted_avg": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Aggregations.WeightedAverageAggregation?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Aggregation)}'."); } + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropMeta, value.Meta); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs index 3119d139dbc..6b9756f8e69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AutoDateHistogramAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class AutoDateHistogramAggregate : IAggregate public string Interval { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "auto_date_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs index c143e3b2a1b..ab3c7a298ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/AverageAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class AverageAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "avg"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs index 66c8eb6edfa..fe20d867b44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BoxplotAggregate.g.cs @@ -59,4 +59,6 @@ public sealed partial class BoxplotAggregate : IAggregate public double Upper { get; init; } [JsonInclude, JsonPropertyName("upper_as_string")] public string? UpperAsString { get; init; } + + string IAggregate.Type => "boxplot"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs index 1a32f623f8b..66853388aba 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketMetricValueAggregate.g.cs @@ -44,4 +44,6 @@ public sealed partial class BucketMetricValueAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "bucket_metric_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs index 85b70e68f2b..61a022f7e1d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/BucketSortAggregation.g.cs @@ -27,6 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class BucketSortAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropGapPolicy = System.Text.Json.JsonEncodedText.Encode("gap_policy"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override BucketSortAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFrom = default; + LocalJsonValue propGapPolicy = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propGapPolicy.TryRead(ref reader, options, PropGapPolicy)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BucketSortAggregation + { + From = propFrom.Value +, + GapPolicy = propGapPolicy.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BucketSortAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropGapPolicy, value.GapPolicy); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BucketSortAggregationConverter))] public sealed partial class BucketSortAggregation { /// @@ -34,7 +98,6 @@ public sealed partial class BucketSortAggregation /// Buckets in positions prior to from will be truncated. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -42,7 +105,6 @@ public sealed partial class BucketSortAggregation /// The policy to apply when gaps are found in the data. /// /// - [JsonInclude, JsonPropertyName("gap_policy")] public Elastic.Clients.Elasticsearch.Aggregations.GapPolicy? GapPolicy { get; set; } /// @@ -51,7 +113,6 @@ public sealed partial class BucketSortAggregation /// Defaults to all buckets of the parent aggregation. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -59,8 +120,6 @@ public sealed partial class BucketSortAggregation /// The list of fields to sort on. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(BucketSortAggregation bucketSortAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.BucketSort(bucketSortAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs index 945b2e1ae39..2da809d9617 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CardinalityAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class CardinalityAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("value")] public long Value { get; init; } + + string IAggregate.Type => "cardinality"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs index 072e2c3f5ca..70fd9783652 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ChildrenAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class ChildrenAggregateConverter : JsonConverter +internal sealed partial class ChildrenAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ChildrenAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ChildrenAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ChildrenAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChildrenAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ChildrenAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChildrenAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ChildrenAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class ChildrenAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "children"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs index 600426a0e04..cc7615b34d9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class CompositeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "composite"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs index 42e67f51da3..06b5d45245f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CompositeBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class CompositeBucketConverter : JsonConverter +internal sealed partial class CompositeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override CompositeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override CompositeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new CompositeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompositeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, CompositeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompositeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'CompositeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs index 5c0dcba229a..bc805586808 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/CumulativeCardinalityAggregate.g.cs @@ -40,4 +40,6 @@ public sealed partial class CumulativeCardinalityAggregate : IAggregate public long Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "simple_long_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs index f1e0896cdb3..6221ed36a4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class DateHistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "date_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs index a42bd78fdb7..2f3cc9237a5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramAggregation.g.cs @@ -27,6 +27,160 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class DateHistogramAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCalendarInterval = System.Text.Json.JsonEncodedText.Encode("calendar_interval"); + private static readonly System.Text.Json.JsonEncodedText PropExtendedBounds = System.Text.Json.JsonEncodedText.Encode("extended_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFixedInterval = System.Text.Json.JsonEncodedText.Encode("fixed_interval"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropHardBounds = System.Text.Json.JsonEncodedText.Encode("hard_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropParams = System.Text.Json.JsonEncodedText.Encode("params"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override DateHistogramAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCalendarInterval = default; + LocalJsonValue propExtendedBounds = default; + LocalJsonValue propField = default; + LocalJsonValue propFixedInterval = default; + LocalJsonValue propFormat = default; + LocalJsonValue propHardBounds = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propOffset = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue?> propParams = default; + LocalJsonValue propScript = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCalendarInterval.TryRead(ref reader, options, PropCalendarInterval)) + { + continue; + } + + if (propExtendedBounds.TryRead(ref reader, options, PropExtendedBounds)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFixedInterval.TryRead(ref reader, options, PropFixedInterval)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propHardBounds.TryRead(ref reader, options, PropHardBounds)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propParams.TryRead(ref reader, options, PropParams)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateHistogramAggregation + { + CalendarInterval = propCalendarInterval.Value +, + ExtendedBounds = propExtendedBounds.Value +, + Field = propField.Value +, + FixedInterval = propFixedInterval.Value +, + Format = propFormat.Value +, + HardBounds = propHardBounds.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + Offset = propOffset.Value +, + Order = propOrder.Value +, + Params = propParams.Value +, + Script = propScript.Value +, + TimeZone = propTimeZone.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateHistogramAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCalendarInterval, value.CalendarInterval); + writer.WriteProperty(options, PropExtendedBounds, value.ExtendedBounds); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFixedInterval, value.FixedInterval); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropHardBounds, value.HardBounds); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOrder, value.Order, null, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropParams, value.Params); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateHistogramAggregationConverter))] public sealed partial class DateHistogramAggregation { /// @@ -35,7 +189,6 @@ public sealed partial class DateHistogramAggregation /// Can be specified using the unit name, such as month, or as a single unit quantity, such as 1M. /// /// - [JsonInclude, JsonPropertyName("calendar_interval")] public Elastic.Clients.Elasticsearch.Aggregations.CalendarInterval? CalendarInterval { get; set; } /// @@ -43,7 +196,6 @@ public sealed partial class DateHistogramAggregation /// Enables extending the bounds of the histogram beyond the data itself. /// /// - [JsonInclude, JsonPropertyName("extended_bounds")] public Elastic.Clients.Elasticsearch.Aggregations.ExtendedBoundsDate? ExtendedBounds { get; set; } /// @@ -51,7 +203,6 @@ public sealed partial class DateHistogramAggregation /// The date field whose values are use to build a histogram. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -59,7 +210,6 @@ public sealed partial class DateHistogramAggregation /// Fixed intervals: a fixed number of SI units and never deviate, regardless of where they fall on the calendar. /// /// - [JsonInclude, JsonPropertyName("fixed_interval")] public Elastic.Clients.Elasticsearch.Duration? FixedInterval { get; set; } /// @@ -68,7 +218,6 @@ public sealed partial class DateHistogramAggregation /// If no format is specified, the first date format specified in the field mapping is used. /// /// - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -76,7 +225,6 @@ public sealed partial class DateHistogramAggregation /// Limits the histogram to specified bounds. /// /// - [JsonInclude, JsonPropertyName("hard_bounds")] public Elastic.Clients.Elasticsearch.Aggregations.ExtendedBoundsDate? HardBounds { get; set; } /// @@ -85,7 +233,6 @@ public sealed partial class DateHistogramAggregation /// By default, all buckets between the first bucket that matches documents and the last one are returned. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -94,7 +241,6 @@ public sealed partial class DateHistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public DateTimeOffset? Missing { get; set; } /// @@ -102,7 +248,6 @@ public sealed partial class DateHistogramAggregation /// Changes the start value of each bucket by the specified positive (+) or negative offset (-) duration. /// /// - [JsonInclude, JsonPropertyName("offset")] public Elastic.Clients.Elasticsearch.Duration? Offset { get; set; } /// @@ -110,12 +255,8 @@ public sealed partial class DateHistogramAggregation /// The sort order of the returned buckets. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("params")] public IDictionary? Params { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -124,7 +265,6 @@ public sealed partial class DateHistogramAggregation /// Defaults to Coordinated Universal Time (UTC). /// /// - [JsonInclude, JsonPropertyName("time_zone")] public string? TimeZone { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(DateHistogramAggregation dateHistogramAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.DateHistogram(dateHistogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs index 1c4587a37dd..bc9593819b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateHistogramBucket.g.cs @@ -27,56 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class DateHistogramBucketConverter : JsonConverter +internal sealed partial class DateHistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override DateHistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override DateHistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DateHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateHistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, DateHistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateHistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DateHistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs index 7c01bcdd83e..e68c891098e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DateRangeAggregate.g.cs @@ -39,4 +39,6 @@ public sealed partial class DateRangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "date_range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs index 6773162c7ea..4518efd8ec8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DerivativeAggregate.g.cs @@ -46,4 +46,6 @@ public sealed partial class DerivativeAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "derivative"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs index cab1c43b3f6..6f5e6ebb498 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class DoubleTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "dterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs index 7b41be3afc5..72d9c3496ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/DoubleTermsBucket.g.cs @@ -27,63 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class DoubleTermsBucketConverter : JsonConverter +internal sealed partial class DoubleTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override DoubleTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override DoubleTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - double key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new DoubleTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, DoubleTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DoubleTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs index bac3a657435..ab8f6273664 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsAggregate.g.cs @@ -77,4 +77,6 @@ public sealed partial class ExtendedStatsAggregate : IAggregate public double? VarianceSampling { get; init; } [JsonInclude, JsonPropertyName("variance_sampling_as_string")] public string? VarianceSamplingAsString { get; init; } + + string IAggregate.Type => "extended_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs index 745361506c4..675a13cef90 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ExtendedStatsBucketAggregate.g.cs @@ -77,4 +77,6 @@ public sealed partial class ExtendedStatsBucketAggregate : IAggregate public double? VarianceSampling { get; init; } [JsonInclude, JsonPropertyName("variance_sampling_as_string")] public string? VarianceSamplingAsString { get; init; } + + string IAggregate.Type => "extended_stats_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs index 20dac2acc0f..d900528c6f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FilterAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class FilterAggregateConverter : JsonConverter +internal sealed partial class FilterAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override FilterAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override FilterAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FilterAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FilterAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, FilterAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FilterAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FilterAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class FilterAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "filter"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs index 7dcc5086217..92f3527f2d0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class FiltersAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "filters"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs index 3551b48bfdb..863b175710e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FiltersBucket.g.cs @@ -27,42 +27,50 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class FiltersBucketConverter : JsonConverter +internal sealed partial class FiltersBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override FiltersBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + + public override FiltersBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FiltersBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FiltersBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value + }; } - public override void Write(Utf8JsonWriter writer, FiltersBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FiltersBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FiltersBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs index 10bd279d590..1f74798ffd2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class FrequentItemSetsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "frequent_item_sets"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs index 88ff41a35f0..c9ec83556bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/FrequentItemSetsBucket.g.cs @@ -27,56 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class FrequentItemSetsBucketConverter : JsonConverter +internal sealed partial class FrequentItemSetsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override FrequentItemSetsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropSupport = System.Text.Json.JsonEncodedText.Encode("support"); + + public override FrequentItemSetsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary> key = default; - double support = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue>> propKey = default; + LocalJsonValue propSupport = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>>(ref reader, options); - continue; - } - - if (property == "support") - { - support = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propSupport.TryRead(ref reader, options, PropSupport)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new FrequentItemSetsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, Support = support }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FrequentItemSetsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + Support = propSupport.Value + }; } - public override void Write(Utf8JsonWriter writer, FrequentItemSetsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FrequentItemSetsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'FrequentItemSetsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropSupport, value.Support); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs index ddc34a2eb4e..d32da055e1e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoBoundsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeoBoundsAggregate : IAggregate public Elastic.Clients.Elasticsearch.GeoBounds? Bounds { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_bounds"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs index 4be076472e7..094be70d111 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoCentroidAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class GeoCentroidAggregate : IAggregate public Elastic.Clients.Elasticsearch.GeoLocation? Location { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_centroid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs index b3d316f4f5e..65021295d16 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoDistanceAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class GeoDistanceAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geo_distance"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs index 5191273fae9..b10bbf7fd47 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeoLineAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class GeoLineAggregate : IAggregate public object Properties { get; init; } [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } + + string IAggregate.Type => "geo_line"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs index 5b7c3c64f79..71da7edf506 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeohashGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geohash_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs index 8a8a6bc482c..633af56910f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohashGridBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class GeohashGridBucketConverter : JsonConverter +internal sealed partial class GeohashGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeohashGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeohashGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohashGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohashGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeohashGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeohashGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeohashGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs index b70f968b98f..dcee019a9fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeohexGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geohex_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs index 4863f027671..2fc150f4ce4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeohexGridBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class GeohexGridBucketConverter : JsonConverter +internal sealed partial class GeohexGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeohexGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeohexGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeohexGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeohexGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeohexGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeohexGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeohexGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs index ff2bbda7bd4..25650a1c804 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class GeotileGridAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "geotile_grid"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs index 8c03fbf568d..f8c13e1b576 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GeotileGridBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class GeotileGridBucketConverter : JsonConverter +internal sealed partial class GeotileGridBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override GeotileGridBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override GeotileGridBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GeotileGridBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeotileGridBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, GeotileGridBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeotileGridBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GeotileGridBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs index 6ba1c78191d..bc5e08e314f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/GlobalAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class GlobalAggregateConverter : JsonConverter +internal sealed partial class GlobalAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override GlobalAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override GlobalAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new GlobalAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GlobalAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, GlobalAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GlobalAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'GlobalAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class GlobalAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "global"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs index dcf051f90b2..6441261ca4a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentileRanksAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HdrPercentileRanksAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs index f82bc12e77d..0ad880053f6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HdrPercentilesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HdrPercentilesAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "hdr_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs index e96f1a21eda..01cd6fbc1d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class HistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs index cd3c90e0d08..8f7fe793ead 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramAggregation.g.cs @@ -27,6 +27,130 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class HistogramAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropExtendedBounds = System.Text.Json.JsonEncodedText.Encode("extended_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropHardBounds = System.Text.Json.JsonEncodedText.Encode("hard_bounds"); + private static readonly System.Text.Json.JsonEncodedText PropInterval = System.Text.Json.JsonEncodedText.Encode("interval"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override HistogramAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propExtendedBounds = default; + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propHardBounds = default; + LocalJsonValue propInterval = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propOffset = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propScript = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExtendedBounds.TryRead(ref reader, options, PropExtendedBounds)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propHardBounds.TryRead(ref reader, options, PropHardBounds)) + { + continue; + } + + if (propInterval.TryRead(ref reader, options, PropInterval)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramAggregation + { + ExtendedBounds = propExtendedBounds.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + HardBounds = propHardBounds.Value +, + Interval = propInterval.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + Offset = propOffset.Value +, + Order = propOrder.Value +, + Script = propScript.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExtendedBounds, value.ExtendedBounds); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropHardBounds, value.HardBounds); + writer.WriteProperty(options, PropInterval, value.Interval); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOrder, value.Order, null, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HistogramAggregationConverter))] public sealed partial class HistogramAggregation { /// @@ -34,7 +158,6 @@ public sealed partial class HistogramAggregation /// Enables extending the bounds of the histogram beyond the data itself. /// /// - [JsonInclude, JsonPropertyName("extended_bounds")] public Elastic.Clients.Elasticsearch.Aggregations.ExtendedBoundsFloat? ExtendedBounds { get; set; } /// @@ -42,9 +165,7 @@ public sealed partial class HistogramAggregation /// The name of the field to aggregate on. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -53,7 +174,6 @@ public sealed partial class HistogramAggregation /// It is particularly useful in the case of open data ranges that can result in a very large number of buckets. /// /// - [JsonInclude, JsonPropertyName("hard_bounds")] public Elastic.Clients.Elasticsearch.Aggregations.ExtendedBoundsFloat? HardBounds { get; set; } /// @@ -62,7 +182,6 @@ public sealed partial class HistogramAggregation /// Must be a positive decimal. /// /// - [JsonInclude, JsonPropertyName("interval")] public double? Interval { get; set; } /// @@ -71,7 +190,6 @@ public sealed partial class HistogramAggregation /// By default, the response will fill gaps in the histogram with empty buckets. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -80,7 +198,6 @@ public sealed partial class HistogramAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public double? Missing { get; set; } /// @@ -89,7 +206,6 @@ public sealed partial class HistogramAggregation /// The bucket boundaries can be shifted by using the offset option. /// /// - [JsonInclude, JsonPropertyName("offset")] public double? Offset { get; set; } /// @@ -98,10 +214,7 @@ public sealed partial class HistogramAggregation /// By default, the returned buckets are sorted by their key ascending. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(HistogramAggregation histogramAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.Histogram(histogramAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs index e1641587177..32d91099c12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/HistogramBucket.g.cs @@ -27,56 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class HistogramBucketConverter : JsonConverter +internal sealed partial class HistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override HistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override HistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new HistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, HistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'HistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs index 19e7421f99a..ecf00747937 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceAggregate.g.cs @@ -27,65 +27,90 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class InferenceAggregateConverter : JsonConverter +internal sealed partial class InferenceAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureImportance = System.Text.Json.JsonEncodedText.Encode("feature_importance"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropTopClasses = System.Text.Json.JsonEncodedText.Encode("top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + private static readonly System.Text.Json.JsonEncodedText PropWarning = System.Text.Json.JsonEncodedText.Encode("warning"); + + public override InferenceAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection? featureImportance = default; - IReadOnlyDictionary? meta = default; - IReadOnlyCollection? topClasses = default; - Elastic.Clients.Elasticsearch.FieldValue? value = default; - string? warning = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propData = default; + LocalJsonValue?> propFeatureImportance = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue?> propTopClasses = default; + LocalJsonValue propValue = default; + LocalJsonValue propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFeatureImportance.TryRead(ref reader, options, PropFeatureImportance)) { - var property = reader.GetString(); - if (property == "feature_importance") - { - featureImportance = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; + } - if (property == "top_classes") - { - topClasses = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } - if (property == "value") - { - value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propTopClasses.TryRead(ref reader, options, PropTopClasses)) + { + continue; + } - if (property == "warning") - { - warning = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propWarning.TryRead(ref reader, options, PropWarning)) + { + continue; } + + propData ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propData[key] = value; } - return new InferenceAggregate { Data = additionalProperties, FeatureImportance = featureImportance, Meta = meta, TopClasses = topClasses, Value = value, Warning = warning }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceAggregate + { + Data = propData +, + FeatureImportance = propFeatureImportance.Value +, + Meta = propMeta.Value +, + TopClasses = propTopClasses.Value +, + Value = propValue.Value +, + Warning = propWarning.Value + }; } - public override void Write(Utf8JsonWriter writer, InferenceAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'InferenceAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureImportance, value.FeatureImportance); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropTopClasses, value.TopClasses); + writer.WriteProperty(options, PropValue, value.Value); + writer.WriteProperty(options, PropWarning, value.Warning); + if (value.Data is not null) + { + foreach (var item in value.Data) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -103,4 +128,6 @@ public sealed partial class InferenceAggregate : IAggregate public IReadOnlyCollection? TopClasses { get; init; } public Elastic.Clients.Elasticsearch.FieldValue? Value { get; init; } public string? Warning { get; init; } + + string IAggregate.Type => "inference"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs index 431c4cac795..73f1d77e5da 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/InferenceConfig.g.cs @@ -39,12 +39,16 @@ internal InferenceConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfig Classification(Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfig("classification", classificationInferenceOptions); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions regressionInferenceOptions) => new InferenceConfig("regression", regressionInferenceOptions); @@ -62,67 +66,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigConverter : JsonConverter +internal sealed partial class InferenceConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override InferenceConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs index ecd1258985b..a7e1a34d9df 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class IpPrefixAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "ip_prefix"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs index e03c5122173..617a59df0ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpPrefixBucket.g.cs @@ -27,70 +27,90 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class IpPrefixBucketConverter : JsonConverter +internal sealed partial class IpPrefixBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override IpPrefixBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropIsIpv6 = System.Text.Json.JsonEncodedText.Encode("is_ipv6"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropNetmask = System.Text.Json.JsonEncodedText.Encode("netmask"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + + public override IpPrefixBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - bool isIpv6 = default; - string key = default; - string? netmask = default; - int prefixLength = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propIsIpv6 = default; + LocalJsonValue propKey = default; + LocalJsonValue propNetmask = default; + LocalJsonValue propPrefixLength = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "is_ipv6") - { - isIpv6 = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "netmask") - { - netmask = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propIsIpv6.TryRead(ref reader, options, PropIsIpv6)) + { + continue; + } - if (property == "prefix_length") - { - prefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propNetmask.TryRead(ref reader, options, PropNetmask)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpPrefixBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, IsIpv6 = isIpv6, Key = key, Netmask = netmask, PrefixLength = prefixLength }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpPrefixBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + IsIpv6 = propIsIpv6.Value +, + Key = propKey.Value +, + Netmask = propNetmask.Value +, + PrefixLength = propPrefixLength.Value + }; } - public override void Write(Utf8JsonWriter writer, IpPrefixBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpPrefixBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'IpPrefixBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropIsIpv6, value.IsIpv6); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropNetmask, value.Netmask); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs index b29a4b1c35b..eeaf5ca6df9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class IpRangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "ip_range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs index ea2b231722d..181abe695bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/IpRangeBucket.g.cs @@ -27,63 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class IpRangeBucketConverter : JsonConverter +internal sealed partial class IpRangeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override IpRangeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropTo = System.Text.Json.JsonEncodedText.Encode("to"); + + public override IpRangeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string? from = default; - string? key = default; - string? to = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propFrom = default; + LocalJsonValue propKey = default; + LocalJsonValue propTo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from") - { - from = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "to") - { - to = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propTo.TryRead(ref reader, options, PropTo)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new IpRangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, From = from, Key = key, To = to }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpRangeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + From = propFrom.Value +, + Key = propKey.Value +, + To = propTo.Value + }; } - public override void Write(Utf8JsonWriter writer, IpRangeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpRangeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'IpRangeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropTo, value.To); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs index 13fa685df54..2e3ba8cc6c7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class LongRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "lrareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs index 11dc48330e5..a55997625a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongRareTermsBucket.g.cs @@ -27,56 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class LongRareTermsBucketConverter : JsonConverter +internal sealed partial class LongRareTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override LongRareTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override LongRareTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, LongRareTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongRareTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'LongRareTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs index 11c3ad82fae..68f568817bd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class LongTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "lterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs index e6e6265dbfa..f017b127653 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/LongTermsBucket.g.cs @@ -27,63 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class LongTermsBucketConverter : JsonConverter +internal sealed partial class LongTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override LongTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override LongTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - long key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new LongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, LongTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'LongTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs index 6b941174faf..bf3ee2fe366 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class MatrixStatsAggregate : IAggregate public IReadOnlyCollection? Fields { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "matrix_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs index db56e60d7af..8fe27f8343a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsAggregation.g.cs @@ -27,6 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class MatrixStatsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + + public override MatrixStatsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue?> propMissing = default; + LocalJsonValue propMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatrixStatsAggregation + { + Fields = propFields.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatrixStatsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MatrixStatsAggregationConverter))] public sealed partial class MatrixStatsAggregation { /// @@ -34,8 +88,6 @@ public sealed partial class MatrixStatsAggregation /// An array of fields for computing the statistics. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -44,7 +96,6 @@ public sealed partial class MatrixStatsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public IDictionary? Missing { get; set; } /// @@ -52,7 +103,6 @@ public sealed partial class MatrixStatsAggregation /// Array value the aggregation will use for array or multi-valued fields. /// /// - [JsonInclude, JsonPropertyName("mode")] public Elastic.Clients.Elasticsearch.SortMode? Mode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(MatrixStatsAggregation matrixStatsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.MatrixStats(matrixStatsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs index f1b01e2dbb5..281880059ab 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MatrixStatsFields.g.cs @@ -30,12 +30,10 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; public sealed partial class MatrixStatsFields { [JsonInclude, JsonPropertyName("correlation")] - [ReadOnlyFieldDictionaryConverter(typeof(double))] public IReadOnlyDictionary Correlation { get; init; } [JsonInclude, JsonPropertyName("count")] public long Count { get; init; } [JsonInclude, JsonPropertyName("covariance")] - [ReadOnlyFieldDictionaryConverter(typeof(double))] public IReadOnlyDictionary Covariance { get; init; } [JsonInclude, JsonPropertyName("kurtosis")] public double Kurtosis { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs index cddda334221..bc132975c80 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MaxAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MaxAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "max"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs index 4d868eea1db..add5e70c90f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MedianAbsoluteDeviationAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MedianAbsoluteDeviationAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "median_absolute_deviation"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs index 08ab4f8d939..977bcf74f06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MinAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class MinAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "min"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs index 230547ba313..061f4a1f550 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MissingAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class MissingAggregateConverter : JsonConverter +internal sealed partial class MissingAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override MissingAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override MissingAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MissingAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MissingAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, MissingAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MissingAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'MissingAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class MissingAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "missing"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs index 8b9a14cd9a2..db9b5ed3a40 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class MultiTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "multi_terms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs index 962a8a079e2..bb2386e7185 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsAggregation.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class MultiTermsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollectMode = System.Text.Json.JsonEncodedText.Encode("collect_mode"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropShowTermDocCountError = System.Text.Json.JsonEncodedText.Encode("show_term_doc_count_error"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override MultiTermsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCollectMode = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propShowTermDocCountError = default; + LocalJsonValue propSize = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryRead(ref reader, options, PropCollectMode)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propShowTermDocCountError.TryRead(ref reader, options, PropShowTermDocCountError)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermsAggregation + { + CollectMode = propCollectMode.Value +, + MinDocCount = propMinDocCount.Value +, + Order = propOrder.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + ShowTermDocCountError = propShowTermDocCountError.Value +, + Size = propSize.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollectMode, value.CollectMode); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropOrder, value.Order, null, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropTerms, value.Terms); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermsAggregationConverter))] public sealed partial class MultiTermsAggregation { /// @@ -34,7 +138,6 @@ public sealed partial class MultiTermsAggregation /// Specifies the strategy for data collection. /// /// - [JsonInclude, JsonPropertyName("collect_mode")] public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -42,7 +145,6 @@ public sealed partial class MultiTermsAggregation /// The minimum number of documents in a bucket for it to be returned. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public long? MinDocCount { get; set; } /// @@ -51,8 +153,6 @@ public sealed partial class MultiTermsAggregation /// Defaults to sorting by descending document count. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } /// @@ -60,7 +160,6 @@ public sealed partial class MultiTermsAggregation /// The minimum number of documents in a bucket on each shard for it to be returned. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -69,7 +168,6 @@ public sealed partial class MultiTermsAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -77,7 +175,6 @@ public sealed partial class MultiTermsAggregation /// Calculates the doc count error on per term basis. /// /// - [JsonInclude, JsonPropertyName("show_term_doc_count_error")] public bool? ShowTermDocCountError { get; set; } /// @@ -85,7 +182,6 @@ public sealed partial class MultiTermsAggregation /// The number of term buckets should be returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -93,7 +189,6 @@ public sealed partial class MultiTermsAggregation /// The field from which to generate sets of terms. /// /// - [JsonInclude, JsonPropertyName("terms")] public ICollection Terms { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(MultiTermsAggregation multiTermsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.MultiTerms(multiTermsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs index 003b8283ea2..06668e56f25 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/MultiTermsBucket.g.cs @@ -27,63 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class MultiTermsBucketConverter : JsonConverter +internal sealed partial class MultiTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override MultiTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + + public override MultiTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - IReadOnlyCollection key = default; - string? keyAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue> propKey = default; + LocalJsonValue propKeyAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new MultiTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key, KeyAsString = keyAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, MultiTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'MultiTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs index e38814bec14..3770c603099 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/NestedAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class NestedAggregateConverter : JsonConverter +internal sealed partial class NestedAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override NestedAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override NestedAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new NestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, NestedAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NestedAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NestedAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class NestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "nested"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs index 33739b8289d..9ec9c660f8c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ParentAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class ParentAggregateConverter : JsonConverter +internal sealed partial class ParentAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ParentAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ParentAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ParentAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ParentAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ParentAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ParentAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ParentAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class ParentAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "parent"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs index bed01ff53b2..a287e24e293 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/PercentilesBucketAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class PercentilesBucketAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "percentiles_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs index e9df9b37862..4de004441cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class RangeAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "range"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs index b8079e6ad04..f3d2400765b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RangeBucket.g.cs @@ -27,77 +27,100 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class RangeBucketConverter : JsonConverter +internal sealed partial class RangeBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override RangeBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropFromAsString = System.Text.Json.JsonEncodedText.Encode("from_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropTo = System.Text.Json.JsonEncodedText.Encode("to"); + private static readonly System.Text.Json.JsonEncodedText PropToAsString = System.Text.Json.JsonEncodedText.Encode("to_as_string"); + + public override RangeBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double? from = default; - string? fromAsString = default; - string? key = default; - double? to = default; - string? toAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propFrom = default; + LocalJsonValue propFromAsString = default; + LocalJsonValue propKey = default; + LocalJsonValue propTo = default; + LocalJsonValue propToAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propFromAsString.TryRead(ref reader, options, PropFromAsString)) + { + continue; + } + + if (propKey.TryRead(ref reader, options, PropKey)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from") - { - from = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "from_as_string") - { - fromAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "to") - { - to = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "to_as_string") - { - toAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + if (propTo.TryRead(ref reader, options, PropTo)) + { + continue; + } + + if (propToAsString.TryRead(ref reader, options, PropToAsString)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new RangeBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, From = from, FromAsString = fromAsString, Key = key, To = to, ToAsString = toAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RangeBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + From = propFrom.Value +, + FromAsString = propFromAsString.Value +, + Key = propKey.Value +, + To = propTo.Value +, + ToAsString = propToAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, RangeBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RangeBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'RangeBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropFromAsString, value.FromAsString); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropTo, value.To); + writer.WriteProperty(options, PropToAsString, value.ToAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs index 4718e6f1823..a6459e2ae44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/RateAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class RateAggregate : IAggregate public double Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "rate"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs index ec6aff078dd..716f6c9acfc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ReverseNestedAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class ReverseNestedAggregateConverter : JsonConverter +internal sealed partial class ReverseNestedAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override ReverseNestedAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override ReverseNestedAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new ReverseNestedAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ReverseNestedAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, ReverseNestedAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ReverseNestedAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ReverseNestedAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class ReverseNestedAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "reverse_nested"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs index 422f7d9a8df..9a6a8831cdc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SamplerAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class SamplerAggregateConverter : JsonConverter +internal sealed partial class SamplerAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override SamplerAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override SamplerAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, SamplerAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamplerAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SamplerAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class SamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "sampler"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs index 64ca2bf26ce..d5ec9eaf5a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ScriptedMetricAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class ScriptedMetricAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("value")] public object Value { get; init; } + + string IAggregate.Type => "scripted_metric"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs index 04c561fc339..3ffae488fb0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class SignificantLongTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "siglterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs index bc249c8d098..1b557888ee4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantLongTermsBucket.g.cs @@ -27,70 +27,90 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class SignificantLongTermsBucketConverter : JsonConverter +internal sealed partial class SignificantLongTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override SignificantLongTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropBgCount = System.Text.Json.JsonEncodedText.Encode("bg_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override SignificantLongTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long bgCount = default; - long docCount = default; - long key = default; - string? keyAsString = default; - double score = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propBgCount = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + LocalJsonValue propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryRead(ref reader, options, PropBgCount)) { - var property = reader.GetString(); - if (property == "bg_count") - { - bgCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } - if (property == "score") - { - score = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantLongTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), BgCount = bgCount, DocCount = docCount, Key = key, KeyAsString = keyAsString, Score = score }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantLongTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + BgCount = propBgCount.Value +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value +, + Score = propScore.Value + }; } - public override void Write(Utf8JsonWriter writer, SignificantLongTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantLongTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SignificantLongTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBgCount, value.BgCount); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + writer.WriteProperty(options, PropScore, value.Score); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs index e2e799a941e..661f9002353 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsAggregate.g.cs @@ -37,4 +37,6 @@ public sealed partial class SignificantStringTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "sigsterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs index 557a647c326..09e7496ecd3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantStringTermsBucket.g.cs @@ -27,63 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class SignificantStringTermsBucketConverter : JsonConverter +internal sealed partial class SignificantStringTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override SignificantStringTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropBgCount = System.Text.Json.JsonEncodedText.Encode("bg_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override SignificantStringTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long bgCount = default; - long docCount = default; - string key = default; - double score = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propBgCount = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propScore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBgCount.TryRead(ref reader, options, PropBgCount)) { - var property = reader.GetString(); - if (property == "bg_count") - { - bgCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "score") - { - score = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new SignificantStringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), BgCount = bgCount, DocCount = docCount, Key = key, Score = score }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantStringTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + BgCount = propBgCount.Value +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + Score = propScore.Value + }; } - public override void Write(Utf8JsonWriter writer, SignificantStringTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantStringTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SignificantStringTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBgCount, value.BgCount); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropScore, value.Score); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs index 09fa408e2cf..e0e2a35ba22 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SignificantTextAggregation.g.cs @@ -27,6 +27,200 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class SignificantTextAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackgroundFilter = System.Text.Json.JsonEncodedText.Encode("background_filter"); + private static readonly System.Text.Json.JsonEncodedText PropChiSquare = System.Text.Json.JsonEncodedText.Encode("chi_square"); + private static readonly System.Text.Json.JsonEncodedText PropExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropExecutionHint = System.Text.Json.JsonEncodedText.Encode("execution_hint"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilterDuplicateText = System.Text.Json.JsonEncodedText.Encode("filter_duplicate_text"); + private static readonly System.Text.Json.JsonEncodedText PropGnd = System.Text.Json.JsonEncodedText.Encode("gnd"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropJlh = System.Text.Json.JsonEncodedText.Encode("jlh"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMutualInformation = System.Text.Json.JsonEncodedText.Encode("mutual_information"); + private static readonly System.Text.Json.JsonEncodedText PropPercentage = System.Text.Json.JsonEncodedText.Encode("percentage"); + private static readonly System.Text.Json.JsonEncodedText PropScriptHeuristic = System.Text.Json.JsonEncodedText.Encode("script_heuristic"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSourceFields = System.Text.Json.JsonEncodedText.Encode("source_fields"); + + public override SignificantTextAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBackgroundFilter = default; + LocalJsonValue propChiSquare = default; + LocalJsonValue propExclude = default; + LocalJsonValue propExecutionHint = default; + LocalJsonValue propField = default; + LocalJsonValue propFilterDuplicateText = default; + LocalJsonValue propGnd = default; + LocalJsonValue propInclude = default; + LocalJsonValue propJlh = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMutualInformation = default; + LocalJsonValue propPercentage = default; + LocalJsonValue propScriptHeuristic = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propSize = default; + LocalJsonValue propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackgroundFilter.TryRead(ref reader, options, PropBackgroundFilter)) + { + continue; + } + + if (propChiSquare.TryRead(ref reader, options, PropChiSquare)) + { + continue; + } + + if (propExclude.TryRead(ref reader, options, PropExclude)) + { + continue; + } + + if (propExecutionHint.TryRead(ref reader, options, PropExecutionHint)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilterDuplicateText.TryRead(ref reader, options, PropFilterDuplicateText)) + { + continue; + } + + if (propGnd.TryRead(ref reader, options, PropGnd)) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propJlh.TryRead(ref reader, options, PropJlh)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMutualInformation.TryRead(ref reader, options, PropMutualInformation)) + { + continue; + } + + if (propPercentage.TryRead(ref reader, options, PropPercentage)) + { + continue; + } + + if (propScriptHeuristic.TryRead(ref reader, options, PropScriptHeuristic)) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSourceFields.TryRead(ref reader, options, PropSourceFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SignificantTextAggregation + { + BackgroundFilter = propBackgroundFilter.Value +, + ChiSquare = propChiSquare.Value +, + Exclude = propExclude.Value +, + ExecutionHint = propExecutionHint.Value +, + Field = propField.Value +, + FilterDuplicateText = propFilterDuplicateText.Value +, + Gnd = propGnd.Value +, + Include = propInclude.Value +, + Jlh = propJlh.Value +, + MinDocCount = propMinDocCount.Value +, + MutualInformation = propMutualInformation.Value +, + Percentage = propPercentage.Value +, + ScriptHeuristic = propScriptHeuristic.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + Size = propSize.Value +, + SourceFields = propSourceFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SignificantTextAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackgroundFilter, value.BackgroundFilter); + writer.WriteProperty(options, PropChiSquare, value.ChiSquare); + writer.WriteProperty(options, PropExclude, value.Exclude); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilterDuplicateText, value.FilterDuplicateText); + writer.WriteProperty(options, PropGnd, value.Gnd); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropJlh, value.Jlh); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMutualInformation, value.MutualInformation); + writer.WriteProperty(options, PropPercentage, value.Percentage); + writer.WriteProperty(options, PropScriptHeuristic, value.ScriptHeuristic); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SignificantTextAggregationConverter))] public sealed partial class SignificantTextAggregation { /// @@ -34,7 +228,6 @@ public sealed partial class SignificantTextAggregation /// A background filter that can be used to focus in on significant terms within a narrower context, instead of the entire index. /// /// - [JsonInclude, JsonPropertyName("background_filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? BackgroundFilter { get; set; } /// @@ -42,7 +235,6 @@ public sealed partial class SignificantTextAggregation /// Use Chi square, as described in "Information Retrieval", Manning et al., Chapter 13.5.2, as the significance score. /// /// - [JsonInclude, JsonPropertyName("chi_square")] public Elastic.Clients.Elasticsearch.Aggregations.ChiSquareHeuristic? ChiSquare { get; set; } /// @@ -50,7 +242,6 @@ public sealed partial class SignificantTextAggregation /// Values to exclude. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -58,7 +249,6 @@ public sealed partial class SignificantTextAggregation /// Determines whether the aggregation will use field values directly or global ordinals. /// /// - [JsonInclude, JsonPropertyName("execution_hint")] public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -66,7 +256,6 @@ public sealed partial class SignificantTextAggregation /// The field from which to return significant text. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -74,7 +263,6 @@ public sealed partial class SignificantTextAggregation /// Whether to out duplicate text to deal with noisy data. /// /// - [JsonInclude, JsonPropertyName("filter_duplicate_text")] public bool? FilterDuplicateText { get; set; } /// @@ -82,7 +270,6 @@ public sealed partial class SignificantTextAggregation /// Use Google normalized distance as described in "The Google Similarity Distance", Cilibrasi and Vitanyi, 2007, as the significance score. /// /// - [JsonInclude, JsonPropertyName("gnd")] public Elastic.Clients.Elasticsearch.Aggregations.GoogleNormalizedDistanceHeuristic? Gnd { get; set; } /// @@ -90,7 +277,6 @@ public sealed partial class SignificantTextAggregation /// Values to include. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? Include { get; set; } /// @@ -98,7 +284,6 @@ public sealed partial class SignificantTextAggregation /// Use JLH score as the significance score. /// /// - [JsonInclude, JsonPropertyName("jlh")] public Elastic.Clients.Elasticsearch.EmptyObject? Jlh { get; set; } /// @@ -106,7 +291,6 @@ public sealed partial class SignificantTextAggregation /// Only return values that are found in more than min_doc_count hits. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public long? MinDocCount { get; set; } /// @@ -114,7 +298,6 @@ public sealed partial class SignificantTextAggregation /// Use mutual information as described in "Information Retrieval", Manning et al., Chapter 13.5.1, as the significance score. /// /// - [JsonInclude, JsonPropertyName("mutual_information")] public Elastic.Clients.Elasticsearch.Aggregations.MutualInformationHeuristic? MutualInformation { get; set; } /// @@ -122,7 +305,6 @@ public sealed partial class SignificantTextAggregation /// A simple calculation of the number of documents in the foreground sample with a term divided by the number of documents in the background with the term. /// /// - [JsonInclude, JsonPropertyName("percentage")] public Elastic.Clients.Elasticsearch.Aggregations.PercentageScoreHeuristic? Percentage { get; set; } /// @@ -130,7 +312,6 @@ public sealed partial class SignificantTextAggregation /// Customized score, implemented via a script. /// /// - [JsonInclude, JsonPropertyName("script_heuristic")] public Elastic.Clients.Elasticsearch.Aggregations.ScriptedHeuristic? ScriptHeuristic { get; set; } /// @@ -139,7 +320,6 @@ public sealed partial class SignificantTextAggregation /// Values will only be considered if their local shard frequency within the set is higher than the shard_min_doc_count. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -148,7 +328,6 @@ public sealed partial class SignificantTextAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -156,7 +335,6 @@ public sealed partial class SignificantTextAggregation /// The number of buckets returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -164,8 +342,6 @@ public sealed partial class SignificantTextAggregation /// Overrides the JSON _source fields from which text will be analyzed. /// /// - [JsonInclude, JsonPropertyName("source_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? SourceFields { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(SignificantTextAggregation significantTextAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.SignificantText(significantTextAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs index 00e7be7375c..bb3f6596d98 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SimpleValueAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class SimpleValueAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "simple_value"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs index 35562889db5..91517ba499c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsAggregate.g.cs @@ -55,4 +55,6 @@ public sealed partial class StatsAggregate : IAggregate public double Sum { get; init; } [JsonInclude, JsonPropertyName("sum_as_string")] public string? SumAsString { get; init; } + + string IAggregate.Type => "stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs index ec9d642824d..09b53f1f69c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StatsBucketAggregate.g.cs @@ -49,4 +49,6 @@ public sealed partial class StatsBucketAggregate : IAggregate public double Sum { get; init; } [JsonInclude, JsonPropertyName("sum_as_string")] public string? SumAsString { get; init; } + + string IAggregate.Type => "stats_bucket"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs index 405760fb953..6a18899063a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class StringRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "srareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs index f704ddde80d..f6c716b7214 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringRareTermsBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class StringRareTermsBucketConverter : JsonConverter +internal sealed partial class StringRareTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override StringRareTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override StringRareTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - string key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringRareTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringRareTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, StringRareTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringRareTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'StringRareTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs index 2bcd1cd10f5..e14b0af63ae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringStatsAggregate.g.cs @@ -49,4 +49,6 @@ public sealed partial class StringStatsAggregate : IAggregate public int? MinLength { get; init; } [JsonInclude, JsonPropertyName("min_length_as_string")] public string? MinLengthAsString { get; init; } + + string IAggregate.Type => "string_stats"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs index 91cc63038f0..c6fd70e6a53 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class StringTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "sterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs index 72ce873ca08..6f8bcd9970e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/StringTermsBucket.g.cs @@ -27,56 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class StringTermsBucketConverter : JsonConverter +internal sealed partial class StringTermsBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override StringTermsBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropDocCountErrorUpperBound = System.Text.Json.JsonEncodedText.Encode("doc_count_error_upper_bound"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override StringTermsBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - long? docCountErrorUpperBound = default; - Elastic.Clients.Elasticsearch.FieldValue key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propDocCountErrorUpperBound = default; + LocalJsonValue propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "doc_count_error_upper_bound") - { - docCountErrorUpperBound = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + if (propDocCountErrorUpperBound.TryRead(ref reader, options, PropDocCountErrorUpperBound)) + { + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new StringTermsBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, DocCountErrorUpperBound = docCountErrorUpperBound, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StringTermsBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + DocCountErrorUpperBound = propDocCountErrorUpperBound.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, StringTermsBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringTermsBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'StringTermsBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropDocCountErrorUpperBound, value.DocCountErrorUpperBound); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs index 23cb1250502..e5eae8deea3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/SumAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class SumAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "sum"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs index b38f73b6d5a..13948b12299 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentileRanksAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TDigestPercentileRanksAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentile_ranks"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs index 4a7003596af..4dc5e72c56a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TDigestPercentilesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TDigestPercentilesAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("values")] public Elastic.Clients.Elasticsearch.Aggregations.Percentiles Values { get; init; } + + string IAggregate.Type => "tdigest_percentiles"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs index a152f0c5218..0d047c25331 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TTestAggregate.g.cs @@ -35,4 +35,6 @@ public sealed partial class TTestAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "t_test"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs index f49f740db06..528624ae9b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TermsAggregation.g.cs @@ -27,6 +27,200 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class TermsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollectMode = System.Text.Json.JsonEncodedText.Encode("collect_mode"); + private static readonly System.Text.Json.JsonEncodedText PropExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropExecutionHint = System.Text.Json.JsonEncodedText.Encode("execution_hint"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocCount = System.Text.Json.JsonEncodedText.Encode("min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMissingBucket = System.Text.Json.JsonEncodedText.Encode("missing_bucket"); + private static readonly System.Text.Json.JsonEncodedText PropMissingOrder = System.Text.Json.JsonEncodedText.Encode("missing_order"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropShardMinDocCount = System.Text.Json.JsonEncodedText.Encode("shard_min_doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropShardSize = System.Text.Json.JsonEncodedText.Encode("shard_size"); + private static readonly System.Text.Json.JsonEncodedText PropShowTermDocCountError = System.Text.Json.JsonEncodedText.Encode("show_term_doc_count_error"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropValueType = System.Text.Json.JsonEncodedText.Encode("value_type"); + + public override TermsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCollectMode = default; + LocalJsonValue propExclude = default; + LocalJsonValue propExecutionHint = default; + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propInclude = default; + LocalJsonValue propMinDocCount = default; + LocalJsonValue propMissing = default; + LocalJsonValue propMissingBucket = default; + LocalJsonValue propMissingOrder = default; + LocalJsonValue>?> propOrder = default; + LocalJsonValue propScript = default; + LocalJsonValue propShardMinDocCount = default; + LocalJsonValue propShardSize = default; + LocalJsonValue propShowTermDocCountError = default; + LocalJsonValue propSize = default; + LocalJsonValue propValueType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollectMode.TryRead(ref reader, options, PropCollectMode)) + { + continue; + } + + if (propExclude.TryRead(ref reader, options, PropExclude)) + { + continue; + } + + if (propExecutionHint.TryRead(ref reader, options, PropExecutionHint)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propMinDocCount.TryRead(ref reader, options, PropMinDocCount)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMissingBucket.TryRead(ref reader, options, PropMissingBucket)) + { + continue; + } + + if (propMissingOrder.TryRead(ref reader, options, PropMissingOrder)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker>?, KeyValuePair>))) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propShardMinDocCount.TryRead(ref reader, options, PropShardMinDocCount)) + { + continue; + } + + if (propShardSize.TryRead(ref reader, options, PropShardSize)) + { + continue; + } + + if (propShowTermDocCountError.TryRead(ref reader, options, PropShowTermDocCountError)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propValueType.TryRead(ref reader, options, PropValueType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsAggregation + { + CollectMode = propCollectMode.Value +, + Exclude = propExclude.Value +, + ExecutionHint = propExecutionHint.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Include = propInclude.Value +, + MinDocCount = propMinDocCount.Value +, + Missing = propMissing.Value +, + MissingBucket = propMissingBucket.Value +, + MissingOrder = propMissingOrder.Value +, + Order = propOrder.Value +, + Script = propScript.Value +, + ShardMinDocCount = propShardMinDocCount.Value +, + ShardSize = propShardSize.Value +, + ShowTermDocCountError = propShowTermDocCountError.Value +, + Size = propSize.Value +, + ValueType = propValueType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollectMode, value.CollectMode); + writer.WriteProperty(options, PropExclude, value.Exclude); + writer.WriteProperty(options, PropExecutionHint, value.ExecutionHint); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropMinDocCount, value.MinDocCount); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMissingBucket, value.MissingBucket); + writer.WriteProperty(options, PropMissingOrder, value.MissingOrder); + writer.WriteProperty(options, PropOrder, value.Order, null, typeof(SingleOrManyMarker>?, KeyValuePair>)); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropShardMinDocCount, value.ShardMinDocCount); + writer.WriteProperty(options, PropShardSize, value.ShardSize); + writer.WriteProperty(options, PropShowTermDocCountError, value.ShowTermDocCountError); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropValueType, value.ValueType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsAggregationConverter))] public sealed partial class TermsAggregation { /// @@ -34,7 +228,6 @@ public sealed partial class TermsAggregation /// Determines how child aggregations should be calculated: breadth-first or depth-first. /// /// - [JsonInclude, JsonPropertyName("collect_mode")] public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationCollectMode? CollectMode { get; set; } /// @@ -43,7 +236,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("exclude")] public Elastic.Clients.Elasticsearch.Aggregations.TermsExclude? Exclude { get; set; } /// @@ -51,7 +243,6 @@ public sealed partial class TermsAggregation /// Determines whether the aggregation will use field values directly or global ordinals. /// /// - [JsonInclude, JsonPropertyName("execution_hint")] public Elastic.Clients.Elasticsearch.Aggregations.TermsAggregationExecutionHint? ExecutionHint { get; set; } /// @@ -59,9 +250,7 @@ public sealed partial class TermsAggregation /// The field from which to return terms. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } /// @@ -70,7 +259,6 @@ public sealed partial class TermsAggregation /// Accepts regular expressions and partitions. /// /// - [JsonInclude, JsonPropertyName("include")] public Elastic.Clients.Elasticsearch.Aggregations.TermsInclude? Include { get; set; } /// @@ -78,7 +266,6 @@ public sealed partial class TermsAggregation /// Only return values that are found in more than min_doc_count hits. /// /// - [JsonInclude, JsonPropertyName("min_doc_count")] public int? MinDocCount { get; set; } /// @@ -87,11 +274,8 @@ public sealed partial class TermsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("missing_bucket")] public bool? MissingBucket { get; set; } - [JsonInclude, JsonPropertyName("missing_order")] public Elastic.Clients.Elasticsearch.Aggregations.MissingOrder? MissingOrder { get; set; } /// @@ -100,10 +284,7 @@ public sealed partial class TermsAggregation /// Defaults to sorting by descending document count. /// /// - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(KeyValuePair))] public ICollection>? Order { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -112,7 +293,6 @@ public sealed partial class TermsAggregation /// Terms will only be considered if their local shard frequency within the set is higher than the shard_min_doc_count. /// /// - [JsonInclude, JsonPropertyName("shard_min_doc_count")] public long? ShardMinDocCount { get; set; } /// @@ -121,7 +301,6 @@ public sealed partial class TermsAggregation /// By default, shard_size will be automatically estimated based on the number of shards and the size parameter. /// /// - [JsonInclude, JsonPropertyName("shard_size")] public int? ShardSize { get; set; } /// @@ -129,7 +308,6 @@ public sealed partial class TermsAggregation /// Set to true to return the doc_count_error_upper_bound, which is an upper bound to the error on the doc_count returned by each shard. /// /// - [JsonInclude, JsonPropertyName("show_term_doc_count_error")] public bool? ShowTermDocCountError { get; set; } /// @@ -137,7 +315,6 @@ public sealed partial class TermsAggregation /// The number of buckets returned out of the overall terms list. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -145,7 +322,6 @@ public sealed partial class TermsAggregation /// Coerced unmapped fields into the specified type. /// /// - [JsonInclude, JsonPropertyName("value_type")] public string? ValueType { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(TermsAggregation termsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.Terms(termsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs index bd927b7576c..cffb8e524c4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TimeSeriesAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "time_series"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs index 3b391a5494c..4fab388ed03 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TimeSeriesBucket.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class TimeSeriesBucketConverter : JsonConverter +internal sealed partial class TimeSeriesBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeSeriesBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + + public override TimeSeriesBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary key = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue> propKey = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new TimeSeriesBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TimeSeriesBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value + }; } - public override void Write(Utf8JsonWriter writer, TimeSeriesBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeSeriesBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'TimeSeriesBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs index 5a7011780ff..b2fc7bde46f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TopHitsAggregate : IAggregate public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata Hits { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "top_hits"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs index 60bdfb33f43..c999dbb78fe 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopHitsAggregation.g.cs @@ -27,6 +27,190 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class TopHitsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override TopHitsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propMissing = default; + LocalJsonValue propScript = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TopHitsAggregation + { + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Field = propField.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + Missing = propMissing.Value +, + Script = propScript.Value +, + ScriptFields = propScriptFields.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + TrackScores = propTrackScores.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TopHitsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopHitsAggregationConverter))] public sealed partial class TopHitsAggregation { /// @@ -34,7 +218,6 @@ public sealed partial class TopHitsAggregation /// Fields for which to return doc values. /// /// - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } /// @@ -42,7 +225,6 @@ public sealed partial class TopHitsAggregation /// If true, returns detailed information about score computation as part of a hit. /// /// - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } /// @@ -50,7 +232,6 @@ public sealed partial class TopHitsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -59,7 +240,6 @@ public sealed partial class TopHitsAggregation /// matching these patterns in the hits.fields property of the response. /// /// - [JsonInclude, JsonPropertyName("fields")] public ICollection? Fields { get; set; } /// @@ -67,7 +247,6 @@ public sealed partial class TopHitsAggregation /// Starting document offset. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } /// @@ -75,7 +254,6 @@ public sealed partial class TopHitsAggregation /// Specifies the highlighter to use for retrieving highlighted snippets from one or more fields in the search results. /// /// - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } /// @@ -84,9 +262,7 @@ public sealed partial class TopHitsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -94,7 +270,6 @@ public sealed partial class TopHitsAggregation /// Returns the result of one or more script evaluations for each hit. /// /// - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } /// @@ -102,7 +277,6 @@ public sealed partial class TopHitsAggregation /// If true, returns sequence number and primary term of the last modification of each hit. /// /// - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -110,7 +284,6 @@ public sealed partial class TopHitsAggregation /// The maximum number of top matching hits to return per bucket. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -119,8 +292,6 @@ public sealed partial class TopHitsAggregation /// By default, the hits are sorted by the score of the main query. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -128,7 +299,6 @@ public sealed partial class TopHitsAggregation /// Selects the fields of the source that are returned. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -136,8 +306,6 @@ public sealed partial class TopHitsAggregation /// Returns values for the specified stored fields (fields that use the store mapping option). /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } /// @@ -145,7 +313,6 @@ public sealed partial class TopHitsAggregation /// If true, calculates and returns document scores, even if the scores are not used for sorting. /// /// - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } /// @@ -153,7 +320,6 @@ public sealed partial class TopHitsAggregation /// If true, returns document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(TopHitsAggregation topHitsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.TopHits(topHitsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs index 3675a8b9148..82797613d28 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class TopMetricsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("top")] public IReadOnlyCollection Top { get; init; } + + string IAggregate.Type => "top_metrics"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs index d063b3c1be9..200c5d58c0c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/TopMetricsAggregation.g.cs @@ -27,6 +27,90 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; +internal sealed partial class TopMetricsAggregationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMetrics = System.Text.Json.JsonEncodedText.Encode("metrics"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + + public override TopMetricsAggregation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue?> propMetrics = default; + LocalJsonValue propMissing = default; + LocalJsonValue propScript = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propMetrics.TryRead(ref reader, options, PropMetrics, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Aggregations.TopMetricsValue>))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TopMetricsAggregation + { + Field = propField.Value +, + Metrics = propMetrics.Value +, + Missing = propMissing.Value +, + Script = propScript.Value +, + Size = propSize.Value +, + Sort = propSort.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TopMetricsAggregation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropMetrics, value.Metrics, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Aggregations.TopMetricsValue>)); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TopMetricsAggregationConverter))] public sealed partial class TopMetricsAggregation { /// @@ -34,7 +118,6 @@ public sealed partial class TopMetricsAggregation /// The field on which to run the aggregation. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field? Field { get; set; } /// @@ -42,8 +125,6 @@ public sealed partial class TopMetricsAggregation /// The fields of the top document to return. /// /// - [JsonInclude, JsonPropertyName("metrics")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Aggregations.TopMetricsValue))] public ICollection? Metrics { get; set; } /// @@ -52,9 +133,7 @@ public sealed partial class TopMetricsAggregation /// By default, documents without a value are ignored. /// /// - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } /// @@ -62,7 +141,6 @@ public sealed partial class TopMetricsAggregation /// The number of top documents from which to return metrics. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -70,8 +148,6 @@ public sealed partial class TopMetricsAggregation /// The sort order of the documents. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Aggregations.Aggregation(TopMetricsAggregation topMetricsAggregation) => Elastic.Clients.Elasticsearch.Aggregations.Aggregation.TopMetrics(topMetricsAggregation); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs index 65f49279fe6..da3578e0e08 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedRareTermsAggregate.g.cs @@ -38,4 +38,6 @@ public sealed partial class UnmappedRareTermsAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "umrareterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs index 49e77c3a953..da1c6018d81 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSamplerAggregate.g.cs @@ -27,49 +27,60 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class UnmappedSamplerAggregateConverter : JsonConverter +internal sealed partial class UnmappedSamplerAggregateConverter : System.Text.Json.Serialization.JsonConverter { - public override UnmappedSamplerAggregate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + + public override UnmappedSamplerAggregate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - IReadOnlyDictionary? meta = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "meta") - { - meta = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } + continue; + } - throw new JsonException("Unknown property read from JSON."); + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new UnmappedSamplerAggregate { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Meta = meta }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnmappedSamplerAggregate + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Meta = propMeta.Value + }; } - public override void Write(Utf8JsonWriter writer, UnmappedSamplerAggregate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnmappedSamplerAggregate value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'UnmappedSamplerAggregate' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropMeta, value.Meta); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } @@ -84,4 +95,6 @@ public sealed partial class UnmappedSamplerAggregate : IAggregate public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary Aggregations { get; init; } public long DocCount { get; init; } public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "unmapped_sampler"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs index 61265ed8a92..a5d5bc23fd8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedSignificantTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class UnmappedSignificantTermsAggregate : IAggregate public long? DocCount { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "umsigterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs index 58914563b27..2bbd309b511 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/UnmappedTermsAggregate.g.cs @@ -42,4 +42,6 @@ public sealed partial class UnmappedTermsAggregate : IAggregate public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("sum_other_doc_count")] public long? SumOtherDocCount { get; init; } + + string IAggregate.Type => "umterms"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs index 697e951c703..5ee4872a5c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/ValueCountAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class ValueCountAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "value_count"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs index 5501a87a5b2..52845a6dd69 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramAggregate.g.cs @@ -33,4 +33,6 @@ public sealed partial class VariableWidthHistogramAggregate : IAggregate public IReadOnlyCollection Buckets { get; init; } [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } + + string IAggregate.Type => "variable_width_histogram"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs index 4d1f82516da..bf7086f6572 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/VariableWidthHistogramBucket.g.cs @@ -27,84 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Aggregations; -internal sealed partial class VariableWidthHistogramBucketConverter : JsonConverter +internal sealed partial class VariableWidthHistogramBucketConverter : System.Text.Json.Serialization.JsonConverter { - public override VariableWidthHistogramBucket Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropDocCount = System.Text.Json.JsonEncodedText.Encode("doc_count"); + private static readonly System.Text.Json.JsonEncodedText PropKey = System.Text.Json.JsonEncodedText.Encode("key"); + private static readonly System.Text.Json.JsonEncodedText PropKeyAsString = System.Text.Json.JsonEncodedText.Encode("key_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText PropMaxAsString = System.Text.Json.JsonEncodedText.Encode("max_as_string"); + private static readonly System.Text.Json.JsonEncodedText PropMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText PropMinAsString = System.Text.Json.JsonEncodedText.Encode("min_as_string"); + + public override VariableWidthHistogramBucket Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - long docCount = default; - double key = default; - string? keyAsString = default; - double max = default; - string? maxAsString = default; - double min = default; - string? minAsString = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAggregations = default; + LocalJsonValue propDocCount = default; + LocalJsonValue propKey = default; + LocalJsonValue propKeyAsString = default; + LocalJsonValue propMax = default; + LocalJsonValue propMaxAsString = default; + LocalJsonValue propMin = default; + LocalJsonValue propMinAsString = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDocCount.TryRead(ref reader, options, PropDocCount)) + { + continue; + } + + if (propKey.TryRead(ref reader, options, PropKey)) + { + continue; + } + + if (propKeyAsString.TryRead(ref reader, options, PropKeyAsString)) + { + continue; + } + + if (propMax.TryRead(ref reader, options, PropMax)) + { + continue; + } + + if (propMaxAsString.TryRead(ref reader, options, PropMaxAsString)) { - var property = reader.GetString(); - if (property == "doc_count") - { - docCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key") - { - key = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "key_as_string") - { - keyAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max") - { - max = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_as_string") - { - maxAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "min") - { - min = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "min_as_string") - { - minAsString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property.Contains("#")) - { - additionalProperties ??= new Dictionary(); - AggregateDictionaryConverter.ReadItem(ref reader, options, additionalProperties, property); - continue; - } - - throw new JsonException("Unknown property read from JSON."); + continue; } + + if (propMin.TryRead(ref reader, options, PropMin)) + { + continue; + } + + if (propMinAsString.TryRead(ref reader, options, PropMinAsString)) + { + continue; + } + + propAggregations ??= new System.Collections.Generic.Dictionary(); + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(ref reader, options, out string key, out Elastic.Clients.Elasticsearch.Aggregations.IAggregate value); + propAggregations[key] = value; } - return new VariableWidthHistogramBucket { Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(additionalProperties), DocCount = docCount, Key = key, KeyAsString = keyAsString, Max = max, MaxAsString = maxAsString, Min = min, MinAsString = minAsString }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VariableWidthHistogramBucket + { + Aggregations = new Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary(propAggregations) +, + DocCount = propDocCount.Value +, + Key = propKey.Value +, + KeyAsString = propKeyAsString.Value +, + Max = propMax.Value +, + MaxAsString = propMaxAsString.Value +, + Min = propMin.Value +, + MinAsString = propMinAsString.Value + }; } - public override void Write(Utf8JsonWriter writer, VariableWidthHistogramBucket value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, VariableWidthHistogramBucket value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'VariableWidthHistogramBucket' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropDocCount, value.DocCount); + writer.WriteProperty(options, PropKey, value.Key); + writer.WriteProperty(options, PropKeyAsString, value.KeyAsString); + writer.WriteProperty(options, PropMax, value.Max); + writer.WriteProperty(options, PropMaxAsString, value.MaxAsString); + writer.WriteProperty(options, PropMin, value.Min); + writer.WriteProperty(options, PropMinAsString, value.MinAsString); + if (value.Aggregations is not null) + { + foreach (var item in value.Aggregations) + { + Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.WriteItem(writer, options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs index 673773b6806..e3cad85c268 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Aggregations/WeightedAverageAggregate.g.cs @@ -47,4 +47,6 @@ public sealed partial class WeightedAverageAggregate : IAggregate public double? Value { get; init; } [JsonInclude, JsonPropertyName("value_as_string")] public string? ValueAsString { get; init; } + + string IAggregate.Type => "weighted_avg"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs index aaec84a9912..d86767aefb0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Analyzers.g.cs @@ -218,289 +218,238 @@ public AnalyzersDescriptor() : base(new Analyzers()) public AnalyzersDescriptor Whitespace(string analyzerName, WhitespaceAnalyzer whitespaceAnalyzer) => AssignVariant(analyzerName, whitespaceAnalyzer); } -internal sealed partial class AnalyzerInterfaceConverter : JsonConverter +internal sealed partial class AnalyzerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override IAnalyzer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "custom"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "arabic": - return JsonSerializer.Deserialize(ref reader, options); - case "armenian": - return JsonSerializer.Deserialize(ref reader, options); - case "basque": - return JsonSerializer.Deserialize(ref reader, options); - case "bengali": - return JsonSerializer.Deserialize(ref reader, options); - case "brazilian": - return JsonSerializer.Deserialize(ref reader, options); - case "bulgarian": - return JsonSerializer.Deserialize(ref reader, options); - case "catalan": - return JsonSerializer.Deserialize(ref reader, options); - case "chinese": - return JsonSerializer.Deserialize(ref reader, options); - case "cjk": - return JsonSerializer.Deserialize(ref reader, options); - case "custom": - return JsonSerializer.Deserialize(ref reader, options); - case "czech": - return JsonSerializer.Deserialize(ref reader, options); - case "danish": - return JsonSerializer.Deserialize(ref reader, options); - case "dutch": - return JsonSerializer.Deserialize(ref reader, options); - case "english": - return JsonSerializer.Deserialize(ref reader, options); - case "estonian": - return JsonSerializer.Deserialize(ref reader, options); - case "fingerprint": - return JsonSerializer.Deserialize(ref reader, options); - case "finnish": - return JsonSerializer.Deserialize(ref reader, options); - case "french": - return JsonSerializer.Deserialize(ref reader, options); - case "galician": - return JsonSerializer.Deserialize(ref reader, options); - case "german": - return JsonSerializer.Deserialize(ref reader, options); - case "greek": - return JsonSerializer.Deserialize(ref reader, options); - case "hindi": - return JsonSerializer.Deserialize(ref reader, options); - case "hungarian": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_analyzer": - return JsonSerializer.Deserialize(ref reader, options); - case "indonesian": - return JsonSerializer.Deserialize(ref reader, options); - case "irish": - return JsonSerializer.Deserialize(ref reader, options); - case "italian": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji": - return JsonSerializer.Deserialize(ref reader, options); - case "language": - return JsonSerializer.Deserialize(ref reader, options); - case "latvian": - return JsonSerializer.Deserialize(ref reader, options); - case "lithuanian": - return JsonSerializer.Deserialize(ref reader, options); - case "nori": - return JsonSerializer.Deserialize(ref reader, options); - case "norwegian": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "persian": - return JsonSerializer.Deserialize(ref reader, options); - case "portuguese": - return JsonSerializer.Deserialize(ref reader, options); - case "romanian": - return JsonSerializer.Deserialize(ref reader, options); - case "russian": - return JsonSerializer.Deserialize(ref reader, options); - case "serbian": - return JsonSerializer.Deserialize(ref reader, options); - case "simple": - return JsonSerializer.Deserialize(ref reader, options); - case "snowball": - return JsonSerializer.Deserialize(ref reader, options); - case "sorani": - return JsonSerializer.Deserialize(ref reader, options); - case "spanish": - return JsonSerializer.Deserialize(ref reader, options); - case "standard": - return JsonSerializer.Deserialize(ref reader, options); - case "stop": - return JsonSerializer.Deserialize(ref reader, options); - case "swedish": - return JsonSerializer.Deserialize(ref reader, options); - case "thai": - return JsonSerializer.Deserialize(ref reader, options); - case "turkish": - return JsonSerializer.Deserialize(ref reader, options); - case "whitespace": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "arabic" => reader.ReadValue(options), + "armenian" => reader.ReadValue(options), + "basque" => reader.ReadValue(options), + "bengali" => reader.ReadValue(options), + "brazilian" => reader.ReadValue(options), + "bulgarian" => reader.ReadValue(options), + "catalan" => reader.ReadValue(options), + "chinese" => reader.ReadValue(options), + "cjk" => reader.ReadValue(options), + "custom" => reader.ReadValue(options), + "czech" => reader.ReadValue(options), + "danish" => reader.ReadValue(options), + "dutch" => reader.ReadValue(options), + "english" => reader.ReadValue(options), + "estonian" => reader.ReadValue(options), + "fingerprint" => reader.ReadValue(options), + "finnish" => reader.ReadValue(options), + "french" => reader.ReadValue(options), + "galician" => reader.ReadValue(options), + "german" => reader.ReadValue(options), + "greek" => reader.ReadValue(options), + "hindi" => reader.ReadValue(options), + "hungarian" => reader.ReadValue(options), + "icu_analyzer" => reader.ReadValue(options), + "indonesian" => reader.ReadValue(options), + "irish" => reader.ReadValue(options), + "italian" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "kuromoji" => reader.ReadValue(options), + "language" => reader.ReadValue(options), + "latvian" => reader.ReadValue(options), + "lithuanian" => reader.ReadValue(options), + "nori" => reader.ReadValue(options), + "norwegian" => reader.ReadValue(options), + "pattern" => reader.ReadValue(options), + "persian" => reader.ReadValue(options), + "portuguese" => reader.ReadValue(options), + "romanian" => reader.ReadValue(options), + "russian" => reader.ReadValue(options), + "serbian" => reader.ReadValue(options), + "simple" => reader.ReadValue(options), + "snowball" => reader.ReadValue(options), + "sorani" => reader.ReadValue(options), + "spanish" => reader.ReadValue(options), + "standard" => reader.ReadValue(options), + "stop" => reader.ReadValue(options), + "swedish" => reader.ReadValue(options), + "thai" => reader.ReadValue(options), + "turkish" => reader.ReadValue(options), + "whitespace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IAnalyzer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, IAnalyzer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IAnalyzer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "arabic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ArabicAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ArabicAnalyzer)value); + break; case "armenian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ArmenianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ArmenianAnalyzer)value); + break; case "basque": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BasqueAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BasqueAnalyzer)value); + break; case "bengali": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BengaliAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BengaliAnalyzer)value); + break; case "brazilian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BrazilianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BrazilianAnalyzer)value); + break; case "bulgarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.BulgarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.BulgarianAnalyzer)value); + break; case "catalan": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CatalanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CatalanAnalyzer)value); + break; case "chinese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ChineseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ChineseAnalyzer)value); + break; case "cjk": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CjkAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CjkAnalyzer)value); + break; case "custom": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CustomAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CustomAnalyzer)value); + break; case "czech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CzechAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CzechAnalyzer)value); + break; case "danish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DanishAnalyzer)value); + break; case "dutch": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DutchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DutchAnalyzer)value); + break; case "english": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EnglishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EnglishAnalyzer)value); + break; case "estonian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EstonianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EstonianAnalyzer)value); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FingerprintAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FingerprintAnalyzer)value); + break; case "finnish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FinnishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FinnishAnalyzer)value); + break; case "french": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FrenchAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FrenchAnalyzer)value); + break; case "galician": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GalicianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GalicianAnalyzer)value); + break; case "german": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GermanAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GermanAnalyzer)value); + break; case "greek": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.GreekAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.GreekAnalyzer)value); + break; case "hindi": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HindiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HindiAnalyzer)value); + break; case "hungarian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HungarianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HungarianAnalyzer)value); + break; case "icu_analyzer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuAnalyzer)value); + break; case "indonesian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IndonesianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IndonesianAnalyzer)value); + break; case "irish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IrishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IrishAnalyzer)value); + break; case "italian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ItalianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ItalianAnalyzer)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordAnalyzer)value); + break; case "kuromoji": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiAnalyzer)value); + break; case "language": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LanguageAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LanguageAnalyzer)value); + break; case "latvian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LatvianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LatvianAnalyzer)value); + break; case "lithuanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LithuanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LithuanianAnalyzer)value); + break; case "nori": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriAnalyzer)value); + break; case "norwegian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NorwegianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NorwegianAnalyzer)value); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternAnalyzer)value); + break; case "persian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PersianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PersianAnalyzer)value); + break; case "portuguese": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PortugueseAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PortugueseAnalyzer)value); + break; case "romanian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RomanianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RomanianAnalyzer)value); + break; case "russian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RussianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RussianAnalyzer)value); + break; case "serbian": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SerbianAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SerbianAnalyzer)value); + break; case "simple": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimpleAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimpleAnalyzer)value); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SnowballAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SnowballAnalyzer)value); + break; case "sorani": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SoraniAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SoraniAnalyzer)value); + break; case "spanish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SpanishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SpanishAnalyzer)value); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StandardAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StandardAnalyzer)value); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StopAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StopAnalyzer)value); + break; case "swedish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SwedishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SwedishAnalyzer)value); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ThaiAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ThaiAnalyzer)value); + break; case "turkish": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TurkishAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TurkishAnalyzer)value); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WhitespaceAnalyzer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IAnalyzer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs index 64f5991c499..548fc2d7e5b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArabicAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class ArabicAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ArabicAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ArabicAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ArabicAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ArabicAnalyzerConverter))] public sealed partial class ArabicAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "arabic"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs index 3641734436a..07dd6631d3d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ArmenianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class ArmenianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ArmenianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ArmenianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ArmenianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ArmenianAnalyzerConverter))] public sealed partial class ArmenianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "armenian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs index 9bdabb5b6ef..178b4afd6c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BasqueAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class BasqueAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BasqueAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BasqueAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BasqueAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BasqueAnalyzerConverter))] public sealed partial class BasqueAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "basque"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs index a9393e534cc..cba7c08579f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BengaliAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class BengaliAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BengaliAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BengaliAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BengaliAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BengaliAnalyzerConverter))] public sealed partial class BengaliAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "bengali"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs index edb89e4c735..99941513ed9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BrazilianAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class BrazilianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BrazilianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BrazilianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BrazilianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BrazilianAnalyzerConverter))] public sealed partial class BrazilianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "brazilian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs index 7d08a972858..fa9c47e24e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/BulgarianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class BulgarianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BulgarianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BulgarianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BulgarianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BulgarianAnalyzerConverter))] public sealed partial class BulgarianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "bulgarian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs index d6215912130..26f7466071a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CatalanAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class CatalanAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CatalanAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CatalanAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CatalanAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CatalanAnalyzerConverter))] public sealed partial class CatalanAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "catalan"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs index 893e7f01f76..93c6c914d61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CharFilters.g.cs @@ -83,65 +83,58 @@ public CharFiltersDescriptor() : base(new CharFilters()) public CharFiltersDescriptor PatternReplace(string charFilterName, PatternReplaceCharFilter patternReplaceCharFilter) => AssignVariant(charFilterName, patternReplaceCharFilter); } -internal sealed partial class CharFilterInterfaceConverter : JsonConverter +internal sealed partial class CharFilterInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ICharFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ICharFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "html_strip": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_normalizer": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_iteration_mark": - return JsonSerializer.Deserialize(ref reader, options); - case "mapping": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_replace": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ICharFilter)); - return null; - } + "html_strip" => reader.ReadValue(options), + "icu_normalizer" => reader.ReadValue(options), + "kuromoji_iteration_mark" => reader.ReadValue(options), + "mapping" => reader.ReadValue(options), + "pattern_replace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ICharFilter)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ICharFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ICharFilter value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "html_strip": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HtmlStripCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HtmlStripCharFilter)value); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationCharFilter)value); + break; case "kuromoji_iteration_mark": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiIterationMarkCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiIterationMarkCharFilter)value); + break; case "mapping": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.MappingCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.MappingCharFilter)value); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternReplaceCharFilter)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ICharFilter)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs index 8a70c33dd66..287af9e7ca0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ChineseAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class ChineseAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ChineseAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ChineseAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChineseAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ChineseAnalyzerConverter))] public sealed partial class ChineseAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "chinese"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs index 3fb380874ff..52c03c567bf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CjkAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class CjkAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CjkAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CjkAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CjkAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CjkAnalyzerConverter))] public sealed partial class CjkAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "cjk"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs index ba1549ff6a7..f7e50c364f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CustomAnalyzer.g.cs @@ -27,22 +27,96 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class CustomAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCharFilter = System.Text.Json.JsonEncodedText.Encode("char_filter"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropPositionOffsetGap = System.Text.Json.JsonEncodedText.Encode("position_offset_gap"); + private static readonly System.Text.Json.JsonEncodedText PropTokenizer = System.Text.Json.JsonEncodedText.Encode("tokenizer"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CustomAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propCharFilter = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propPositionOffsetGap = default; + LocalJsonValue propTokenizer = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCharFilter.TryRead(ref reader, options, PropCharFilter, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propPositionOffsetGap.TryRead(ref reader, options, PropPositionOffsetGap)) + { + continue; + } + + if (propTokenizer.TryRead(ref reader, options, PropTokenizer)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CustomAnalyzer + { + CharFilter = propCharFilter.Value +, + Filter = propFilter.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + PositionOffsetGap = propPositionOffsetGap.Value +, + Tokenizer = propTokenizer.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CustomAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCharFilter, value.CharFilter, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropPositionOffsetGap, value.PositionOffsetGap); + writer.WriteProperty(options, PropTokenizer, value.Tokenizer); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CustomAnalyzerConverter))] public sealed partial class CustomAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("char_filter")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? CharFilter { get; set; } - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Filter { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("position_offset_gap")] public int? PositionOffsetGap { get; set; } - [JsonInclude, JsonPropertyName("tokenizer")] public string Tokenizer { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "custom"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs index 85203810347..ff7f143b539 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/CzechAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class CzechAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CzechAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CzechAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CzechAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CzechAnalyzerConverter))] public sealed partial class CzechAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "czech"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs index 96f1845395b..1ed88d344ac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DanishAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class DanishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DanishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DanishAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DanishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DanishAnalyzerConverter))] public sealed partial class DanishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "danish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs index 7fdbe496526..f0ee6988bd1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/DutchAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class DutchAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DutchAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DutchAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DutchAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DutchAnalyzerConverter))] public sealed partial class DutchAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "dutch"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs index bf63091004e..0df62272b1a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EnglishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class EnglishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override EnglishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnglishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnglishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnglishAnalyzerConverter))] public sealed partial class EnglishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "english"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs index a1e4374a3f5..fbc1b9abeec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/EstonianAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class EstonianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override EstonianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EstonianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EstonianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EstonianAnalyzerConverter))] public sealed partial class EstonianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "estonian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs index f91086db2f4..c609637fa30 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FingerprintAnalyzer.g.cs @@ -27,24 +27,108 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class FingerprintAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMaxOutputSize = System.Text.Json.JsonEncodedText.Encode("max_output_size"); + private static readonly System.Text.Json.JsonEncodedText PropPreserveOriginal = System.Text.Json.JsonEncodedText.Encode("preserve_original"); + private static readonly System.Text.Json.JsonEncodedText PropSeparator = System.Text.Json.JsonEncodedText.Encode("separator"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override FingerprintAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propMaxOutputSize = default; + LocalJsonValue propPreserveOriginal = default; + LocalJsonValue propSeparator = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxOutputSize.TryRead(ref reader, options, PropMaxOutputSize)) + { + continue; + } + + if (propPreserveOriginal.TryRead(ref reader, options, PropPreserveOriginal)) + { + continue; + } + + if (propSeparator.TryRead(ref reader, options, PropSeparator)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FingerprintAnalyzer + { + MaxOutputSize = propMaxOutputSize.Value +, + PreserveOriginal = propPreserveOriginal.Value +, + Separator = propSeparator.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMaxOutputSize, value.MaxOutputSize); + writer.WriteProperty(options, PropPreserveOriginal, value.PreserveOriginal); + writer.WriteProperty(options, PropSeparator, value.Separator); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FingerprintAnalyzerConverter))] public sealed partial class FingerprintAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("max_output_size")] public int MaxOutputSize { get; set; } - [JsonInclude, JsonPropertyName("preserve_original")] public bool PreserveOriginal { get; set; } - [JsonInclude, JsonPropertyName("separator")] public string Separator { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "fingerprint"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs index 26daf3595db..817d66f2f04 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FinnishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class FinnishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FinnishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FinnishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FinnishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FinnishAnalyzerConverter))] public sealed partial class FinnishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "finnish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs index 71a3152f6f5..fbea8733f61 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/FrenchAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class FrenchAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FrenchAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FrenchAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FrenchAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FrenchAnalyzerConverter))] public sealed partial class FrenchAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "french"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs index f1ddff66f9b..bd82ec5293f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GalicianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class GalicianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GalicianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GalicianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GalicianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GalicianAnalyzerConverter))] public sealed partial class GalicianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "galician"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs index bd0b04a470f..4f9ca1ec299 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GermanAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class GermanAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GermanAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GermanAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GermanAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GermanAnalyzerConverter))] public sealed partial class GermanAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "german"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs index 89b4442eddd..1c827e8b90b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/GreekAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class GreekAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GreekAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GreekAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GreekAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GreekAnalyzerConverter))] public sealed partial class GreekAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "greek"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs index c3142b0a785..277d8bfd10c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HindiAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class HindiAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HindiAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HindiAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HindiAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HindiAnalyzerConverter))] public sealed partial class HindiAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "hindi"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs index 1df50363051..acce2d9a35c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/HungarianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class HungarianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HungarianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HungarianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HungarianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HungarianAnalyzerConverter))] public sealed partial class HungarianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "hungarian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs index a970bc92251..992e6fc1945 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IndonesianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class IndonesianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IndonesianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndonesianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndonesianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndonesianAnalyzerConverter))] public sealed partial class IndonesianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "indonesian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs index eb1d2959527..c2b177e4205 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/IrishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class IrishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IrishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IrishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IrishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IrishAnalyzerConverter))] public sealed partial class IrishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "irish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs index f3c6ac186c8..ff46389884b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ItalianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class ItalianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ItalianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ItalianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ItalianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ItalianAnalyzerConverter))] public sealed partial class ItalianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "italian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs index 91a70863b7f..3f5174aca23 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/KeywordMarkerTokenFilter.g.cs @@ -27,22 +27,97 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class KeywordMarkerTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIgnoreCase = System.Text.Json.JsonEncodedText.Encode("ignore_case"); + private static readonly System.Text.Json.JsonEncodedText PropKeywords = System.Text.Json.JsonEncodedText.Encode("keywords"); + private static readonly System.Text.Json.JsonEncodedText PropKeywordsPath = System.Text.Json.JsonEncodedText.Encode("keywords_path"); + private static readonly System.Text.Json.JsonEncodedText PropKeywordsPattern = System.Text.Json.JsonEncodedText.Encode("keywords_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override KeywordMarkerTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propIgnoreCase = default; + LocalJsonValue?> propKeywords = default; + LocalJsonValue propKeywordsPath = default; + LocalJsonValue propKeywordsPattern = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryRead(ref reader, options, PropIgnoreCase)) + { + continue; + } + + if (propKeywords.TryRead(ref reader, options, PropKeywords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propKeywordsPath.TryRead(ref reader, options, PropKeywordsPath)) + { + continue; + } + + if (propKeywordsPattern.TryRead(ref reader, options, PropKeywordsPattern)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KeywordMarkerTokenFilter + { + IgnoreCase = propIgnoreCase.Value +, + Keywords = propKeywords.Value +, + KeywordsPath = propKeywordsPath.Value +, + KeywordsPattern = propKeywordsPattern.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeywordMarkerTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIgnoreCase, value.IgnoreCase); + writer.WriteProperty(options, PropKeywords, value.Keywords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropKeywordsPath, value.KeywordsPath); + writer.WriteProperty(options, PropKeywordsPattern, value.KeywordsPattern); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KeywordMarkerTokenFilterConverter))] public sealed partial class KeywordMarkerTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("ignore_case")] public bool? IgnoreCase { get; set; } - [JsonInclude, JsonPropertyName("keywords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Keywords { get; set; } - [JsonInclude, JsonPropertyName("keywords_path")] public string? KeywordsPath { get; set; } - [JsonInclude, JsonPropertyName("keywords_pattern")] public string? KeywordsPattern { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "keyword_marker"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs index 00a6d5a7171..902a3c095c0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LanguageAnalyzer.g.cs @@ -27,22 +27,97 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class LanguageAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override LanguageAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLanguage = default; + LocalJsonValue> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LanguageAnalyzer + { + Language = propLanguage.Value +, + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LanguageAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LanguageAnalyzerConverter))] public sealed partial class LanguageAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.Analysis.Language Language { get; set; } - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "language"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs index 760fd6484b5..9e5e550def1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LatvianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class LatvianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LatvianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LatvianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LatvianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LatvianAnalyzerConverter))] public sealed partial class LatvianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "latvian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs index 4a5f774ff5d..a2b480f12f8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/LithuanianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class LithuanianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LithuanianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LithuanianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LithuanianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LithuanianAnalyzerConverter))] public sealed partial class LithuanianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "lithuanian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs index e32a1cbe1ac..188198a8f6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Normalizers.g.cs @@ -74,49 +74,46 @@ public NormalizersDescriptor() : base(new Normalizers()) public NormalizersDescriptor Lowercase(string normalizerName, LowercaseNormalizer lowercaseNormalizer) => AssignVariant(normalizerName, lowercaseNormalizer); } -internal sealed partial class NormalizerInterfaceConverter : JsonConverter +internal sealed partial class NormalizerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override INormalizer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override INormalizer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "custom"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "custom": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "custom" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(INormalizer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, INormalizer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, INormalizer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "custom": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CustomNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CustomNormalizer)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseNormalizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseNormalizer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(INormalizer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs index 873ae454f84..e1d9e54e448 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/NorwegianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class NorwegianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NorwegianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NorwegianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NorwegianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NorwegianAnalyzerConverter))] public sealed partial class NorwegianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "norwegian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs index 90b4f9f3e43..63fd0ca3ad9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PatternAnalyzer.g.cs @@ -27,22 +27,97 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class PatternAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropLowercase = System.Text.Json.JsonEncodedText.Encode("lowercase"); + private static readonly System.Text.Json.JsonEncodedText PropPattern = System.Text.Json.JsonEncodedText.Encode("pattern"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PatternAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFlags = default; + LocalJsonValue propLowercase = default; + LocalJsonValue propPattern = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } + + if (propLowercase.TryRead(ref reader, options, PropLowercase)) + { + continue; + } + + if (propPattern.TryRead(ref reader, options, PropPattern)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PatternAnalyzer + { + Flags = propFlags.Value +, + Lowercase = propLowercase.Value +, + Pattern = propPattern.Value +, + Stopwords = propStopwords.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PatternAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropLowercase, value.Lowercase); + writer.WriteProperty(options, PropPattern, value.Pattern); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PatternAnalyzerConverter))] public sealed partial class PatternAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("flags")] public string? Flags { get; set; } - [JsonInclude, JsonPropertyName("lowercase")] public bool? Lowercase { get; set; } - [JsonInclude, JsonPropertyName("pattern")] public string Pattern { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "pattern"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs index f889fe2782e..4f2e24ad430 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PersianAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class PersianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PersianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PersianAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PersianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PersianAnalyzerConverter))] public sealed partial class PersianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "persian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs index edc88d5e128..de0f5c22c6d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PhoneticTokenFilter.g.cs @@ -27,26 +27,119 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class PhoneticTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEncoder = System.Text.Json.JsonEncodedText.Encode("encoder"); + private static readonly System.Text.Json.JsonEncodedText PropLanguageset = System.Text.Json.JsonEncodedText.Encode("languageset"); + private static readonly System.Text.Json.JsonEncodedText PropMaxCodeLen = System.Text.Json.JsonEncodedText.Encode("max_code_len"); + private static readonly System.Text.Json.JsonEncodedText PropNameType = System.Text.Json.JsonEncodedText.Encode("name_type"); + private static readonly System.Text.Json.JsonEncodedText PropReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText PropRuleType = System.Text.Json.JsonEncodedText.Encode("rule_type"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override PhoneticTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propEncoder = default; + LocalJsonValue?> propLanguageset = default; + LocalJsonValue propMaxCodeLen = default; + LocalJsonValue propNameType = default; + LocalJsonValue propReplace = default; + LocalJsonValue propRuleType = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEncoder.TryRead(ref reader, options, PropEncoder)) + { + continue; + } + + if (propLanguageset.TryRead(ref reader, options, PropLanguageset, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Analysis.PhoneticLanguage>))) + { + continue; + } + + if (propMaxCodeLen.TryRead(ref reader, options, PropMaxCodeLen)) + { + continue; + } + + if (propNameType.TryRead(ref reader, options, PropNameType)) + { + continue; + } + + if (propReplace.TryRead(ref reader, options, PropReplace)) + { + continue; + } + + if (propRuleType.TryRead(ref reader, options, PropRuleType)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PhoneticTokenFilter + { + Encoder = propEncoder.Value +, + Languageset = propLanguageset.Value +, + MaxCodeLen = propMaxCodeLen.Value +, + NameType = propNameType.Value +, + Replace = propReplace.Value +, + RuleType = propRuleType.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEncoder, value.Encoder); + writer.WriteProperty(options, PropLanguageset, value.Languageset, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Analysis.PhoneticLanguage>)); + writer.WriteProperty(options, PropMaxCodeLen, value.MaxCodeLen); + writer.WriteProperty(options, PropNameType, value.NameType); + writer.WriteProperty(options, PropReplace, value.Replace); + writer.WriteProperty(options, PropRuleType, value.RuleType); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhoneticTokenFilterConverter))] public sealed partial class PhoneticTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("encoder")] public Elastic.Clients.Elasticsearch.Analysis.PhoneticEncoder Encoder { get; set; } - [JsonInclude, JsonPropertyName("languageset")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Analysis.PhoneticLanguage))] public ICollection? Languageset { get; set; } - [JsonInclude, JsonPropertyName("max_code_len")] public int? MaxCodeLen { get; set; } - [JsonInclude, JsonPropertyName("name_type")] public Elastic.Clients.Elasticsearch.Analysis.PhoneticNameType? NameType { get; set; } - [JsonInclude, JsonPropertyName("replace")] public bool? Replace { get; set; } - [JsonInclude, JsonPropertyName("rule_type")] public Elastic.Clients.Elasticsearch.Analysis.PhoneticRuleType? RuleType { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "phonetic"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs index 871b8aefa64..531ba40f57d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/PortugueseAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class PortugueseAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PortugueseAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PortugueseAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PortugueseAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PortugueseAnalyzerConverter))] public sealed partial class PortugueseAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "portuguese"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs index b7b3a587660..af1b3c95bda 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RomanianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class RomanianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override RomanianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RomanianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RomanianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RomanianAnalyzerConverter))] public sealed partial class RomanianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "romanian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs index b1c60d62fb8..39c44f119d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/RussianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class RussianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override RussianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RussianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RussianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RussianAnalyzerConverter))] public sealed partial class RussianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "russian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs index 26cfb2729d5..3323a4e8c44 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SerbianAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class SerbianAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SerbianAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SerbianAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SerbianAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SerbianAnalyzerConverter))] public sealed partial class SerbianAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "serbian"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs index f816558cc40..8331d9dd30c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SnowballAnalyzer.g.cs @@ -27,18 +27,75 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class SnowballAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override SnowballAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLanguage = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SnowballAnalyzer + { + Language = propLanguage.Value +, + Stopwords = propStopwords.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnowballAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SnowballAnalyzerConverter))] public sealed partial class SnowballAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("language")] public Elastic.Clients.Elasticsearch.Analysis.SnowballLanguage Language { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "snowball"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs index af879465e82..181043943a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SoraniAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class SoraniAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SoraniAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SoraniAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SoraniAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SoraniAnalyzerConverter))] public sealed partial class SoraniAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "sorani"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs index bba23e77175..27e11d43ce0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SpanishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class SpanishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SpanishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SpanishAnalyzerConverter))] public sealed partial class SpanishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "spanish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs index f89bcc5f1ec..b66bbd15c72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StandardAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class StandardAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropMaxTokenLength = System.Text.Json.JsonEncodedText.Encode("max_token_length"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override StandardAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propMaxTokenLength = default; + LocalJsonValue?> propStopwords = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propMaxTokenLength.TryRead(ref reader, options, PropMaxTokenLength)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StandardAnalyzer + { + MaxTokenLength = propMaxTokenLength.Value +, + Stopwords = propStopwords.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StandardAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMaxTokenLength, value.MaxTokenLength); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StandardAnalyzerConverter))] public sealed partial class StandardAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("max_token_length")] public int? MaxTokenLength { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "standard"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs index b92fc84576f..b73d1fb28a3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StemmerTokenFilter.g.cs @@ -27,52 +27,54 @@ namespace Elastic.Clients.Elasticsearch.Analysis; -internal sealed partial class StemmerTokenFilterConverter : JsonConverter +internal sealed partial class StemmerTokenFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override StemmerTokenFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropLanguage1 = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StemmerTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new StemmerTokenFilter(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLanguage = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propLanguage.TryRead(ref reader, options, PropLanguage) || propLanguage.TryRead(ref reader, options, PropLanguage1)) { - var property = reader.GetString(); - if (property == "language" || property == "name") - { - variant.Language = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } - public override void Write(Utf8JsonWriter writer, StemmerTokenFilter value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Language)) - { - writer.WritePropertyName("language"); - writer.WriteStringValue(value.Language); + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - writer.WritePropertyName("type"); - writer.WriteStringValue("stemmer"); - if (!string.IsNullOrEmpty(value.Version)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StemmerTokenFilter { - writer.WritePropertyName("version"); - writer.WriteStringValue(value.Version); - } + Language = propLanguage.Value +, + Version = propVersion.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, StemmerTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs index 9467b26a75b..1b3086273a6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopAnalyzer.g.cs @@ -27,18 +27,75 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class StopAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StopAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopAnalyzerConverter))] public sealed partial class StopAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "stop"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs index d1093f2ebef..886197ea98c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/StopTokenFilter.g.cs @@ -27,22 +27,97 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class StopTokenFilterConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIgnoreCase = System.Text.Json.JsonEncodedText.Encode("ignore_case"); + private static readonly System.Text.Json.JsonEncodedText PropRemoveTrailing = System.Text.Json.JsonEncodedText.Encode("remove_trailing"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override StopTokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propIgnoreCase = default; + LocalJsonValue propRemoveTrailing = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIgnoreCase.TryRead(ref reader, options, PropIgnoreCase)) + { + continue; + } + + if (propRemoveTrailing.TryRead(ref reader, options, PropRemoveTrailing)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new StopTokenFilter + { + IgnoreCase = propIgnoreCase.Value +, + RemoveTrailing = propRemoveTrailing.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, StopTokenFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIgnoreCase, value.IgnoreCase); + writer.WriteProperty(options, PropRemoveTrailing, value.RemoveTrailing); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StopTokenFilterConverter))] public sealed partial class StopTokenFilter : ITokenFilter { - [JsonInclude, JsonPropertyName("ignore_case")] public bool? IgnoreCase { get; set; } - [JsonInclude, JsonPropertyName("remove_trailing")] public bool? RemoveTrailing { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "stop"; - [JsonInclude, JsonPropertyName("version")] public string? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs index 1158c84638a..39712d3f208 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/SwedishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class SwedishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SwedishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SwedishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SwedishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SwedishAnalyzerConverter))] public sealed partial class SwedishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "swedish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs index 6ce5aceb322..a9b981e49cb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/ThaiAnalyzer.g.cs @@ -27,15 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class ThaiAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ThaiAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ThaiAnalyzer + { + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ThaiAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ThaiAnalyzerConverter))] public sealed partial class ThaiAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "thai"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs index 2fa0d6a043c..825d8b4070e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TokenFilters.g.cs @@ -209,275 +209,226 @@ public TokenFiltersDescriptor() : base(new TokenFilters()) public TokenFiltersDescriptor WordDelimiter(string tokenFilterName, WordDelimiterTokenFilter wordDelimiterTokenFilter) => AssignVariant(tokenFilterName, wordDelimiterTokenFilter); } -internal sealed partial class TokenFilterInterfaceConverter : JsonConverter +internal sealed partial class TokenFilterInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ITokenFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ITokenFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "asciifolding": - return JsonSerializer.Deserialize(ref reader, options); - case "common_grams": - return JsonSerializer.Deserialize(ref reader, options); - case "condition": - return JsonSerializer.Deserialize(ref reader, options); - case "delimited_payload": - return JsonSerializer.Deserialize(ref reader, options); - case "dictionary_decompounder": - return JsonSerializer.Deserialize(ref reader, options); - case "edge_ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "elision": - return JsonSerializer.Deserialize(ref reader, options); - case "fingerprint": - return JsonSerializer.Deserialize(ref reader, options); - case "hunspell": - return JsonSerializer.Deserialize(ref reader, options); - case "hyphenation_decompounder": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_collation": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_folding": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_normalizer": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_transform": - return JsonSerializer.Deserialize(ref reader, options); - case "keep_types": - return JsonSerializer.Deserialize(ref reader, options); - case "keep": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword_marker": - return JsonSerializer.Deserialize(ref reader, options); - case "kstem": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_part_of_speech": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_readingform": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_stemmer": - return JsonSerializer.Deserialize(ref reader, options); - case "length": - return JsonSerializer.Deserialize(ref reader, options); - case "limit": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - case "multiplexer": - return JsonSerializer.Deserialize(ref reader, options); - case "ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "nori_part_of_speech": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_capture": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern_replace": - return JsonSerializer.Deserialize(ref reader, options); - case "phonetic": - return JsonSerializer.Deserialize(ref reader, options); - case "porter_stem": - return JsonSerializer.Deserialize(ref reader, options); - case "predicate_token_filter": - return JsonSerializer.Deserialize(ref reader, options); - case "remove_duplicates": - return JsonSerializer.Deserialize(ref reader, options); - case "reverse": - return JsonSerializer.Deserialize(ref reader, options); - case "shingle": - return JsonSerializer.Deserialize(ref reader, options); - case "snowball": - return JsonSerializer.Deserialize(ref reader, options); - case "stemmer_override": - return JsonSerializer.Deserialize(ref reader, options); - case "stemmer": - return JsonSerializer.Deserialize(ref reader, options); - case "stop": - return JsonSerializer.Deserialize(ref reader, options); - case "synonym_graph": - return JsonSerializer.Deserialize(ref reader, options); - case "synonym": - return JsonSerializer.Deserialize(ref reader, options); - case "trim": - return JsonSerializer.Deserialize(ref reader, options); - case "truncate": - return JsonSerializer.Deserialize(ref reader, options); - case "unique": - return JsonSerializer.Deserialize(ref reader, options); - case "uppercase": - return JsonSerializer.Deserialize(ref reader, options); - case "word_delimiter_graph": - return JsonSerializer.Deserialize(ref reader, options); - case "word_delimiter": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenFilter)); - return null; - } + "asciifolding" => reader.ReadValue(options), + "common_grams" => reader.ReadValue(options), + "condition" => reader.ReadValue(options), + "delimited_payload" => reader.ReadValue(options), + "dictionary_decompounder" => reader.ReadValue(options), + "edge_ngram" => reader.ReadValue(options), + "elision" => reader.ReadValue(options), + "fingerprint" => reader.ReadValue(options), + "hunspell" => reader.ReadValue(options), + "hyphenation_decompounder" => reader.ReadValue(options), + "icu_collation" => reader.ReadValue(options), + "icu_folding" => reader.ReadValue(options), + "icu_normalizer" => reader.ReadValue(options), + "icu_transform" => reader.ReadValue(options), + "keep_types" => reader.ReadValue(options), + "keep" => reader.ReadValue(options), + "keyword_marker" => reader.ReadValue(options), + "kstem" => reader.ReadValue(options), + "kuromoji_part_of_speech" => reader.ReadValue(options), + "kuromoji_readingform" => reader.ReadValue(options), + "kuromoji_stemmer" => reader.ReadValue(options), + "length" => reader.ReadValue(options), + "limit" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + "multiplexer" => reader.ReadValue(options), + "ngram" => reader.ReadValue(options), + "nori_part_of_speech" => reader.ReadValue(options), + "pattern_capture" => reader.ReadValue(options), + "pattern_replace" => reader.ReadValue(options), + "phonetic" => reader.ReadValue(options), + "porter_stem" => reader.ReadValue(options), + "predicate_token_filter" => reader.ReadValue(options), + "remove_duplicates" => reader.ReadValue(options), + "reverse" => reader.ReadValue(options), + "shingle" => reader.ReadValue(options), + "snowball" => reader.ReadValue(options), + "stemmer_override" => reader.ReadValue(options), + "stemmer" => reader.ReadValue(options), + "stop" => reader.ReadValue(options), + "synonym_graph" => reader.ReadValue(options), + "synonym" => reader.ReadValue(options), + "trim" => reader.ReadValue(options), + "truncate" => reader.ReadValue(options), + "unique" => reader.ReadValue(options), + "uppercase" => reader.ReadValue(options), + "word_delimiter_graph" => reader.ReadValue(options), + "word_delimiter" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ITokenFilter)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ITokenFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ITokenFilter value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "asciifolding": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.AsciiFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.AsciiFoldingTokenFilter)value); + break; case "common_grams": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CommonGramsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CommonGramsTokenFilter)value); + break; case "condition": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ConditionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ConditionTokenFilter)value); + break; case "delimited_payload": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DelimitedPayloadTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DelimitedPayloadTokenFilter)value); + break; case "dictionary_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.DictionaryDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.DictionaryDecompounderTokenFilter)value); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenFilter)value); + break; case "elision": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ElisionTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ElisionTokenFilter)value); + break; case "fingerprint": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.FingerprintTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.FingerprintTokenFilter)value); + break; case "hunspell": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HunspellTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HunspellTokenFilter)value); + break; case "hyphenation_decompounder": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.HyphenationDecompounderTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.HyphenationDecompounderTokenFilter)value); + break; case "icu_collation": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuCollationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuCollationTokenFilter)value); + break; case "icu_folding": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuFoldingTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuFoldingTokenFilter)value); + break; case "icu_normalizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuNormalizationTokenFilter)value); + break; case "icu_transform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuTransformTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuTransformTokenFilter)value); + break; case "keep_types": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeepTypesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeepTypesTokenFilter)value); + break; case "keep": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeepWordsTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeepWordsTokenFilter)value); + break; case "keyword_marker": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordMarkerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordMarkerTokenFilter)value); + break; case "kstem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KStemTokenFilter)value); + break; case "kuromoji_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiPartOfSpeechTokenFilter)value); + break; case "kuromoji_readingform": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiReadingFormTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiReadingFormTokenFilter)value); + break; case "kuromoji_stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiStemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiStemmerTokenFilter)value); + break; case "length": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LengthTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LengthTokenFilter)value); + break; case "limit": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LimitTokenCountTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LimitTokenCountTokenFilter)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenFilter)value); + break; case "multiplexer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.MultiplexerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.MultiplexerTokenFilter)value); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NGramTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NGramTokenFilter)value); + break; case "nori_part_of_speech": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriPartOfSpeechTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriPartOfSpeechTokenFilter)value); + break; case "pattern_capture": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternCaptureTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternCaptureTokenFilter)value); + break; case "pattern_replace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternReplaceTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternReplaceTokenFilter)value); + break; case "phonetic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PhoneticTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PhoneticTokenFilter)value); + break; case "porter_stem": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PorterStemTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PorterStemTokenFilter)value); + break; case "predicate_token_filter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PredicateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PredicateTokenFilter)value); + break; case "remove_duplicates": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.RemoveDuplicatesTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.RemoveDuplicatesTokenFilter)value); + break; case "reverse": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ReverseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ReverseTokenFilter)value); + break; case "shingle": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ShingleTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ShingleTokenFilter)value); + break; case "snowball": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SnowballTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SnowballTokenFilter)value); + break; case "stemmer_override": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StemmerOverrideTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StemmerOverrideTokenFilter)value); + break; case "stemmer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StemmerTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StemmerTokenFilter)value); + break; case "stop": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StopTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StopTokenFilter)value); + break; case "synonym_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SynonymGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SynonymGraphTokenFilter)value); + break; case "synonym": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SynonymTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SynonymTokenFilter)value); + break; case "trim": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TrimTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TrimTokenFilter)value); + break; case "truncate": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.TruncateTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.TruncateTokenFilter)value); + break; case "unique": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UniqueTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UniqueTokenFilter)value); + break; case "uppercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UppercaseTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UppercaseTokenFilter)value); + break; case "word_delimiter_graph": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WordDelimiterGraphTokenFilter)value); + break; case "word_delimiter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WordDelimiterTokenFilter), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WordDelimiterTokenFilter)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ITokenFilter)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs index 54f24ae2bab..e17a65c75e3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/Tokenizers.g.cs @@ -122,130 +122,110 @@ public TokenizersDescriptor() : base(new Tokenizers()) public TokenizersDescriptor Whitespace(string tokenizerName, WhitespaceTokenizer whitespaceTokenizer) => AssignVariant(tokenizerName, whitespaceTokenizer); } -internal sealed partial class TokenizerInterfaceConverter : JsonConverter +internal sealed partial class TokenizerInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ITokenizer Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ITokenizer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "char_group": - return JsonSerializer.Deserialize(ref reader, options); - case "classic": - return JsonSerializer.Deserialize(ref reader, options); - case "edge_ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "kuromoji_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "letter": - return JsonSerializer.Deserialize(ref reader, options); - case "lowercase": - return JsonSerializer.Deserialize(ref reader, options); - case "ngram": - return JsonSerializer.Deserialize(ref reader, options); - case "nori_tokenizer": - return JsonSerializer.Deserialize(ref reader, options); - case "path_hierarchy": - return JsonSerializer.Deserialize(ref reader, options); - case "pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "simple_pattern_split": - return JsonSerializer.Deserialize(ref reader, options); - case "simple_pattern": - return JsonSerializer.Deserialize(ref reader, options); - case "standard": - return JsonSerializer.Deserialize(ref reader, options); - case "thai": - return JsonSerializer.Deserialize(ref reader, options); - case "uax_url_email": - return JsonSerializer.Deserialize(ref reader, options); - case "whitespace": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ITokenizer)); - return null; - } + "char_group" => reader.ReadValue(options), + "classic" => reader.ReadValue(options), + "edge_ngram" => reader.ReadValue(options), + "icu_tokenizer" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "kuromoji_tokenizer" => reader.ReadValue(options), + "letter" => reader.ReadValue(options), + "lowercase" => reader.ReadValue(options), + "ngram" => reader.ReadValue(options), + "nori_tokenizer" => reader.ReadValue(options), + "path_hierarchy" => reader.ReadValue(options), + "pattern" => reader.ReadValue(options), + "simple_pattern_split" => reader.ReadValue(options), + "simple_pattern" => reader.ReadValue(options), + "standard" => reader.ReadValue(options), + "thai" => reader.ReadValue(options), + "uax_url_email" => reader.ReadValue(options), + "whitespace" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ITokenizer)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ITokenizer value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ITokenizer value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "char_group": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.CharGroupTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.CharGroupTokenizer)value); + break; case "classic": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ClassicTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ClassicTokenizer)value); + break; case "edge_ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.EdgeNGramTokenizer)value); + break; case "icu_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.IcuTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.IcuTokenizer)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KeywordTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KeywordTokenizer)value); + break; case "kuromoji_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.KuromojiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.KuromojiTokenizer)value); + break; case "letter": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LetterTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LetterTokenizer)value); + break; case "lowercase": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.LowercaseTokenizer)value); + break; case "ngram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NGramTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NGramTokenizer)value); + break; case "nori_tokenizer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.NoriTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.NoriTokenizer)value); + break; case "path_hierarchy": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PathHierarchyTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PathHierarchyTokenizer)value); + break; case "pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.PatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.PatternTokenizer)value); + break; case "simple_pattern_split": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimplePatternSplitTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimplePatternSplitTokenizer)value); + break; case "simple_pattern": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.SimplePatternTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.SimplePatternTokenizer)value); + break; case "standard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.StandardTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.StandardTokenizer)value); + break; case "thai": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.ThaiTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.ThaiTokenizer)value); + break; case "uax_url_email": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.UaxEmailUrlTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.UaxEmailUrlTokenizer)value); + break; case "whitespace": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Analysis.WhitespaceTokenizer), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Analysis.WhitespaceTokenizer)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ITokenizer)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs index 29aad7e4200..5202085256f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Analysis/TurkishAnalyzer.g.cs @@ -27,17 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Analysis; +internal sealed partial class TurkishAnalyzerConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropStemExclusion = System.Text.Json.JsonEncodedText.Encode("stem_exclusion"); + private static readonly System.Text.Json.JsonEncodedText PropStopwords = System.Text.Json.JsonEncodedText.Encode("stopwords"); + private static readonly System.Text.Json.JsonEncodedText PropStopwordsPath = System.Text.Json.JsonEncodedText.Encode("stopwords_path"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TurkishAnalyzer Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propStemExclusion = default; + LocalJsonValue?> propStopwords = default; + LocalJsonValue propStopwordsPath = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propStemExclusion.TryRead(ref reader, options, PropStemExclusion)) + { + continue; + } + + if (propStopwords.TryRead(ref reader, options, PropStopwords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propStopwordsPath.TryRead(ref reader, options, PropStopwordsPath)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TurkishAnalyzer + { + StemExclusion = propStemExclusion.Value +, + Stopwords = propStopwords.Value +, + StopwordsPath = propStopwordsPath.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TurkishAnalyzer value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropStemExclusion, value.StemExclusion); + writer.WriteProperty(options, PropStopwords, value.Stopwords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropStopwordsPath, value.StopwordsPath); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TurkishAnalyzerConverter))] public sealed partial class TurkishAnalyzer : IAnalyzer { - [JsonInclude, JsonPropertyName("stem_exclusion")] public ICollection? StemExclusion { get; set; } - [JsonInclude, JsonPropertyName("stopwords")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Stopwords { get; set; } - [JsonInclude, JsonPropertyName("stopwords_path")] public string? StopwordsPath { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "turkish"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs index bcaf721928d..93e3b586e50 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/AsyncSearch/AsyncSearch.g.cs @@ -27,6 +27,187 @@ namespace Elastic.Clients.Elasticsearch.AsyncSearch; +internal sealed partial class AsyncSearchConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override AsyncSearch Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AsyncSearch + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AsyncSearch value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class AsyncSearchConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(AsyncSearch<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(AsyncSearchConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(AsyncSearchConverterFactory))] public sealed partial class AsyncSearch { /// @@ -34,15 +215,10 @@ public sealed partial class AsyncSearch /// Partial aggregations results, coming from the shards that have already completed the execution of the query. /// /// - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } /// @@ -51,13 +227,9 @@ public sealed partial class AsyncSearch /// If this number increases compared to the last retrieved results for a get asynch search request, you can expect additional results included in the search response. /// /// - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } /// @@ -66,14 +238,9 @@ public sealed partial class AsyncSearch /// Note that in order for shard results to be included in the search response, they need to be reduced first. /// /// - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs index 62b3163daa1..492f855571b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Cluster/ComponentTemplateSummary.g.cs @@ -38,7 +38,6 @@ public sealed partial class ComponentTemplateSummary [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } [JsonInclude, JsonPropertyName("settings")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.IndexSettings))] public IReadOnlyDictionary? Settings { get; init; } [JsonInclude, JsonPropertyName("version")] public long? Version { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs index 00c49f9380c..c2fe4eb7f3c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/CompletionStats.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch; public sealed partial class CompletionStats { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.FieldSizeUsage))] public IReadOnlyDictionary? Fields { get; init; } /// diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs index 7305368830a..5550e97eb35 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/FieldCaps/FieldCapability.g.cs @@ -27,6 +27,150 @@ namespace Elastic.Clients.Elasticsearch.Core.FieldCaps; +internal sealed partial class FieldCapabilityConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregatable = System.Text.Json.JsonEncodedText.Encode("aggregatable"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropMetadataField = System.Text.Json.JsonEncodedText.Encode("metadata_field"); + private static readonly System.Text.Json.JsonEncodedText PropMetricConflictsIndices = System.Text.Json.JsonEncodedText.Encode("metric_conflicts_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonAggregatableIndices = System.Text.Json.JsonEncodedText.Encode("non_aggregatable_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonDimensionIndices = System.Text.Json.JsonEncodedText.Encode("non_dimension_indices"); + private static readonly System.Text.Json.JsonEncodedText PropNonSearchableIndices = System.Text.Json.JsonEncodedText.Encode("non_searchable_indices"); + private static readonly System.Text.Json.JsonEncodedText PropSearchable = System.Text.Json.JsonEncodedText.Encode("searchable"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FieldCapability Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregatable = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propMetadataField = default; + LocalJsonValue?> propMetricConflictsIndices = default; + LocalJsonValue?> propNonAggregatableIndices = default; + LocalJsonValue?> propNonDimensionIndices = default; + LocalJsonValue?> propNonSearchableIndices = default; + LocalJsonValue propSearchable = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregatable.TryRead(ref reader, options, PropAggregatable)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propMetadataField.TryRead(ref reader, options, PropMetadataField)) + { + continue; + } + + if (propMetricConflictsIndices.TryRead(ref reader, options, PropMetricConflictsIndices)) + { + continue; + } + + if (propNonAggregatableIndices.TryRead(ref reader, options, PropNonAggregatableIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propNonDimensionIndices.TryRead(ref reader, options, PropNonDimensionIndices)) + { + continue; + } + + if (propNonSearchableIndices.TryRead(ref reader, options, PropNonSearchableIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propSearchable.TryRead(ref reader, options, PropSearchable)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCapability + { + Aggregatable = propAggregatable.Value +, + Indices = propIndices.Value +, + Meta = propMeta.Value +, + MetadataField = propMetadataField.Value +, + MetricConflictsIndices = propMetricConflictsIndices.Value +, + NonAggregatableIndices = propNonAggregatableIndices.Value +, + NonDimensionIndices = propNonDimensionIndices.Value +, + NonSearchableIndices = propNonSearchableIndices.Value +, + Searchable = propSearchable.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCapability value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregatable, value.Aggregatable); + writer.WriteProperty(options, PropIndices, value.Indices, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropMetadataField, value.MetadataField); + writer.WriteProperty(options, PropMetricConflictsIndices, value.MetricConflictsIndices); + writer.WriteProperty(options, PropNonAggregatableIndices, value.NonAggregatableIndices, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropNonDimensionIndices, value.NonDimensionIndices); + writer.WriteProperty(options, PropNonSearchableIndices, value.NonSearchableIndices, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropSearchable, value.Searchable); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCapabilityConverter))] public sealed partial class FieldCapability { /// @@ -34,7 +178,6 @@ public sealed partial class FieldCapability /// Whether this field can be aggregated on all indices. /// /// - [JsonInclude, JsonPropertyName("aggregatable")] public bool Aggregatable { get; init; } /// @@ -42,8 +185,6 @@ public sealed partial class FieldCapability /// The list of indices where this field has the same type family, or null if all indices have the same type family for the field. /// /// - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Indices { get; init; } /// @@ -51,7 +192,6 @@ public sealed partial class FieldCapability /// Merged metadata across all indices as a map of string keys to arrays of values. A value length of 1 indicates that all indices had the same value for this key, while a length of 2 or more indicates that not all indices had the same value for this key. /// /// - [JsonInclude, JsonPropertyName("meta")] public IReadOnlyDictionary? Meta { get; init; } /// @@ -59,7 +199,6 @@ public sealed partial class FieldCapability /// Whether this field is registered as a metadata field. /// /// - [JsonInclude, JsonPropertyName("metadata_field")] public bool? MetadataField { get; init; } /// @@ -68,7 +207,6 @@ public sealed partial class FieldCapability /// don’t have the same time_series_metric value for this field. /// /// - [JsonInclude, JsonPropertyName("metric_conflicts_indices")] public IReadOnlyCollection? MetricConflictsIndices { get; init; } /// @@ -76,8 +214,6 @@ public sealed partial class FieldCapability /// The list of indices where this field is not aggregatable, or null if all indices have the same definition for the field. /// /// - [JsonInclude, JsonPropertyName("non_aggregatable_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? NonAggregatableIndices { get; init; } /// @@ -86,7 +222,6 @@ public sealed partial class FieldCapability /// field marked as a dimension and other indices, the ones in this list, do not. /// /// - [JsonInclude, JsonPropertyName("non_dimension_indices")] public IReadOnlyCollection? NonDimensionIndices { get; init; } /// @@ -94,8 +229,6 @@ public sealed partial class FieldCapability /// The list of indices where this field is not searchable, or null if all indices have the same definition for the field. /// /// - [JsonInclude, JsonPropertyName("non_searchable_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? NonSearchableIndices { get; init; } /// @@ -103,7 +236,6 @@ public sealed partial class FieldCapability /// Whether this field is indexed for search on all indices. /// /// - [JsonInclude, JsonPropertyName("searchable")] public bool Searchable { get; init; } /// @@ -111,7 +243,6 @@ public sealed partial class FieldCapability /// Whether this field is used as a time series dimension. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; init; } /// @@ -120,8 +251,6 @@ public sealed partial class FieldCapability /// metrics, absent if the field is not used as metric. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; init; } - [JsonInclude, JsonPropertyName("type")] public string Type { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs index 07624ca28ed..beabc6bddd7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Get/GetResult.g.cs @@ -27,27 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Core.Get; +internal sealed partial class GetResultConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override GetResult Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue propIndex = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GetResult + { + Fields = propFields.Value +, + Found = propFound.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + Index = propIndex.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GetResult value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class GetResultConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(GetResult<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(GetResultConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(GetResultConverterFactory))] public sealed partial class GetResult { - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.FieldValues? Fields { get; init; } - [JsonInclude, JsonPropertyName("found")] public bool Found { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs index 389fd578f42..6690b5dadf4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/HealthReport/DiagnosisAffectedResources.g.cs @@ -27,17 +27,85 @@ namespace Elastic.Clients.Elasticsearch.Core.HealthReport; +internal sealed partial class DiagnosisAffectedResourcesConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFeatureStates = System.Text.Json.JsonEncodedText.Encode("feature_states"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + private static readonly System.Text.Json.JsonEncodedText PropSlmPolicies = System.Text.Json.JsonEncodedText.Encode("slm_policies"); + private static readonly System.Text.Json.JsonEncodedText PropSnapshotRepositories = System.Text.Json.JsonEncodedText.Encode("snapshot_repositories"); + + public override DiagnosisAffectedResources Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propFeatureStates = default; + LocalJsonValue?> propIndices = default; + LocalJsonValue?> propNodes = default; + LocalJsonValue?> propSlmPolicies = default; + LocalJsonValue?> propSnapshotRepositories = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFeatureStates.TryRead(ref reader, options, PropFeatureStates)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propNodes.TryRead(ref reader, options, PropNodes)) + { + continue; + } + + if (propSlmPolicies.TryRead(ref reader, options, PropSlmPolicies)) + { + continue; + } + + if (propSnapshotRepositories.TryRead(ref reader, options, PropSnapshotRepositories)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DiagnosisAffectedResources + { + FeatureStates = propFeatureStates.Value +, + Indices = propIndices.Value +, + Nodes = propNodes.Value +, + SlmPolicies = propSlmPolicies.Value +, + SnapshotRepositories = propSnapshotRepositories.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DiagnosisAffectedResources value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFeatureStates, value.FeatureStates); + writer.WriteProperty(options, PropIndices, value.Indices, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropNodes, value.Nodes); + writer.WriteProperty(options, PropSlmPolicies, value.SlmPolicies); + writer.WriteProperty(options, PropSnapshotRepositories, value.SnapshotRepositories); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DiagnosisAffectedResourcesConverter))] public sealed partial class DiagnosisAffectedResources { - [JsonInclude, JsonPropertyName("feature_states")] public IReadOnlyCollection? FeatureStates { get; init; } - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Indices { get; init; } - [JsonInclude, JsonPropertyName("nodes")] public IReadOnlyCollection? Nodes { get; init; } - [JsonInclude, JsonPropertyName("slm_policies")] public IReadOnlyCollection? SlmPolicies { get; init; } - [JsonInclude, JsonPropertyName("snapshot_repositories")] public IReadOnlyCollection? SnapshotRepositories { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs index eb20a84fc6e..643e4d70290 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MGet/MultiGetOperation.g.cs @@ -27,6 +27,100 @@ namespace Elastic.Clients.Elasticsearch.Core.MGet; +internal sealed partial class MultiGetOperationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MultiGetOperation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiGetOperation + { + Id = propId.Value +, + Index = propIndex.Value +, + Routing = propRouting.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiGetOperation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiGetOperationConverter))] public sealed partial class MultiGetOperation { /// @@ -34,7 +128,6 @@ public sealed partial class MultiGetOperation /// The unique document ID. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Id Id { get; set; } /// @@ -42,7 +135,6 @@ public sealed partial class MultiGetOperation /// The index that contains the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -50,7 +142,6 @@ public sealed partial class MultiGetOperation /// The key for the primary shard the document resides on. Required if routing is used during indexing. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -58,7 +149,6 @@ public sealed partial class MultiGetOperation /// If false, excludes all _source fields. /// /// - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } /// @@ -66,12 +156,8 @@ public sealed partial class MultiGetOperation /// The stored fields you want to retrieve. /// /// - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs index 48bf0448faf..f23ab37898d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultiSearchItem.g.cs @@ -27,36 +27,212 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; +internal sealed partial class MultiSearchItemConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHitsMetadata = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumReducePhases = System.Text.Json.JsonEncodedText.Encode("num_reduce_phases"); + private static readonly System.Text.Json.JsonEncodedText PropPitId = System.Text.Json.JsonEncodedText.Encode("pit_id"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropScrollId = System.Text.Json.JsonEncodedText.Encode("_scroll_id"); + private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards"); + private static readonly System.Text.Json.JsonEncodedText PropStatus = System.Text.Json.JsonEncodedText.Encode("status"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminatedEarly = System.Text.Json.JsonEncodedText.Encode("terminated_early"); + private static readonly System.Text.Json.JsonEncodedText PropTimedOut = System.Text.Json.JsonEncodedText.Encode("timed_out"); + private static readonly System.Text.Json.JsonEncodedText PropTook = System.Text.Json.JsonEncodedText.Encode("took"); + + public override MultiSearchItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAggregations = default; + LocalJsonValue propClusters = default; + LocalJsonValue?> propFields = default; + LocalJsonValue> propHitsMetadata = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue propNumReducePhases = default; + LocalJsonValue propPitId = default; + LocalJsonValue propProfile = default; + LocalJsonValue propScrollId = default; + LocalJsonValue propShards = default; + LocalJsonValue propStatus = default; + LocalJsonValue?> propSuggest = default; + LocalJsonValue propTerminatedEarly = default; + LocalJsonValue propTimedOut = default; + LocalJsonValue propTook = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations)) + { + continue; + } + + if (propClusters.TryRead(ref reader, options, PropClusters)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHitsMetadata.TryRead(ref reader, options, PropHitsMetadata)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propNumReducePhases.TryRead(ref reader, options, PropNumReducePhases)) + { + continue; + } + + if (propPitId.TryRead(ref reader, options, PropPitId)) + { + continue; + } + + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } + + if (propScrollId.TryRead(ref reader, options, PropScrollId)) + { + continue; + } + + if (propShards.TryRead(ref reader, options, PropShards)) + { + continue; + } + + if (propStatus.TryRead(ref reader, options, PropStatus)) + { + continue; + } + + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } + + if (propTerminatedEarly.TryRead(ref reader, options, PropTerminatedEarly)) + { + continue; + } + + if (propTimedOut.TryRead(ref reader, options, PropTimedOut)) + { + continue; + } + + if (propTook.TryRead(ref reader, options, PropTook)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiSearchItem + { + Aggregations = propAggregations.Value +, + Clusters = propClusters.Value +, + Fields = propFields.Value +, + HitsMetadata = propHitsMetadata.Value +, + MaxScore = propMaxScore.Value +, + NumReducePhases = propNumReducePhases.Value +, + PitId = propPitId.Value +, + Profile = propProfile.Value +, + ScrollId = propScrollId.Value +, + Shards = propShards.Value +, + Status = propStatus.Value +, + Suggest = propSuggest.Value +, + TerminatedEarly = propTerminatedEarly.Value +, + TimedOut = propTimedOut.Value +, + Took = propTook.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiSearchItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropClusters, value.Clusters); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHitsMetadata, value.HitsMetadata); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropNumReducePhases, value.NumReducePhases); + writer.WriteProperty(options, PropPitId, value.PitId); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropScrollId, value.ScrollId); + writer.WriteProperty(options, PropShards, value.Shards); + writer.WriteProperty(options, PropStatus, value.Status); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminatedEarly, value.TerminatedEarly); + writer.WriteProperty(options, PropTimedOut, value.TimedOut); + writer.WriteProperty(options, PropTook, value.Took); + writer.WriteEndObject(); + } +} + +internal sealed partial class MultiSearchItemConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(MultiSearchItem<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(MultiSearchItemConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(MultiSearchItemConverterFactory))] public sealed partial class MultiSearchItem { - [JsonInclude, JsonPropertyName("aggregations")] public Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionary? Aggregations { get; init; } - [JsonInclude, JsonPropertyName("_clusters")] public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("hits")] public Elastic.Clients.Elasticsearch.Core.Search.HitsMetadata HitsMetadata { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } - [JsonInclude, JsonPropertyName("num_reduce_phases")] public long? NumReducePhases { get; init; } - [JsonInclude, JsonPropertyName("pit_id")] public string? PitId { get; init; } - [JsonInclude, JsonPropertyName("profile")] public Elastic.Clients.Elasticsearch.Core.Search.Profile? Profile { get; init; } - [JsonInclude, JsonPropertyName("_scroll_id")] public Elastic.Clients.Elasticsearch.ScrollId? ScrollId { get; init; } - [JsonInclude, JsonPropertyName("_shards")] public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; } - [JsonInclude, JsonPropertyName("status")] public int? Status { get; init; } - [JsonInclude, JsonPropertyName("suggest")] public Elastic.Clients.Elasticsearch.Core.Search.SuggestDictionary? Suggest { get; init; } - [JsonInclude, JsonPropertyName("terminated_early")] public bool? TerminatedEarly { get; init; } - [JsonInclude, JsonPropertyName("timed_out")] public bool TimedOut { get; init; } - [JsonInclude, JsonPropertyName("took")] public long Took { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index 1cac0049899..61e699389cd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -27,399 +27,336 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; -internal sealed partial class MultisearchBodyConverter : JsonConverter +internal sealed partial class MultisearchBodyConverter : System.Text.Json.Serialization.JsonConverter { - public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new MultisearchBody(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropExt = System.Text.Json.JsonEncodedText.Encode("ext"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesBoost = System.Text.Json.JsonEncodedText.Encode("indices_boost"); + private static readonly System.Text.Json.JsonEncodedText PropKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropPit = System.Text.Json.JsonEncodedText.Encode("pit"); + private static readonly System.Text.Json.JsonEncodedText PropPostFilter = System.Text.Json.JsonEncodedText.Encode("post_filter"); + private static readonly System.Text.Json.JsonEncodedText PropProfile = System.Text.Json.JsonEncodedText.Encode("profile"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRescore = System.Text.Json.JsonEncodedText.Encode("rescore"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAfter = System.Text.Json.JsonEncodedText.Encode("search_after"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStats = System.Text.Json.JsonEncodedText.Encode("stats"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSuggest = System.Text.Json.JsonEncodedText.Encode("suggest"); + private static readonly System.Text.Json.JsonEncodedText PropTerminateAfter = System.Text.Json.JsonEncodedText.Encode("terminate_after"); + private static readonly System.Text.Json.JsonEncodedText PropTimeout = System.Text.Json.JsonEncodedText.Encode("timeout"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropTrackTotalHits = System.Text.Json.JsonEncodedText.Encode("track_total_hits"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override MultisearchBody Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue?> propExt = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue>?> propIndicesBoost = default; + LocalJsonValue?> propKnn = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propPit = default; + LocalJsonValue propPostFilter = default; + LocalJsonValue propProfile = default; + LocalJsonValue propQuery = default; + LocalJsonValue?> propRescore = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue?> propSearchAfter = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue?> propStats = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propSuggest = default; + LocalJsonValue propTerminateAfter = default; + LocalJsonValue propTimeout = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propTrackTotalHits = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "collapse") - { - variant.Collapse = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "docvalue_fields") - { - variant.DocvalueFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "explain") - { - variant.Explain = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ext") - { - variant.Ext = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "fields") - { - variant.Fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "from") - { - variant.From = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_boost") - { - variant.IndicesBoost = JsonSerializer.Deserialize>?>(ref reader, options); - continue; - } - - if (property == "knn") - { - variant.Knn = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "min_score") - { - variant.MinScore = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "pit") - { - variant.Pit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "post_filter") - { - variant.PostFilter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "profile") - { - variant.Profile = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rescore") - { - variant.Rescore = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "search_after") - { - variant.SearchAfter = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seq_no_primary_term") - { - variant.SeqNoPrimaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "size") - { - variant.Size = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - variant.Source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "stats") - { - variant.Stats = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stored_fields") - { - reader.Read(); - variant.StoredFields = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } - - if (property == "suggest") - { - variant.Suggest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terminate_after") - { - variant.TerminateAfter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "timeout") - { - variant.Timeout = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_scores") - { - variant.TrackScores = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "track_total_hits") - { - variant.TrackTotalHits = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - - return variant; - } - - public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } - if (value.Collapse is not null) - { - writer.WritePropertyName("collapse"); - JsonSerializer.Serialize(writer, value.Collapse, options); - } + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } - if (value.DocvalueFields is not null) - { - writer.WritePropertyName("docvalue_fields"); - JsonSerializer.Serialize(writer, value.DocvalueFields, options); - } + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } - if (value.Explain.HasValue) - { - writer.WritePropertyName("explain"); - writer.WriteBooleanValue(value.Explain.Value); - } + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } - if (value.Ext is not null) - { - writer.WritePropertyName("ext"); - JsonSerializer.Serialize(writer, value.Ext, options); - } + if (propExt.TryRead(ref reader, options, PropExt)) + { + continue; + } - if (value.Fields is not null) - { - writer.WritePropertyName("fields"); - JsonSerializer.Serialize(writer, value.Fields, options); - } + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } - if (value.From.HasValue) - { - writer.WritePropertyName("from"); - writer.WriteNumberValue(value.From.Value); - } + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.IndicesBoost is not null) - { - writer.WritePropertyName("indices_boost"); - JsonSerializer.Serialize(writer, value.IndicesBoost, options); - } + if (propIndicesBoost.TryRead(ref reader, options, PropIndicesBoost)) + { + continue; + } - if (value.Knn is not null) - { - writer.WritePropertyName("knn"); - JsonSerializer.Serialize(writer, value.Knn, options); - } + if (propKnn.TryRead(ref reader, options, PropKnn, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>))) + { + continue; + } - if (value.MinScore.HasValue) - { - writer.WritePropertyName("min_score"); - writer.WriteNumberValue(value.MinScore.Value); - } + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } - if (value.Pit is not null) - { - writer.WritePropertyName("pit"); - JsonSerializer.Serialize(writer, value.Pit, options); - } + if (propPit.TryRead(ref reader, options, PropPit)) + { + continue; + } - if (value.PostFilter is not null) - { - writer.WritePropertyName("post_filter"); - JsonSerializer.Serialize(writer, value.PostFilter, options); - } + if (propPostFilter.TryRead(ref reader, options, PropPostFilter)) + { + continue; + } - if (value.Profile.HasValue) - { - writer.WritePropertyName("profile"); - writer.WriteBooleanValue(value.Profile.Value); - } + if (propProfile.TryRead(ref reader, options, PropProfile)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Rescore is not null) - { - writer.WritePropertyName("rescore"); - JsonSerializer.Serialize(writer, value.Rescore, options); - } + if (propRescore.TryRead(ref reader, options, PropRescore, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>))) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.SearchAfter is not null) - { - writer.WritePropertyName("search_after"); - JsonSerializer.Serialize(writer, value.SearchAfter, options); - } + if (propSearchAfter.TryRead(ref reader, options, PropSearchAfter)) + { + continue; + } - if (value.SeqNoPrimaryTerm.HasValue) - { - writer.WritePropertyName("seq_no_primary_term"); - writer.WriteBooleanValue(value.SeqNoPrimaryTerm.Value); - } + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } - if (value.Size.HasValue) - { - writer.WritePropertyName("size"); - writer.WriteNumberValue(value.Size.Value); - } + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } - if (value.Source is not null) - { - writer.WritePropertyName("_source"); - JsonSerializer.Serialize(writer, value.Source, options); - } + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } - if (value.Stats is not null) - { - writer.WritePropertyName("stats"); - JsonSerializer.Serialize(writer, value.Stats, options); - } + if (propStats.TryRead(ref reader, options, PropStats)) + { + continue; + } - if (value.StoredFields is not null) - { - writer.WritePropertyName("stored_fields"); - new FieldsConverter().Write(writer, value.StoredFields, options); - } + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - if (value.Suggest is not null) - { - writer.WritePropertyName("suggest"); - JsonSerializer.Serialize(writer, value.Suggest, options); - } + if (propSuggest.TryRead(ref reader, options, PropSuggest)) + { + continue; + } - if (value.TerminateAfter.HasValue) - { - writer.WritePropertyName("terminate_after"); - writer.WriteNumberValue(value.TerminateAfter.Value); - } + if (propTerminateAfter.TryRead(ref reader, options, PropTerminateAfter)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Timeout)) - { - writer.WritePropertyName("timeout"); - writer.WriteStringValue(value.Timeout); - } + if (propTimeout.TryRead(ref reader, options, PropTimeout)) + { + continue; + } - if (value.TrackScores.HasValue) - { - writer.WritePropertyName("track_scores"); - writer.WriteBooleanValue(value.TrackScores.Value); - } + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } - if (value.TrackTotalHits is not null) - { - writer.WritePropertyName("track_total_hits"); - JsonSerializer.Serialize(writer, value.TrackTotalHits, options); - } + if (propTrackTotalHits.TryRead(ref reader, options, PropTrackTotalHits)) + { + continue; + } - if (value.Version.HasValue) - { - writer.WritePropertyName("version"); - writer.WriteBooleanValue(value.Version.Value); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultisearchBody + { + Aggregations = propAggregations.Value +, + Collapse = propCollapse.Value +, + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Ext = propExt.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + IndicesBoost = propIndicesBoost.Value +, + Knn = propKnn.Value +, + MinScore = propMinScore.Value +, + Pit = propPit.Value +, + PostFilter = propPostFilter.Value +, + Profile = propProfile.Value +, + Query = propQuery.Value +, + Rescore = propRescore.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + SearchAfter = propSearchAfter.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + Stats = propStats.Value +, + StoredFields = propStoredFields.Value +, + Suggest = propSuggest.Value +, + TerminateAfter = propTerminateAfter.Value +, + Timeout = propTimeout.Value +, + TrackScores = propTrackScores.Value +, + TrackTotalHits = propTrackTotalHits.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultisearchBody value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropExt, value.Ext); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndicesBoost, value.IndicesBoost); + writer.WriteProperty(options, PropKnn, value.Knn, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.KnnSearch>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropPit, value.Pit); + writer.WriteProperty(options, PropPostFilter, value.PostFilter); + writer.WriteProperty(options, PropProfile, value.Profile); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRescore, value.Rescore, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.Rescore>)); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSearchAfter, value.SearchAfter); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStats, value.Stats); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropSuggest, value.Suggest); + writer.WriteProperty(options, PropTerminateAfter, value.TerminateAfter); + writer.WriteProperty(options, PropTimeout, value.Timeout); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropTrackTotalHits, value.TrackTotalHits); + writer.WriteProperty(options, PropVersion, value.Version); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs index c9ff671b68d..92c85733acc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchHeader.g.cs @@ -27,35 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Core.MSearch; +internal sealed partial class MultisearchHeaderConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowNoIndices = System.Text.Json.JsonEncodedText.Encode("allow_no_indices"); + private static readonly System.Text.Json.JsonEncodedText PropAllowPartialSearchResults = System.Text.Json.JsonEncodedText.Encode("allow_partial_search_results"); + private static readonly System.Text.Json.JsonEncodedText PropCcsMinimizeRoundtrips = System.Text.Json.JsonEncodedText.Encode("ccs_minimize_roundtrips"); + private static readonly System.Text.Json.JsonEncodedText PropExpandWildcards = System.Text.Json.JsonEncodedText.Encode("expand_wildcards"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreThrottled = System.Text.Json.JsonEncodedText.Encode("ignore_throttled"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnavailable = System.Text.Json.JsonEncodedText.Encode("ignore_unavailable"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropPreference = System.Text.Json.JsonEncodedText.Encode("preference"); + private static readonly System.Text.Json.JsonEncodedText PropRequestCache = System.Text.Json.JsonEncodedText.Encode("request_cache"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSearchType = System.Text.Json.JsonEncodedText.Encode("search_type"); + + public override MultisearchHeader Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowNoIndices = default; + LocalJsonValue propAllowPartialSearchResults = default; + LocalJsonValue propCcsMinimizeRoundtrips = default; + LocalJsonValue?> propExpandWildcards = default; + LocalJsonValue propIgnoreThrottled = default; + LocalJsonValue propIgnoreUnavailable = default; + LocalJsonValue propIndices = default; + LocalJsonValue propPreference = default; + LocalJsonValue propRequestCache = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSearchType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryRead(ref reader, options, PropAllowNoIndices)) + { + continue; + } + + if (propAllowPartialSearchResults.TryRead(ref reader, options, PropAllowPartialSearchResults)) + { + continue; + } + + if (propCcsMinimizeRoundtrips.TryRead(ref reader, options, PropCcsMinimizeRoundtrips)) + { + continue; + } + + if (propExpandWildcards.TryRead(ref reader, options, PropExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.ExpandWildcard>))) + { + continue; + } + + if (propIgnoreThrottled.TryRead(ref reader, options, PropIgnoreThrottled)) + { + continue; + } + + if (propIgnoreUnavailable.TryRead(ref reader, options, PropIgnoreUnavailable)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propPreference.TryRead(ref reader, options, PropPreference)) + { + continue; + } + + if (propRequestCache.TryRead(ref reader, options, PropRequestCache)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSearchType.TryRead(ref reader, options, PropSearchType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultisearchHeader + { + AllowNoIndices = propAllowNoIndices.Value +, + AllowPartialSearchResults = propAllowPartialSearchResults.Value +, + CcsMinimizeRoundtrips = propCcsMinimizeRoundtrips.Value +, + ExpandWildcards = propExpandWildcards.Value +, + IgnoreThrottled = propIgnoreThrottled.Value +, + IgnoreUnavailable = propIgnoreUnavailable.Value +, + Indices = propIndices.Value +, + Preference = propPreference.Value +, + RequestCache = propRequestCache.Value +, + Routing = propRouting.Value +, + SearchType = propSearchType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultisearchHeader value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowNoIndices, value.AllowNoIndices); + writer.WriteProperty(options, PropAllowPartialSearchResults, value.AllowPartialSearchResults); + writer.WriteProperty(options, PropCcsMinimizeRoundtrips, value.CcsMinimizeRoundtrips); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.ExpandWildcard>)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropPreference, value.Preference); + writer.WriteProperty(options, PropRequestCache, value.RequestCache); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSearchType, value.SearchType); + writer.WriteEndObject(); + } +} + /// /// /// Contains parameters used to limit or change the subsequent search body request. /// /// +[JsonConverter(typeof(MultisearchHeaderConverter))] public sealed partial class MultisearchHeader { - [JsonInclude, JsonPropertyName("allow_no_indices")] public bool? AllowNoIndices { get; set; } - [JsonInclude, JsonPropertyName("allow_partial_search_results")] public bool? AllowPartialSearchResults { get; set; } - [JsonInclude, JsonPropertyName("ccs_minimize_roundtrips")] public bool? CcsMinimizeRoundtrips { get; set; } - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } - [JsonInclude, JsonPropertyName("ignore_throttled")] public bool? IgnoreThrottled { get; set; } - [JsonInclude, JsonPropertyName("ignore_unavailable")] public bool? IgnoreUnavailable { get; set; } - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } - [JsonInclude, JsonPropertyName("preference")] public string? Preference { get; set; } - [JsonInclude, JsonPropertyName("request_cache")] public bool? RequestCache { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } - [JsonInclude, JsonPropertyName("search_type")] public Elastic.Clients.Elasticsearch.SearchType? SearchType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs index a21f16a7f7d..e4eff5f06ea 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsOperation.g.cs @@ -27,6 +27,160 @@ namespace Elastic.Clients.Elasticsearch.Core.Mtermvectors; +internal sealed partial class MultiTermVectorsOperationConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFieldStatistics = System.Text.Json.JsonEncodedText.Encode("field_statistics"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropOffsets = System.Text.Json.JsonEncodedText.Encode("offsets"); + private static readonly System.Text.Json.JsonEncodedText PropPayloads = System.Text.Json.JsonEncodedText.Encode("payloads"); + private static readonly System.Text.Json.JsonEncodedText PropPositions = System.Text.Json.JsonEncodedText.Encode("positions"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropTermStatistics = System.Text.Json.JsonEncodedText.Encode("term_statistics"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MultiTermVectorsOperation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDoc = default; + LocalJsonValue propFields = default; + LocalJsonValue propFieldStatistics = default; + LocalJsonValue propFilter = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propOffsets = default; + LocalJsonValue propPayloads = default; + LocalJsonValue propPositions = default; + LocalJsonValue propRouting = default; + LocalJsonValue propTermStatistics = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFieldStatistics.TryRead(ref reader, options, PropFieldStatistics)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propOffsets.TryRead(ref reader, options, PropOffsets)) + { + continue; + } + + if (propPayloads.TryRead(ref reader, options, PropPayloads)) + { + continue; + } + + if (propPositions.TryRead(ref reader, options, PropPositions)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propTermStatistics.TryRead(ref reader, options, PropTermStatistics)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiTermVectorsOperation + { + Doc = propDoc.Value +, + Fields = propFields.Value +, + FieldStatistics = propFieldStatistics.Value +, + Filter = propFilter.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Offsets = propOffsets.Value +, + Payloads = propPayloads.Value +, + Positions = propPositions.Value +, + Routing = propRouting.Value +, + TermStatistics = propTermStatistics.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiTermVectorsOperation value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFieldStatistics, value.FieldStatistics); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropOffsets, value.Offsets); + writer.WriteProperty(options, PropPayloads, value.Payloads); + writer.WriteProperty(options, PropPositions, value.Positions); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropTermStatistics, value.TermStatistics); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiTermVectorsOperationConverter))] public sealed partial class MultiTermVectorsOperation { /// @@ -34,7 +188,6 @@ public sealed partial class MultiTermVectorsOperation /// An artificial document (a document not present in the index) for which you want to retrieve term vectors. /// /// - [JsonInclude, JsonPropertyName("doc")] public object? Doc { get; set; } /// @@ -43,8 +196,6 @@ public sealed partial class MultiTermVectorsOperation /// Used as the default list unless a specific field list is provided in the completion_fields or fielddata_fields parameters. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -52,7 +203,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes the document count, sum of document frequencies, and sum of total term frequencies. /// /// - [JsonInclude, JsonPropertyName("field_statistics")] public bool? FieldStatistics { get; set; } /// @@ -60,7 +210,6 @@ public sealed partial class MultiTermVectorsOperation /// Filter terms based on their tf-idf scores. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.Core.TermVectors.Filter? Filter { get; set; } /// @@ -68,7 +217,6 @@ public sealed partial class MultiTermVectorsOperation /// The ID of the document. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Id? Id { get; set; } /// @@ -76,7 +224,6 @@ public sealed partial class MultiTermVectorsOperation /// The index of the document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -84,7 +231,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term offsets. /// /// - [JsonInclude, JsonPropertyName("offsets")] public bool? Offsets { get; set; } /// @@ -92,7 +238,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term payloads. /// /// - [JsonInclude, JsonPropertyName("payloads")] public bool? Payloads { get; set; } /// @@ -100,7 +245,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term positions. /// /// - [JsonInclude, JsonPropertyName("positions")] public bool? Positions { get; set; } /// @@ -108,7 +252,6 @@ public sealed partial class MultiTermVectorsOperation /// Custom value used to route operations to a specific shard. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -116,7 +259,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, the response includes term frequency and document frequency. /// /// - [JsonInclude, JsonPropertyName("term_statistics")] public bool? TermStatistics { get; set; } /// @@ -124,7 +266,6 @@ public sealed partial class MultiTermVectorsOperation /// If true, returns the document version as part of a hit. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } /// @@ -132,7 +273,6 @@ public sealed partial class MultiTermVectorsOperation /// Specific version type. /// /// - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs index e8ec6d5f061..3fb09185679 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Mtermvectors/MultiTermVectorsResult.g.cs @@ -38,7 +38,6 @@ public sealed partial class MultiTermVectorsResult [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } [JsonInclude, JsonPropertyName("term_vectors")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Core.TermVectors.TermVector))] public IReadOnlyDictionary? TermVectors { get; init; } [JsonInclude, JsonPropertyName("took")] public long? Took { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs index 687bd0ffd08..8efadf838b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/RankEval/RankEvalQuery.g.cs @@ -27,11 +27,63 @@ namespace Elastic.Clients.Elasticsearch.Core.RankEval; +internal sealed partial class RankEvalQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + + public override RankEvalQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propQuery = default; + LocalJsonValue propSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new RankEvalQuery { Query = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RankEvalQuery + { + Query = propQuery.Value +, + Size = propSize.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RankEvalQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RankEvalQueryConverter))] public sealed partial class RankEvalQuery { - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query Query { get; set; } - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs index 0c75aa06abf..68bc9a63d4b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Reindex/Source.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Core.Reindex; +internal sealed partial class SourceConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropRemote = System.Text.Json.JsonEncodedText.Encode("remote"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSlice = System.Text.Json.JsonEncodedText.Encode("slice"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSourceFields = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override Source Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propIndices = default; + LocalJsonValue propQuery = default; + LocalJsonValue propRemote = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue propSize = default; + LocalJsonValue propSlice = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSourceFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propRemote.TryRead(ref reader, options, PropRemote)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSlice.TryRead(ref reader, options, PropSlice)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + if (propSourceFields.TryRead(ref reader, options, PropSourceFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Source + { + Indices = propIndices.Value +, + Query = propQuery.Value +, + Remote = propRemote.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + Size = propSize.Value +, + Slice = propSlice.Value +, + Sort = propSort.Value +, + SourceFields = propSourceFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Source value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropRemote, value.Remote); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSlice, value.Slice); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSourceFields, value.SourceFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SourceConverter))] public sealed partial class Source { /// @@ -35,7 +139,6 @@ public sealed partial class Source /// Accepts a comma-separated list to reindex from multiple sources. /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.Indices Indices { get; set; } /// @@ -43,7 +146,6 @@ public sealed partial class Source /// Specifies the documents to reindex using the Query DSL. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } /// @@ -51,9 +153,7 @@ public sealed partial class Source /// A remote instance of Elasticsearch that you want to index from. /// /// - [JsonInclude, JsonPropertyName("remote")] public Elastic.Clients.Elasticsearch.Core.Reindex.RemoteSource? Remote { get; set; } - [JsonInclude, JsonPropertyName("runtime_mappings")] public IDictionary? RuntimeMappings { get; set; } /// @@ -62,7 +162,6 @@ public sealed partial class Source /// Use when indexing from remote to ensure that the batches fit within the on-heap buffer, which defaults to a maximum size of 100 MB. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -70,10 +169,7 @@ public sealed partial class Source /// Slice the reindex request manually using the provided slice ID and total number of slices. /// /// - [JsonInclude, JsonPropertyName("slice")] public Elastic.Clients.Elasticsearch.SlicedScroll? Slice { get; set; } - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } /// @@ -82,8 +178,6 @@ public sealed partial class Source /// Set to a list to reindex select fields. /// /// - [JsonInclude, JsonPropertyName("_source")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? SourceFields { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs index 7e8b2f44500..503130aa23a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionContext.g.cs @@ -27,6 +27,90 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class CompletionContextConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropContext = System.Text.Json.JsonEncodedText.Encode("context"); + private static readonly System.Text.Json.JsonEncodedText PropNeighbours = System.Text.Json.JsonEncodedText.Encode("neighbours"); + private static readonly System.Text.Json.JsonEncodedText PropPrecision = System.Text.Json.JsonEncodedText.Encode("precision"); + private static readonly System.Text.Json.JsonEncodedText PropPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + + public override CompletionContext Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propContext = default; + LocalJsonValue?> propNeighbours = default; + LocalJsonValue propPrecision = default; + LocalJsonValue propPrefix = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propContext.TryRead(ref reader, options, PropContext)) + { + continue; + } + + if (propNeighbours.TryRead(ref reader, options, PropNeighbours)) + { + continue; + } + + if (propPrecision.TryRead(ref reader, options, PropPrecision)) + { + continue; + } + + if (propPrefix.TryRead(ref reader, options, PropPrefix)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new CompletionContext { Context = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionContext + { + Boost = propBoost.Value +, + Context = propContext.Value +, + Neighbours = propNeighbours.Value +, + Precision = propPrecision.Value +, + Prefix = propPrefix.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionContext value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropContext, value.Context); + writer.WriteProperty(options, PropNeighbours, value.Neighbours); + writer.WriteProperty(options, PropPrecision, value.Precision); + writer.WriteProperty(options, PropPrefix, value.Prefix); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionContextConverter))] public sealed partial class CompletionContext { /// @@ -35,7 +119,6 @@ public sealed partial class CompletionContext /// The score is computed by multiplying the boost with the suggestion weight. /// /// - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } /// @@ -43,7 +126,6 @@ public sealed partial class CompletionContext /// The value of the category to filter/boost on. /// /// - [JsonInclude, JsonPropertyName("context")] public Elastic.Clients.Elasticsearch.Core.Search.Context Context { get; set; } /// @@ -53,7 +135,6 @@ public sealed partial class CompletionContext /// Defaults to generating neighbors for index time precision level. /// /// - [JsonInclude, JsonPropertyName("neighbours")] public ICollection? Neighbours { get; set; } /// @@ -63,7 +144,6 @@ public sealed partial class CompletionContext /// Defaults to index time precision level. /// /// - [JsonInclude, JsonPropertyName("precision")] public Elastic.Clients.Elasticsearch.GeohashPrecision? Precision { get; set; } /// @@ -71,7 +151,6 @@ public sealed partial class CompletionContext /// Whether the category value should be treated as a prefix or not. /// /// - [JsonInclude, JsonPropertyName("prefix")] public bool? Prefix { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs index c294fa934bc..d351bf6ffe6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggest.g.cs @@ -27,15 +27,93 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class CompletionSuggestConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override CompletionSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue>> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker>, Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, null, typeof(SingleOrManyMarker>, Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +internal sealed partial class CompletionSuggestConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(CompletionSuggest<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(CompletionSuggestConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(CompletionSuggestConverterFactory))] public sealed partial class CompletionSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [GenericConverter(typeof(SingleOrManyCollectionConverter<>), unwrap: true)] public IReadOnlyCollection> Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "completion"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs index 3e0c73771fb..065bba7b8d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/CompletionSuggestOption.g.cs @@ -27,27 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class CompletionSuggestOptionConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropCollateMatch = System.Text.Json.JsonEncodedText.Encode("collate_match"); + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("score"); + private static readonly System.Text.Json.JsonEncodedText PropScore0 = System.Text.Json.JsonEncodedText.Encode("_score"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override CompletionSuggestOption Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCollateMatch = default; + LocalJsonValue>?> propContexts = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propRouting = default; + LocalJsonValue propScore = default; + LocalJsonValue propScore0 = default; + LocalJsonValue propSource = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollateMatch.TryRead(ref reader, options, PropCollateMatch)) + { + continue; + } + + if (propContexts.TryRead(ref reader, options, PropContexts)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; + } + + if (propScore0.TryRead(ref reader, options, PropScore0)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionSuggestOption + { + CollateMatch = propCollateMatch.Value +, + Contexts = propContexts.Value +, + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Routing = propRouting.Value +, + Score = propScore.Value +, + Score0 = propScore0.Value +, + Source = propSource.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionSuggestOption value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollateMatch, value.CollateMatch); + writer.WriteProperty(options, PropContexts, value.Contexts); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropScore, value.Score); + writer.WriteProperty(options, PropScore0, value.Score0); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +internal sealed partial class CompletionSuggestOptionConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(CompletionSuggestOption<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(CompletionSuggestOptionConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(CompletionSuggestOptionConverterFactory))] public sealed partial class CompletionSuggestOption { - [JsonInclude, JsonPropertyName("collate_match")] public bool? CollateMatch { get; init; } - [JsonInclude, JsonPropertyName("contexts")] public IReadOnlyDictionary>? Contexts { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string? Index { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("score")] public double? Score { get; init; } - [JsonInclude, JsonPropertyName("_score")] public double? Score0 { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs index 06fbcd812b5..e8f750975f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldCollapse.g.cs @@ -27,9 +27,72 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class FieldCollapseConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxConcurrentGroupSearches = System.Text.Json.JsonEncodedText.Encode("max_concurrent_group_searches"); + + public override FieldCollapse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCollapse = default; + LocalJsonValue propField = default; + LocalJsonValue?> propInnerHits = default; + LocalJsonValue propMaxConcurrentGroupSearches = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.InnerHits>))) + { + continue; + } + + if (propMaxConcurrentGroupSearches.TryRead(ref reader, options, PropMaxConcurrentGroupSearches)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldCollapse + { + Collapse = propCollapse.Value +, + Field = propField.Value +, + InnerHits = propInnerHits.Value +, + MaxConcurrentGroupSearches = propMaxConcurrentGroupSearches.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldCollapse value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropInnerHits, value.InnerHits, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.Core.Search.InnerHits>)); + writer.WriteProperty(options, PropMaxConcurrentGroupSearches, value.MaxConcurrentGroupSearches); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldCollapseConverter))] public sealed partial class FieldCollapse { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } /// @@ -37,7 +100,6 @@ public sealed partial class FieldCollapse /// The field to collapse the result set on /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -45,8 +107,6 @@ public sealed partial class FieldCollapse /// The number of inner hits and their sort order /// /// - [JsonInclude, JsonPropertyName("inner_hits")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.InnerHits))] public ICollection? InnerHits { get; set; } /// @@ -54,7 +114,6 @@ public sealed partial class FieldCollapse /// The number of concurrent requests allowed to retrieve the inner_hits per group /// /// - [JsonInclude, JsonPropertyName("max_concurrent_group_searches")] public int? MaxConcurrentGroupSearches { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs index eb342fd32f5..73048a58ca7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/FieldSuggester.g.cs @@ -39,12 +39,16 @@ internal FieldSuggester(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal FieldSuggester() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static FieldSuggester Completion(Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggester completionSuggester) => new FieldSuggester("completion", completionSuggester); public static FieldSuggester Phrase(Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester phraseSuggester) => new FieldSuggester("phrase", phraseSuggester); @@ -88,121 +92,103 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class FieldSuggesterConverter : JsonConverter +internal sealed partial class FieldSuggesterConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldSuggester Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText PropRegex = System.Text.Json.JsonEncodedText.Encode("regex"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText VariantCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + private static readonly System.Text.Json.JsonEncodedText VariantPhrase = System.Text.Json.JsonEncodedText.Encode("phrase"); + private static readonly System.Text.Json.JsonEncodedText VariantTerm = System.Text.Json.JsonEncodedText.Encode("term"); + + public override FieldSuggester Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propPrefix = default; + LocalJsonValue propRegex = default; + LocalJsonValue propText = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - string? prefixValue = default; - string? regexValue = default; - string? textValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propPrefix.TryRead(ref reader, options, PropPrefix)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "prefix") - { - prefixValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "regex") + if (propRegex.TryRead(ref reader, options, PropRegex)) { - regexValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "text") + if (propText.TryRead(ref reader, options, PropText)) { - textValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "completion") + if (reader.ValueTextEquals(VariantCompletion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCompletion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "phrase") + if (reader.ValueTextEquals(VariantPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "term") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FieldSuggester' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new FieldSuggester(variantNameValue, variantValue); - result.Prefix = prefixValue; - result.Regex = regexValue; - result.Text = textValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldSuggester + { + VariantType = variantType, + Variant = variant, + Prefix = propPrefix.Value + , + Regex = propRegex.Value + , + Text = propText.Value + }; } - public override void Write(Utf8JsonWriter writer, FieldSuggester value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSuggester value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Prefix)) + switch (value.VariantType) { - writer.WritePropertyName("prefix"); - writer.WriteStringValue(value.Prefix); - } - - if (!string.IsNullOrEmpty(value.Regex)) - { - writer.WritePropertyName("regex"); - writer.WriteStringValue(value.Regex); - } - - if (!string.IsNullOrEmpty(value.Text)) - { - writer.WritePropertyName("text"); - writer.WriteStringValue(value.Text); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "completion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggester)value.Variant, options); - break; - case "phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.TermSuggester)value.Variant, options); - break; - } + case "": + break; + case "completion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.CompletionSuggester?)value.Variant); + break; + case "phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggester?)value.Variant); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.TermSuggester?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FieldSuggester)}'."); } + writer.WriteProperty(options, PropPrefix, value.Prefix); + writer.WriteProperty(options, PropRegex, value.Regex); + writer.WriteProperty(options, PropText, value.Text); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs index ef12eaa8957..43899a46098 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HighlightField.g.cs @@ -27,6 +27,250 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class HighlightFieldConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoundaryChars = System.Text.Json.JsonEncodedText.Encode("boundary_chars"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryMaxScan = System.Text.Json.JsonEncodedText.Encode("boundary_max_scan"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryScanner = System.Text.Json.JsonEncodedText.Encode("boundary_scanner"); + private static readonly System.Text.Json.JsonEncodedText PropBoundaryScannerLocale = System.Text.Json.JsonEncodedText.Encode("boundary_scanner_locale"); + private static readonly System.Text.Json.JsonEncodedText PropFragmenter = System.Text.Json.JsonEncodedText.Encode("fragmenter"); + private static readonly System.Text.Json.JsonEncodedText PropFragmentOffset = System.Text.Json.JsonEncodedText.Encode("fragment_offset"); + private static readonly System.Text.Json.JsonEncodedText PropFragmentSize = System.Text.Json.JsonEncodedText.Encode("fragment_size"); + private static readonly System.Text.Json.JsonEncodedText PropHighlightFilter = System.Text.Json.JsonEncodedText.Encode("highlight_filter"); + private static readonly System.Text.Json.JsonEncodedText PropHighlightQuery = System.Text.Json.JsonEncodedText.Encode("highlight_query"); + private static readonly System.Text.Json.JsonEncodedText PropMatchedFields = System.Text.Json.JsonEncodedText.Encode("matched_fields"); + private static readonly System.Text.Json.JsonEncodedText PropMaxAnalyzedOffset = System.Text.Json.JsonEncodedText.Encode("max_analyzed_offset"); + private static readonly System.Text.Json.JsonEncodedText PropMaxFragmentLength = System.Text.Json.JsonEncodedText.Encode("max_fragment_length"); + private static readonly System.Text.Json.JsonEncodedText PropNoMatchSize = System.Text.Json.JsonEncodedText.Encode("no_match_size"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfFragments = System.Text.Json.JsonEncodedText.Encode("number_of_fragments"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropPhraseLimit = System.Text.Json.JsonEncodedText.Encode("phrase_limit"); + private static readonly System.Text.Json.JsonEncodedText PropPostTags = System.Text.Json.JsonEncodedText.Encode("post_tags"); + private static readonly System.Text.Json.JsonEncodedText PropPreTags = System.Text.Json.JsonEncodedText.Encode("pre_tags"); + private static readonly System.Text.Json.JsonEncodedText PropRequireFieldMatch = System.Text.Json.JsonEncodedText.Encode("require_field_match"); + private static readonly System.Text.Json.JsonEncodedText PropTagsSchema = System.Text.Json.JsonEncodedText.Encode("tags_schema"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HighlightField Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoundaryChars = default; + LocalJsonValue propBoundaryMaxScan = default; + LocalJsonValue propBoundaryScanner = default; + LocalJsonValue propBoundaryScannerLocale = default; + LocalJsonValue propFragmenter = default; + LocalJsonValue propFragmentOffset = default; + LocalJsonValue propFragmentSize = default; + LocalJsonValue propHighlightFilter = default; + LocalJsonValue propHighlightQuery = default; + LocalJsonValue propMatchedFields = default; + LocalJsonValue propMaxAnalyzedOffset = default; + LocalJsonValue propMaxFragmentLength = default; + LocalJsonValue propNoMatchSize = default; + LocalJsonValue propNumberOfFragments = default; + LocalJsonValue?> propOptions = default; + LocalJsonValue propOrder = default; + LocalJsonValue propPhraseLimit = default; + LocalJsonValue?> propPostTags = default; + LocalJsonValue?> propPreTags = default; + LocalJsonValue propRequireFieldMatch = default; + LocalJsonValue propTagsSchema = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoundaryChars.TryRead(ref reader, options, PropBoundaryChars)) + { + continue; + } + + if (propBoundaryMaxScan.TryRead(ref reader, options, PropBoundaryMaxScan)) + { + continue; + } + + if (propBoundaryScanner.TryRead(ref reader, options, PropBoundaryScanner)) + { + continue; + } + + if (propBoundaryScannerLocale.TryRead(ref reader, options, PropBoundaryScannerLocale)) + { + continue; + } + + if (propFragmenter.TryRead(ref reader, options, PropFragmenter)) + { + continue; + } + + if (propFragmentOffset.TryRead(ref reader, options, PropFragmentOffset)) + { + continue; + } + + if (propFragmentSize.TryRead(ref reader, options, PropFragmentSize)) + { + continue; + } + + if (propHighlightFilter.TryRead(ref reader, options, PropHighlightFilter)) + { + continue; + } + + if (propHighlightQuery.TryRead(ref reader, options, PropHighlightQuery)) + { + continue; + } + + if (propMatchedFields.TryRead(ref reader, options, PropMatchedFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMaxAnalyzedOffset.TryRead(ref reader, options, PropMaxAnalyzedOffset)) + { + continue; + } + + if (propMaxFragmentLength.TryRead(ref reader, options, PropMaxFragmentLength)) + { + continue; + } + + if (propNoMatchSize.TryRead(ref reader, options, PropNoMatchSize)) + { + continue; + } + + if (propNumberOfFragments.TryRead(ref reader, options, PropNumberOfFragments)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } + + if (propPhraseLimit.TryRead(ref reader, options, PropPhraseLimit)) + { + continue; + } + + if (propPostTags.TryRead(ref reader, options, PropPostTags)) + { + continue; + } + + if (propPreTags.TryRead(ref reader, options, PropPreTags)) + { + continue; + } + + if (propRequireFieldMatch.TryRead(ref reader, options, PropRequireFieldMatch)) + { + continue; + } + + if (propTagsSchema.TryRead(ref reader, options, PropTagsSchema)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HighlightField + { + BoundaryChars = propBoundaryChars.Value +, + BoundaryMaxScan = propBoundaryMaxScan.Value +, + BoundaryScanner = propBoundaryScanner.Value +, + BoundaryScannerLocale = propBoundaryScannerLocale.Value +, + Fragmenter = propFragmenter.Value +, + FragmentOffset = propFragmentOffset.Value +, + FragmentSize = propFragmentSize.Value +, + HighlightFilter = propHighlightFilter.Value +, + HighlightQuery = propHighlightQuery.Value +, + MatchedFields = propMatchedFields.Value +, + MaxAnalyzedOffset = propMaxAnalyzedOffset.Value +, + MaxFragmentLength = propMaxFragmentLength.Value +, + NoMatchSize = propNoMatchSize.Value +, + NumberOfFragments = propNumberOfFragments.Value +, + Options = propOptions.Value +, + Order = propOrder.Value +, + PhraseLimit = propPhraseLimit.Value +, + PostTags = propPostTags.Value +, + PreTags = propPreTags.Value +, + RequireFieldMatch = propRequireFieldMatch.Value +, + TagsSchema = propTagsSchema.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlightField value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoundaryChars, value.BoundaryChars); + writer.WriteProperty(options, PropBoundaryMaxScan, value.BoundaryMaxScan); + writer.WriteProperty(options, PropBoundaryScanner, value.BoundaryScanner); + writer.WriteProperty(options, PropBoundaryScannerLocale, value.BoundaryScannerLocale); + writer.WriteProperty(options, PropFragmenter, value.Fragmenter); + writer.WriteProperty(options, PropFragmentOffset, value.FragmentOffset); + writer.WriteProperty(options, PropFragmentSize, value.FragmentSize); + writer.WriteProperty(options, PropHighlightFilter, value.HighlightFilter); + writer.WriteProperty(options, PropHighlightQuery, value.HighlightQuery); + writer.WriteProperty(options, PropMatchedFields, value.MatchedFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMaxAnalyzedOffset, value.MaxAnalyzedOffset); + writer.WriteProperty(options, PropMaxFragmentLength, value.MaxFragmentLength); + writer.WriteProperty(options, PropNoMatchSize, value.NoMatchSize); + writer.WriteProperty(options, PropNumberOfFragments, value.NumberOfFragments); + writer.WriteProperty(options, PropOptions, value.Options); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropPhraseLimit, value.PhraseLimit); + writer.WriteProperty(options, PropPostTags, value.PostTags); + writer.WriteProperty(options, PropPreTags, value.PreTags); + writer.WriteProperty(options, PropRequireFieldMatch, value.RequireFieldMatch); + writer.WriteProperty(options, PropTagsSchema, value.TagsSchema); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HighlightFieldConverter))] public sealed partial class HighlightField { /// @@ -34,7 +278,6 @@ public sealed partial class HighlightField /// A string that contains each boundary character. /// /// - [JsonInclude, JsonPropertyName("boundary_chars")] public string? BoundaryChars { get; set; } /// @@ -42,7 +285,6 @@ public sealed partial class HighlightField /// How far to scan for boundary characters. /// /// - [JsonInclude, JsonPropertyName("boundary_max_scan")] public int? BoundaryMaxScan { get; set; } /// @@ -52,7 +294,6 @@ public sealed partial class HighlightField /// Defaults to sentence for the unified highlighter. Defaults to chars for the fvh highlighter. /// /// - [JsonInclude, JsonPropertyName("boundary_scanner")] public Elastic.Clients.Elasticsearch.Core.Search.BoundaryScanner? BoundaryScanner { get; set; } /// @@ -61,7 +302,6 @@ public sealed partial class HighlightField /// This parameter takes a form of a language tag, for example: "en-US", "fr-FR", "ja-JP". /// /// - [JsonInclude, JsonPropertyName("boundary_scanner_locale")] public string? BoundaryScannerLocale { get; set; } /// @@ -70,9 +310,7 @@ public sealed partial class HighlightField /// Only valid for the plain highlighter. /// /// - [JsonInclude, JsonPropertyName("fragmenter")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterFragmenter? Fragmenter { get; set; } - [JsonInclude, JsonPropertyName("fragment_offset")] public int? FragmentOffset { get; set; } /// @@ -80,9 +318,7 @@ public sealed partial class HighlightField /// The size of the highlighted fragment in characters. /// /// - [JsonInclude, JsonPropertyName("fragment_size")] public int? FragmentSize { get; set; } - [JsonInclude, JsonPropertyName("highlight_filter")] public bool? HighlightFilter { get; set; } /// @@ -91,10 +327,7 @@ public sealed partial class HighlightField /// This is especially useful if you use a rescore query because those are not taken into account by highlighting by default. /// /// - [JsonInclude, JsonPropertyName("highlight_query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? HighlightQuery { get; set; } - [JsonInclude, JsonPropertyName("matched_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? MatchedFields { get; set; } /// @@ -104,9 +337,7 @@ public sealed partial class HighlightField /// The max_analyzed_offset query setting does not override the index.highlight.max_analyzed_offset setting, which prevails when it’s set to lower value than the query setting. /// /// - [JsonInclude, JsonPropertyName("max_analyzed_offset")] public int? MaxAnalyzedOffset { get; set; } - [JsonInclude, JsonPropertyName("max_fragment_length")] public int? MaxFragmentLength { get; set; } /// @@ -114,7 +345,6 @@ public sealed partial class HighlightField /// The amount of text you want to return from the beginning of the field if there are no matching fragments to highlight. /// /// - [JsonInclude, JsonPropertyName("no_match_size")] public int? NoMatchSize { get; set; } /// @@ -126,9 +356,7 @@ public sealed partial class HighlightField /// If number_of_fragments is 0, fragment_size is ignored. /// /// - [JsonInclude, JsonPropertyName("number_of_fragments")] public int? NumberOfFragments { get; set; } - [JsonInclude, JsonPropertyName("options")] public IDictionary? Options { get; set; } /// @@ -139,7 +367,6 @@ public sealed partial class HighlightField /// Each highlighter applies its own logic to compute relevancy scores. /// /// - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterOrder? Order { get; set; } /// @@ -150,7 +377,6 @@ public sealed partial class HighlightField /// Only supported by the fvh highlighter. /// /// - [JsonInclude, JsonPropertyName("phrase_limit")] public int? PhraseLimit { get; set; } /// @@ -159,7 +385,6 @@ public sealed partial class HighlightField /// By default, highlighted text is wrapped in <em> and </em> tags. /// /// - [JsonInclude, JsonPropertyName("post_tags")] public ICollection? PostTags { get; set; } /// @@ -168,7 +393,6 @@ public sealed partial class HighlightField /// By default, highlighted text is wrapped in <em> and </em> tags. /// /// - [JsonInclude, JsonPropertyName("pre_tags")] public ICollection? PreTags { get; set; } /// @@ -177,7 +401,6 @@ public sealed partial class HighlightField /// Set to false to highlight all fields. /// /// - [JsonInclude, JsonPropertyName("require_field_match")] public bool? RequireFieldMatch { get; set; } /// @@ -185,9 +408,7 @@ public sealed partial class HighlightField /// Set to styled to use the built-in tag schema. /// /// - [JsonInclude, JsonPropertyName("tags_schema")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterTagsSchema? TagsSchema { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.Core.Search.HighlighterType? Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs index bddd3f292b6..1d4dc699acf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Hit.g.cs @@ -27,47 +27,267 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class HitConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropExplanation = System.Text.Json.JsonEncodedText.Encode("_explanation"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIgnored = System.Text.Json.JsonEncodedText.Encode("_ignored"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoredFieldValues = System.Text.Json.JsonEncodedText.Encode("ignored_field_values"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText PropMatchedQueries = System.Text.Json.JsonEncodedText.Encode("matched_queries"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("_nested"); + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("_node"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRank = System.Text.Json.JsonEncodedText.Encode("_rank"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropScore = System.Text.Json.JsonEncodedText.Encode("_score"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropShard = System.Text.Json.JsonEncodedText.Encode("_shard"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + + public override Hit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propExplanation = default; + LocalJsonValue?> propFields = default; + LocalJsonValue>?> propHighlight = default; + LocalJsonValue propId = default; + LocalJsonValue?> propIgnored = default; + LocalJsonValue>?> propIgnoredFieldValues = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propInnerHits = default; + LocalJsonValue?> propMatchedQueries = default; + LocalJsonValue propNested = default; + LocalJsonValue propNode = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRank = default; + LocalJsonValue propRouting = default; + LocalJsonValue propScore = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propShard = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExplanation.TryRead(ref reader, options, PropExplanation)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIgnored.TryRead(ref reader, options, PropIgnored)) + { + continue; + } + + if (propIgnoredFieldValues.TryRead(ref reader, options, PropIgnoredFieldValues)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits)) + { + continue; + } + + if (propMatchedQueries.TryRead(ref reader, options, PropMatchedQueries)) + { + continue; + } + + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } + + if (propNode.TryRead(ref reader, options, PropNode)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRank.TryRead(ref reader, options, PropRank)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propScore.TryRead(ref reader, options, PropScore)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propShard.TryRead(ref reader, options, PropShard)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Hit + { + Explanation = propExplanation.Value +, + Fields = propFields.Value +, + Highlight = propHighlight.Value +, + Id = propId.Value +, + Ignored = propIgnored.Value +, + IgnoredFieldValues = propIgnoredFieldValues.Value +, + Index = propIndex.Value +, + InnerHits = propInnerHits.Value +, + MatchedQueries = propMatchedQueries.Value +, + Nested = propNested.Value +, + Node = propNode.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Rank = propRank.Value +, + Routing = propRouting.Value +, + Score = propScore.Value +, + SeqNo = propSeqNo.Value +, + Shard = propShard.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Hit value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExplanation, value.Explanation); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIgnored, value.Ignored); + writer.WriteProperty(options, PropIgnoredFieldValues, value.IgnoredFieldValues); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropInnerHits, value.InnerHits); + writer.WriteProperty(options, PropMatchedQueries, value.MatchedQueries); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropNode, value.Node); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRank, value.Rank); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropScore, value.Score); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropShard, value.Shard); + writer.WriteProperty(options, PropSort, value.Sort); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(Hit<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitConverterFactory))] public sealed partial class Hit { - [JsonInclude, JsonPropertyName("_explanation")] public Elastic.Clients.Elasticsearch.Core.Explain.Explanation? Explanation { get; init; } - [JsonInclude, JsonPropertyName("fields")] public IReadOnlyDictionary? Fields { get; init; } - [JsonInclude, JsonPropertyName("highlight")] public IReadOnlyDictionary>? Highlight { get; init; } - [JsonInclude, JsonPropertyName("_id")] public string? Id { get; init; } - [JsonInclude, JsonPropertyName("_ignored")] public IReadOnlyCollection? Ignored { get; init; } - [JsonInclude, JsonPropertyName("ignored_field_values")] public IReadOnlyDictionary>? IgnoredFieldValues { get; init; } - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } - [JsonInclude, JsonPropertyName("inner_hits")] public IReadOnlyDictionary? InnerHits { get; init; } - [JsonInclude, JsonPropertyName("matched_queries")] public IReadOnlyCollection? MatchedQueries { get; init; } - [JsonInclude, JsonPropertyName("_nested")] public Elastic.Clients.Elasticsearch.Core.Search.NestedIdentity? Nested { get; init; } - [JsonInclude, JsonPropertyName("_node")] public string? Node { get; init; } - [JsonInclude, JsonPropertyName("_primary_term")] public long? PrimaryTerm { get; init; } - [JsonInclude, JsonPropertyName("_rank")] public int? Rank { get; init; } - [JsonInclude, JsonPropertyName("_routing")] public string? Routing { get; init; } - [JsonInclude, JsonPropertyName("_score")] public double? Score { get; init; } - [JsonInclude, JsonPropertyName("_seq_no")] public long? SeqNo { get; init; } - [JsonInclude, JsonPropertyName("_shard")] public string? Shard { get; init; } - [JsonInclude, JsonPropertyName("sort")] public IReadOnlyCollection? Sort { get; init; } - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TDocument? Source { get; init; } - [JsonInclude, JsonPropertyName("_version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs index 78f5579d8de..426c07e8d2f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/HitsMetadata.g.cs @@ -27,11 +27,80 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class HitsMetadataConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropHits = System.Text.Json.JsonEncodedText.Encode("hits"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScore = System.Text.Json.JsonEncodedText.Encode("max_score"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override HitsMetadata Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propHits = default; + LocalJsonValue propMaxScore = default; + LocalJsonValue?> propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHits.TryRead(ref reader, options, PropHits)) + { + continue; + } + + if (propMaxScore.TryRead(ref reader, options, PropMaxScore)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsMetadata + { + Hits = propHits.Value +, + MaxScore = propMaxScore.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsMetadata value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHits, value.Hits); + writer.WriteProperty(options, PropMaxScore, value.MaxScore); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsMetadataConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsMetadata<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitsMetadataConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitsMetadataConverterFactory))] public sealed partial class HitsMetadata { - [JsonInclude, JsonPropertyName("hits")] public IReadOnlyCollection> Hits { get; init; } - [JsonInclude, JsonPropertyName("max_score")] public double? MaxScore { get; init; } /// @@ -39,6 +108,5 @@ public sealed partial class HitsMetadata /// Total hit count information, present only if track_total_hits wasn't false in the search request. /// /// - [JsonInclude, JsonPropertyName("total")] public Union? Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs index f896031d7d9..cd778b8fc0b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/InnerHits.g.cs @@ -27,16 +27,195 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class InnerHitsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCollapse = System.Text.Json.JsonEncodedText.Encode("collapse"); + private static readonly System.Text.Json.JsonEncodedText PropDocvalueFields = System.Text.Json.JsonEncodedText.Encode("docvalue_fields"); + private static readonly System.Text.Json.JsonEncodedText PropExplain = System.Text.Json.JsonEncodedText.Encode("explain"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFrom = System.Text.Json.JsonEncodedText.Encode("from"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNoPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("seq_no_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropSize = System.Text.Json.JsonEncodedText.Encode("size"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropStoredFields = System.Text.Json.JsonEncodedText.Encode("stored_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrackScores = System.Text.Json.JsonEncodedText.Encode("track_scores"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override InnerHits Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCollapse = default; + LocalJsonValue?> propDocvalueFields = default; + LocalJsonValue propExplain = default; + LocalJsonValue propFields = default; + LocalJsonValue propFrom = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propName = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propSeqNoPrimaryTerm = default; + LocalJsonValue propSize = default; + LocalJsonValue?> propSort = default; + LocalJsonValue propSource = default; + LocalJsonValue propStoredFields = default; + LocalJsonValue propTrackScores = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCollapse.TryRead(ref reader, options, PropCollapse)) + { + continue; + } + + if (propDocvalueFields.TryRead(ref reader, options, PropDocvalueFields)) + { + continue; + } + + if (propExplain.TryRead(ref reader, options, PropExplain)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFrom.TryRead(ref reader, options, PropFrom)) + { + continue; + } + + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } + + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propSeqNoPrimaryTerm.TryRead(ref reader, options, PropSeqNoPrimaryTerm)) + { + continue; + } + + if (propSize.TryRead(ref reader, options, PropSize)) + { + continue; + } + + if (propSort.TryRead(ref reader, options, PropSort, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>))) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propStoredFields.TryRead(ref reader, options, PropStoredFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrackScores.TryRead(ref reader, options, PropTrackScores)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InnerHits + { + Collapse = propCollapse.Value +, + DocvalueFields = propDocvalueFields.Value +, + Explain = propExplain.Value +, + Fields = propFields.Value +, + From = propFrom.Value +, + Highlight = propHighlight.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + Name = propName.Value +, + ScriptFields = propScriptFields.Value +, + SeqNoPrimaryTerm = propSeqNoPrimaryTerm.Value +, + Size = propSize.Value +, + Sort = propSort.Value +, + Source = propSource.Value +, + StoredFields = propStoredFields.Value +, + TrackScores = propTrackScores.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InnerHits value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCollapse, value.Collapse); + writer.WriteProperty(options, PropDocvalueFields, value.DocvalueFields); + writer.WriteProperty(options, PropExplain, value.Explain); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFrom, value.From); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropSeqNoPrimaryTerm, value.SeqNoPrimaryTerm); + writer.WriteProperty(options, PropSize, value.Size); + writer.WriteProperty(options, PropSort, value.Sort, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.SortOptions>)); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropStoredFields, value.StoredFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrackScores, value.TrackScores); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InnerHitsConverter))] public sealed partial class InnerHits { - [JsonInclude, JsonPropertyName("collapse")] public Elastic.Clients.Elasticsearch.Core.Search.FieldCollapse? Collapse { get; set; } - [JsonInclude, JsonPropertyName("docvalue_fields")] public ICollection? DocvalueFields { get; set; } - [JsonInclude, JsonPropertyName("explain")] public bool? Explain { get; set; } - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -44,11 +223,8 @@ public sealed partial class InnerHits /// Inner hit starting document offset. /// /// - [JsonInclude, JsonPropertyName("from")] public int? From { get; set; } - [JsonInclude, JsonPropertyName("highlight")] public Elastic.Clients.Elasticsearch.Core.Search.Highlight? Highlight { get; set; } - [JsonInclude, JsonPropertyName("ignore_unmapped")] public bool? IgnoreUnmapped { get; set; } /// @@ -57,11 +233,8 @@ public sealed partial class InnerHits /// Useful when a search request contains multiple inner hits. /// /// - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.Name? Name { get; set; } - [JsonInclude, JsonPropertyName("script_fields")] public IDictionary? ScriptFields { get; set; } - [JsonInclude, JsonPropertyName("seq_no_primary_term")] public bool? SeqNoPrimaryTerm { get; set; } /// @@ -69,7 +242,6 @@ public sealed partial class InnerHits /// The maximum number of hits to return per inner_hits. /// /// - [JsonInclude, JsonPropertyName("size")] public int? Size { get; set; } /// @@ -78,17 +250,10 @@ public sealed partial class InnerHits /// By default, inner hits are sorted by score. /// /// - [JsonInclude, JsonPropertyName("sort")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.SortOptions))] public ICollection? Sort { get; set; } - [JsonInclude, JsonPropertyName("_source")] public Elastic.Clients.Elasticsearch.Core.Search.SourceConfig? Source { get; set; } - [JsonInclude, JsonPropertyName("stored_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? StoredFields { get; set; } - [JsonInclude, JsonPropertyName("track_scores")] public bool? TrackScores { get; set; } - [JsonInclude, JsonPropertyName("version")] public bool? Version { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs index d00e32970ee..53e1e4f859c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/PhraseSuggest.g.cs @@ -27,15 +27,76 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class PhraseSuggestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override PhraseSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PhraseSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhraseSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PhraseSuggestConverter))] public sealed partial class PhraseSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.PhraseSuggestOption))] public IReadOnlyCollection Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "phrase"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs index 4690dd4d38a..a5ec028be00 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Rescore.g.cs @@ -39,12 +39,16 @@ internal Rescore(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Rescore() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Rescore LearningToRank(Elastic.Clients.Elasticsearch.Core.Search.LearningToRank learningToRank) => new Rescore("learning_to_rank", learningToRank); public static Rescore Query(Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery rescoreQuery) => new Rescore("query", rescoreQuery); @@ -65,83 +69,71 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RescoreConverter : JsonConverter +internal sealed partial class RescoreConverter : System.Text.Json.Serialization.JsonConverter { - public override Rescore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropWindowSize = System.Text.Json.JsonEncodedText.Encode("window_size"); + private static readonly System.Text.Json.JsonEncodedText VariantLearningToRank = System.Text.Json.JsonEncodedText.Encode("learning_to_rank"); + private static readonly System.Text.Json.JsonEncodedText VariantQuery = System.Text.Json.JsonEncodedText.Encode("query"); - object? variantValue = default; - string? variantNameValue = default; - int? windowSizeValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Rescore Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propWindowSize = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propWindowSize.TryRead(ref reader, options, PropWindowSize)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "window_size") - { - windowSizeValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "learning_to_rank") + if (reader.ValueTextEquals(VariantLearningToRank)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLearningToRank.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "query") + if (reader.ValueTextEquals(VariantQuery)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuery.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Rescore' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Rescore(variantNameValue, variantValue); - result.WindowSize = windowSizeValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Rescore + { + VariantType = variantType, + Variant = variant, + WindowSize = propWindowSize.Value + }; } - public override void Write(Utf8JsonWriter writer, Rescore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Rescore value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.WindowSize.HasValue) - { - writer.WritePropertyName("window_size"); - writer.WriteNumberValue(value.WindowSize.Value); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "learning_to_rank": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.LearningToRank)value.Variant, options); - break; - case "query": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery)value.Variant, options); - break; - } + case "": + break; + case "learning_to_rank": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LearningToRank?)value.Variant); + break; + case "query": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.RescoreQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Rescore)}'."); } + writer.WriteProperty(options, PropWindowSize, value.WindowSize); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs index 9d3e6ebe178..308ee700ced 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SmoothingModel.g.cs @@ -39,12 +39,16 @@ internal SmoothingModel(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SmoothingModel() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SmoothingModel Laplace(Elastic.Clients.Elasticsearch.Core.Search.LaplaceSmoothingModel laplaceSmoothingModel) => new SmoothingModel("laplace", laplaceSmoothingModel); public static SmoothingModel LinearInterpolation(Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel linearInterpolationSmoothingModel) => new SmoothingModel("linear_interpolation", linearInterpolationSmoothingModel); @@ -63,77 +67,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SmoothingModelConverter : JsonConverter +internal sealed partial class SmoothingModelConverter : System.Text.Json.Serialization.JsonConverter { - public override SmoothingModel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantLaplace = System.Text.Json.JsonEncodedText.Encode("laplace"); + private static readonly System.Text.Json.JsonEncodedText VariantLinearInterpolation = System.Text.Json.JsonEncodedText.Encode("linear_interpolation"); + private static readonly System.Text.Json.JsonEncodedText VariantStupidBackoff = System.Text.Json.JsonEncodedText.Encode("stupid_backoff"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override SmoothingModel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantLaplace)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "laplace") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLaplace.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "linear_interpolation") + if (reader.ValueTextEquals(VariantLinearInterpolation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinearInterpolation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "stupid_backoff") + if (reader.ValueTextEquals(VariantStupidBackoff)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStupidBackoff.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SmoothingModel' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SmoothingModel(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SmoothingModel { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, SmoothingModel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SmoothingModel value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "laplace": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.LaplaceSmoothingModel)value.Variant, options); - break; - case "linear_interpolation": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel)value.Variant, options); - break; - case "stupid_backoff": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Core.Search.StupidBackoffSmoothingModel)value.Variant, options); - break; - } + case "": + break; + case "laplace": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LaplaceSmoothingModel?)value.Variant); + break; + case "linear_interpolation": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.LinearInterpolationSmoothingModel?)value.Variant); + break; + case "stupid_backoff": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Core.Search.StupidBackoffSmoothingModel?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SmoothingModel)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs index ecf27ebf675..eb2ba270fc0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs @@ -27,52 +27,57 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; -internal sealed partial class SourceFilterConverter : JsonConverter +internal sealed partial class SourceFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override SourceFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropExcludes = System.Text.Json.JsonEncodedText.Encode("excludes"); + private static readonly System.Text.Json.JsonEncodedText PropExcludes1 = System.Text.Json.JsonEncodedText.Encode("exclude"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes = System.Text.Json.JsonEncodedText.Encode("includes"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes1 = System.Text.Json.JsonEncodedText.Encode("include"); + + public override SourceFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new SourceFilter(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propExcludes = default; + LocalJsonValue propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propExcludes.TryRead(ref reader, options, PropExcludes, typeof(SingleOrManyFieldsMarker)) || propExcludes.TryRead(ref reader, options, PropExcludes1, typeof(SingleOrManyFieldsMarker))) { - var property = reader.GetString(); - if (property == "excludes" || property == "exclude") - { - reader.Read(); - variant.Excludes = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } - - if (property == "includes" || property == "include") - { - reader.Read(); - variant.Includes = new FieldsConverter().Read(ref reader, typeToConvert, options); - continue; - } + continue; } - } - return variant; - } + if (propIncludes.TryRead(ref reader, options, PropIncludes, typeof(SingleOrManyFieldsMarker)) || propIncludes.TryRead(ref reader, options, PropIncludes1, typeof(SingleOrManyFieldsMarker))) + { + continue; + } - public override void Write(Utf8JsonWriter writer, SourceFilter value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Excludes is not null) - { - writer.WritePropertyName("excludes"); - new FieldsConverter().Write(writer, value.Excludes, options); + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new SourceFilter { Includes = result }; + } + catch (System.Text.Json.JsonException) + { + throw; + } } - if (value.Includes is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SourceFilter { - writer.WritePropertyName("includes"); - new FieldsConverter().Write(writer, value.Includes, options); - } + Excludes = propExcludes.Value +, + Includes = propIncludes.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceFilter value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExcludes, value.Excludes, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIncludes, value.Includes, null, typeof(SingleOrManyFieldsMarker)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs index 3cde4af0f69..84d75b47365 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SuggestDictionary.g.cs @@ -33,9 +33,10 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; public partial interface ISuggest { + public string? Type { get; } } -[GenericConverter(typeof(SuggestDictionaryConverter<>), unwrap: true)] +[JsonConverter(typeof(SuggestDictionaryConverterFactory))] public partial class SuggestDictionary : IsAReadOnlyDictionary> { public SuggestDictionary(IReadOnlyDictionary> backingDictionary) : base(backingDictionary) @@ -48,61 +49,87 @@ public SuggestDictionary(IReadOnlyDictionary? TryGet(string key) where T : class, ISuggest => BackingDictionary.TryGetValue(key, out var value) ? value.Cast().ToArray() : null; } -internal sealed partial class SuggestDictionaryConverter : JsonConverter> +internal sealed partial class SuggestDictionaryConverter : System.Text.Json.Serialization.JsonConverter> { - public override SuggestDictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override SuggestDictionary Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var dictionary = new Dictionary>(); - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException($"Expected {JsonTokenType.StartObject} but read {reader.TokenType}."); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var dictionary = new System.Collections.Generic.Dictionary>(); + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - throw new JsonException($"Expected {JsonTokenType.PropertyName} but read {reader.TokenType}."); - var name = reader.GetString(); - reader.Read(); - ReadItem(ref reader, options, dictionary, name); + ReadItem(ref reader, options, out string name, out IReadOnlyCollection value); + dictionary[name] = value; } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); return new SuggestDictionary(dictionary); } - public override void Write(Utf8JsonWriter writer, SuggestDictionary value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestDictionary value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'SuggestDictionary' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + foreach (var pair in value) + { + WriteItem(writer, options, pair.Key, pair.Value); + } + + writer.WriteEndObject(); } - public static void ReadItem(ref Utf8JsonReader reader, JsonSerializerOptions options, Dictionary> dictionary, string name) + internal static void ReadItem(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions options, out string name, out IReadOnlyCollection value) { - var nameParts = name.Split('#'); - if (nameParts.Length != 2) - throw new JsonException($"Unable to parse typed-key '{name}'."); - var type = nameParts[0]; - switch (type) + var key = reader.ReadPropertyName(options); + reader.Read(); + var parts = key.Split('#'); + if (parts.Length != 2) { - case "completion": - { - var item = JsonSerializer.Deserialize>>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } - - case "phrase": - { - var item = JsonSerializer.Deserialize>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + throw new System.Text.Json.JsonException($"Unable to parse typed-key '{key}' for variant '{nameof(IReadOnlyCollection)}'."); + } - case "term": - { - var item = JsonSerializer.Deserialize>(ref reader, options); - dictionary.Add(nameParts[1], item); - break; - } + var discriminator = parts[0]; + name = parts[1]; + value = discriminator switch + { + "completion" => reader.ReadValue>>(options), + "phrase" => reader.ReadValue>(options), + "term" => reader.ReadValue>(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IReadOnlyCollection)}'.") + }; + } + internal static void WriteItem(System.Text.Json.Utf8JsonWriter writer, System.Text.Json.JsonSerializerOptions options, string name, IReadOnlyCollection value) + { + var key = value.First().Type + '#' + name; + switch (value) + { + case IReadOnlyCollection> v: + writer.WriteProperty(options, key, v); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v); + break; + case IReadOnlyCollection v: + writer.WriteProperty(options, key, v); + break; default: - throw new NotSupportedException($"The tagged variant '{type}' is currently not supported."); + throw new System.Text.Json.JsonException($"Variant '{0}' is not supported for type '{nameof(IReadOnlyCollection)}'."); } } +} + +internal sealed partial class SuggestDictionaryConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(SuggestDictionary<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(SuggestDictionaryConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs index 4c45bb505e6..f6cc9132776 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/Suggester.g.cs @@ -27,53 +27,49 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; -internal sealed partial class SuggesterConverter : JsonConverter +internal sealed partial class SuggesterConverter : System.Text.Json.Serialization.JsonConverter { - public override Suggester Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropSuggesters = System.Text.Json.JsonEncodedText.Encode("suggesters"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override Suggester Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new Suggester(); - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propSuggesters = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propText.TryRead(ref reader, options, PropText)) { - var property = reader.GetString(); - if (property == "text") - { - variant.Text = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + propSuggesters ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out Elastic.Clients.Elasticsearch.Core.Search.FieldSuggester value); + propSuggesters[key] = value; } - variant.Suggesters = additionalProperties; - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Suggester + { + Suggesters = propSuggesters +, + Text = propText.Value + }; } - public override void Write(Utf8JsonWriter writer, Suggester value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Suggester value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); + writer.WriteProperty(options, PropText, value.Text); if (value.Suggesters is not null) { - foreach (var additionalProperty in value.Suggesters) + foreach (var item in value.Suggesters) { - writer.WritePropertyName(additionalProperty.Key); - JsonSerializer.Serialize(writer, additionalProperty.Value, options); + writer.WriteProperty(options, item.Key, item.Value); } } - if (!string.IsNullOrEmpty(value.Text)) - { - writer.WritePropertyName("text"); - writer.WriteStringValue(value.Text); - } - writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs index c7a1b48092c..a5f71d8f15e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/TermSuggest.g.cs @@ -27,15 +27,76 @@ namespace Elastic.Clients.Elasticsearch.Core.Search; +internal sealed partial class TermSuggestConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropLength = System.Text.Json.JsonEncodedText.Encode("length"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOptions = System.Text.Json.JsonEncodedText.Encode("options"); + private static readonly System.Text.Json.JsonEncodedText PropText = System.Text.Json.JsonEncodedText.Encode("text"); + + public override TermSuggest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propLength = default; + LocalJsonValue propOffset = default; + LocalJsonValue> propOptions = default; + LocalJsonValue propText = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propLength.TryRead(ref reader, options, PropLength)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset)) + { + continue; + } + + if (propOptions.TryRead(ref reader, options, PropOptions, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Core.Search.TermSuggestOption>))) + { + continue; + } + + if (propText.TryRead(ref reader, options, PropText)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermSuggest + { + Length = propLength.Value +, + Offset = propOffset.Value +, + Options = propOptions.Value +, + Text = propText.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermSuggest value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropLength, value.Length); + writer.WriteProperty(options, PropOffset, value.Offset); + writer.WriteProperty(options, PropOptions, value.Options, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.Core.Search.TermSuggestOption>)); + writer.WriteProperty(options, PropText, value.Text); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermSuggestConverter))] public sealed partial class TermSuggest : ISuggest { - [JsonInclude, JsonPropertyName("length")] public int Length { get; init; } - [JsonInclude, JsonPropertyName("offset")] public int Offset { get; init; } - [JsonInclude, JsonPropertyName("options")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.Core.Search.TermSuggestOption))] public IReadOnlyCollection Options { get; init; } - [JsonInclude, JsonPropertyName("text")] public string Text { get; init; } + + string ISuggest.Type => "term"; } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs index 5dc8b54516f..c7f2f24e89c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/DanglingIndices/DanglingIndex.g.cs @@ -27,15 +27,74 @@ namespace Elastic.Clients.Elasticsearch.DanglingIndices; +internal sealed partial class DanglingIndexConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCreationDateMillis = System.Text.Json.JsonEncodedText.Encode("creation_date_millis"); + private static readonly System.Text.Json.JsonEncodedText PropIndexName = System.Text.Json.JsonEncodedText.Encode("index_name"); + private static readonly System.Text.Json.JsonEncodedText PropIndexUuid = System.Text.Json.JsonEncodedText.Encode("index_uuid"); + private static readonly System.Text.Json.JsonEncodedText PropNodeIds = System.Text.Json.JsonEncodedText.Encode("node_ids"); + + public override DanglingIndex Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCreationDateMillis = default; + LocalJsonValue propIndexName = default; + LocalJsonValue propIndexUuid = default; + LocalJsonValue> propNodeIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCreationDateMillis.TryRead(ref reader, options, PropCreationDateMillis)) + { + continue; + } + + if (propIndexName.TryRead(ref reader, options, PropIndexName)) + { + continue; + } + + if (propIndexUuid.TryRead(ref reader, options, PropIndexUuid)) + { + continue; + } + + if (propNodeIds.TryRead(ref reader, options, PropNodeIds, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DanglingIndex + { + CreationDateMillis = propCreationDateMillis.Value +, + IndexName = propIndexName.Value +, + IndexUuid = propIndexUuid.Value +, + NodeIds = propNodeIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DanglingIndex value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCreationDateMillis, value.CreationDateMillis); + writer.WriteProperty(options, PropIndexName, value.IndexName); + writer.WriteProperty(options, PropIndexUuid, value.IndexUuid); + writer.WriteProperty(options, PropNodeIds, value.NodeIds, null, typeof(SingleOrManyMarker, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DanglingIndexConverter))] public sealed partial class DanglingIndex { - [JsonInclude, JsonPropertyName("creation_date_millis")] public long CreationDateMillis { get; init; } - [JsonInclude, JsonPropertyName("index_name")] public string IndexName { get; init; } - [JsonInclude, JsonPropertyName("index_uuid")] public string IndexUuid { get; init; } - [JsonInclude, JsonPropertyName("node_ids")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection NodeIds { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs index fc7a0cf8953..a504834344c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enrich/EnrichPolicy.g.cs @@ -27,20 +27,97 @@ namespace Elastic.Clients.Elasticsearch.Enrich; +internal sealed partial class EnrichPolicyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropElasticsearchVersion = System.Text.Json.JsonEncodedText.Encode("elasticsearch_version"); + private static readonly System.Text.Json.JsonEncodedText PropEnrichFields = System.Text.Json.JsonEncodedText.Encode("enrich_fields"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMatchField = System.Text.Json.JsonEncodedText.Encode("match_field"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + + public override EnrichPolicy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propElasticsearchVersion = default; + LocalJsonValue propEnrichFields = default; + LocalJsonValue propIndices = default; + LocalJsonValue propMatchField = default; + LocalJsonValue propName = default; + LocalJsonValue propQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propElasticsearchVersion.TryRead(ref reader, options, PropElasticsearchVersion)) + { + continue; + } + + if (propEnrichFields.TryRead(ref reader, options, PropEnrichFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propMatchField.TryRead(ref reader, options, PropMatchField)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EnrichPolicy + { + ElasticsearchVersion = propElasticsearchVersion.Value +, + EnrichFields = propEnrichFields.Value +, + Indices = propIndices.Value +, + MatchField = propMatchField.Value +, + Name = propName.Value +, + Query = propQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichPolicy value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropElasticsearchVersion, value.ElasticsearchVersion); + writer.WriteProperty(options, PropEnrichFields, value.EnrichFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropMatchField, value.MatchField); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(EnrichPolicyConverter))] public sealed partial class EnrichPolicy { - [JsonInclude, JsonPropertyName("elasticsearch_version")] public string? ElasticsearchVersion { get; set; } - [JsonInclude, JsonPropertyName("enrich_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields EnrichFields { get; set; } - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices Indices { get; set; } - [JsonInclude, JsonPropertyName("match_field")] public Elastic.Clients.Elasticsearch.Field MatchField { get; set; } - [JsonInclude, JsonPropertyName("name")] public Elastic.Clients.Elasticsearch.Name? Name { get; set; } - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs index bb501a37b36..bb407c5522c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Aggregations.g.cs @@ -49,74 +49,102 @@ public enum CalendarInterval Day } -internal sealed class CalendarIntervalConverter : JsonConverter +internal sealed partial class CalendarIntervalConverter : System.Text.Json.Serialization.JsonConverter { - public override CalendarInterval Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYear = System.Text.Json.JsonEncodedText.Encode("year"); + private static readonly System.Text.Json.JsonEncodedText MemberYear1 = System.Text.Json.JsonEncodedText.Encode("1y"); + private static readonly System.Text.Json.JsonEncodedText MemberWeek = System.Text.Json.JsonEncodedText.Encode("week"); + private static readonly System.Text.Json.JsonEncodedText MemberWeek1 = System.Text.Json.JsonEncodedText.Encode("1w"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond1 = System.Text.Json.JsonEncodedText.Encode("1s"); + private static readonly System.Text.Json.JsonEncodedText MemberQuarter = System.Text.Json.JsonEncodedText.Encode("quarter"); + private static readonly System.Text.Json.JsonEncodedText MemberQuarter1 = System.Text.Json.JsonEncodedText.Encode("1q"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth = System.Text.Json.JsonEncodedText.Encode("month"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth1 = System.Text.Json.JsonEncodedText.Encode("1M"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute = System.Text.Json.JsonEncodedText.Encode("minute"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute1 = System.Text.Json.JsonEncodedText.Encode("1m"); + private static readonly System.Text.Json.JsonEncodedText MemberHour = System.Text.Json.JsonEncodedText.Encode("hour"); + private static readonly System.Text.Json.JsonEncodedText MemberHour1 = System.Text.Json.JsonEncodedText.Encode("1h"); + private static readonly System.Text.Json.JsonEncodedText MemberDay = System.Text.Json.JsonEncodedText.Encode("day"); + private static readonly System.Text.Json.JsonEncodedText MemberDay1 = System.Text.Json.JsonEncodedText.Encode("1d"); + + public override CalendarInterval Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "year": - case "1y": - return CalendarInterval.Year; - case "week": - case "1w": - return CalendarInterval.Week; - case "second": - case "1s": - return CalendarInterval.Second; - case "quarter": - case "1q": - return CalendarInterval.Quarter; - case "month": - case "1M": - return CalendarInterval.Month; - case "minute": - case "1m": - return CalendarInterval.Minute; - case "hour": - case "1h": - return CalendarInterval.Hour; - case "day": - case "1d": - return CalendarInterval.Day; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYear) || reader.ValueTextEquals(MemberYear1)) + { + return CalendarInterval.Year; + } + + if (reader.ValueTextEquals(MemberWeek) || reader.ValueTextEquals(MemberWeek1)) + { + return CalendarInterval.Week; + } + + if (reader.ValueTextEquals(MemberSecond) || reader.ValueTextEquals(MemberSecond1)) + { + return CalendarInterval.Second; + } + + if (reader.ValueTextEquals(MemberQuarter) || reader.ValueTextEquals(MemberQuarter1)) + { + return CalendarInterval.Quarter; + } + + if (reader.ValueTextEquals(MemberMonth) || reader.ValueTextEquals(MemberMonth1)) + { + return CalendarInterval.Month; + } + + if (reader.ValueTextEquals(MemberMinute) || reader.ValueTextEquals(MemberMinute1)) + { + return CalendarInterval.Minute; + } + + if (reader.ValueTextEquals(MemberHour) || reader.ValueTextEquals(MemberHour1)) + { + return CalendarInterval.Hour; + } + + if (reader.ValueTextEquals(MemberDay) || reader.ValueTextEquals(MemberDay1)) + { + return CalendarInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CalendarInterval)}'."); } - public override void Write(Utf8JsonWriter writer, CalendarInterval value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CalendarInterval value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CalendarInterval.Year: - writer.WriteStringValue("year"); - return; + writer.WriteStringValue(MemberYear); + break; case CalendarInterval.Week: - writer.WriteStringValue("week"); - return; + writer.WriteStringValue(MemberWeek); + break; case CalendarInterval.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case CalendarInterval.Quarter: - writer.WriteStringValue("quarter"); - return; + writer.WriteStringValue(MemberQuarter); + break; case CalendarInterval.Month: - writer.WriteStringValue("month"); - return; + writer.WriteStringValue(MemberMonth); + break; case CalendarInterval.Minute: - writer.WriteStringValue("minute"); - return; + writer.WriteStringValue(MemberMinute); + break; case CalendarInterval.Hour: - writer.WriteStringValue("hour"); - return; + writer.WriteStringValue(MemberHour); + break; case CalendarInterval.Day: - writer.WriteStringValue("day"); - return; + writer.WriteStringValue(MemberDay); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CalendarInterval)}'."); } - - writer.WriteNullValue(); } } @@ -160,51 +188,67 @@ public enum CardinalityExecutionMode Direct } -internal sealed class CardinalityExecutionModeConverter : JsonConverter +internal sealed partial class CardinalityExecutionModeConverter : System.Text.Json.Serialization.JsonConverter { - public override CardinalityExecutionMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSegmentOrdinals = System.Text.Json.JsonEncodedText.Encode("segment_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberSaveTimeHeuristic = System.Text.Json.JsonEncodedText.Encode("save_time_heuristic"); + private static readonly System.Text.Json.JsonEncodedText MemberSaveMemoryHeuristic = System.Text.Json.JsonEncodedText.Encode("save_memory_heuristic"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberDirect = System.Text.Json.JsonEncodedText.Encode("direct"); + + public override CardinalityExecutionMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "segment_ordinals": - return CardinalityExecutionMode.SegmentOrdinals; - case "save_time_heuristic": - return CardinalityExecutionMode.SaveTimeHeuristic; - case "save_memory_heuristic": - return CardinalityExecutionMode.SaveMemoryHeuristic; - case "global_ordinals": - return CardinalityExecutionMode.GlobalOrdinals; - case "direct": - return CardinalityExecutionMode.Direct; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSegmentOrdinals)) + { + return CardinalityExecutionMode.SegmentOrdinals; + } + + if (reader.ValueTextEquals(MemberSaveTimeHeuristic)) + { + return CardinalityExecutionMode.SaveTimeHeuristic; + } + + if (reader.ValueTextEquals(MemberSaveMemoryHeuristic)) + { + return CardinalityExecutionMode.SaveMemoryHeuristic; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinals)) + { + return CardinalityExecutionMode.GlobalOrdinals; + } + + if (reader.ValueTextEquals(MemberDirect)) + { + return CardinalityExecutionMode.Direct; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CardinalityExecutionMode)}'."); } - public override void Write(Utf8JsonWriter writer, CardinalityExecutionMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CardinalityExecutionMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CardinalityExecutionMode.SegmentOrdinals: - writer.WriteStringValue("segment_ordinals"); - return; + writer.WriteStringValue(MemberSegmentOrdinals); + break; case CardinalityExecutionMode.SaveTimeHeuristic: - writer.WriteStringValue("save_time_heuristic"); - return; + writer.WriteStringValue(MemberSaveTimeHeuristic); + break; case CardinalityExecutionMode.SaveMemoryHeuristic: - writer.WriteStringValue("save_memory_heuristic"); - return; + writer.WriteStringValue(MemberSaveMemoryHeuristic); + break; case CardinalityExecutionMode.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; case CardinalityExecutionMode.Direct: - writer.WriteStringValue("direct"); - return; + writer.WriteStringValue(MemberDirect); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CardinalityExecutionMode)}'."); } - - writer.WriteNullValue(); } } @@ -236,41 +280,49 @@ public enum GapPolicy InsertZeros } -internal sealed class GapPolicyConverter : JsonConverter +internal sealed partial class GapPolicyConverter : System.Text.Json.Serialization.JsonConverter { - public override GapPolicy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSkip = System.Text.Json.JsonEncodedText.Encode("skip"); + private static readonly System.Text.Json.JsonEncodedText MemberKeepValues = System.Text.Json.JsonEncodedText.Encode("keep_values"); + private static readonly System.Text.Json.JsonEncodedText MemberInsertZeros = System.Text.Json.JsonEncodedText.Encode("insert_zeros"); + + public override GapPolicy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSkip)) + { + return GapPolicy.Skip; + } + + if (reader.ValueTextEquals(MemberKeepValues)) { - case "skip": - return GapPolicy.Skip; - case "keep_values": - return GapPolicy.KeepValues; - case "insert_zeros": - return GapPolicy.InsertZeros; + return GapPolicy.KeepValues; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberInsertZeros)) + { + return GapPolicy.InsertZeros; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GapPolicy)}'."); } - public override void Write(Utf8JsonWriter writer, GapPolicy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GapPolicy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GapPolicy.Skip: - writer.WriteStringValue("skip"); - return; + writer.WriteStringValue(MemberSkip); + break; case GapPolicy.KeepValues: - writer.WriteStringValue("keep_values"); - return; + writer.WriteStringValue(MemberKeepValues); + break; case GapPolicy.InsertZeros: - writer.WriteStringValue("insert_zeros"); - return; + writer.WriteStringValue(MemberInsertZeros); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GapPolicy)}'."); } - - writer.WriteNullValue(); } } @@ -291,56 +343,76 @@ public enum MinimumInterval Day } -internal sealed class MinimumIntervalConverter : JsonConverter +internal sealed partial class MinimumIntervalConverter : System.Text.Json.Serialization.JsonConverter { - public override MinimumInterval Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYear = System.Text.Json.JsonEncodedText.Encode("year"); + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberMonth = System.Text.Json.JsonEncodedText.Encode("month"); + private static readonly System.Text.Json.JsonEncodedText MemberMinute = System.Text.Json.JsonEncodedText.Encode("minute"); + private static readonly System.Text.Json.JsonEncodedText MemberHour = System.Text.Json.JsonEncodedText.Encode("hour"); + private static readonly System.Text.Json.JsonEncodedText MemberDay = System.Text.Json.JsonEncodedText.Encode("day"); + + public override MinimumInterval Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "year": - return MinimumInterval.Year; - case "second": - return MinimumInterval.Second; - case "month": - return MinimumInterval.Month; - case "minute": - return MinimumInterval.Minute; - case "hour": - return MinimumInterval.Hour; - case "day": - return MinimumInterval.Day; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYear)) + { + return MinimumInterval.Year; + } + + if (reader.ValueTextEquals(MemberSecond)) + { + return MinimumInterval.Second; + } + + if (reader.ValueTextEquals(MemberMonth)) + { + return MinimumInterval.Month; + } + + if (reader.ValueTextEquals(MemberMinute)) + { + return MinimumInterval.Minute; + } + + if (reader.ValueTextEquals(MemberHour)) + { + return MinimumInterval.Hour; + } + + if (reader.ValueTextEquals(MemberDay)) + { + return MinimumInterval.Day; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MinimumInterval)}'."); } - public override void Write(Utf8JsonWriter writer, MinimumInterval value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MinimumInterval value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MinimumInterval.Year: - writer.WriteStringValue("year"); - return; + writer.WriteStringValue(MemberYear); + break; case MinimumInterval.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case MinimumInterval.Month: - writer.WriteStringValue("month"); - return; + writer.WriteStringValue(MemberMonth); + break; case MinimumInterval.Minute: - writer.WriteStringValue("minute"); - return; + writer.WriteStringValue(MemberMinute); + break; case MinimumInterval.Hour: - writer.WriteStringValue("hour"); - return; + writer.WriteStringValue(MemberHour); + break; case MinimumInterval.Day: - writer.WriteStringValue("day"); - return; + writer.WriteStringValue(MemberDay); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MinimumInterval)}'."); } - - writer.WriteNullValue(); } } @@ -355,41 +427,49 @@ public enum MissingOrder Default } -internal sealed class MissingOrderConverter : JsonConverter +internal sealed partial class MissingOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override MissingOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLast = System.Text.Json.JsonEncodedText.Encode("last"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + private static readonly System.Text.Json.JsonEncodedText MemberDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override MissingOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLast)) { - case "last": - return MissingOrder.Last; - case "first": - return MissingOrder.First; - case "default": - return MissingOrder.Default; + return MissingOrder.Last; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFirst)) + { + return MissingOrder.First; + } + + if (reader.ValueTextEquals(MemberDefault)) + { + return MissingOrder.Default; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MissingOrder)}'."); } - public override void Write(Utf8JsonWriter writer, MissingOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MissingOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MissingOrder.Last: - writer.WriteStringValue("last"); - return; + writer.WriteStringValue(MemberLast); + break; case MissingOrder.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; case MissingOrder.Default: - writer.WriteStringValue("default"); - return; + writer.WriteStringValue(MemberDefault); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MissingOrder)}'."); } - - writer.WriteNullValue(); } } @@ -440,56 +520,76 @@ public enum NormalizeMethod Mean } -internal sealed class NormalizeMethodConverter : JsonConverter +internal sealed partial class NormalizeMethodConverter : System.Text.Json.Serialization.JsonConverter { - public override NormalizeMethod Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberZScore = System.Text.Json.JsonEncodedText.Encode("z-score"); + private static readonly System.Text.Json.JsonEncodedText MemberSoftmax = System.Text.Json.JsonEncodedText.Encode("softmax"); + private static readonly System.Text.Json.JsonEncodedText MemberRescale0100 = System.Text.Json.JsonEncodedText.Encode("rescale_0_100"); + private static readonly System.Text.Json.JsonEncodedText MemberRescale01 = System.Text.Json.JsonEncodedText.Encode("rescale_0_1"); + private static readonly System.Text.Json.JsonEncodedText MemberPercentOfSum = System.Text.Json.JsonEncodedText.Encode("percent_of_sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMean = System.Text.Json.JsonEncodedText.Encode("mean"); + + public override NormalizeMethod Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "z-score": - return NormalizeMethod.ZScore; - case "softmax": - return NormalizeMethod.Softmax; - case "rescale_0_100": - return NormalizeMethod.Rescale0100; - case "rescale_0_1": - return NormalizeMethod.Rescale01; - case "percent_of_sum": - return NormalizeMethod.PercentOfSum; - case "mean": - return NormalizeMethod.Mean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberZScore)) + { + return NormalizeMethod.ZScore; + } + + if (reader.ValueTextEquals(MemberSoftmax)) + { + return NormalizeMethod.Softmax; + } + + if (reader.ValueTextEquals(MemberRescale0100)) + { + return NormalizeMethod.Rescale0100; + } + + if (reader.ValueTextEquals(MemberRescale01)) + { + return NormalizeMethod.Rescale01; + } + + if (reader.ValueTextEquals(MemberPercentOfSum)) + { + return NormalizeMethod.PercentOfSum; + } + + if (reader.ValueTextEquals(MemberMean)) + { + return NormalizeMethod.Mean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NormalizeMethod)}'."); } - public override void Write(Utf8JsonWriter writer, NormalizeMethod value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NormalizeMethod value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NormalizeMethod.ZScore: - writer.WriteStringValue("z-score"); - return; + writer.WriteStringValue(MemberZScore); + break; case NormalizeMethod.Softmax: - writer.WriteStringValue("softmax"); - return; + writer.WriteStringValue(MemberSoftmax); + break; case NormalizeMethod.Rescale0100: - writer.WriteStringValue("rescale_0_100"); - return; + writer.WriteStringValue(MemberRescale0100); + break; case NormalizeMethod.Rescale01: - writer.WriteStringValue("rescale_0_1"); - return; + writer.WriteStringValue(MemberRescale01); + break; case NormalizeMethod.PercentOfSum: - writer.WriteStringValue("percent_of_sum"); - return; + writer.WriteStringValue(MemberPercentOfSum); + break; case NormalizeMethod.Mean: - writer.WriteStringValue("mean"); - return; + writer.WriteStringValue(MemberMean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NormalizeMethod)}'."); } - - writer.WriteNullValue(); } } @@ -512,36 +612,40 @@ public enum RateMode Sum } -internal sealed class RateModeConverter : JsonConverter +internal sealed partial class RateModeConverter : System.Text.Json.Serialization.JsonConverter { - public override RateMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberValueCount = System.Text.Json.JsonEncodedText.Encode("value_count"); + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + + public override RateMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberValueCount)) { - case "value_count": - return RateMode.ValueCount; - case "sum": - return RateMode.Sum; + return RateMode.ValueCount; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSum)) + { + return RateMode.Sum; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RateMode)}'."); } - public override void Write(Utf8JsonWriter writer, RateMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RateMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RateMode.ValueCount: - writer.WriteStringValue("value_count"); - return; + writer.WriteStringValue(MemberValueCount); + break; case RateMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RateMode)}'."); } - - writer.WriteNullValue(); } } @@ -571,41 +675,49 @@ public enum SamplerAggregationExecutionHint BytesHash } -internal sealed class SamplerAggregationExecutionHintConverter : JsonConverter +internal sealed partial class SamplerAggregationExecutionHintConverter : System.Text.Json.Serialization.JsonConverter { - public override SamplerAggregationExecutionHint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMap = System.Text.Json.JsonEncodedText.Encode("map"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText MemberBytesHash = System.Text.Json.JsonEncodedText.Encode("bytes_hash"); + + public override SamplerAggregationExecutionHint Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMap)) { - case "map": - return SamplerAggregationExecutionHint.Map; - case "global_ordinals": - return SamplerAggregationExecutionHint.GlobalOrdinals; - case "bytes_hash": - return SamplerAggregationExecutionHint.BytesHash; + return SamplerAggregationExecutionHint.Map; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGlobalOrdinals)) + { + return SamplerAggregationExecutionHint.GlobalOrdinals; + } + + if (reader.ValueTextEquals(MemberBytesHash)) + { + return SamplerAggregationExecutionHint.BytesHash; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SamplerAggregationExecutionHint)}'."); } - public override void Write(Utf8JsonWriter writer, SamplerAggregationExecutionHint value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SamplerAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SamplerAggregationExecutionHint.Map: - writer.WriteStringValue("map"); - return; + writer.WriteStringValue(MemberMap); + break; case SamplerAggregationExecutionHint.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; case SamplerAggregationExecutionHint.BytesHash: - writer.WriteStringValue("bytes_hash"); - return; + writer.WriteStringValue(MemberBytesHash); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SamplerAggregationExecutionHint)}'."); } - - writer.WriteNullValue(); } } @@ -628,36 +740,40 @@ public enum TermsAggregationCollectMode BreadthFirst } -internal sealed class TermsAggregationCollectModeConverter : JsonConverter +internal sealed partial class TermsAggregationCollectModeConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsAggregationCollectMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDepthFirst = System.Text.Json.JsonEncodedText.Encode("depth_first"); + private static readonly System.Text.Json.JsonEncodedText MemberBreadthFirst = System.Text.Json.JsonEncodedText.Encode("breadth_first"); + + public override TermsAggregationCollectMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDepthFirst)) + { + return TermsAggregationCollectMode.DepthFirst; + } + + if (reader.ValueTextEquals(MemberBreadthFirst)) { - case "depth_first": - return TermsAggregationCollectMode.DepthFirst; - case "breadth_first": - return TermsAggregationCollectMode.BreadthFirst; + return TermsAggregationCollectMode.BreadthFirst; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermsAggregationCollectMode)}'."); } - public override void Write(Utf8JsonWriter writer, TermsAggregationCollectMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregationCollectMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermsAggregationCollectMode.DepthFirst: - writer.WriteStringValue("depth_first"); - return; + writer.WriteStringValue(MemberDepthFirst); + break; case TermsAggregationCollectMode.BreadthFirst: - writer.WriteStringValue("breadth_first"); - return; + writer.WriteStringValue(MemberBreadthFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermsAggregationCollectMode)}'."); } - - writer.WriteNullValue(); } } @@ -674,46 +790,58 @@ public enum TermsAggregationExecutionHint GlobalOrdinals } -internal sealed class TermsAggregationExecutionHintConverter : JsonConverter +internal sealed partial class TermsAggregationExecutionHintConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsAggregationExecutionHint Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMap = System.Text.Json.JsonEncodedText.Encode("map"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinalsLowCardinality = System.Text.Json.JsonEncodedText.Encode("global_ordinals_low_cardinality"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinalsHash = System.Text.Json.JsonEncodedText.Encode("global_ordinals_hash"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("global_ordinals"); + + public override TermsAggregationExecutionHint Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMap)) + { + return TermsAggregationExecutionHint.Map; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinalsLowCardinality)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinalsHash)) + { + return TermsAggregationExecutionHint.GlobalOrdinalsHash; + } + + if (reader.ValueTextEquals(MemberGlobalOrdinals)) { - case "map": - return TermsAggregationExecutionHint.Map; - case "global_ordinals_low_cardinality": - return TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality; - case "global_ordinals_hash": - return TermsAggregationExecutionHint.GlobalOrdinalsHash; - case "global_ordinals": - return TermsAggregationExecutionHint.GlobalOrdinals; + return TermsAggregationExecutionHint.GlobalOrdinals; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermsAggregationExecutionHint)}'."); } - public override void Write(Utf8JsonWriter writer, TermsAggregationExecutionHint value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsAggregationExecutionHint value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermsAggregationExecutionHint.Map: - writer.WriteStringValue("map"); - return; + writer.WriteStringValue(MemberMap); + break; case TermsAggregationExecutionHint.GlobalOrdinalsLowCardinality: - writer.WriteStringValue("global_ordinals_low_cardinality"); - return; + writer.WriteStringValue(MemberGlobalOrdinalsLowCardinality); + break; case TermsAggregationExecutionHint.GlobalOrdinalsHash: - writer.WriteStringValue("global_ordinals_hash"); - return; + writer.WriteStringValue(MemberGlobalOrdinalsHash); + break; case TermsAggregationExecutionHint.GlobalOrdinals: - writer.WriteStringValue("global_ordinals"); - return; + writer.WriteStringValue(MemberGlobalOrdinals); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermsAggregationExecutionHint)}'."); } - - writer.WriteNullValue(); } } @@ -743,41 +871,49 @@ public enum TTestType Heteroscedastic } -internal sealed class TTestTypeConverter : JsonConverter +internal sealed partial class TTestTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TTestType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPaired = System.Text.Json.JsonEncodedText.Encode("paired"); + private static readonly System.Text.Json.JsonEncodedText MemberHomoscedastic = System.Text.Json.JsonEncodedText.Encode("homoscedastic"); + private static readonly System.Text.Json.JsonEncodedText MemberHeteroscedastic = System.Text.Json.JsonEncodedText.Encode("heteroscedastic"); + + public override TTestType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPaired)) + { + return TTestType.Paired; + } + + if (reader.ValueTextEquals(MemberHomoscedastic)) { - case "paired": - return TTestType.Paired; - case "homoscedastic": - return TTestType.Homoscedastic; - case "heteroscedastic": - return TTestType.Heteroscedastic; + return TTestType.Homoscedastic; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberHeteroscedastic)) + { + return TTestType.Heteroscedastic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TTestType)}'."); } - public override void Write(Utf8JsonWriter writer, TTestType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TTestType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TTestType.Paired: - writer.WriteStringValue("paired"); - return; + writer.WriteStringValue(MemberPaired); + break; case TTestType.Homoscedastic: - writer.WriteStringValue("homoscedastic"); - return; + writer.WriteStringValue(MemberHomoscedastic); + break; case TTestType.Heteroscedastic: - writer.WriteStringValue("heteroscedastic"); - return; + writer.WriteStringValue(MemberHeteroscedastic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TTestType)}'."); } - - writer.WriteNullValue(); } } @@ -806,75 +942,111 @@ public enum ValueType Boolean } -internal sealed class ValueTypeConverter : JsonConverter +internal sealed partial class ValueTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ValueType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberNumeric = System.Text.Json.JsonEncodedText.Encode("numeric"); + private static readonly System.Text.Json.JsonEncodedText MemberNumber = System.Text.Json.JsonEncodedText.Encode("number"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + + public override ValueType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "string": - return ValueType.String; - case "numeric": - return ValueType.Numeric; - case "number": - return ValueType.Number; - case "long": - return ValueType.Long; - case "ip": - return ValueType.Ip; - case "geo_point": - return ValueType.GeoPoint; - case "double": - return ValueType.Double; - case "date_nanos": - return ValueType.DateNanos; - case "date": - return ValueType.Date; - case "boolean": - return ValueType.Boolean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) + { + return ValueType.String; + } + + if (reader.ValueTextEquals(MemberNumeric)) + { + return ValueType.Numeric; + } + + if (reader.ValueTextEquals(MemberNumber)) + { + return ValueType.Number; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return ValueType.Long; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return ValueType.Ip; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return ValueType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return ValueType.Double; + } + + if (reader.ValueTextEquals(MemberDateNanos)) + { + return ValueType.DateNanos; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return ValueType.Date; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return ValueType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ValueType)}'."); } - public override void Write(Utf8JsonWriter writer, ValueType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ValueType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ValueType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ValueType.Numeric: - writer.WriteStringValue("numeric"); - return; + writer.WriteStringValue(MemberNumeric); + break; case ValueType.Number: - writer.WriteStringValue("number"); - return; + writer.WriteStringValue(MemberNumber); + break; case ValueType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case ValueType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case ValueType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case ValueType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case ValueType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case ValueType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case ValueType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ValueType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs index dae02bf828f..1c91281ee75 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Analysis.g.cs @@ -39,41 +39,49 @@ public enum DelimitedPayloadEncoding Float } -internal sealed class DelimitedPayloadEncodingConverter : JsonConverter +internal sealed partial class DelimitedPayloadEncodingConverter : System.Text.Json.Serialization.JsonConverter { - public override DelimitedPayloadEncoding Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("int"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentity = System.Text.Json.JsonEncodedText.Encode("identity"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + + public override DelimitedPayloadEncoding Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInteger)) + { + return DelimitedPayloadEncoding.Integer; + } + + if (reader.ValueTextEquals(MemberIdentity)) + { + return DelimitedPayloadEncoding.Identity; + } + + if (reader.ValueTextEquals(MemberFloat)) { - case "int": - return DelimitedPayloadEncoding.Integer; - case "identity": - return DelimitedPayloadEncoding.Identity; - case "float": - return DelimitedPayloadEncoding.Float; + return DelimitedPayloadEncoding.Float; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DelimitedPayloadEncoding)}'."); } - public override void Write(Utf8JsonWriter writer, DelimitedPayloadEncoding value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DelimitedPayloadEncoding value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DelimitedPayloadEncoding.Integer: - writer.WriteStringValue("int"); - return; + writer.WriteStringValue(MemberInteger); + break; case DelimitedPayloadEncoding.Identity: - writer.WriteStringValue("identity"); - return; + writer.WriteStringValue(MemberIdentity); + break; case DelimitedPayloadEncoding.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DelimitedPayloadEncoding)}'."); } - - writer.WriteNullValue(); } } @@ -86,36 +94,40 @@ public enum EdgeNGramSide Back } -internal sealed class EdgeNGramSideConverter : JsonConverter +internal sealed partial class EdgeNGramSideConverter : System.Text.Json.Serialization.JsonConverter { - public override EdgeNGramSide Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFront = System.Text.Json.JsonEncodedText.Encode("front"); + private static readonly System.Text.Json.JsonEncodedText MemberBack = System.Text.Json.JsonEncodedText.Encode("back"); + + public override EdgeNGramSide Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFront)) + { + return EdgeNGramSide.Front; + } + + if (reader.ValueTextEquals(MemberBack)) { - case "front": - return EdgeNGramSide.Front; - case "back": - return EdgeNGramSide.Back; + return EdgeNGramSide.Back; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EdgeNGramSide)}'."); } - public override void Write(Utf8JsonWriter writer, EdgeNGramSide value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EdgeNGramSide value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EdgeNGramSide.Front: - writer.WriteStringValue("front"); - return; + writer.WriteStringValue(MemberFront); + break; case EdgeNGramSide.Back: - writer.WriteStringValue("back"); - return; + writer.WriteStringValue(MemberBack); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EdgeNGramSide)}'."); } - - writer.WriteNullValue(); } } @@ -128,36 +140,40 @@ public enum IcuCollationAlternate NonIgnorable } -internal sealed class IcuCollationAlternateConverter : JsonConverter +internal sealed partial class IcuCollationAlternateConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationAlternate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShifted = System.Text.Json.JsonEncodedText.Encode("shifted"); + private static readonly System.Text.Json.JsonEncodedText MemberNonIgnorable = System.Text.Json.JsonEncodedText.Encode("non-ignorable"); + + public override IcuCollationAlternate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShifted)) + { + return IcuCollationAlternate.Shifted; + } + + if (reader.ValueTextEquals(MemberNonIgnorable)) { - case "shifted": - return IcuCollationAlternate.Shifted; - case "non-ignorable": - return IcuCollationAlternate.NonIgnorable; + return IcuCollationAlternate.NonIgnorable; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationAlternate)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationAlternate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationAlternate value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationAlternate.Shifted: - writer.WriteStringValue("shifted"); - return; + writer.WriteStringValue(MemberShifted); + break; case IcuCollationAlternate.NonIgnorable: - writer.WriteStringValue("non-ignorable"); - return; + writer.WriteStringValue(MemberNonIgnorable); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationAlternate)}'."); } - - writer.WriteNullValue(); } } @@ -170,36 +186,40 @@ public enum IcuCollationCaseFirst Lower } -internal sealed class IcuCollationCaseFirstConverter : JsonConverter +internal sealed partial class IcuCollationCaseFirstConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationCaseFirst Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUpper = System.Text.Json.JsonEncodedText.Encode("upper"); + private static readonly System.Text.Json.JsonEncodedText MemberLower = System.Text.Json.JsonEncodedText.Encode("lower"); + + public override IcuCollationCaseFirst Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUpper)) { - case "upper": - return IcuCollationCaseFirst.Upper; - case "lower": - return IcuCollationCaseFirst.Lower; + return IcuCollationCaseFirst.Upper; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLower)) + { + return IcuCollationCaseFirst.Lower; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationCaseFirst)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationCaseFirst value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationCaseFirst value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationCaseFirst.Upper: - writer.WriteStringValue("upper"); - return; + writer.WriteStringValue(MemberUpper); + break; case IcuCollationCaseFirst.Lower: - writer.WriteStringValue("lower"); - return; + writer.WriteStringValue(MemberLower); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationCaseFirst)}'."); } - - writer.WriteNullValue(); } } @@ -212,36 +232,40 @@ public enum IcuCollationDecomposition Identical } -internal sealed class IcuCollationDecompositionConverter : JsonConverter +internal sealed partial class IcuCollationDecompositionConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationDecomposition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentical = System.Text.Json.JsonEncodedText.Encode("identical"); + + public override IcuCollationDecomposition Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNo)) + { + return IcuCollationDecomposition.No; + } + + if (reader.ValueTextEquals(MemberIdentical)) { - case "no": - return IcuCollationDecomposition.No; - case "identical": - return IcuCollationDecomposition.Identical; + return IcuCollationDecomposition.Identical; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationDecomposition)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationDecomposition value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationDecomposition value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationDecomposition.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case IcuCollationDecomposition.Identical: - writer.WriteStringValue("identical"); - return; + writer.WriteStringValue(MemberIdentical); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationDecomposition)}'."); } - - writer.WriteNullValue(); } } @@ -260,51 +284,67 @@ public enum IcuCollationStrength Identical } -internal sealed class IcuCollationStrengthConverter : JsonConverter +internal sealed partial class IcuCollationStrengthConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuCollationStrength Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTertiary = System.Text.Json.JsonEncodedText.Encode("tertiary"); + private static readonly System.Text.Json.JsonEncodedText MemberSecondary = System.Text.Json.JsonEncodedText.Encode("secondary"); + private static readonly System.Text.Json.JsonEncodedText MemberQuaternary = System.Text.Json.JsonEncodedText.Encode("quaternary"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + private static readonly System.Text.Json.JsonEncodedText MemberIdentical = System.Text.Json.JsonEncodedText.Encode("identical"); + + public override IcuCollationStrength Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "tertiary": - return IcuCollationStrength.Tertiary; - case "secondary": - return IcuCollationStrength.Secondary; - case "quaternary": - return IcuCollationStrength.Quaternary; - case "primary": - return IcuCollationStrength.Primary; - case "identical": - return IcuCollationStrength.Identical; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTertiary)) + { + return IcuCollationStrength.Tertiary; + } + + if (reader.ValueTextEquals(MemberSecondary)) + { + return IcuCollationStrength.Secondary; + } + + if (reader.ValueTextEquals(MemberQuaternary)) + { + return IcuCollationStrength.Quaternary; + } + + if (reader.ValueTextEquals(MemberPrimary)) + { + return IcuCollationStrength.Primary; + } + + if (reader.ValueTextEquals(MemberIdentical)) + { + return IcuCollationStrength.Identical; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuCollationStrength)}'."); } - public override void Write(Utf8JsonWriter writer, IcuCollationStrength value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationStrength value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuCollationStrength.Tertiary: - writer.WriteStringValue("tertiary"); - return; + writer.WriteStringValue(MemberTertiary); + break; case IcuCollationStrength.Secondary: - writer.WriteStringValue("secondary"); - return; + writer.WriteStringValue(MemberSecondary); + break; case IcuCollationStrength.Quaternary: - writer.WriteStringValue("quaternary"); - return; + writer.WriteStringValue(MemberQuaternary); + break; case IcuCollationStrength.Primary: - writer.WriteStringValue("primary"); - return; + writer.WriteStringValue(MemberPrimary); + break; case IcuCollationStrength.Identical: - writer.WriteStringValue("identical"); - return; + writer.WriteStringValue(MemberIdentical); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuCollationStrength)}'."); } - - writer.WriteNullValue(); } } @@ -317,36 +357,40 @@ public enum IcuNormalizationMode Compose } -internal sealed class IcuNormalizationModeConverter : JsonConverter +internal sealed partial class IcuNormalizationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuNormalizationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDecompose = System.Text.Json.JsonEncodedText.Encode("decompose"); + private static readonly System.Text.Json.JsonEncodedText MemberCompose = System.Text.Json.JsonEncodedText.Encode("compose"); + + public override IcuNormalizationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDecompose)) { - case "decompose": - return IcuNormalizationMode.Decompose; - case "compose": - return IcuNormalizationMode.Compose; + return IcuNormalizationMode.Decompose; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCompose)) + { + return IcuNormalizationMode.Compose; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuNormalizationMode)}'."); } - public override void Write(Utf8JsonWriter writer, IcuNormalizationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuNormalizationMode.Decompose: - writer.WriteStringValue("decompose"); - return; + writer.WriteStringValue(MemberDecompose); + break; case IcuNormalizationMode.Compose: - writer.WriteStringValue("compose"); - return; + writer.WriteStringValue(MemberCompose); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuNormalizationMode)}'."); } - - writer.WriteNullValue(); } } @@ -361,41 +405,49 @@ public enum IcuNormalizationType Nfc } -internal sealed class IcuNormalizationTypeConverter : JsonConverter +internal sealed partial class IcuNormalizationTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuNormalizationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNfkcCf = System.Text.Json.JsonEncodedText.Encode("nfkc_cf"); + private static readonly System.Text.Json.JsonEncodedText MemberNfkc = System.Text.Json.JsonEncodedText.Encode("nfkc"); + private static readonly System.Text.Json.JsonEncodedText MemberNfc = System.Text.Json.JsonEncodedText.Encode("nfc"); + + public override IcuNormalizationType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNfkcCf)) + { + return IcuNormalizationType.NfkcCf; + } + + if (reader.ValueTextEquals(MemberNfkc)) + { + return IcuNormalizationType.Nfkc; + } + + if (reader.ValueTextEquals(MemberNfc)) { - case "nfkc_cf": - return IcuNormalizationType.NfkcCf; - case "nfkc": - return IcuNormalizationType.Nfkc; - case "nfc": - return IcuNormalizationType.Nfc; + return IcuNormalizationType.Nfc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuNormalizationType)}'."); } - public override void Write(Utf8JsonWriter writer, IcuNormalizationType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuNormalizationType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuNormalizationType.NfkcCf: - writer.WriteStringValue("nfkc_cf"); - return; + writer.WriteStringValue(MemberNfkcCf); + break; case IcuNormalizationType.Nfkc: - writer.WriteStringValue("nfkc"); - return; + writer.WriteStringValue(MemberNfkc); + break; case IcuNormalizationType.Nfc: - writer.WriteStringValue("nfc"); - return; + writer.WriteStringValue(MemberNfc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuNormalizationType)}'."); } - - writer.WriteNullValue(); } } @@ -408,36 +460,40 @@ public enum IcuTransformDirection Forward } -internal sealed class IcuTransformDirectionConverter : JsonConverter +internal sealed partial class IcuTransformDirectionConverter : System.Text.Json.Serialization.JsonConverter { - public override IcuTransformDirection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReverse = System.Text.Json.JsonEncodedText.Encode("reverse"); + private static readonly System.Text.Json.JsonEncodedText MemberForward = System.Text.Json.JsonEncodedText.Encode("forward"); + + public override IcuTransformDirection Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReverse)) + { + return IcuTransformDirection.Reverse; + } + + if (reader.ValueTextEquals(MemberForward)) { - case "reverse": - return IcuTransformDirection.Reverse; - case "forward": - return IcuTransformDirection.Forward; + return IcuTransformDirection.Forward; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IcuTransformDirection)}'."); } - public override void Write(Utf8JsonWriter writer, IcuTransformDirection value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuTransformDirection value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IcuTransformDirection.Reverse: - writer.WriteStringValue("reverse"); - return; + writer.WriteStringValue(MemberReverse); + break; case IcuTransformDirection.Forward: - writer.WriteStringValue("forward"); - return; + writer.WriteStringValue(MemberForward); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IcuTransformDirection)}'."); } - - writer.WriteNullValue(); } } @@ -450,36 +506,40 @@ public enum KeepTypesMode Exclude } -internal sealed class KeepTypesModeConverter : JsonConverter +internal sealed partial class KeepTypesModeConverter : System.Text.Json.Serialization.JsonConverter { - public override KeepTypesMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override KeepTypesMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInclude)) { - case "include": - return KeepTypesMode.Include; - case "exclude": - return KeepTypesMode.Exclude; + return KeepTypesMode.Include; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExclude)) + { + return KeepTypesMode.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(KeepTypesMode)}'."); } - public override void Write(Utf8JsonWriter writer, KeepTypesMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeepTypesMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case KeepTypesMode.Include: - writer.WriteStringValue("include"); - return; + writer.WriteStringValue(MemberInclude); + break; case KeepTypesMode.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(KeepTypesMode)}'."); } - - writer.WriteNullValue(); } } @@ -494,41 +554,49 @@ public enum KuromojiTokenizationMode Extended } -internal sealed class KuromojiTokenizationModeConverter : JsonConverter +internal sealed partial class KuromojiTokenizationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override KuromojiTokenizationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberExtended = System.Text.Json.JsonEncodedText.Encode("extended"); + + public override KuromojiTokenizationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSearch)) { - case "search": - return KuromojiTokenizationMode.Search; - case "normal": - return KuromojiTokenizationMode.Normal; - case "extended": - return KuromojiTokenizationMode.Extended; + return KuromojiTokenizationMode.Search; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNormal)) + { + return KuromojiTokenizationMode.Normal; + } + + if (reader.ValueTextEquals(MemberExtended)) + { + return KuromojiTokenizationMode.Extended; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(KuromojiTokenizationMode)}'."); } - public override void Write(Utf8JsonWriter writer, KuromojiTokenizationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, KuromojiTokenizationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case KuromojiTokenizationMode.Search: - writer.WriteStringValue("search"); - return; + writer.WriteStringValue(MemberSearch); + break; case KuromojiTokenizationMode.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case KuromojiTokenizationMode.Extended: - writer.WriteStringValue("extended"); - return; + writer.WriteStringValue(MemberExtended); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(KuromojiTokenizationMode)}'."); } - - writer.WriteNullValue(); } } @@ -605,196 +673,328 @@ public enum Language Arabic } -internal sealed class LanguageConverter : JsonConverter +internal sealed partial class LanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override Language Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTurkish = System.Text.Json.JsonEncodedText.Encode("Turkish"); + private static readonly System.Text.Json.JsonEncodedText MemberThai = System.Text.Json.JsonEncodedText.Encode("Thai"); + private static readonly System.Text.Json.JsonEncodedText MemberSwedish = System.Text.Json.JsonEncodedText.Encode("Swedish"); + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("Spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberSorani = System.Text.Json.JsonEncodedText.Encode("Sorani"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("Russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("Romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPortuguese = System.Text.Json.JsonEncodedText.Encode("Portuguese"); + private static readonly System.Text.Json.JsonEncodedText MemberPersian = System.Text.Json.JsonEncodedText.Encode("Persian"); + private static readonly System.Text.Json.JsonEncodedText MemberNorwegian = System.Text.Json.JsonEncodedText.Encode("Norwegian"); + private static readonly System.Text.Json.JsonEncodedText MemberLatvian = System.Text.Json.JsonEncodedText.Encode("Latvian"); + private static readonly System.Text.Json.JsonEncodedText MemberItalian = System.Text.Json.JsonEncodedText.Encode("Italian"); + private static readonly System.Text.Json.JsonEncodedText MemberIrish = System.Text.Json.JsonEncodedText.Encode("Irish"); + private static readonly System.Text.Json.JsonEncodedText MemberIndonesian = System.Text.Json.JsonEncodedText.Encode("Indonesian"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("Hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberHindi = System.Text.Json.JsonEncodedText.Encode("Hindi"); + private static readonly System.Text.Json.JsonEncodedText MemberGreek = System.Text.Json.JsonEncodedText.Encode("Greek"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("German"); + private static readonly System.Text.Json.JsonEncodedText MemberGalician = System.Text.Json.JsonEncodedText.Encode("Galician"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("French"); + private static readonly System.Text.Json.JsonEncodedText MemberFinnish = System.Text.Json.JsonEncodedText.Encode("Finnish"); + private static readonly System.Text.Json.JsonEncodedText MemberEstonian = System.Text.Json.JsonEncodedText.Encode("Estonian"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("English"); + private static readonly System.Text.Json.JsonEncodedText MemberDutch = System.Text.Json.JsonEncodedText.Encode("Dutch"); + private static readonly System.Text.Json.JsonEncodedText MemberDanish = System.Text.Json.JsonEncodedText.Encode("Danish"); + private static readonly System.Text.Json.JsonEncodedText MemberCzech = System.Text.Json.JsonEncodedText.Encode("Czech"); + private static readonly System.Text.Json.JsonEncodedText MemberCjk = System.Text.Json.JsonEncodedText.Encode("Cjk"); + private static readonly System.Text.Json.JsonEncodedText MemberChinese = System.Text.Json.JsonEncodedText.Encode("Chinese"); + private static readonly System.Text.Json.JsonEncodedText MemberCatalan = System.Text.Json.JsonEncodedText.Encode("Catalan"); + private static readonly System.Text.Json.JsonEncodedText MemberBulgarian = System.Text.Json.JsonEncodedText.Encode("Bulgarian"); + private static readonly System.Text.Json.JsonEncodedText MemberBrazilian = System.Text.Json.JsonEncodedText.Encode("Brazilian"); + private static readonly System.Text.Json.JsonEncodedText MemberBasque = System.Text.Json.JsonEncodedText.Encode("Basque"); + private static readonly System.Text.Json.JsonEncodedText MemberArmenian = System.Text.Json.JsonEncodedText.Encode("Armenian"); + private static readonly System.Text.Json.JsonEncodedText MemberArabic = System.Text.Json.JsonEncodedText.Encode("Arabic"); + + public override Language Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "Turkish": - return Language.Turkish; - case "Thai": - return Language.Thai; - case "Swedish": - return Language.Swedish; - case "Spanish": - return Language.Spanish; - case "Sorani": - return Language.Sorani; - case "Russian": - return Language.Russian; - case "Romanian": - return Language.Romanian; - case "Portuguese": - return Language.Portuguese; - case "Persian": - return Language.Persian; - case "Norwegian": - return Language.Norwegian; - case "Latvian": - return Language.Latvian; - case "Italian": - return Language.Italian; - case "Irish": - return Language.Irish; - case "Indonesian": - return Language.Indonesian; - case "Hungarian": - return Language.Hungarian; - case "Hindi": - return Language.Hindi; - case "Greek": - return Language.Greek; - case "German": - return Language.German; - case "Galician": - return Language.Galician; - case "French": - return Language.French; - case "Finnish": - return Language.Finnish; - case "Estonian": - return Language.Estonian; - case "English": - return Language.English; - case "Dutch": - return Language.Dutch; - case "Danish": - return Language.Danish; - case "Czech": - return Language.Czech; - case "Cjk": - return Language.Cjk; - case "Chinese": - return Language.Chinese; - case "Catalan": - return Language.Catalan; - case "Bulgarian": - return Language.Bulgarian; - case "Brazilian": - return Language.Brazilian; - case "Basque": - return Language.Basque; - case "Armenian": - return Language.Armenian; - case "Arabic": - return Language.Arabic; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTurkish)) + { + return Language.Turkish; + } + + if (reader.ValueTextEquals(MemberThai)) + { + return Language.Thai; + } + + if (reader.ValueTextEquals(MemberSwedish)) + { + return Language.Swedish; + } + + if (reader.ValueTextEquals(MemberSpanish)) + { + return Language.Spanish; + } + + if (reader.ValueTextEquals(MemberSorani)) + { + return Language.Sorani; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return Language.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return Language.Romanian; + } + + if (reader.ValueTextEquals(MemberPortuguese)) + { + return Language.Portuguese; + } + + if (reader.ValueTextEquals(MemberPersian)) + { + return Language.Persian; + } + + if (reader.ValueTextEquals(MemberNorwegian)) + { + return Language.Norwegian; + } + + if (reader.ValueTextEquals(MemberLatvian)) + { + return Language.Latvian; + } + + if (reader.ValueTextEquals(MemberItalian)) + { + return Language.Italian; + } + + if (reader.ValueTextEquals(MemberIrish)) + { + return Language.Irish; + } + + if (reader.ValueTextEquals(MemberIndonesian)) + { + return Language.Indonesian; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return Language.Hungarian; + } + + if (reader.ValueTextEquals(MemberHindi)) + { + return Language.Hindi; + } + + if (reader.ValueTextEquals(MemberGreek)) + { + return Language.Greek; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return Language.German; + } + + if (reader.ValueTextEquals(MemberGalician)) + { + return Language.Galician; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return Language.French; + } + + if (reader.ValueTextEquals(MemberFinnish)) + { + return Language.Finnish; + } + + if (reader.ValueTextEquals(MemberEstonian)) + { + return Language.Estonian; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return Language.English; + } + + if (reader.ValueTextEquals(MemberDutch)) + { + return Language.Dutch; + } + + if (reader.ValueTextEquals(MemberDanish)) + { + return Language.Danish; + } + + if (reader.ValueTextEquals(MemberCzech)) + { + return Language.Czech; + } + + if (reader.ValueTextEquals(MemberCjk)) + { + return Language.Cjk; + } + + if (reader.ValueTextEquals(MemberChinese)) + { + return Language.Chinese; + } + + if (reader.ValueTextEquals(MemberCatalan)) + { + return Language.Catalan; + } + + if (reader.ValueTextEquals(MemberBulgarian)) + { + return Language.Bulgarian; + } + + if (reader.ValueTextEquals(MemberBrazilian)) + { + return Language.Brazilian; + } + + if (reader.ValueTextEquals(MemberBasque)) + { + return Language.Basque; + } + + if (reader.ValueTextEquals(MemberArmenian)) + { + return Language.Armenian; + } + + if (reader.ValueTextEquals(MemberArabic)) + { + return Language.Arabic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Language)}'."); } - public override void Write(Utf8JsonWriter writer, Language value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Language value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Language.Turkish: - writer.WriteStringValue("Turkish"); - return; + writer.WriteStringValue(MemberTurkish); + break; case Language.Thai: - writer.WriteStringValue("Thai"); - return; + writer.WriteStringValue(MemberThai); + break; case Language.Swedish: - writer.WriteStringValue("Swedish"); - return; + writer.WriteStringValue(MemberSwedish); + break; case Language.Spanish: - writer.WriteStringValue("Spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case Language.Sorani: - writer.WriteStringValue("Sorani"); - return; + writer.WriteStringValue(MemberSorani); + break; case Language.Russian: - writer.WriteStringValue("Russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case Language.Romanian: - writer.WriteStringValue("Romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case Language.Portuguese: - writer.WriteStringValue("Portuguese"); - return; + writer.WriteStringValue(MemberPortuguese); + break; case Language.Persian: - writer.WriteStringValue("Persian"); - return; + writer.WriteStringValue(MemberPersian); + break; case Language.Norwegian: - writer.WriteStringValue("Norwegian"); - return; + writer.WriteStringValue(MemberNorwegian); + break; case Language.Latvian: - writer.WriteStringValue("Latvian"); - return; + writer.WriteStringValue(MemberLatvian); + break; case Language.Italian: - writer.WriteStringValue("Italian"); - return; + writer.WriteStringValue(MemberItalian); + break; case Language.Irish: - writer.WriteStringValue("Irish"); - return; + writer.WriteStringValue(MemberIrish); + break; case Language.Indonesian: - writer.WriteStringValue("Indonesian"); - return; + writer.WriteStringValue(MemberIndonesian); + break; case Language.Hungarian: - writer.WriteStringValue("Hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case Language.Hindi: - writer.WriteStringValue("Hindi"); - return; + writer.WriteStringValue(MemberHindi); + break; case Language.Greek: - writer.WriteStringValue("Greek"); - return; + writer.WriteStringValue(MemberGreek); + break; case Language.German: - writer.WriteStringValue("German"); - return; + writer.WriteStringValue(MemberGerman); + break; case Language.Galician: - writer.WriteStringValue("Galician"); - return; + writer.WriteStringValue(MemberGalician); + break; case Language.French: - writer.WriteStringValue("French"); - return; + writer.WriteStringValue(MemberFrench); + break; case Language.Finnish: - writer.WriteStringValue("Finnish"); - return; + writer.WriteStringValue(MemberFinnish); + break; case Language.Estonian: - writer.WriteStringValue("Estonian"); - return; + writer.WriteStringValue(MemberEstonian); + break; case Language.English: - writer.WriteStringValue("English"); - return; + writer.WriteStringValue(MemberEnglish); + break; case Language.Dutch: - writer.WriteStringValue("Dutch"); - return; + writer.WriteStringValue(MemberDutch); + break; case Language.Danish: - writer.WriteStringValue("Danish"); - return; + writer.WriteStringValue(MemberDanish); + break; case Language.Czech: - writer.WriteStringValue("Czech"); - return; + writer.WriteStringValue(MemberCzech); + break; case Language.Cjk: - writer.WriteStringValue("Cjk"); - return; + writer.WriteStringValue(MemberCjk); + break; case Language.Chinese: - writer.WriteStringValue("Chinese"); - return; + writer.WriteStringValue(MemberChinese); + break; case Language.Catalan: - writer.WriteStringValue("Catalan"); - return; + writer.WriteStringValue(MemberCatalan); + break; case Language.Bulgarian: - writer.WriteStringValue("Bulgarian"); - return; + writer.WriteStringValue(MemberBulgarian); + break; case Language.Brazilian: - writer.WriteStringValue("Brazilian"); - return; + writer.WriteStringValue(MemberBrazilian); + break; case Language.Basque: - writer.WriteStringValue("Basque"); - return; + writer.WriteStringValue(MemberBasque); + break; case Language.Armenian: - writer.WriteStringValue("Armenian"); - return; + writer.WriteStringValue(MemberArmenian); + break; case Language.Arabic: - writer.WriteStringValue("Arabic"); - return; + writer.WriteStringValue(MemberArabic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Language)}'."); } - - writer.WriteNullValue(); } } @@ -809,41 +1009,49 @@ public enum NoriDecompoundMode Discard } -internal sealed class NoriDecompoundModeConverter : JsonConverter +internal sealed partial class NoriDecompoundModeConverter : System.Text.Json.Serialization.JsonConverter { - public override NoriDecompoundMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberMixed = System.Text.Json.JsonEncodedText.Encode("mixed"); + private static readonly System.Text.Json.JsonEncodedText MemberDiscard = System.Text.Json.JsonEncodedText.Encode("discard"); + + public override NoriDecompoundMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) + { + return NoriDecompoundMode.None; + } + + if (reader.ValueTextEquals(MemberMixed)) { - case "none": - return NoriDecompoundMode.None; - case "mixed": - return NoriDecompoundMode.Mixed; - case "discard": - return NoriDecompoundMode.Discard; + return NoriDecompoundMode.Mixed; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDiscard)) + { + return NoriDecompoundMode.Discard; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NoriDecompoundMode)}'."); } - public override void Write(Utf8JsonWriter writer, NoriDecompoundMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NoriDecompoundMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NoriDecompoundMode.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case NoriDecompoundMode.Mixed: - writer.WriteStringValue("mixed"); - return; + writer.WriteStringValue(MemberMixed); + break; case NoriDecompoundMode.Discard: - writer.WriteStringValue("discard"); - return; + writer.WriteStringValue(MemberDiscard); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NoriDecompoundMode)}'."); } - - writer.WriteNullValue(); } } @@ -876,86 +1084,130 @@ public enum PhoneticEncoder BeiderMorse } -internal sealed class PhoneticEncoderConverter : JsonConverter +internal sealed partial class PhoneticEncoderConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticEncoder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSoundex = System.Text.Json.JsonEncodedText.Encode("soundex"); + private static readonly System.Text.Json.JsonEncodedText MemberRefinedSoundex = System.Text.Json.JsonEncodedText.Encode("refined_soundex"); + private static readonly System.Text.Json.JsonEncodedText MemberNysiis = System.Text.Json.JsonEncodedText.Encode("nysiis"); + private static readonly System.Text.Json.JsonEncodedText MemberMetaphone = System.Text.Json.JsonEncodedText.Encode("metaphone"); + private static readonly System.Text.Json.JsonEncodedText MemberKoelnerphonetik = System.Text.Json.JsonEncodedText.Encode("koelnerphonetik"); + private static readonly System.Text.Json.JsonEncodedText MemberHaasephonetik = System.Text.Json.JsonEncodedText.Encode("haasephonetik"); + private static readonly System.Text.Json.JsonEncodedText MemberDoubleMetaphone = System.Text.Json.JsonEncodedText.Encode("double_metaphone"); + private static readonly System.Text.Json.JsonEncodedText MemberDaitchMokotoff = System.Text.Json.JsonEncodedText.Encode("daitch_mokotoff"); + private static readonly System.Text.Json.JsonEncodedText MemberCologne = System.Text.Json.JsonEncodedText.Encode("cologne"); + private static readonly System.Text.Json.JsonEncodedText MemberCaverphone2 = System.Text.Json.JsonEncodedText.Encode("caverphone2"); + private static readonly System.Text.Json.JsonEncodedText MemberCaverphone1 = System.Text.Json.JsonEncodedText.Encode("caverphone1"); + private static readonly System.Text.Json.JsonEncodedText MemberBeiderMorse = System.Text.Json.JsonEncodedText.Encode("beider_morse"); + + public override PhoneticEncoder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "soundex": - return PhoneticEncoder.Soundex; - case "refined_soundex": - return PhoneticEncoder.RefinedSoundex; - case "nysiis": - return PhoneticEncoder.Nysiis; - case "metaphone": - return PhoneticEncoder.Metaphone; - case "koelnerphonetik": - return PhoneticEncoder.Koelnerphonetik; - case "haasephonetik": - return PhoneticEncoder.Haasephonetik; - case "double_metaphone": - return PhoneticEncoder.DoubleMetaphone; - case "daitch_mokotoff": - return PhoneticEncoder.DaitchMokotoff; - case "cologne": - return PhoneticEncoder.Cologne; - case "caverphone2": - return PhoneticEncoder.Caverphone2; - case "caverphone1": - return PhoneticEncoder.Caverphone1; - case "beider_morse": - return PhoneticEncoder.BeiderMorse; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSoundex)) + { + return PhoneticEncoder.Soundex; + } + + if (reader.ValueTextEquals(MemberRefinedSoundex)) + { + return PhoneticEncoder.RefinedSoundex; + } + + if (reader.ValueTextEquals(MemberNysiis)) + { + return PhoneticEncoder.Nysiis; + } + + if (reader.ValueTextEquals(MemberMetaphone)) + { + return PhoneticEncoder.Metaphone; + } + + if (reader.ValueTextEquals(MemberKoelnerphonetik)) + { + return PhoneticEncoder.Koelnerphonetik; + } + + if (reader.ValueTextEquals(MemberHaasephonetik)) + { + return PhoneticEncoder.Haasephonetik; + } + + if (reader.ValueTextEquals(MemberDoubleMetaphone)) + { + return PhoneticEncoder.DoubleMetaphone; + } + + if (reader.ValueTextEquals(MemberDaitchMokotoff)) + { + return PhoneticEncoder.DaitchMokotoff; + } + + if (reader.ValueTextEquals(MemberCologne)) + { + return PhoneticEncoder.Cologne; + } + + if (reader.ValueTextEquals(MemberCaverphone2)) + { + return PhoneticEncoder.Caverphone2; + } + + if (reader.ValueTextEquals(MemberCaverphone1)) + { + return PhoneticEncoder.Caverphone1; + } + + if (reader.ValueTextEquals(MemberBeiderMorse)) + { + return PhoneticEncoder.BeiderMorse; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticEncoder)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticEncoder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticEncoder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticEncoder.Soundex: - writer.WriteStringValue("soundex"); - return; + writer.WriteStringValue(MemberSoundex); + break; case PhoneticEncoder.RefinedSoundex: - writer.WriteStringValue("refined_soundex"); - return; + writer.WriteStringValue(MemberRefinedSoundex); + break; case PhoneticEncoder.Nysiis: - writer.WriteStringValue("nysiis"); - return; + writer.WriteStringValue(MemberNysiis); + break; case PhoneticEncoder.Metaphone: - writer.WriteStringValue("metaphone"); - return; + writer.WriteStringValue(MemberMetaphone); + break; case PhoneticEncoder.Koelnerphonetik: - writer.WriteStringValue("koelnerphonetik"); - return; + writer.WriteStringValue(MemberKoelnerphonetik); + break; case PhoneticEncoder.Haasephonetik: - writer.WriteStringValue("haasephonetik"); - return; + writer.WriteStringValue(MemberHaasephonetik); + break; case PhoneticEncoder.DoubleMetaphone: - writer.WriteStringValue("double_metaphone"); - return; + writer.WriteStringValue(MemberDoubleMetaphone); + break; case PhoneticEncoder.DaitchMokotoff: - writer.WriteStringValue("daitch_mokotoff"); - return; + writer.WriteStringValue(MemberDaitchMokotoff); + break; case PhoneticEncoder.Cologne: - writer.WriteStringValue("cologne"); - return; + writer.WriteStringValue(MemberCologne); + break; case PhoneticEncoder.Caverphone2: - writer.WriteStringValue("caverphone2"); - return; + writer.WriteStringValue(MemberCaverphone2); + break; case PhoneticEncoder.Caverphone1: - writer.WriteStringValue("caverphone1"); - return; + writer.WriteStringValue(MemberCaverphone1); + break; case PhoneticEncoder.BeiderMorse: - writer.WriteStringValue("beider_morse"); - return; + writer.WriteStringValue(MemberBeiderMorse); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticEncoder)}'."); } - - writer.WriteNullValue(); } } @@ -988,86 +1240,130 @@ public enum PhoneticLanguage Any } -internal sealed class PhoneticLanguageConverter : JsonConverter +internal sealed partial class PhoneticLanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPolish = System.Text.Json.JsonEncodedText.Encode("polish"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberHebrew = System.Text.Json.JsonEncodedText.Encode("hebrew"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("german"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("french"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("english"); + private static readonly System.Text.Json.JsonEncodedText MemberCyrillic = System.Text.Json.JsonEncodedText.Encode("cyrillic"); + private static readonly System.Text.Json.JsonEncodedText MemberCommon = System.Text.Json.JsonEncodedText.Encode("common"); + private static readonly System.Text.Json.JsonEncodedText MemberAny = System.Text.Json.JsonEncodedText.Encode("any"); + + public override PhoneticLanguage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "spanish": - return PhoneticLanguage.Spanish; - case "russian": - return PhoneticLanguage.Russian; - case "romanian": - return PhoneticLanguage.Romanian; - case "polish": - return PhoneticLanguage.Polish; - case "hungarian": - return PhoneticLanguage.Hungarian; - case "hebrew": - return PhoneticLanguage.Hebrew; - case "german": - return PhoneticLanguage.German; - case "french": - return PhoneticLanguage.French; - case "english": - return PhoneticLanguage.English; - case "cyrillic": - return PhoneticLanguage.Cyrillic; - case "common": - return PhoneticLanguage.Common; - case "any": - return PhoneticLanguage.Any; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpanish)) + { + return PhoneticLanguage.Spanish; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return PhoneticLanguage.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return PhoneticLanguage.Romanian; + } + + if (reader.ValueTextEquals(MemberPolish)) + { + return PhoneticLanguage.Polish; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return PhoneticLanguage.Hungarian; + } + + if (reader.ValueTextEquals(MemberHebrew)) + { + return PhoneticLanguage.Hebrew; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return PhoneticLanguage.German; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return PhoneticLanguage.French; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return PhoneticLanguage.English; + } + + if (reader.ValueTextEquals(MemberCyrillic)) + { + return PhoneticLanguage.Cyrillic; + } + + if (reader.ValueTextEquals(MemberCommon)) + { + return PhoneticLanguage.Common; + } + + if (reader.ValueTextEquals(MemberAny)) + { + return PhoneticLanguage.Any; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticLanguage)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticLanguage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticLanguage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticLanguage.Spanish: - writer.WriteStringValue("spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case PhoneticLanguage.Russian: - writer.WriteStringValue("russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case PhoneticLanguage.Romanian: - writer.WriteStringValue("romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case PhoneticLanguage.Polish: - writer.WriteStringValue("polish"); - return; + writer.WriteStringValue(MemberPolish); + break; case PhoneticLanguage.Hungarian: - writer.WriteStringValue("hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case PhoneticLanguage.Hebrew: - writer.WriteStringValue("hebrew"); - return; + writer.WriteStringValue(MemberHebrew); + break; case PhoneticLanguage.German: - writer.WriteStringValue("german"); - return; + writer.WriteStringValue(MemberGerman); + break; case PhoneticLanguage.French: - writer.WriteStringValue("french"); - return; + writer.WriteStringValue(MemberFrench); + break; case PhoneticLanguage.English: - writer.WriteStringValue("english"); - return; + writer.WriteStringValue(MemberEnglish); + break; case PhoneticLanguage.Cyrillic: - writer.WriteStringValue("cyrillic"); - return; + writer.WriteStringValue(MemberCyrillic); + break; case PhoneticLanguage.Common: - writer.WriteStringValue("common"); - return; + writer.WriteStringValue(MemberCommon); + break; case PhoneticLanguage.Any: - writer.WriteStringValue("any"); - return; + writer.WriteStringValue(MemberAny); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticLanguage)}'."); } - - writer.WriteNullValue(); } } @@ -1082,41 +1378,49 @@ public enum PhoneticNameType Ashkenazi } -internal sealed class PhoneticNameTypeConverter : JsonConverter +internal sealed partial class PhoneticNameTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticNameType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSephardic = System.Text.Json.JsonEncodedText.Encode("sephardic"); + private static readonly System.Text.Json.JsonEncodedText MemberGeneric = System.Text.Json.JsonEncodedText.Encode("generic"); + private static readonly System.Text.Json.JsonEncodedText MemberAshkenazi = System.Text.Json.JsonEncodedText.Encode("ashkenazi"); + + public override PhoneticNameType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSephardic)) + { + return PhoneticNameType.Sephardic; + } + + if (reader.ValueTextEquals(MemberGeneric)) + { + return PhoneticNameType.Generic; + } + + if (reader.ValueTextEquals(MemberAshkenazi)) { - case "sephardic": - return PhoneticNameType.Sephardic; - case "generic": - return PhoneticNameType.Generic; - case "ashkenazi": - return PhoneticNameType.Ashkenazi; + return PhoneticNameType.Ashkenazi; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticNameType)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticNameType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticNameType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticNameType.Sephardic: - writer.WriteStringValue("sephardic"); - return; + writer.WriteStringValue(MemberSephardic); + break; case PhoneticNameType.Generic: - writer.WriteStringValue("generic"); - return; + writer.WriteStringValue(MemberGeneric); + break; case PhoneticNameType.Ashkenazi: - writer.WriteStringValue("ashkenazi"); - return; + writer.WriteStringValue(MemberAshkenazi); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticNameType)}'."); } - - writer.WriteNullValue(); } } @@ -1129,36 +1433,40 @@ public enum PhoneticRuleType Approx } -internal sealed class PhoneticRuleTypeConverter : JsonConverter +internal sealed partial class PhoneticRuleTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PhoneticRuleType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberExact = System.Text.Json.JsonEncodedText.Encode("exact"); + private static readonly System.Text.Json.JsonEncodedText MemberApprox = System.Text.Json.JsonEncodedText.Encode("approx"); + + public override PhoneticRuleType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberExact)) { - case "exact": - return PhoneticRuleType.Exact; - case "approx": - return PhoneticRuleType.Approx; + return PhoneticRuleType.Exact; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberApprox)) + { + return PhoneticRuleType.Approx; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PhoneticRuleType)}'."); } - public override void Write(Utf8JsonWriter writer, PhoneticRuleType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PhoneticRuleType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PhoneticRuleType.Exact: - writer.WriteStringValue("exact"); - return; + writer.WriteStringValue(MemberExact); + break; case PhoneticRuleType.Approx: - writer.WriteStringValue("approx"); - return; + writer.WriteStringValue(MemberApprox); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PhoneticRuleType)}'."); } - - writer.WriteNullValue(); } } @@ -1211,136 +1519,220 @@ public enum SnowballLanguage Armenian } -internal sealed class SnowballLanguageConverter : JsonConverter +internal sealed partial class SnowballLanguageConverter : System.Text.Json.Serialization.JsonConverter { - public override SnowballLanguage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTurkish = System.Text.Json.JsonEncodedText.Encode("Turkish"); + private static readonly System.Text.Json.JsonEncodedText MemberSwedish = System.Text.Json.JsonEncodedText.Encode("Swedish"); + private static readonly System.Text.Json.JsonEncodedText MemberSpanish = System.Text.Json.JsonEncodedText.Encode("Spanish"); + private static readonly System.Text.Json.JsonEncodedText MemberRussian = System.Text.Json.JsonEncodedText.Encode("Russian"); + private static readonly System.Text.Json.JsonEncodedText MemberRomanian = System.Text.Json.JsonEncodedText.Encode("Romanian"); + private static readonly System.Text.Json.JsonEncodedText MemberPortuguese = System.Text.Json.JsonEncodedText.Encode("Portuguese"); + private static readonly System.Text.Json.JsonEncodedText MemberPorter = System.Text.Json.JsonEncodedText.Encode("Porter"); + private static readonly System.Text.Json.JsonEncodedText MemberNorwegian = System.Text.Json.JsonEncodedText.Encode("Norwegian"); + private static readonly System.Text.Json.JsonEncodedText MemberLovins = System.Text.Json.JsonEncodedText.Encode("Lovins"); + private static readonly System.Text.Json.JsonEncodedText MemberKp = System.Text.Json.JsonEncodedText.Encode("Kp"); + private static readonly System.Text.Json.JsonEncodedText MemberItalian = System.Text.Json.JsonEncodedText.Encode("Italian"); + private static readonly System.Text.Json.JsonEncodedText MemberHungarian = System.Text.Json.JsonEncodedText.Encode("Hungarian"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman2 = System.Text.Json.JsonEncodedText.Encode("German2"); + private static readonly System.Text.Json.JsonEncodedText MemberGerman = System.Text.Json.JsonEncodedText.Encode("German"); + private static readonly System.Text.Json.JsonEncodedText MemberFrench = System.Text.Json.JsonEncodedText.Encode("French"); + private static readonly System.Text.Json.JsonEncodedText MemberFinnish = System.Text.Json.JsonEncodedText.Encode("Finnish"); + private static readonly System.Text.Json.JsonEncodedText MemberEnglish = System.Text.Json.JsonEncodedText.Encode("English"); + private static readonly System.Text.Json.JsonEncodedText MemberDutch = System.Text.Json.JsonEncodedText.Encode("Dutch"); + private static readonly System.Text.Json.JsonEncodedText MemberDanish = System.Text.Json.JsonEncodedText.Encode("Danish"); + private static readonly System.Text.Json.JsonEncodedText MemberCatalan = System.Text.Json.JsonEncodedText.Encode("Catalan"); + private static readonly System.Text.Json.JsonEncodedText MemberBasque = System.Text.Json.JsonEncodedText.Encode("Basque"); + private static readonly System.Text.Json.JsonEncodedText MemberArmenian = System.Text.Json.JsonEncodedText.Encode("Armenian"); + + public override SnowballLanguage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "Turkish": - return SnowballLanguage.Turkish; - case "Swedish": - return SnowballLanguage.Swedish; - case "Spanish": - return SnowballLanguage.Spanish; - case "Russian": - return SnowballLanguage.Russian; - case "Romanian": - return SnowballLanguage.Romanian; - case "Portuguese": - return SnowballLanguage.Portuguese; - case "Porter": - return SnowballLanguage.Porter; - case "Norwegian": - return SnowballLanguage.Norwegian; - case "Lovins": - return SnowballLanguage.Lovins; - case "Kp": - return SnowballLanguage.Kp; - case "Italian": - return SnowballLanguage.Italian; - case "Hungarian": - return SnowballLanguage.Hungarian; - case "German2": - return SnowballLanguage.German2; - case "German": - return SnowballLanguage.German; - case "French": - return SnowballLanguage.French; - case "Finnish": - return SnowballLanguage.Finnish; - case "English": - return SnowballLanguage.English; - case "Dutch": - return SnowballLanguage.Dutch; - case "Danish": - return SnowballLanguage.Danish; - case "Catalan": - return SnowballLanguage.Catalan; - case "Basque": - return SnowballLanguage.Basque; - case "Armenian": - return SnowballLanguage.Armenian; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTurkish)) + { + return SnowballLanguage.Turkish; + } + + if (reader.ValueTextEquals(MemberSwedish)) + { + return SnowballLanguage.Swedish; + } + + if (reader.ValueTextEquals(MemberSpanish)) + { + return SnowballLanguage.Spanish; + } + + if (reader.ValueTextEquals(MemberRussian)) + { + return SnowballLanguage.Russian; + } + + if (reader.ValueTextEquals(MemberRomanian)) + { + return SnowballLanguage.Romanian; + } + + if (reader.ValueTextEquals(MemberPortuguese)) + { + return SnowballLanguage.Portuguese; + } + + if (reader.ValueTextEquals(MemberPorter)) + { + return SnowballLanguage.Porter; + } + + if (reader.ValueTextEquals(MemberNorwegian)) + { + return SnowballLanguage.Norwegian; + } + + if (reader.ValueTextEquals(MemberLovins)) + { + return SnowballLanguage.Lovins; + } + + if (reader.ValueTextEquals(MemberKp)) + { + return SnowballLanguage.Kp; + } + + if (reader.ValueTextEquals(MemberItalian)) + { + return SnowballLanguage.Italian; + } + + if (reader.ValueTextEquals(MemberHungarian)) + { + return SnowballLanguage.Hungarian; + } + + if (reader.ValueTextEquals(MemberGerman2)) + { + return SnowballLanguage.German2; + } + + if (reader.ValueTextEquals(MemberGerman)) + { + return SnowballLanguage.German; + } + + if (reader.ValueTextEquals(MemberFrench)) + { + return SnowballLanguage.French; + } + + if (reader.ValueTextEquals(MemberFinnish)) + { + return SnowballLanguage.Finnish; + } + + if (reader.ValueTextEquals(MemberEnglish)) + { + return SnowballLanguage.English; + } + + if (reader.ValueTextEquals(MemberDutch)) + { + return SnowballLanguage.Dutch; + } + + if (reader.ValueTextEquals(MemberDanish)) + { + return SnowballLanguage.Danish; + } + + if (reader.ValueTextEquals(MemberCatalan)) + { + return SnowballLanguage.Catalan; + } + + if (reader.ValueTextEquals(MemberBasque)) + { + return SnowballLanguage.Basque; + } + + if (reader.ValueTextEquals(MemberArmenian)) + { + return SnowballLanguage.Armenian; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnowballLanguage)}'."); } - public override void Write(Utf8JsonWriter writer, SnowballLanguage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnowballLanguage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnowballLanguage.Turkish: - writer.WriteStringValue("Turkish"); - return; + writer.WriteStringValue(MemberTurkish); + break; case SnowballLanguage.Swedish: - writer.WriteStringValue("Swedish"); - return; + writer.WriteStringValue(MemberSwedish); + break; case SnowballLanguage.Spanish: - writer.WriteStringValue("Spanish"); - return; + writer.WriteStringValue(MemberSpanish); + break; case SnowballLanguage.Russian: - writer.WriteStringValue("Russian"); - return; + writer.WriteStringValue(MemberRussian); + break; case SnowballLanguage.Romanian: - writer.WriteStringValue("Romanian"); - return; + writer.WriteStringValue(MemberRomanian); + break; case SnowballLanguage.Portuguese: - writer.WriteStringValue("Portuguese"); - return; + writer.WriteStringValue(MemberPortuguese); + break; case SnowballLanguage.Porter: - writer.WriteStringValue("Porter"); - return; + writer.WriteStringValue(MemberPorter); + break; case SnowballLanguage.Norwegian: - writer.WriteStringValue("Norwegian"); - return; + writer.WriteStringValue(MemberNorwegian); + break; case SnowballLanguage.Lovins: - writer.WriteStringValue("Lovins"); - return; + writer.WriteStringValue(MemberLovins); + break; case SnowballLanguage.Kp: - writer.WriteStringValue("Kp"); - return; + writer.WriteStringValue(MemberKp); + break; case SnowballLanguage.Italian: - writer.WriteStringValue("Italian"); - return; + writer.WriteStringValue(MemberItalian); + break; case SnowballLanguage.Hungarian: - writer.WriteStringValue("Hungarian"); - return; + writer.WriteStringValue(MemberHungarian); + break; case SnowballLanguage.German2: - writer.WriteStringValue("German2"); - return; + writer.WriteStringValue(MemberGerman2); + break; case SnowballLanguage.German: - writer.WriteStringValue("German"); - return; + writer.WriteStringValue(MemberGerman); + break; case SnowballLanguage.French: - writer.WriteStringValue("French"); - return; + writer.WriteStringValue(MemberFrench); + break; case SnowballLanguage.Finnish: - writer.WriteStringValue("Finnish"); - return; + writer.WriteStringValue(MemberFinnish); + break; case SnowballLanguage.English: - writer.WriteStringValue("English"); - return; + writer.WriteStringValue(MemberEnglish); + break; case SnowballLanguage.Dutch: - writer.WriteStringValue("Dutch"); - return; + writer.WriteStringValue(MemberDutch); + break; case SnowballLanguage.Danish: - writer.WriteStringValue("Danish"); - return; + writer.WriteStringValue(MemberDanish); + break; case SnowballLanguage.Catalan: - writer.WriteStringValue("Catalan"); - return; + writer.WriteStringValue(MemberCatalan); + break; case SnowballLanguage.Basque: - writer.WriteStringValue("Basque"); - return; + writer.WriteStringValue(MemberBasque); + break; case SnowballLanguage.Armenian: - writer.WriteStringValue("Armenian"); - return; + writer.WriteStringValue(MemberArmenian); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnowballLanguage)}'."); } - - writer.WriteNullValue(); } } @@ -1353,36 +1745,40 @@ public enum SynonymFormat Solr } -internal sealed class SynonymFormatConverter : JsonConverter +internal sealed partial class SynonymFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override SynonymFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWordnet = System.Text.Json.JsonEncodedText.Encode("wordnet"); + private static readonly System.Text.Json.JsonEncodedText MemberSolr = System.Text.Json.JsonEncodedText.Encode("solr"); + + public override SynonymFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWordnet)) { - case "wordnet": - return SynonymFormat.Wordnet; - case "solr": - return SynonymFormat.Solr; + return SynonymFormat.Wordnet; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSolr)) + { + return SynonymFormat.Solr; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SynonymFormat)}'."); } - public override void Write(Utf8JsonWriter writer, SynonymFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SynonymFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SynonymFormat.Wordnet: - writer.WriteStringValue("wordnet"); - return; + writer.WriteStringValue(MemberWordnet); + break; case SynonymFormat.Solr: - writer.WriteStringValue("solr"); - return; + writer.WriteStringValue(MemberSolr); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SynonymFormat)}'."); } - - writer.WriteNullValue(); } } @@ -1403,55 +1799,75 @@ public enum TokenChar Custom } -internal sealed class TokenCharConverter : JsonConverter +internal sealed partial class TokenCharConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenChar Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWhitespace = System.Text.Json.JsonEncodedText.Encode("whitespace"); + private static readonly System.Text.Json.JsonEncodedText MemberSymbol = System.Text.Json.JsonEncodedText.Encode("symbol"); + private static readonly System.Text.Json.JsonEncodedText MemberPunctuation = System.Text.Json.JsonEncodedText.Encode("punctuation"); + private static readonly System.Text.Json.JsonEncodedText MemberLetter = System.Text.Json.JsonEncodedText.Encode("letter"); + private static readonly System.Text.Json.JsonEncodedText MemberDigit = System.Text.Json.JsonEncodedText.Encode("digit"); + private static readonly System.Text.Json.JsonEncodedText MemberCustom = System.Text.Json.JsonEncodedText.Encode("custom"); + + public override TokenChar Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "whitespace": - return TokenChar.Whitespace; - case "symbol": - return TokenChar.Symbol; - case "punctuation": - return TokenChar.Punctuation; - case "letter": - return TokenChar.Letter; - case "digit": - return TokenChar.Digit; - case "custom": - return TokenChar.Custom; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWhitespace)) + { + return TokenChar.Whitespace; + } + + if (reader.ValueTextEquals(MemberSymbol)) + { + return TokenChar.Symbol; + } + + if (reader.ValueTextEquals(MemberPunctuation)) + { + return TokenChar.Punctuation; + } + + if (reader.ValueTextEquals(MemberLetter)) + { + return TokenChar.Letter; + } + + if (reader.ValueTextEquals(MemberDigit)) + { + return TokenChar.Digit; + } + + if (reader.ValueTextEquals(MemberCustom)) + { + return TokenChar.Custom; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TokenChar)}'."); } - public override void Write(Utf8JsonWriter writer, TokenChar value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenChar value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TokenChar.Whitespace: - writer.WriteStringValue("whitespace"); - return; + writer.WriteStringValue(MemberWhitespace); + break; case TokenChar.Symbol: - writer.WriteStringValue("symbol"); - return; + writer.WriteStringValue(MemberSymbol); + break; case TokenChar.Punctuation: - writer.WriteStringValue("punctuation"); - return; + writer.WriteStringValue(MemberPunctuation); + break; case TokenChar.Letter: - writer.WriteStringValue("letter"); - return; + writer.WriteStringValue(MemberLetter); + break; case TokenChar.Digit: - writer.WriteStringValue("digit"); - return; + writer.WriteStringValue(MemberDigit); + break; case TokenChar.Custom: - writer.WriteStringValue("custom"); - return; + writer.WriteStringValue(MemberCustom); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TokenChar)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs index f8a92c8f479..8f345f8defc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Cluster.g.cs @@ -41,46 +41,58 @@ public enum AllocationExplainDecision Always } -internal sealed class AllocationExplainDecisionConverter : JsonConverter +internal sealed partial class AllocationExplainDecisionConverter : System.Text.Json.Serialization.JsonConverter { - public override AllocationExplainDecision Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("YES"); + private static readonly System.Text.Json.JsonEncodedText MemberThrottle = System.Text.Json.JsonEncodedText.Encode("THROTTLE"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("NO"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("ALWAYS"); + + public override AllocationExplainDecision Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return AllocationExplainDecision.Yes; + } + + if (reader.ValueTextEquals(MemberThrottle)) + { + return AllocationExplainDecision.Throttle; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return AllocationExplainDecision.No; + } + + if (reader.ValueTextEquals(MemberAlways)) { - case "YES": - return AllocationExplainDecision.Yes; - case "THROTTLE": - return AllocationExplainDecision.Throttle; - case "NO": - return AllocationExplainDecision.No; - case "ALWAYS": - return AllocationExplainDecision.Always; + return AllocationExplainDecision.Always; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AllocationExplainDecision)}'."); } - public override void Write(Utf8JsonWriter writer, AllocationExplainDecision value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AllocationExplainDecision value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AllocationExplainDecision.Yes: - writer.WriteStringValue("YES"); - return; + writer.WriteStringValue(MemberYes); + break; case AllocationExplainDecision.Throttle: - writer.WriteStringValue("THROTTLE"); - return; + writer.WriteStringValue(MemberThrottle); + break; case AllocationExplainDecision.No: - writer.WriteStringValue("NO"); - return; + writer.WriteStringValue(MemberNo); + break; case AllocationExplainDecision.Always: - writer.WriteStringValue("ALWAYS"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AllocationExplainDecision)}'."); } - - writer.WriteNullValue(); } } @@ -105,66 +117,94 @@ public enum Decision AllocationDelayed } -internal sealed class DecisionConverter : JsonConverter +internal sealed partial class DecisionConverter : System.Text.Json.Serialization.JsonConverter { - public override Decision Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("yes"); + private static readonly System.Text.Json.JsonEncodedText MemberWorseBalance = System.Text.Json.JsonEncodedText.Encode("worse_balance"); + private static readonly System.Text.Json.JsonEncodedText MemberThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText MemberNoValidShardCopy = System.Text.Json.JsonEncodedText.Encode("no_valid_shard_copy"); + private static readonly System.Text.Json.JsonEncodedText MemberNoAttempt = System.Text.Json.JsonEncodedText.Encode("no_attempt"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberAwaitingInfo = System.Text.Json.JsonEncodedText.Encode("awaiting_info"); + private static readonly System.Text.Json.JsonEncodedText MemberAllocationDelayed = System.Text.Json.JsonEncodedText.Encode("allocation_delayed"); + + public override Decision Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return Decision.Yes; + } + + if (reader.ValueTextEquals(MemberWorseBalance)) { - case "yes": - return Decision.Yes; - case "worse_balance": - return Decision.WorseBalance; - case "throttled": - return Decision.Throttled; - case "no_valid_shard_copy": - return Decision.NoValidShardCopy; - case "no_attempt": - return Decision.NoAttempt; - case "no": - return Decision.No; - case "awaiting_info": - return Decision.AwaitingInfo; - case "allocation_delayed": - return Decision.AllocationDelayed; + return Decision.WorseBalance; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberThrottled)) + { + return Decision.Throttled; + } + + if (reader.ValueTextEquals(MemberNoValidShardCopy)) + { + return Decision.NoValidShardCopy; + } + + if (reader.ValueTextEquals(MemberNoAttempt)) + { + return Decision.NoAttempt; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return Decision.No; + } + + if (reader.ValueTextEquals(MemberAwaitingInfo)) + { + return Decision.AwaitingInfo; + } + + if (reader.ValueTextEquals(MemberAllocationDelayed)) + { + return Decision.AllocationDelayed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Decision)}'."); } - public override void Write(Utf8JsonWriter writer, Decision value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Decision value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Decision.Yes: - writer.WriteStringValue("yes"); - return; + writer.WriteStringValue(MemberYes); + break; case Decision.WorseBalance: - writer.WriteStringValue("worse_balance"); - return; + writer.WriteStringValue(MemberWorseBalance); + break; case Decision.Throttled: - writer.WriteStringValue("throttled"); - return; + writer.WriteStringValue(MemberThrottled); + break; case Decision.NoValidShardCopy: - writer.WriteStringValue("no_valid_shard_copy"); - return; + writer.WriteStringValue(MemberNoValidShardCopy); + break; case Decision.NoAttempt: - writer.WriteStringValue("no_attempt"); - return; + writer.WriteStringValue(MemberNoAttempt); + break; case Decision.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case Decision.AwaitingInfo: - writer.WriteStringValue("awaiting_info"); - return; + writer.WriteStringValue(MemberAwaitingInfo); + break; case Decision.AllocationDelayed: - writer.WriteStringValue("allocation_delayed"); - return; + writer.WriteStringValue(MemberAllocationDelayed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Decision)}'."); } - - writer.WriteNullValue(); } } @@ -203,100 +243,156 @@ public enum UnassignedInformationReason AllocationFailed } -internal sealed class UnassignedInformationReasonConverter : JsonConverter +internal sealed partial class UnassignedInformationReasonConverter : System.Text.Json.Serialization.JsonConverter { - public override UnassignedInformationReason Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRerouteCancelled = System.Text.Json.JsonEncodedText.Encode("REROUTE_CANCELLED"); + private static readonly System.Text.Json.JsonEncodedText MemberReplicaAdded = System.Text.Json.JsonEncodedText.Encode("REPLICA_ADDED"); + private static readonly System.Text.Json.JsonEncodedText MemberReinitialized = System.Text.Json.JsonEncodedText.Encode("REINITIALIZED"); + private static readonly System.Text.Json.JsonEncodedText MemberReallocatedReplica = System.Text.Json.JsonEncodedText.Encode("REALLOCATED_REPLICA"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimaryFailed = System.Text.Json.JsonEncodedText.Encode("PRIMARY_FAILED"); + private static readonly System.Text.Json.JsonEncodedText MemberNodeLeft = System.Text.Json.JsonEncodedText.Encode("NODE_LEFT"); + private static readonly System.Text.Json.JsonEncodedText MemberNewIndexRestored = System.Text.Json.JsonEncodedText.Encode("NEW_INDEX_RESTORED"); + private static readonly System.Text.Json.JsonEncodedText MemberManualAllocation = System.Text.Json.JsonEncodedText.Encode("MANUAL_ALLOCATION"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexReopened = System.Text.Json.JsonEncodedText.Encode("INDEX_REOPENED"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexCreated = System.Text.Json.JsonEncodedText.Encode("INDEX_CREATED"); + private static readonly System.Text.Json.JsonEncodedText MemberForcedEmptyPrimary = System.Text.Json.JsonEncodedText.Encode("FORCED_EMPTY_PRIMARY"); + private static readonly System.Text.Json.JsonEncodedText MemberExistingIndexRestored = System.Text.Json.JsonEncodedText.Encode("EXISTING_INDEX_RESTORED"); + private static readonly System.Text.Json.JsonEncodedText MemberDanglingIndexImported = System.Text.Json.JsonEncodedText.Encode("DANGLING_INDEX_IMPORTED"); + private static readonly System.Text.Json.JsonEncodedText MemberClusterRecovered = System.Text.Json.JsonEncodedText.Encode("CLUSTER_RECOVERED"); + private static readonly System.Text.Json.JsonEncodedText MemberAllocationFailed = System.Text.Json.JsonEncodedText.Encode("ALLOCATION_FAILED"); + + public override UnassignedInformationReason Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRerouteCancelled)) + { + return UnassignedInformationReason.RerouteCancelled; + } + + if (reader.ValueTextEquals(MemberReplicaAdded)) + { + return UnassignedInformationReason.ReplicaAdded; + } + + if (reader.ValueTextEquals(MemberReinitialized)) + { + return UnassignedInformationReason.Reinitialized; + } + + if (reader.ValueTextEquals(MemberReallocatedReplica)) + { + return UnassignedInformationReason.ReallocatedReplica; + } + + if (reader.ValueTextEquals(MemberPrimaryFailed)) + { + return UnassignedInformationReason.PrimaryFailed; + } + + if (reader.ValueTextEquals(MemberNodeLeft)) + { + return UnassignedInformationReason.NodeLeft; + } + + if (reader.ValueTextEquals(MemberNewIndexRestored)) + { + return UnassignedInformationReason.NewIndexRestored; + } + + if (reader.ValueTextEquals(MemberManualAllocation)) + { + return UnassignedInformationReason.ManualAllocation; + } + + if (reader.ValueTextEquals(MemberIndexReopened)) { - case "REROUTE_CANCELLED": - return UnassignedInformationReason.RerouteCancelled; - case "REPLICA_ADDED": - return UnassignedInformationReason.ReplicaAdded; - case "REINITIALIZED": - return UnassignedInformationReason.Reinitialized; - case "REALLOCATED_REPLICA": - return UnassignedInformationReason.ReallocatedReplica; - case "PRIMARY_FAILED": - return UnassignedInformationReason.PrimaryFailed; - case "NODE_LEFT": - return UnassignedInformationReason.NodeLeft; - case "NEW_INDEX_RESTORED": - return UnassignedInformationReason.NewIndexRestored; - case "MANUAL_ALLOCATION": - return UnassignedInformationReason.ManualAllocation; - case "INDEX_REOPENED": - return UnassignedInformationReason.IndexReopened; - case "INDEX_CREATED": - return UnassignedInformationReason.IndexCreated; - case "FORCED_EMPTY_PRIMARY": - return UnassignedInformationReason.ForcedEmptyPrimary; - case "EXISTING_INDEX_RESTORED": - return UnassignedInformationReason.ExistingIndexRestored; - case "DANGLING_INDEX_IMPORTED": - return UnassignedInformationReason.DanglingIndexImported; - case "CLUSTER_RECOVERED": - return UnassignedInformationReason.ClusterRecovered; - case "ALLOCATION_FAILED": - return UnassignedInformationReason.AllocationFailed; + return UnassignedInformationReason.IndexReopened; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberIndexCreated)) + { + return UnassignedInformationReason.IndexCreated; + } + + if (reader.ValueTextEquals(MemberForcedEmptyPrimary)) + { + return UnassignedInformationReason.ForcedEmptyPrimary; + } + + if (reader.ValueTextEquals(MemberExistingIndexRestored)) + { + return UnassignedInformationReason.ExistingIndexRestored; + } + + if (reader.ValueTextEquals(MemberDanglingIndexImported)) + { + return UnassignedInformationReason.DanglingIndexImported; + } + + if (reader.ValueTextEquals(MemberClusterRecovered)) + { + return UnassignedInformationReason.ClusterRecovered; + } + + if (reader.ValueTextEquals(MemberAllocationFailed)) + { + return UnassignedInformationReason.AllocationFailed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(UnassignedInformationReason)}'."); } - public override void Write(Utf8JsonWriter writer, UnassignedInformationReason value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnassignedInformationReason value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case UnassignedInformationReason.RerouteCancelled: - writer.WriteStringValue("REROUTE_CANCELLED"); - return; + writer.WriteStringValue(MemberRerouteCancelled); + break; case UnassignedInformationReason.ReplicaAdded: - writer.WriteStringValue("REPLICA_ADDED"); - return; + writer.WriteStringValue(MemberReplicaAdded); + break; case UnassignedInformationReason.Reinitialized: - writer.WriteStringValue("REINITIALIZED"); - return; + writer.WriteStringValue(MemberReinitialized); + break; case UnassignedInformationReason.ReallocatedReplica: - writer.WriteStringValue("REALLOCATED_REPLICA"); - return; + writer.WriteStringValue(MemberReallocatedReplica); + break; case UnassignedInformationReason.PrimaryFailed: - writer.WriteStringValue("PRIMARY_FAILED"); - return; + writer.WriteStringValue(MemberPrimaryFailed); + break; case UnassignedInformationReason.NodeLeft: - writer.WriteStringValue("NODE_LEFT"); - return; + writer.WriteStringValue(MemberNodeLeft); + break; case UnassignedInformationReason.NewIndexRestored: - writer.WriteStringValue("NEW_INDEX_RESTORED"); - return; + writer.WriteStringValue(MemberNewIndexRestored); + break; case UnassignedInformationReason.ManualAllocation: - writer.WriteStringValue("MANUAL_ALLOCATION"); - return; + writer.WriteStringValue(MemberManualAllocation); + break; case UnassignedInformationReason.IndexReopened: - writer.WriteStringValue("INDEX_REOPENED"); - return; + writer.WriteStringValue(MemberIndexReopened); + break; case UnassignedInformationReason.IndexCreated: - writer.WriteStringValue("INDEX_CREATED"); - return; + writer.WriteStringValue(MemberIndexCreated); + break; case UnassignedInformationReason.ForcedEmptyPrimary: - writer.WriteStringValue("FORCED_EMPTY_PRIMARY"); - return; + writer.WriteStringValue(MemberForcedEmptyPrimary); + break; case UnassignedInformationReason.ExistingIndexRestored: - writer.WriteStringValue("EXISTING_INDEX_RESTORED"); - return; + writer.WriteStringValue(MemberExistingIndexRestored); + break; case UnassignedInformationReason.DanglingIndexImported: - writer.WriteStringValue("DANGLING_INDEX_IMPORTED"); - return; + writer.WriteStringValue(MemberDanglingIndexImported); + break; case UnassignedInformationReason.ClusterRecovered: - writer.WriteStringValue("CLUSTER_RECOVERED"); - return; + writer.WriteStringValue(MemberClusterRecovered); + break; case UnassignedInformationReason.AllocationFailed: - writer.WriteStringValue("ALLOCATION_FAILED"); - return; + writer.WriteStringValue(MemberAllocationFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(UnassignedInformationReason)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs index c3bc56ecfd4..d695e50adef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.HealthReport.g.cs @@ -41,46 +41,58 @@ public enum ImpactArea Backup } -internal sealed class ImpactAreaConverter : JsonConverter +internal sealed partial class ImpactAreaConverter : System.Text.Json.Serialization.JsonConverter { - public override ImpactArea Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberDeploymentManagement = System.Text.Json.JsonEncodedText.Encode("deployment_management"); + private static readonly System.Text.Json.JsonEncodedText MemberBackup = System.Text.Json.JsonEncodedText.Encode("backup"); + + public override ImpactArea Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSearch)) + { + return ImpactArea.Search; + } + + if (reader.ValueTextEquals(MemberIngest)) { - case "search": - return ImpactArea.Search; - case "ingest": - return ImpactArea.Ingest; - case "deployment_management": - return ImpactArea.DeploymentManagement; - case "backup": - return ImpactArea.Backup; + return ImpactArea.Ingest; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDeploymentManagement)) + { + return ImpactArea.DeploymentManagement; + } + + if (reader.ValueTextEquals(MemberBackup)) + { + return ImpactArea.Backup; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ImpactArea)}'."); } - public override void Write(Utf8JsonWriter writer, ImpactArea value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ImpactArea value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ImpactArea.Search: - writer.WriteStringValue("search"); - return; + writer.WriteStringValue(MemberSearch); + break; case ImpactArea.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case ImpactArea.DeploymentManagement: - writer.WriteStringValue("deployment_management"); - return; + writer.WriteStringValue(MemberDeploymentManagement); + break; case ImpactArea.Backup: - writer.WriteStringValue("backup"); - return; + writer.WriteStringValue(MemberBackup); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ImpactArea)}'."); } - - writer.WriteNullValue(); } } @@ -97,45 +109,57 @@ public enum IndicatorHealthStatus Green } -internal sealed class IndicatorHealthStatusConverter : JsonConverter +internal sealed partial class IndicatorHealthStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override IndicatorHealthStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYellow = System.Text.Json.JsonEncodedText.Encode("yellow"); + private static readonly System.Text.Json.JsonEncodedText MemberUnknown = System.Text.Json.JsonEncodedText.Encode("unknown"); + private static readonly System.Text.Json.JsonEncodedText MemberRed = System.Text.Json.JsonEncodedText.Encode("red"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen = System.Text.Json.JsonEncodedText.Encode("green"); + + public override IndicatorHealthStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYellow)) + { + return IndicatorHealthStatus.Yellow; + } + + if (reader.ValueTextEquals(MemberUnknown)) { - case "yellow": - return IndicatorHealthStatus.Yellow; - case "unknown": - return IndicatorHealthStatus.Unknown; - case "red": - return IndicatorHealthStatus.Red; - case "green": - return IndicatorHealthStatus.Green; + return IndicatorHealthStatus.Unknown; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRed)) + { + return IndicatorHealthStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen)) + { + return IndicatorHealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndicatorHealthStatus)}'."); } - public override void Write(Utf8JsonWriter writer, IndicatorHealthStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicatorHealthStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndicatorHealthStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case IndicatorHealthStatus.Unknown: - writer.WriteStringValue("unknown"); - return; + writer.WriteStringValue(MemberUnknown); + break; case IndicatorHealthStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case IndicatorHealthStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndicatorHealthStatus)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs index d585ddc3ee1..5b37649defd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.Search.g.cs @@ -60,41 +60,49 @@ public enum BoundaryScanner Chars } -internal sealed class BoundaryScannerConverter : JsonConverter +internal sealed partial class BoundaryScannerConverter : System.Text.Json.Serialization.JsonConverter { - public override BoundaryScanner Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWord = System.Text.Json.JsonEncodedText.Encode("word"); + private static readonly System.Text.Json.JsonEncodedText MemberSentence = System.Text.Json.JsonEncodedText.Encode("sentence"); + private static readonly System.Text.Json.JsonEncodedText MemberChars = System.Text.Json.JsonEncodedText.Encode("chars"); + + public override BoundaryScanner Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWord)) { - case "word": - return BoundaryScanner.Word; - case "sentence": - return BoundaryScanner.Sentence; - case "chars": - return BoundaryScanner.Chars; + return BoundaryScanner.Word; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSentence)) + { + return BoundaryScanner.Sentence; + } + + if (reader.ValueTextEquals(MemberChars)) + { + return BoundaryScanner.Chars; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(BoundaryScanner)}'."); } - public override void Write(Utf8JsonWriter writer, BoundaryScanner value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, BoundaryScanner value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case BoundaryScanner.Word: - writer.WriteStringValue("word"); - return; + writer.WriteStringValue(MemberWord); + break; case BoundaryScanner.Sentence: - writer.WriteStringValue("sentence"); - return; + writer.WriteStringValue(MemberSentence); + break; case BoundaryScanner.Chars: - writer.WriteStringValue("chars"); - return; + writer.WriteStringValue(MemberChars); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(BoundaryScanner)}'."); } - - writer.WriteNullValue(); } } @@ -107,36 +115,40 @@ public enum HighlighterEncoder Default } -internal sealed class HighlighterEncoderConverter : JsonConverter +internal sealed partial class HighlighterEncoderConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterEncoder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberHtml = System.Text.Json.JsonEncodedText.Encode("html"); + private static readonly System.Text.Json.JsonEncodedText MemberDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override HighlighterEncoder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberHtml)) { - case "html": - return HighlighterEncoder.Html; - case "default": - return HighlighterEncoder.Default; + return HighlighterEncoder.Html; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDefault)) + { + return HighlighterEncoder.Default; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterEncoder)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterEncoder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterEncoder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterEncoder.Html: - writer.WriteStringValue("html"); - return; + writer.WriteStringValue(MemberHtml); + break; case HighlighterEncoder.Default: - writer.WriteStringValue("default"); - return; + writer.WriteStringValue(MemberDefault); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterEncoder)}'."); } - - writer.WriteNullValue(); } } @@ -149,36 +161,40 @@ public enum HighlighterFragmenter Simple } -internal sealed class HighlighterFragmenterConverter : JsonConverter +internal sealed partial class HighlighterFragmenterConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterFragmenter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpan = System.Text.Json.JsonEncodedText.Encode("span"); + private static readonly System.Text.Json.JsonEncodedText MemberSimple = System.Text.Json.JsonEncodedText.Encode("simple"); + + public override HighlighterFragmenter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpan)) + { + return HighlighterFragmenter.Span; + } + + if (reader.ValueTextEquals(MemberSimple)) { - case "span": - return HighlighterFragmenter.Span; - case "simple": - return HighlighterFragmenter.Simple; + return HighlighterFragmenter.Simple; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterFragmenter)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterFragmenter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterFragmenter value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterFragmenter.Span: - writer.WriteStringValue("span"); - return; + writer.WriteStringValue(MemberSpan); + break; case HighlighterFragmenter.Simple: - writer.WriteStringValue("simple"); - return; + writer.WriteStringValue(MemberSimple); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterFragmenter)}'."); } - - writer.WriteNullValue(); } } @@ -189,31 +205,31 @@ public enum HighlighterOrder Score } -internal sealed class HighlighterOrderConverter : JsonConverter +internal sealed partial class HighlighterOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScore = System.Text.Json.JsonEncodedText.Encode("score"); + + public override HighlighterOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScore)) { - case "score": - return HighlighterOrder.Score; + return HighlighterOrder.Score; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterOrder)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterOrder.Score: - writer.WriteStringValue("score"); - return; + writer.WriteStringValue(MemberScore); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterOrder)}'."); } - - writer.WriteNullValue(); } } @@ -224,31 +240,31 @@ public enum HighlighterTagsSchema Styled } -internal sealed class HighlighterTagsSchemaConverter : JsonConverter +internal sealed partial class HighlighterTagsSchemaConverter : System.Text.Json.Serialization.JsonConverter { - public override HighlighterTagsSchema Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStyled = System.Text.Json.JsonEncodedText.Encode("styled"); + + public override HighlighterTagsSchema Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStyled)) { - case "styled": - return HighlighterTagsSchema.Styled; + return HighlighterTagsSchema.Styled; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HighlighterTagsSchema)}'."); } - public override void Write(Utf8JsonWriter writer, HighlighterTagsSchema value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HighlighterTagsSchema value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HighlighterTagsSchema.Styled: - writer.WriteStringValue("styled"); - return; + writer.WriteStringValue(MemberStyled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HighlighterTagsSchema)}'."); } - - writer.WriteNullValue(); } } @@ -256,9 +272,11 @@ public override void Write(Utf8JsonWriter writer, HighlighterTagsSchema value, J public readonly partial struct HighlighterType : IEnumStruct { public HighlighterType(string value) => Value = value; - +#if NET7_0_OR_GREATER + static HighlighterType IEnumStruct.Create(string value) => value; +#else HighlighterType IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -336,51 +354,67 @@ public enum ScoreMode Avg } -internal sealed class ScoreModeConverter : JsonConverter +internal sealed partial class ScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTotal = System.Text.Json.JsonEncodedText.Encode("total"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override ScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "total": - return ScoreMode.Total; - case "multiply": - return ScoreMode.Multiply; - case "min": - return ScoreMode.Min; - case "max": - return ScoreMode.Max; - case "avg": - return ScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTotal)) + { + return ScoreMode.Total; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return ScoreMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return ScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return ScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return ScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, ScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ScoreMode.Total: - writer.WriteStringValue("total"); - return; + writer.WriteStringValue(MemberTotal); + break; case ScoreMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case ScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case ScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case ScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -424,51 +458,67 @@ public enum StringDistance DamerauLevenshtein } -internal sealed class StringDistanceConverter : JsonConverter +internal sealed partial class StringDistanceConverter : System.Text.Json.Serialization.JsonConverter { - public override StringDistance Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNgram = System.Text.Json.JsonEncodedText.Encode("ngram"); + private static readonly System.Text.Json.JsonEncodedText MemberLevenshtein = System.Text.Json.JsonEncodedText.Encode("levenshtein"); + private static readonly System.Text.Json.JsonEncodedText MemberJaroWinkler = System.Text.Json.JsonEncodedText.Encode("jaro_winkler"); + private static readonly System.Text.Json.JsonEncodedText MemberInternal = System.Text.Json.JsonEncodedText.Encode("internal"); + private static readonly System.Text.Json.JsonEncodedText MemberDamerauLevenshtein = System.Text.Json.JsonEncodedText.Encode("damerau_levenshtein"); + + public override StringDistance Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "ngram": - return StringDistance.Ngram; - case "levenshtein": - return StringDistance.Levenshtein; - case "jaro_winkler": - return StringDistance.JaroWinkler; - case "internal": - return StringDistance.Internal; - case "damerau_levenshtein": - return StringDistance.DamerauLevenshtein; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNgram)) + { + return StringDistance.Ngram; + } + + if (reader.ValueTextEquals(MemberLevenshtein)) + { + return StringDistance.Levenshtein; + } + + if (reader.ValueTextEquals(MemberJaroWinkler)) + { + return StringDistance.JaroWinkler; + } + + if (reader.ValueTextEquals(MemberInternal)) + { + return StringDistance.Internal; + } + + if (reader.ValueTextEquals(MemberDamerauLevenshtein)) + { + return StringDistance.DamerauLevenshtein; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(StringDistance)}'."); } - public override void Write(Utf8JsonWriter writer, StringDistance value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StringDistance value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case StringDistance.Ngram: - writer.WriteStringValue("ngram"); - return; + writer.WriteStringValue(MemberNgram); + break; case StringDistance.Levenshtein: - writer.WriteStringValue("levenshtein"); - return; + writer.WriteStringValue(MemberLevenshtein); + break; case StringDistance.JaroWinkler: - writer.WriteStringValue("jaro_winkler"); - return; + writer.WriteStringValue(MemberJaroWinkler); + break; case StringDistance.Internal: - writer.WriteStringValue("internal"); - return; + writer.WriteStringValue(MemberInternal); + break; case StringDistance.DamerauLevenshtein: - writer.WriteStringValue("damerau_levenshtein"); - return; + writer.WriteStringValue(MemberDamerauLevenshtein); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(StringDistance)}'."); } - - writer.WriteNullValue(); } } @@ -491,36 +541,40 @@ public enum SuggestSort Frequency } -internal sealed class SuggestSortConverter : JsonConverter +internal sealed partial class SuggestSortConverter : System.Text.Json.Serialization.JsonConverter { - public override SuggestSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScore = System.Text.Json.JsonEncodedText.Encode("score"); + private static readonly System.Text.Json.JsonEncodedText MemberFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + + public override SuggestSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScore)) { - case "score": - return SuggestSort.Score; - case "frequency": - return SuggestSort.Frequency; + return SuggestSort.Score; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFrequency)) + { + return SuggestSort.Frequency; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SuggestSort)}'."); } - public override void Write(Utf8JsonWriter writer, SuggestSort value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestSort value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SuggestSort.Score: - writer.WriteStringValue("score"); - return; + writer.WriteStringValue(MemberScore); + break; case SuggestSort.Frequency: - writer.WriteStringValue("frequency"); - return; + writer.WriteStringValue(MemberFrequency); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SuggestSort)}'."); } - - writer.WriteNullValue(); } } @@ -543,35 +597,39 @@ public enum TotalHitsRelation Eq } -internal sealed class TotalHitsRelationConverter : JsonConverter +internal sealed partial class TotalHitsRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override TotalHitsRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberEq = System.Text.Json.JsonEncodedText.Encode("eq"); + + public override TotalHitsRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGte)) { - case "gte": - return TotalHitsRelation.Gte; - case "eq": - return TotalHitsRelation.Eq; + return TotalHitsRelation.Gte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberEq)) + { + return TotalHitsRelation.Eq; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TotalHitsRelation)}'."); } - public override void Write(Utf8JsonWriter writer, TotalHitsRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TotalHitsRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TotalHitsRelation.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case TotalHitsRelation.Eq: - writer.WriteStringValue("eq"); - return; + writer.WriteStringValue(MemberEq); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TotalHitsRelation)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs index ba5a373ae24..9d35ae7a12e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Core.SearchMvt.g.cs @@ -37,36 +37,40 @@ public enum GridAggregationType Geohex } -internal sealed class GridAggregationTypeConverter : JsonConverter +internal sealed partial class GridAggregationTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GridAggregationType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGeotile = System.Text.Json.JsonEncodedText.Encode("geotile"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohex = System.Text.Json.JsonEncodedText.Encode("geohex"); + + public override GridAggregationType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGeotile)) + { + return GridAggregationType.Geotile; + } + + if (reader.ValueTextEquals(MemberGeohex)) { - case "geotile": - return GridAggregationType.Geotile; - case "geohex": - return GridAggregationType.Geohex; + return GridAggregationType.Geohex; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GridAggregationType)}'."); } - public override void Write(Utf8JsonWriter writer, GridAggregationType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GridAggregationType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GridAggregationType.Geotile: - writer.WriteStringValue("geotile"); - return; + writer.WriteStringValue(MemberGeotile); + break; case GridAggregationType.Geohex: - writer.WriteStringValue("geohex"); - return; + writer.WriteStringValue(MemberGeohex); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GridAggregationType)}'."); } - - writer.WriteNullValue(); } } @@ -81,40 +85,48 @@ public enum GridType Centroid } -internal sealed class GridTypeConverter : JsonConverter +internal sealed partial class GridTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GridType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPoint = System.Text.Json.JsonEncodedText.Encode("point"); + private static readonly System.Text.Json.JsonEncodedText MemberGrid = System.Text.Json.JsonEncodedText.Encode("grid"); + private static readonly System.Text.Json.JsonEncodedText MemberCentroid = System.Text.Json.JsonEncodedText.Encode("centroid"); + + public override GridType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPoint)) { - case "point": - return GridType.Point; - case "grid": - return GridType.Grid; - case "centroid": - return GridType.Centroid; + return GridType.Point; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGrid)) + { + return GridType.Grid; + } + + if (reader.ValueTextEquals(MemberCentroid)) + { + return GridType.Centroid; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GridType)}'."); } - public override void Write(Utf8JsonWriter writer, GridType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GridType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GridType.Point: - writer.WriteStringValue("point"); - return; + writer.WriteStringValue(MemberPoint); + break; case GridType.Grid: - writer.WriteStringValue("grid"); - return; + writer.WriteStringValue(MemberGrid); + break; case GridType.Centroid: - writer.WriteStringValue("centroid"); - return; + writer.WriteStringValue(MemberCentroid); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GridType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs index b7c7782a161..420b680bc2d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.CrossClusterReplication.g.cs @@ -37,35 +37,39 @@ public enum FollowerIndexStatus Active } -internal sealed class FollowerIndexStatusConverter : JsonConverter +internal sealed partial class FollowerIndexStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override FollowerIndexStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPaused = System.Text.Json.JsonEncodedText.Encode("paused"); + private static readonly System.Text.Json.JsonEncodedText MemberActive = System.Text.Json.JsonEncodedText.Encode("active"); + + public override FollowerIndexStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPaused)) { - case "paused": - return FollowerIndexStatus.Paused; - case "active": - return FollowerIndexStatus.Active; + return FollowerIndexStatus.Paused; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberActive)) + { + return FollowerIndexStatus.Active; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FollowerIndexStatus)}'."); } - public override void Write(Utf8JsonWriter writer, FollowerIndexStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FollowerIndexStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FollowerIndexStatus.Paused: - writer.WriteStringValue("paused"); - return; + writer.WriteStringValue(MemberPaused); + break; case FollowerIndexStatus.Active: - writer.WriteStringValue("active"); - return; + writer.WriteStringValue(MemberActive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FollowerIndexStatus)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs index e515e745ac1..95030b980e4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Enrich.g.cs @@ -41,46 +41,58 @@ public enum EnrichPolicyPhase Complete } -internal sealed class EnrichPolicyPhaseConverter : JsonConverter +internal sealed partial class EnrichPolicyPhaseConverter : System.Text.Json.Serialization.JsonConverter { - public override EnrichPolicyPhase Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberScheduled = System.Text.Json.JsonEncodedText.Encode("SCHEDULED"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("RUNNING"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("FAILED"); + private static readonly System.Text.Json.JsonEncodedText MemberComplete = System.Text.Json.JsonEncodedText.Encode("COMPLETE"); + + public override EnrichPolicyPhase Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberScheduled)) + { + return EnrichPolicyPhase.Scheduled; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return EnrichPolicyPhase.Running; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return EnrichPolicyPhase.Failed; + } + + if (reader.ValueTextEquals(MemberComplete)) { - case "SCHEDULED": - return EnrichPolicyPhase.Scheduled; - case "RUNNING": - return EnrichPolicyPhase.Running; - case "FAILED": - return EnrichPolicyPhase.Failed; - case "COMPLETE": - return EnrichPolicyPhase.Complete; + return EnrichPolicyPhase.Complete; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EnrichPolicyPhase)}'."); } - public override void Write(Utf8JsonWriter writer, EnrichPolicyPhase value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EnrichPolicyPhase value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EnrichPolicyPhase.Scheduled: - writer.WriteStringValue("SCHEDULED"); - return; + writer.WriteStringValue(MemberScheduled); + break; case EnrichPolicyPhase.Running: - writer.WriteStringValue("RUNNING"); - return; + writer.WriteStringValue(MemberRunning); + break; case EnrichPolicyPhase.Failed: - writer.WriteStringValue("FAILED"); - return; + writer.WriteStringValue(MemberFailed); + break; case EnrichPolicyPhase.Complete: - writer.WriteStringValue("COMPLETE"); - return; + writer.WriteStringValue(MemberComplete); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EnrichPolicyPhase)}'."); } - - writer.WriteNullValue(); } } @@ -95,40 +107,48 @@ public enum PolicyType GeoMatch } -internal sealed class PolicyTypeConverter : JsonConverter +internal sealed partial class PolicyTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override PolicyType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText MemberMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoMatch = System.Text.Json.JsonEncodedText.Encode("geo_match"); + + public override PolicyType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRange)) + { + return PolicyType.Range; + } + + if (reader.ValueTextEquals(MemberMatch)) { - case "range": - return PolicyType.Range; - case "match": - return PolicyType.Match; - case "geo_match": - return PolicyType.GeoMatch; + return PolicyType.Match; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeoMatch)) + { + return PolicyType.GeoMatch; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(PolicyType)}'."); } - public override void Write(Utf8JsonWriter writer, PolicyType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PolicyType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case PolicyType.Range: - writer.WriteStringValue("range"); - return; + writer.WriteStringValue(MemberRange); + break; case PolicyType.Match: - writer.WriteStringValue("match"); - return; + writer.WriteStringValue(MemberMatch); + break; case PolicyType.GeoMatch: - writer.WriteStringValue("geo_match"); - return; + writer.WriteStringValue(MemberGeoMatch); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(PolicyType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs index d4d3772640b..c3275327608 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Eql.g.cs @@ -47,35 +47,39 @@ public enum ResultPosition Head } -internal sealed class ResultPositionConverter : JsonConverter +internal sealed partial class ResultPositionConverter : System.Text.Json.Serialization.JsonConverter { - public override ResultPosition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTail = System.Text.Json.JsonEncodedText.Encode("tail"); + private static readonly System.Text.Json.JsonEncodedText MemberHead = System.Text.Json.JsonEncodedText.Encode("head"); + + public override ResultPosition Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTail)) { - case "tail": - return ResultPosition.Tail; - case "head": - return ResultPosition.Head; + return ResultPosition.Tail; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberHead)) + { + return ResultPosition.Head; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ResultPosition)}'."); } - public override void Write(Utf8JsonWriter writer, ResultPosition value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResultPosition value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ResultPosition.Tail: - writer.WriteStringValue("tail"); - return; + writer.WriteStringValue(MemberTail); + break; case ResultPosition.Head: - writer.WriteStringValue("head"); - return; + writer.WriteStringValue(MemberHead); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ResultPosition)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs index 88f73b46228..9b58823cad0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Esql.g.cs @@ -49,65 +49,93 @@ public enum EsqlFormat Arrow } -internal sealed class EsqlFormatConverter : JsonConverter +internal sealed partial class EsqlFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override EsqlFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYaml = System.Text.Json.JsonEncodedText.Encode("yaml"); + private static readonly System.Text.Json.JsonEncodedText MemberTxt = System.Text.Json.JsonEncodedText.Encode("txt"); + private static readonly System.Text.Json.JsonEncodedText MemberTsv = System.Text.Json.JsonEncodedText.Encode("tsv"); + private static readonly System.Text.Json.JsonEncodedText MemberSmile = System.Text.Json.JsonEncodedText.Encode("smile"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText MemberCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText MemberCbor = System.Text.Json.JsonEncodedText.Encode("cbor"); + private static readonly System.Text.Json.JsonEncodedText MemberArrow = System.Text.Json.JsonEncodedText.Encode("arrow"); + + public override EsqlFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYaml)) + { + return EsqlFormat.Yaml; + } + + if (reader.ValueTextEquals(MemberTxt)) + { + return EsqlFormat.Txt; + } + + if (reader.ValueTextEquals(MemberTsv)) + { + return EsqlFormat.Tsv; + } + + if (reader.ValueTextEquals(MemberSmile)) { - case "yaml": - return EsqlFormat.Yaml; - case "txt": - return EsqlFormat.Txt; - case "tsv": - return EsqlFormat.Tsv; - case "smile": - return EsqlFormat.Smile; - case "json": - return EsqlFormat.Json; - case "csv": - return EsqlFormat.Csv; - case "cbor": - return EsqlFormat.Cbor; - case "arrow": - return EsqlFormat.Arrow; + return EsqlFormat.Smile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return EsqlFormat.Json; + } + + if (reader.ValueTextEquals(MemberCsv)) + { + return EsqlFormat.Csv; + } + + if (reader.ValueTextEquals(MemberCbor)) + { + return EsqlFormat.Cbor; + } + + if (reader.ValueTextEquals(MemberArrow)) + { + return EsqlFormat.Arrow; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EsqlFormat)}'."); } - public override void Write(Utf8JsonWriter writer, EsqlFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EsqlFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EsqlFormat.Yaml: - writer.WriteStringValue("yaml"); - return; + writer.WriteStringValue(MemberYaml); + break; case EsqlFormat.Txt: - writer.WriteStringValue("txt"); - return; + writer.WriteStringValue(MemberTxt); + break; case EsqlFormat.Tsv: - writer.WriteStringValue("tsv"); - return; + writer.WriteStringValue(MemberTsv); + break; case EsqlFormat.Smile: - writer.WriteStringValue("smile"); - return; + writer.WriteStringValue(MemberSmile); + break; case EsqlFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; case EsqlFormat.Csv: - writer.WriteStringValue("csv"); - return; + writer.WriteStringValue(MemberCsv); + break; case EsqlFormat.Cbor: - writer.WriteStringValue("cbor"); - return; + writer.WriteStringValue(MemberCbor); + break; case EsqlFormat.Arrow: - writer.WriteStringValue("arrow"); - return; + writer.WriteStringValue(MemberArrow); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EsqlFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs index a5fbdb62bbf..6bcd06ceb3f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.IndexManagement.g.cs @@ -39,41 +39,49 @@ public enum Feature Aliases } -internal sealed class FeatureConverter : JsonConverter +internal sealed partial class FeatureConverter : System.Text.Json.Serialization.JsonConverter { - public override Feature Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText MemberMappings = System.Text.Json.JsonEncodedText.Encode("mappings"); + private static readonly System.Text.Json.JsonEncodedText MemberAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + + public override Feature Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSettings)) + { + return Feature.Settings; + } + + if (reader.ValueTextEquals(MemberMappings)) + { + return Feature.Mappings; + } + + if (reader.ValueTextEquals(MemberAliases)) { - case "settings": - return Feature.Settings; - case "mappings": - return Feature.Mappings; - case "aliases": - return Feature.Aliases; + return Feature.Aliases; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Feature)}'."); } - public override void Write(Utf8JsonWriter writer, Feature value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Feature value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Feature.Settings: - writer.WriteStringValue("settings"); - return; + writer.WriteStringValue(MemberSettings); + break; case Feature.Mappings: - writer.WriteStringValue("mappings"); - return; + writer.WriteStringValue(MemberMappings); + break; case Feature.Aliases: - writer.WriteStringValue("aliases"); - return; + writer.WriteStringValue(MemberAliases); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Feature)}'."); } - - writer.WriteNullValue(); } } @@ -88,41 +96,49 @@ public enum IndexCheckOnStartup Checksum } -internal sealed class IndexCheckOnStartupConverter : JsonConverter +internal sealed partial class IndexCheckOnStartupConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexCheckOnStartup Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrue = System.Text.Json.JsonEncodedText.Encode("true"); + private static readonly System.Text.Json.JsonEncodedText MemberFalse = System.Text.Json.JsonEncodedText.Encode("false"); + private static readonly System.Text.Json.JsonEncodedText MemberChecksum = System.Text.Json.JsonEncodedText.Encode("checksum"); + + public override IndexCheckOnStartup Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrue)) { - case "true": - return IndexCheckOnStartup.True; - case "false": - return IndexCheckOnStartup.False; - case "checksum": - return IndexCheckOnStartup.Checksum; + return IndexCheckOnStartup.True; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFalse)) + { + return IndexCheckOnStartup.False; + } + + if (reader.ValueTextEquals(MemberChecksum)) + { + return IndexCheckOnStartup.Checksum; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexCheckOnStartup)}'."); } - public override void Write(Utf8JsonWriter writer, IndexCheckOnStartup value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexCheckOnStartup value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexCheckOnStartup.True: - writer.WriteStringValue("true"); - return; + writer.WriteStringValue(MemberTrue); + break; case IndexCheckOnStartup.False: - writer.WriteStringValue("false"); - return; + writer.WriteStringValue(MemberFalse); + break; case IndexCheckOnStartup.Checksum: - writer.WriteStringValue("checksum"); - return; + writer.WriteStringValue(MemberChecksum); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexCheckOnStartup)}'."); } - - writer.WriteNullValue(); } } @@ -135,36 +151,40 @@ public enum IndexMetadataState Close } -internal sealed class IndexMetadataStateConverter : JsonConverter +internal sealed partial class IndexMetadataStateConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexMetadataState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpen = System.Text.Json.JsonEncodedText.Encode("open"); + private static readonly System.Text.Json.JsonEncodedText MemberClose = System.Text.Json.JsonEncodedText.Encode("close"); + + public override IndexMetadataState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpen)) { - case "open": - return IndexMetadataState.Open; - case "close": - return IndexMetadataState.Close; + return IndexMetadataState.Open; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberClose)) + { + return IndexMetadataState.Close; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexMetadataState)}'."); } - public override void Write(Utf8JsonWriter writer, IndexMetadataState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexMetadataState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexMetadataState.Open: - writer.WriteStringValue("open"); - return; + writer.WriteStringValue(MemberOpen); + break; case IndexMetadataState.Close: - writer.WriteStringValue("close"); - return; + writer.WriteStringValue(MemberClose); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexMetadataState)}'."); } - - writer.WriteNullValue(); } } @@ -181,46 +201,58 @@ public enum IndexRoutingAllocationOptions All } -internal sealed class IndexRoutingAllocationOptionsConverter : JsonConverter +internal sealed partial class IndexRoutingAllocationOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexRoutingAllocationOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPrimaries = System.Text.Json.JsonEncodedText.Encode("primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNewPrimaries = System.Text.Json.JsonEncodedText.Encode("new_primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override IndexRoutingAllocationOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPrimaries)) + { + return IndexRoutingAllocationOptions.Primaries; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return IndexRoutingAllocationOptions.None; + } + + if (reader.ValueTextEquals(MemberNewPrimaries)) + { + return IndexRoutingAllocationOptions.NewPrimaries; + } + + if (reader.ValueTextEquals(MemberAll)) { - case "primaries": - return IndexRoutingAllocationOptions.Primaries; - case "none": - return IndexRoutingAllocationOptions.None; - case "new_primaries": - return IndexRoutingAllocationOptions.NewPrimaries; - case "all": - return IndexRoutingAllocationOptions.All; + return IndexRoutingAllocationOptions.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexRoutingAllocationOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexRoutingAllocationOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexRoutingAllocationOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexRoutingAllocationOptions.Primaries: - writer.WriteStringValue("primaries"); - return; + writer.WriteStringValue(MemberPrimaries); + break; case IndexRoutingAllocationOptions.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case IndexRoutingAllocationOptions.NewPrimaries: - writer.WriteStringValue("new_primaries"); - return; + writer.WriteStringValue(MemberNewPrimaries); + break; case IndexRoutingAllocationOptions.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexRoutingAllocationOptions)}'."); } - - writer.WriteNullValue(); } } @@ -237,46 +269,58 @@ public enum IndexRoutingRebalanceOptions All } -internal sealed class IndexRoutingRebalanceOptionsConverter : JsonConverter +internal sealed partial class IndexRoutingRebalanceOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexRoutingRebalanceOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReplicas = System.Text.Json.JsonEncodedText.Encode("replicas"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimaries = System.Text.Json.JsonEncodedText.Encode("primaries"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override IndexRoutingRebalanceOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReplicas)) + { + return IndexRoutingRebalanceOptions.Replicas; + } + + if (reader.ValueTextEquals(MemberPrimaries)) { - case "replicas": - return IndexRoutingRebalanceOptions.Replicas; - case "primaries": - return IndexRoutingRebalanceOptions.Primaries; - case "none": - return IndexRoutingRebalanceOptions.None; - case "all": - return IndexRoutingRebalanceOptions.All; + return IndexRoutingRebalanceOptions.Primaries; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNone)) + { + return IndexRoutingRebalanceOptions.None; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return IndexRoutingRebalanceOptions.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexRoutingRebalanceOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexRoutingRebalanceOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexRoutingRebalanceOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexRoutingRebalanceOptions.Replicas: - writer.WriteStringValue("replicas"); - return; + writer.WriteStringValue(MemberReplicas); + break; case IndexRoutingRebalanceOptions.Primaries: - writer.WriteStringValue("primaries"); - return; + writer.WriteStringValue(MemberPrimaries); + break; case IndexRoutingRebalanceOptions.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case IndexRoutingRebalanceOptions.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexRoutingRebalanceOptions)}'."); } - - writer.WriteNullValue(); } } @@ -291,41 +335,49 @@ public enum ManagedBy Datastream } -internal sealed class ManagedByConverter : JsonConverter +internal sealed partial class ManagedByConverter : System.Text.Json.Serialization.JsonConverter { - public override ManagedBy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnmanaged = System.Text.Json.JsonEncodedText.Encode("Unmanaged"); + private static readonly System.Text.Json.JsonEncodedText MemberIlm = System.Text.Json.JsonEncodedText.Encode("Index Lifecycle Management"); + private static readonly System.Text.Json.JsonEncodedText MemberDatastream = System.Text.Json.JsonEncodedText.Encode("Data stream lifecycle"); + + public override ManagedBy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUnmanaged)) { - case "Unmanaged": - return ManagedBy.Unmanaged; - case "Index Lifecycle Management": - return ManagedBy.Ilm; - case "Data stream lifecycle": - return ManagedBy.Datastream; + return ManagedBy.Unmanaged; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberIlm)) + { + return ManagedBy.Ilm; + } + + if (reader.ValueTextEquals(MemberDatastream)) + { + return ManagedBy.Datastream; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ManagedBy)}'."); } - public override void Write(Utf8JsonWriter writer, ManagedBy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ManagedBy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ManagedBy.Unmanaged: - writer.WriteStringValue("Unmanaged"); - return; + writer.WriteStringValue(MemberUnmanaged); + break; case ManagedBy.Ilm: - writer.WriteStringValue("Index Lifecycle Management"); - return; + writer.WriteStringValue(MemberIlm); + break; case ManagedBy.Datastream: - writer.WriteStringValue("Data stream lifecycle"); - return; + writer.WriteStringValue(MemberDatastream); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ManagedBy)}'."); } - - writer.WriteNullValue(); } } @@ -338,36 +390,40 @@ public enum NumericFielddataFormat Array } -internal sealed class NumericFielddataFormatConverter : JsonConverter +internal sealed partial class NumericFielddataFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override NumericFielddataFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + private static readonly System.Text.Json.JsonEncodedText MemberArray = System.Text.Json.JsonEncodedText.Encode("array"); + + public override NumericFielddataFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDisabled)) + { + return NumericFielddataFormat.Disabled; + } + + if (reader.ValueTextEquals(MemberArray)) { - case "disabled": - return NumericFielddataFormat.Disabled; - case "array": - return NumericFielddataFormat.Array; + return NumericFielddataFormat.Array; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NumericFielddataFormat)}'."); } - public override void Write(Utf8JsonWriter writer, NumericFielddataFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumericFielddataFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NumericFielddataFormat.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; case NumericFielddataFormat.Array: - writer.WriteStringValue("array"); - return; + writer.WriteStringValue(MemberArray); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NumericFielddataFormat)}'."); } - - writer.WriteNullValue(); } } @@ -380,36 +436,40 @@ public enum SegmentSortMissing First } -internal sealed class SegmentSortMissingConverter : JsonConverter +internal sealed partial class SegmentSortMissingConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortMissing Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLast = System.Text.Json.JsonEncodedText.Encode("_last"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("_first"); + + public override SegmentSortMissing Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLast)) { - case "_last": - return SegmentSortMissing.Last; - case "_first": - return SegmentSortMissing.First; + return SegmentSortMissing.Last; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFirst)) + { + return SegmentSortMissing.First; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortMissing)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortMissing value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortMissing value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortMissing.Last: - writer.WriteStringValue("_last"); - return; + writer.WriteStringValue(MemberLast); + break; case SegmentSortMissing.First: - writer.WriteStringValue("_first"); - return; + writer.WriteStringValue(MemberFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortMissing)}'."); } - - writer.WriteNullValue(); } } @@ -422,38 +482,42 @@ public enum SegmentSortMode Max } -internal sealed class SegmentSortModeConverter : JsonConverter +internal sealed partial class SegmentSortModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMin1 = System.Text.Json.JsonEncodedText.Encode("MIN"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberMax1 = System.Text.Json.JsonEncodedText.Encode("MAX"); + + public override SegmentSortMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMin) || reader.ValueTextEquals(MemberMin1)) + { + return SegmentSortMode.Min; + } + + if (reader.ValueTextEquals(MemberMax) || reader.ValueTextEquals(MemberMax1)) { - case "min": - case "MIN": - return SegmentSortMode.Min; - case "max": - case "MAX": - return SegmentSortMode.Max; + return SegmentSortMode.Max; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortMode)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case SegmentSortMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortMode)}'."); } - - writer.WriteNullValue(); } } @@ -466,38 +530,42 @@ public enum SegmentSortOrder Asc } -internal sealed class SegmentSortOrderConverter : JsonConverter +internal sealed partial class SegmentSortOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override SegmentSortOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDesc = System.Text.Json.JsonEncodedText.Encode("desc"); + private static readonly System.Text.Json.JsonEncodedText MemberDesc1 = System.Text.Json.JsonEncodedText.Encode("DESC"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc = System.Text.Json.JsonEncodedText.Encode("asc"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc1 = System.Text.Json.JsonEncodedText.Encode("ASC"); + + public override SegmentSortOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDesc) || reader.ValueTextEquals(MemberDesc1)) { - case "desc": - case "DESC": - return SegmentSortOrder.Desc; - case "asc": - case "ASC": - return SegmentSortOrder.Asc; + return SegmentSortOrder.Desc; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAsc) || reader.ValueTextEquals(MemberAsc1)) + { + return SegmentSortOrder.Asc; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SegmentSortOrder)}'."); } - public override void Write(Utf8JsonWriter writer, SegmentSortOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SegmentSortOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SegmentSortOrder.Desc: - writer.WriteStringValue("desc"); - return; + writer.WriteStringValue(MemberDesc); + break; case SegmentSortOrder.Asc: - writer.WriteStringValue("asc"); - return; + writer.WriteStringValue(MemberAsc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SegmentSortOrder)}'."); } - - writer.WriteNullValue(); } } @@ -514,46 +582,58 @@ public enum ShardRoutingState Initializing } -internal sealed class ShardRoutingStateConverter : JsonConverter +internal sealed partial class ShardRoutingStateConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardRoutingState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnassigned = System.Text.Json.JsonEncodedText.Encode("UNASSIGNED"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("STARTED"); + private static readonly System.Text.Json.JsonEncodedText MemberRelocating = System.Text.Json.JsonEncodedText.Encode("RELOCATING"); + private static readonly System.Text.Json.JsonEncodedText MemberInitializing = System.Text.Json.JsonEncodedText.Encode("INITIALIZING"); + + public override ShardRoutingState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUnassigned)) + { + return ShardRoutingState.Unassigned; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return ShardRoutingState.Started; + } + + if (reader.ValueTextEquals(MemberRelocating)) + { + return ShardRoutingState.Relocating; + } + + if (reader.ValueTextEquals(MemberInitializing)) { - case "UNASSIGNED": - return ShardRoutingState.Unassigned; - case "STARTED": - return ShardRoutingState.Started; - case "RELOCATING": - return ShardRoutingState.Relocating; - case "INITIALIZING": - return ShardRoutingState.Initializing; + return ShardRoutingState.Initializing; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardRoutingState)}'."); } - public override void Write(Utf8JsonWriter writer, ShardRoutingState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardRoutingState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardRoutingState.Unassigned: - writer.WriteStringValue("UNASSIGNED"); - return; + writer.WriteStringValue(MemberUnassigned); + break; case ShardRoutingState.Started: - writer.WriteStringValue("STARTED"); - return; + writer.WriteStringValue(MemberStarted); + break; case ShardRoutingState.Relocating: - writer.WriteStringValue("RELOCATING"); - return; + writer.WriteStringValue(MemberRelocating); + break; case ShardRoutingState.Initializing: - writer.WriteStringValue("INITIALIZING"); - return; + writer.WriteStringValue(MemberInitializing); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardRoutingState)}'."); } - - writer.WriteNullValue(); } } @@ -568,41 +648,49 @@ public enum ShardStoreAllocation Primary } -internal sealed class ShardStoreAllocationConverter : JsonConverter +internal sealed partial class ShardStoreAllocationConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStoreAllocation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUnused = System.Text.Json.JsonEncodedText.Encode("unused"); + private static readonly System.Text.Json.JsonEncodedText MemberReplica = System.Text.Json.JsonEncodedText.Encode("replica"); + private static readonly System.Text.Json.JsonEncodedText MemberPrimary = System.Text.Json.JsonEncodedText.Encode("primary"); + + public override ShardStoreAllocation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUnused)) + { + return ShardStoreAllocation.Unused; + } + + if (reader.ValueTextEquals(MemberReplica)) + { + return ShardStoreAllocation.Replica; + } + + if (reader.ValueTextEquals(MemberPrimary)) { - case "unused": - return ShardStoreAllocation.Unused; - case "replica": - return ShardStoreAllocation.Replica; - case "primary": - return ShardStoreAllocation.Primary; + return ShardStoreAllocation.Primary; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardStoreAllocation)}'."); } - public override void Write(Utf8JsonWriter writer, ShardStoreAllocation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoreAllocation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardStoreAllocation.Unused: - writer.WriteStringValue("unused"); - return; + writer.WriteStringValue(MemberUnused); + break; case ShardStoreAllocation.Replica: - writer.WriteStringValue("replica"); - return; + writer.WriteStringValue(MemberReplica); + break; case ShardStoreAllocation.Primary: - writer.WriteStringValue("primary"); - return; + writer.WriteStringValue(MemberPrimary); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardStoreAllocation)}'."); } - - writer.WriteNullValue(); } } @@ -639,46 +727,58 @@ public enum ShardStoreStatus All } -internal sealed class ShardStoreStatusConverter : JsonConverter +internal sealed partial class ShardStoreStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStoreStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYellow = System.Text.Json.JsonEncodedText.Encode("yellow"); + private static readonly System.Text.Json.JsonEncodedText MemberRed = System.Text.Json.JsonEncodedText.Encode("red"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen = System.Text.Json.JsonEncodedText.Encode("green"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ShardStoreStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYellow)) { - case "yellow": - return ShardStoreStatus.Yellow; - case "red": - return ShardStoreStatus.Red; - case "green": - return ShardStoreStatus.Green; - case "all": - return ShardStoreStatus.All; + return ShardStoreStatus.Yellow; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRed)) + { + return ShardStoreStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen)) + { + return ShardStoreStatus.Green; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ShardStoreStatus.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardStoreStatus)}'."); } - public override void Write(Utf8JsonWriter writer, ShardStoreStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStoreStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardStoreStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case ShardStoreStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case ShardStoreStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; case ShardStoreStatus.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardStoreStatus)}'."); } - - writer.WriteNullValue(); } } @@ -686,9 +786,11 @@ public override void Write(Utf8JsonWriter writer, ShardStoreStatus value, JsonSe public readonly partial struct StorageType : IEnumStruct { public StorageType(string value) => Value = value; - +#if NET7_0_OR_GREATER + static StorageType IEnumStruct.Create(string value) => value; +#else StorageType IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -761,37 +863,41 @@ public enum TranslogDurability Async } -internal sealed class TranslogDurabilityConverter : JsonConverter +internal sealed partial class TranslogDurabilityConverter : System.Text.Json.Serialization.JsonConverter { - public override TranslogDurability Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRequest = System.Text.Json.JsonEncodedText.Encode("request"); + private static readonly System.Text.Json.JsonEncodedText MemberRequest1 = System.Text.Json.JsonEncodedText.Encode("REQUEST"); + private static readonly System.Text.Json.JsonEncodedText MemberAsync = System.Text.Json.JsonEncodedText.Encode("async"); + private static readonly System.Text.Json.JsonEncodedText MemberAsync1 = System.Text.Json.JsonEncodedText.Encode("ASYNC"); + + public override TranslogDurability Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRequest) || reader.ValueTextEquals(MemberRequest1)) + { + return TranslogDurability.Request; + } + + if (reader.ValueTextEquals(MemberAsync) || reader.ValueTextEquals(MemberAsync1)) { - case "request": - case "REQUEST": - return TranslogDurability.Request; - case "async": - case "ASYNC": - return TranslogDurability.Async; + return TranslogDurability.Async; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TranslogDurability)}'."); } - public override void Write(Utf8JsonWriter writer, TranslogDurability value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TranslogDurability value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TranslogDurability.Request: - writer.WriteStringValue("request"); - return; + writer.WriteStringValue(MemberRequest); + break; case TranslogDurability.Async: - writer.WriteStringValue("async"); - return; + writer.WriteStringValue(MemberAsync); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TranslogDurability)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs index ab0a177455b..b6911bf1218 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Inference.g.cs @@ -41,45 +41,57 @@ public enum TaskType Completion } -internal sealed class TaskTypeConverter : JsonConverter +internal sealed partial class TaskTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TaskType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText MemberSparseEmbedding = System.Text.Json.JsonEncodedText.Encode("sparse_embedding"); + private static readonly System.Text.Json.JsonEncodedText MemberRerank = System.Text.Json.JsonEncodedText.Encode("rerank"); + private static readonly System.Text.Json.JsonEncodedText MemberCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + + public override TaskType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTextEmbedding)) + { + return TaskType.TextEmbedding; + } + + if (reader.ValueTextEquals(MemberSparseEmbedding)) { - case "text_embedding": - return TaskType.TextEmbedding; - case "sparse_embedding": - return TaskType.SparseEmbedding; - case "rerank": - return TaskType.Rerank; - case "completion": - return TaskType.Completion; + return TaskType.SparseEmbedding; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRerank)) + { + return TaskType.Rerank; + } + + if (reader.ValueTextEquals(MemberCompletion)) + { + return TaskType.Completion; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TaskType)}'."); } - public override void Write(Utf8JsonWriter writer, TaskType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TaskType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TaskType.TextEmbedding: - writer.WriteStringValue("text_embedding"); - return; + writer.WriteStringValue(MemberTextEmbedding); + break; case TaskType.SparseEmbedding: - writer.WriteStringValue("sparse_embedding"); - return; + writer.WriteStringValue(MemberSparseEmbedding); + break; case TaskType.Rerank: - writer.WriteStringValue("rerank"); - return; + writer.WriteStringValue(MemberRerank); + break; case TaskType.Completion: - writer.WriteStringValue("completion"); - return; + writer.WriteStringValue(MemberCompletion); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TaskType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs index 6e2a0890436..08751a24188 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Ingest.g.cs @@ -49,66 +49,94 @@ public enum ConvertType Auto } -internal sealed class ConvertTypeConverter : JsonConverter +internal sealed partial class ConvertTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ConvertType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("integer"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override ConvertType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "string": - return ConvertType.String; - case "long": - return ConvertType.Long; - case "ip": - return ConvertType.Ip; - case "integer": - return ConvertType.Integer; - case "float": - return ConvertType.Float; - case "double": - return ConvertType.Double; - case "boolean": - return ConvertType.Boolean; - case "auto": - return ConvertType.Auto; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) + { + return ConvertType.String; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return ConvertType.Long; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return ConvertType.Ip; + } + + if (reader.ValueTextEquals(MemberInteger)) + { + return ConvertType.Integer; + } + + if (reader.ValueTextEquals(MemberFloat)) + { + return ConvertType.Float; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return ConvertType.Double; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return ConvertType.Boolean; + } + + if (reader.ValueTextEquals(MemberAuto)) + { + return ConvertType.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ConvertType)}'."); } - public override void Write(Utf8JsonWriter writer, ConvertType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ConvertType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ConvertType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ConvertType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case ConvertType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case ConvertType.Integer: - writer.WriteStringValue("integer"); - return; + writer.WriteStringValue(MemberInteger); + break; case ConvertType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case ConvertType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case ConvertType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; case ConvertType.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ConvertType)}'."); } - - writer.WriteNullValue(); } } @@ -127,51 +155,67 @@ public enum FingerprintDigest Md5 } -internal sealed class FingerprintDigestConverter : JsonConverter +internal sealed partial class FingerprintDigestConverter : System.Text.Json.Serialization.JsonConverter { - public override FingerprintDigest Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSha512 = System.Text.Json.JsonEncodedText.Encode("SHA-512"); + private static readonly System.Text.Json.JsonEncodedText MemberSha256 = System.Text.Json.JsonEncodedText.Encode("SHA-256"); + private static readonly System.Text.Json.JsonEncodedText MemberSha1 = System.Text.Json.JsonEncodedText.Encode("SHA-1"); + private static readonly System.Text.Json.JsonEncodedText MemberMurmurhash3 = System.Text.Json.JsonEncodedText.Encode("MurmurHash3"); + private static readonly System.Text.Json.JsonEncodedText MemberMd5 = System.Text.Json.JsonEncodedText.Encode("MD5"); + + public override FingerprintDigest Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "SHA-512": - return FingerprintDigest.Sha512; - case "SHA-256": - return FingerprintDigest.Sha256; - case "SHA-1": - return FingerprintDigest.Sha1; - case "MurmurHash3": - return FingerprintDigest.Murmurhash3; - case "MD5": - return FingerprintDigest.Md5; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSha512)) + { + return FingerprintDigest.Sha512; + } + + if (reader.ValueTextEquals(MemberSha256)) + { + return FingerprintDigest.Sha256; + } + + if (reader.ValueTextEquals(MemberSha1)) + { + return FingerprintDigest.Sha1; + } + + if (reader.ValueTextEquals(MemberMurmurhash3)) + { + return FingerprintDigest.Murmurhash3; + } + + if (reader.ValueTextEquals(MemberMd5)) + { + return FingerprintDigest.Md5; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FingerprintDigest)}'."); } - public override void Write(Utf8JsonWriter writer, FingerprintDigest value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintDigest value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FingerprintDigest.Sha512: - writer.WriteStringValue("SHA-512"); - return; + writer.WriteStringValue(MemberSha512); + break; case FingerprintDigest.Sha256: - writer.WriteStringValue("SHA-256"); - return; + writer.WriteStringValue(MemberSha256); + break; case FingerprintDigest.Sha1: - writer.WriteStringValue("SHA-1"); - return; + writer.WriteStringValue(MemberSha1); + break; case FingerprintDigest.Murmurhash3: - writer.WriteStringValue("MurmurHash3"); - return; + writer.WriteStringValue(MemberMurmurhash3); + break; case FingerprintDigest.Md5: - writer.WriteStringValue("MD5"); - return; + writer.WriteStringValue(MemberMd5); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FingerprintDigest)}'."); } - - writer.WriteNullValue(); } } @@ -184,36 +228,40 @@ public enum GeoGridTargetFormat Geojson } -internal sealed class GeoGridTargetFormatConverter : JsonConverter +internal sealed partial class GeoGridTargetFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoGridTargetFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWkt = System.Text.Json.JsonEncodedText.Encode("wkt"); + private static readonly System.Text.Json.JsonEncodedText MemberGeojson = System.Text.Json.JsonEncodedText.Encode("geojson"); + + public override GeoGridTargetFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWkt)) + { + return GeoGridTargetFormat.Wkt; + } + + if (reader.ValueTextEquals(MemberGeojson)) { - case "wkt": - return GeoGridTargetFormat.Wkt; - case "geojson": - return GeoGridTargetFormat.Geojson; + return GeoGridTargetFormat.Geojson; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoGridTargetFormat)}'."); } - public override void Write(Utf8JsonWriter writer, GeoGridTargetFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoGridTargetFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoGridTargetFormat.Wkt: - writer.WriteStringValue("wkt"); - return; + writer.WriteStringValue(MemberWkt); + break; case GeoGridTargetFormat.Geojson: - writer.WriteStringValue("geojson"); - return; + writer.WriteStringValue(MemberGeojson); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoGridTargetFormat)}'."); } - - writer.WriteNullValue(); } } @@ -228,41 +276,49 @@ public enum GeoGridTileType Geohash } -internal sealed class GeoGridTileTypeConverter : JsonConverter +internal sealed partial class GeoGridTileTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoGridTileType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberGeotile = System.Text.Json.JsonEncodedText.Encode("geotile"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohex = System.Text.Json.JsonEncodedText.Encode("geohex"); + private static readonly System.Text.Json.JsonEncodedText MemberGeohash = System.Text.Json.JsonEncodedText.Encode("geohash"); + + public override GeoGridTileType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberGeotile)) { - case "geotile": - return GeoGridTileType.Geotile; - case "geohex": - return GeoGridTileType.Geohex; - case "geohash": - return GeoGridTileType.Geohash; + return GeoGridTileType.Geotile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeohex)) + { + return GeoGridTileType.Geohex; + } + + if (reader.ValueTextEquals(MemberGeohash)) + { + return GeoGridTileType.Geohash; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoGridTileType)}'."); } - public override void Write(Utf8JsonWriter writer, GeoGridTileType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoGridTileType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoGridTileType.Geotile: - writer.WriteStringValue("geotile"); - return; + writer.WriteStringValue(MemberGeotile); + break; case GeoGridTileType.Geohex: - writer.WriteStringValue("geohex"); - return; + writer.WriteStringValue(MemberGeohex); + break; case GeoGridTileType.Geohash: - writer.WriteStringValue("geohash"); - return; + writer.WriteStringValue(MemberGeohash); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoGridTileType)}'."); } - - writer.WriteNullValue(); } } @@ -285,36 +341,40 @@ public enum JsonProcessorConflictStrategy Merge } -internal sealed class JsonProcessorConflictStrategyConverter : JsonConverter +internal sealed partial class JsonProcessorConflictStrategyConverter : System.Text.Json.Serialization.JsonConverter { - public override JsonProcessorConflictStrategy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText MemberMerge = System.Text.Json.JsonEncodedText.Encode("merge"); + + public override JsonProcessorConflictStrategy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberReplace)) + { + return JsonProcessorConflictStrategy.Replace; + } + + if (reader.ValueTextEquals(MemberMerge)) { - case "replace": - return JsonProcessorConflictStrategy.Replace; - case "merge": - return JsonProcessorConflictStrategy.Merge; + return JsonProcessorConflictStrategy.Merge; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JsonProcessorConflictStrategy)}'."); } - public override void Write(Utf8JsonWriter writer, JsonProcessorConflictStrategy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JsonProcessorConflictStrategy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JsonProcessorConflictStrategy.Replace: - writer.WriteStringValue("replace"); - return; + writer.WriteStringValue(MemberReplace); + break; case JsonProcessorConflictStrategy.Merge: - writer.WriteStringValue("merge"); - return; + writer.WriteStringValue(MemberMerge); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JsonProcessorConflictStrategy)}'."); } - - writer.WriteNullValue(); } } @@ -327,36 +387,40 @@ public enum ShapeType GeoShape } -internal sealed class ShapeTypeConverter : JsonConverter +internal sealed partial class ShapeTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ShapeType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + + public override ShapeType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShape)) { - case "shape": - return ShapeType.Shape; - case "geo_shape": - return ShapeType.GeoShape; + return ShapeType.Shape; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberGeoShape)) + { + return ShapeType.GeoShape; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShapeType)}'."); } - public override void Write(Utf8JsonWriter writer, ShapeType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShapeType.Shape: - writer.WriteStringValue("shape"); - return; + writer.WriteStringValue(MemberShape); + break; case ShapeType.GeoShape: - writer.WriteStringValue("geo_shape"); - return; + writer.WriteStringValue(MemberGeoShape); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShapeType)}'."); } - - writer.WriteNullValue(); } } @@ -375,50 +439,66 @@ public enum UserAgentProperty Device } -internal sealed class UserAgentPropertyConverter : JsonConverter +internal sealed partial class UserAgentPropertyConverter : System.Text.Json.Serialization.JsonConverter { - public override UserAgentProperty Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberOs = System.Text.Json.JsonEncodedText.Encode("os"); + private static readonly System.Text.Json.JsonEncodedText MemberOriginal = System.Text.Json.JsonEncodedText.Encode("original"); + private static readonly System.Text.Json.JsonEncodedText MemberName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText MemberDevice = System.Text.Json.JsonEncodedText.Encode("device"); + + public override UserAgentProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "version": - return UserAgentProperty.Version; - case "os": - return UserAgentProperty.Os; - case "original": - return UserAgentProperty.Original; - case "name": - return UserAgentProperty.Name; - case "device": - return UserAgentProperty.Device; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return UserAgentProperty.Version; + } + + if (reader.ValueTextEquals(MemberOs)) + { + return UserAgentProperty.Os; + } + + if (reader.ValueTextEquals(MemberOriginal)) + { + return UserAgentProperty.Original; + } + + if (reader.ValueTextEquals(MemberName)) + { + return UserAgentProperty.Name; + } + + if (reader.ValueTextEquals(MemberDevice)) + { + return UserAgentProperty.Device; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(UserAgentProperty)}'."); } - public override void Write(Utf8JsonWriter writer, UserAgentProperty value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, UserAgentProperty value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case UserAgentProperty.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case UserAgentProperty.Os: - writer.WriteStringValue("os"); - return; + writer.WriteStringValue(MemberOs); + break; case UserAgentProperty.Original: - writer.WriteStringValue("original"); - return; + writer.WriteStringValue(MemberOriginal); + break; case UserAgentProperty.Name: - writer.WriteStringValue("name"); - return; + writer.WriteStringValue(MemberName); + break; case UserAgentProperty.Device: - writer.WriteStringValue("device"); - return; + writer.WriteStringValue(MemberDevice); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(UserAgentProperty)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs index 00f97d8b1e7..369c8787420 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.LicenseManagement.g.cs @@ -41,46 +41,58 @@ public enum LicenseStatus Active } -internal sealed class LicenseStatusConverter : JsonConverter +internal sealed partial class LicenseStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override LicenseStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberValid = System.Text.Json.JsonEncodedText.Encode("valid"); + private static readonly System.Text.Json.JsonEncodedText MemberInvalid = System.Text.Json.JsonEncodedText.Encode("invalid"); + private static readonly System.Text.Json.JsonEncodedText MemberExpired = System.Text.Json.JsonEncodedText.Encode("expired"); + private static readonly System.Text.Json.JsonEncodedText MemberActive = System.Text.Json.JsonEncodedText.Encode("active"); + + public override LicenseStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberValid)) + { + return LicenseStatus.Valid; + } + + if (reader.ValueTextEquals(MemberInvalid)) + { + return LicenseStatus.Invalid; + } + + if (reader.ValueTextEquals(MemberExpired)) + { + return LicenseStatus.Expired; + } + + if (reader.ValueTextEquals(MemberActive)) { - case "valid": - return LicenseStatus.Valid; - case "invalid": - return LicenseStatus.Invalid; - case "expired": - return LicenseStatus.Expired; - case "active": - return LicenseStatus.Active; + return LicenseStatus.Active; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LicenseStatus)}'."); } - public override void Write(Utf8JsonWriter writer, LicenseStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LicenseStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LicenseStatus.Valid: - writer.WriteStringValue("valid"); - return; + writer.WriteStringValue(MemberValid); + break; case LicenseStatus.Invalid: - writer.WriteStringValue("invalid"); - return; + writer.WriteStringValue(MemberInvalid); + break; case LicenseStatus.Expired: - writer.WriteStringValue("expired"); - return; + writer.WriteStringValue(MemberExpired); + break; case LicenseStatus.Active: - writer.WriteStringValue("active"); - return; + writer.WriteStringValue(MemberActive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LicenseStatus)}'."); } - - writer.WriteNullValue(); } } @@ -107,70 +119,102 @@ public enum LicenseType Basic } -internal sealed class LicenseTypeConverter : JsonConverter +internal sealed partial class LicenseTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override LicenseType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrial = System.Text.Json.JsonEncodedText.Encode("trial"); + private static readonly System.Text.Json.JsonEncodedText MemberStandard = System.Text.Json.JsonEncodedText.Encode("standard"); + private static readonly System.Text.Json.JsonEncodedText MemberSilver = System.Text.Json.JsonEncodedText.Encode("silver"); + private static readonly System.Text.Json.JsonEncodedText MemberPlatinum = System.Text.Json.JsonEncodedText.Encode("platinum"); + private static readonly System.Text.Json.JsonEncodedText MemberMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText MemberGold = System.Text.Json.JsonEncodedText.Encode("gold"); + private static readonly System.Text.Json.JsonEncodedText MemberEnterprise = System.Text.Json.JsonEncodedText.Encode("enterprise"); + private static readonly System.Text.Json.JsonEncodedText MemberDev = System.Text.Json.JsonEncodedText.Encode("dev"); + private static readonly System.Text.Json.JsonEncodedText MemberBasic = System.Text.Json.JsonEncodedText.Encode("basic"); + + public override LicenseType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrial)) + { + return LicenseType.Trial; + } + + if (reader.ValueTextEquals(MemberStandard)) { - case "trial": - return LicenseType.Trial; - case "standard": - return LicenseType.Standard; - case "silver": - return LicenseType.Silver; - case "platinum": - return LicenseType.Platinum; - case "missing": - return LicenseType.Missing; - case "gold": - return LicenseType.Gold; - case "enterprise": - return LicenseType.Enterprise; - case "dev": - return LicenseType.Dev; - case "basic": - return LicenseType.Basic; + return LicenseType.Standard; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSilver)) + { + return LicenseType.Silver; + } + + if (reader.ValueTextEquals(MemberPlatinum)) + { + return LicenseType.Platinum; + } + + if (reader.ValueTextEquals(MemberMissing)) + { + return LicenseType.Missing; + } + + if (reader.ValueTextEquals(MemberGold)) + { + return LicenseType.Gold; + } + + if (reader.ValueTextEquals(MemberEnterprise)) + { + return LicenseType.Enterprise; + } + + if (reader.ValueTextEquals(MemberDev)) + { + return LicenseType.Dev; + } + + if (reader.ValueTextEquals(MemberBasic)) + { + return LicenseType.Basic; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LicenseType)}'."); } - public override void Write(Utf8JsonWriter writer, LicenseType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LicenseType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LicenseType.Trial: - writer.WriteStringValue("trial"); - return; + writer.WriteStringValue(MemberTrial); + break; case LicenseType.Standard: - writer.WriteStringValue("standard"); - return; + writer.WriteStringValue(MemberStandard); + break; case LicenseType.Silver: - writer.WriteStringValue("silver"); - return; + writer.WriteStringValue(MemberSilver); + break; case LicenseType.Platinum: - writer.WriteStringValue("platinum"); - return; + writer.WriteStringValue(MemberPlatinum); + break; case LicenseType.Missing: - writer.WriteStringValue("missing"); - return; + writer.WriteStringValue(MemberMissing); + break; case LicenseType.Gold: - writer.WriteStringValue("gold"); - return; + writer.WriteStringValue(MemberGold); + break; case LicenseType.Enterprise: - writer.WriteStringValue("enterprise"); - return; + writer.WriteStringValue(MemberEnterprise); + break; case LicenseType.Dev: - writer.WriteStringValue("dev"); - return; + writer.WriteStringValue(MemberDev); + break; case LicenseType.Basic: - writer.WriteStringValue("basic"); - return; + writer.WriteStringValue(MemberBasic); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LicenseType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs index a9f89e68101..55fdca7c171 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.MachineLearning.g.cs @@ -41,46 +41,58 @@ public enum AppliesTo Actual } -internal sealed class AppliesToConverter : JsonConverter +internal sealed partial class AppliesToConverter : System.Text.Json.Serialization.JsonConverter { - public override AppliesTo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTypical = System.Text.Json.JsonEncodedText.Encode("typical"); + private static readonly System.Text.Json.JsonEncodedText MemberTime = System.Text.Json.JsonEncodedText.Encode("time"); + private static readonly System.Text.Json.JsonEncodedText MemberDiffFromTypical = System.Text.Json.JsonEncodedText.Encode("diff_from_typical"); + private static readonly System.Text.Json.JsonEncodedText MemberActual = System.Text.Json.JsonEncodedText.Encode("actual"); + + public override AppliesTo Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTypical)) + { + return AppliesTo.Typical; + } + + if (reader.ValueTextEquals(MemberTime)) + { + return AppliesTo.Time; + } + + if (reader.ValueTextEquals(MemberDiffFromTypical)) { - case "typical": - return AppliesTo.Typical; - case "time": - return AppliesTo.Time; - case "diff_from_typical": - return AppliesTo.DiffFromTypical; - case "actual": - return AppliesTo.Actual; + return AppliesTo.DiffFromTypical; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberActual)) + { + return AppliesTo.Actual; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AppliesTo)}'."); } - public override void Write(Utf8JsonWriter writer, AppliesTo value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AppliesTo value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AppliesTo.Typical: - writer.WriteStringValue("typical"); - return; + writer.WriteStringValue(MemberTypical); + break; case AppliesTo.Time: - writer.WriteStringValue("time"); - return; + writer.WriteStringValue(MemberTime); + break; case AppliesTo.DiffFromTypical: - writer.WriteStringValue("diff_from_typical"); - return; + writer.WriteStringValue(MemberDiffFromTypical); + break; case AppliesTo.Actual: - writer.WriteStringValue("actual"); - return; + writer.WriteStringValue(MemberActual); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AppliesTo)}'."); } - - writer.WriteNullValue(); } } @@ -93,36 +105,40 @@ public enum CategorizationStatus Ok } -internal sealed class CategorizationStatusConverter : JsonConverter +internal sealed partial class CategorizationStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override CategorizationStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWarn = System.Text.Json.JsonEncodedText.Encode("warn"); + private static readonly System.Text.Json.JsonEncodedText MemberOk = System.Text.Json.JsonEncodedText.Encode("ok"); + + public override CategorizationStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWarn)) + { + return CategorizationStatus.Warn; + } + + if (reader.ValueTextEquals(MemberOk)) { - case "warn": - return CategorizationStatus.Warn; - case "ok": - return CategorizationStatus.Ok; + return CategorizationStatus.Ok; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CategorizationStatus)}'."); } - public override void Write(Utf8JsonWriter writer, CategorizationStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CategorizationStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CategorizationStatus.Warn: - writer.WriteStringValue("warn"); - return; + writer.WriteStringValue(MemberWarn); + break; case CategorizationStatus.Ok: - writer.WriteStringValue("ok"); - return; + writer.WriteStringValue(MemberOk); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CategorizationStatus)}'."); } - - writer.WriteNullValue(); } } @@ -137,41 +153,49 @@ public enum ChunkingMode Auto } -internal sealed class ChunkingModeConverter : JsonConverter +internal sealed partial class ChunkingModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ChunkingMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOff = System.Text.Json.JsonEncodedText.Encode("off"); + private static readonly System.Text.Json.JsonEncodedText MemberManual = System.Text.Json.JsonEncodedText.Encode("manual"); + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override ChunkingMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOff)) + { + return ChunkingMode.Off; + } + + if (reader.ValueTextEquals(MemberManual)) { - case "off": - return ChunkingMode.Off; - case "manual": - return ChunkingMode.Manual; - case "auto": - return ChunkingMode.Auto; + return ChunkingMode.Manual; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAuto)) + { + return ChunkingMode.Auto; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ChunkingMode)}'."); } - public override void Write(Utf8JsonWriter writer, ChunkingMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChunkingMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ChunkingMode.Off: - writer.WriteStringValue("off"); - return; + writer.WriteStringValue(MemberOff); + break; case ChunkingMode.Manual: - writer.WriteStringValue("manual"); - return; + writer.WriteStringValue(MemberManual); + break; case ChunkingMode.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ChunkingMode)}'."); } - - writer.WriteNullValue(); } } @@ -188,46 +212,58 @@ public enum ConditionOperator Gt } -internal sealed class ConditionOperatorConverter : JsonConverter +internal sealed partial class ConditionOperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override ConditionOperator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText MemberLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberGt = System.Text.Json.JsonEncodedText.Encode("gt"); + + public override ConditionOperator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLte)) { - case "lte": - return ConditionOperator.Lte; - case "lt": - return ConditionOperator.Lt; - case "gte": - return ConditionOperator.Gte; - case "gt": - return ConditionOperator.Gt; + return ConditionOperator.Lte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLt)) + { + return ConditionOperator.Lt; + } + + if (reader.ValueTextEquals(MemberGte)) + { + return ConditionOperator.Gte; + } + + if (reader.ValueTextEquals(MemberGt)) + { + return ConditionOperator.Gt; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ConditionOperator)}'."); } - public override void Write(Utf8JsonWriter writer, ConditionOperator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ConditionOperator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ConditionOperator.Lte: - writer.WriteStringValue("lte"); - return; + writer.WriteStringValue(MemberLte); + break; case ConditionOperator.Lt: - writer.WriteStringValue("lt"); - return; + writer.WriteStringValue(MemberLt); + break; case ConditionOperator.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case ConditionOperator.Gt: - writer.WriteStringValue("gt"); - return; + writer.WriteStringValue(MemberGt); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ConditionOperator)}'."); } - - writer.WriteNullValue(); } } @@ -244,46 +280,58 @@ public enum DatafeedState Started } -internal sealed class DatafeedStateConverter : JsonConverter +internal sealed partial class DatafeedStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DatafeedState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + + public override DatafeedState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DatafeedState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) { - case "stopping": - return DatafeedState.Stopping; - case "stopped": - return DatafeedState.Stopped; - case "starting": - return DatafeedState.Starting; - case "started": - return DatafeedState.Started; + return DatafeedState.Stopped; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStarting)) + { + return DatafeedState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DatafeedState.Started; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DatafeedState)}'."); } - public override void Write(Utf8JsonWriter writer, DatafeedState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatafeedState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DatafeedState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DatafeedState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case DatafeedState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DatafeedState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DatafeedState)}'."); } - - writer.WriteNullValue(); } } @@ -302,51 +350,67 @@ public enum DataframeState Failed } -internal sealed class DataframeStateConverter : JsonConverter +internal sealed partial class DataframeStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override DataframeState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "stopping": - return DataframeState.Stopping; - case "stopped": - return DataframeState.Stopped; - case "starting": - return DataframeState.Starting; - case "started": - return DataframeState.Started; - case "failed": - return DataframeState.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DataframeState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return DataframeState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DataframeState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return DataframeState.Started; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return DataframeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DataframeState)}'."); } - public override void Write(Utf8JsonWriter writer, DataframeState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DataframeState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DataframeState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case DataframeState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DataframeState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DataframeState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DataframeState)}'."); } - - writer.WriteNullValue(); } } @@ -376,41 +440,49 @@ public enum DeploymentAllocationState FullyAllocated } -internal sealed class DeploymentAllocationStateConverter : JsonConverter +internal sealed partial class DeploymentAllocationStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DeploymentAllocationState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFullyAllocated = System.Text.Json.JsonEncodedText.Encode("fully_allocated"); + + public override DeploymentAllocationState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStarting)) { - case "starting": - return DeploymentAllocationState.Starting; - case "started": - return DeploymentAllocationState.Started; - case "fully_allocated": - return DeploymentAllocationState.FullyAllocated; + return DeploymentAllocationState.Starting; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStarted)) + { + return DeploymentAllocationState.Started; + } + + if (reader.ValueTextEquals(MemberFullyAllocated)) + { + return DeploymentAllocationState.FullyAllocated; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DeploymentAllocationState)}'."); } - public override void Write(Utf8JsonWriter writer, DeploymentAllocationState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeploymentAllocationState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DeploymentAllocationState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DeploymentAllocationState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DeploymentAllocationState.FullyAllocated: - writer.WriteStringValue("fully_allocated"); - return; + writer.WriteStringValue(MemberFullyAllocated); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DeploymentAllocationState)}'."); } - - writer.WriteNullValue(); } } @@ -447,46 +519,58 @@ public enum DeploymentAssignmentState Failed } -internal sealed class DeploymentAssignmentStateConverter : JsonConverter +internal sealed partial class DeploymentAssignmentStateConverter : System.Text.Json.Serialization.JsonConverter { - public override DeploymentAssignmentState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override DeploymentAssignmentState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return DeploymentAssignmentState.Stopping; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return DeploymentAssignmentState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) { - case "stopping": - return DeploymentAssignmentState.Stopping; - case "starting": - return DeploymentAssignmentState.Starting; - case "started": - return DeploymentAssignmentState.Started; - case "failed": - return DeploymentAssignmentState.Failed; + return DeploymentAssignmentState.Started; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFailed)) + { + return DeploymentAssignmentState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DeploymentAssignmentState)}'."); } - public override void Write(Utf8JsonWriter writer, DeploymentAssignmentState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DeploymentAssignmentState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DeploymentAssignmentState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case DeploymentAssignmentState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case DeploymentAssignmentState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case DeploymentAssignmentState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DeploymentAssignmentState)}'."); } - - writer.WriteNullValue(); } } @@ -503,46 +587,58 @@ public enum ExcludeFrequent All } -internal sealed class ExcludeFrequentConverter : JsonConverter +internal sealed partial class ExcludeFrequentConverter : System.Text.Json.Serialization.JsonConverter { - public override ExcludeFrequent Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOver = System.Text.Json.JsonEncodedText.Encode("over"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberBy = System.Text.Json.JsonEncodedText.Encode("by"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ExcludeFrequent Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOver)) + { + return ExcludeFrequent.Over; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ExcludeFrequent.None; + } + + if (reader.ValueTextEquals(MemberBy)) { - case "over": - return ExcludeFrequent.Over; - case "none": - return ExcludeFrequent.None; - case "by": - return ExcludeFrequent.By; - case "all": - return ExcludeFrequent.All; + return ExcludeFrequent.By; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAll)) + { + return ExcludeFrequent.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ExcludeFrequent)}'."); } - public override void Write(Utf8JsonWriter writer, ExcludeFrequent value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExcludeFrequent value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ExcludeFrequent.Over: - writer.WriteStringValue("over"); - return; + writer.WriteStringValue(MemberOver); + break; case ExcludeFrequent.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ExcludeFrequent.By: - writer.WriteStringValue("by"); - return; + writer.WriteStringValue(MemberBy); + break; case ExcludeFrequent.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ExcludeFrequent)}'."); } - - writer.WriteNullValue(); } } @@ -555,36 +651,40 @@ public enum FilterType Exclude } -internal sealed class FilterTypeConverter : JsonConverter +internal sealed partial class FilterTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FilterType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override FilterType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInclude)) + { + return FilterType.Include; + } + + if (reader.ValueTextEquals(MemberExclude)) { - case "include": - return FilterType.Include; - case "exclude": - return FilterType.Exclude; + return FilterType.Exclude; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FilterType)}'."); } - public override void Write(Utf8JsonWriter writer, FilterType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FilterType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FilterType.Include: - writer.WriteStringValue("include"); - return; + writer.WriteStringValue(MemberInclude); + break; case FilterType.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FilterType)}'."); } - - writer.WriteNullValue(); } } @@ -633,51 +733,67 @@ public enum Include Definition } -internal sealed class IncludeConverter : JsonConverter +internal sealed partial class IncludeConverter : System.Text.Json.Serialization.JsonConverter { - public override Include Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTotalFeatureImportance = System.Text.Json.JsonEncodedText.Encode("total_feature_importance"); + private static readonly System.Text.Json.JsonEncodedText MemberHyperparameters = System.Text.Json.JsonEncodedText.Encode("hyperparameters"); + private static readonly System.Text.Json.JsonEncodedText MemberFeatureImportanceBaseline = System.Text.Json.JsonEncodedText.Encode("feature_importance_baseline"); + private static readonly System.Text.Json.JsonEncodedText MemberDefinitionStatus = System.Text.Json.JsonEncodedText.Encode("definition_status"); + private static readonly System.Text.Json.JsonEncodedText MemberDefinition = System.Text.Json.JsonEncodedText.Encode("definition"); + + public override Include Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "total_feature_importance": - return Include.TotalFeatureImportance; - case "hyperparameters": - return Include.Hyperparameters; - case "feature_importance_baseline": - return Include.FeatureImportanceBaseline; - case "definition_status": - return Include.DefinitionStatus; - case "definition": - return Include.Definition; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTotalFeatureImportance)) + { + return Include.TotalFeatureImportance; + } + + if (reader.ValueTextEquals(MemberHyperparameters)) + { + return Include.Hyperparameters; + } + + if (reader.ValueTextEquals(MemberFeatureImportanceBaseline)) + { + return Include.FeatureImportanceBaseline; + } + + if (reader.ValueTextEquals(MemberDefinitionStatus)) + { + return Include.DefinitionStatus; + } + + if (reader.ValueTextEquals(MemberDefinition)) + { + return Include.Definition; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Include)}'."); } - public override void Write(Utf8JsonWriter writer, Include value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Include value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Include.TotalFeatureImportance: - writer.WriteStringValue("total_feature_importance"); - return; + writer.WriteStringValue(MemberTotalFeatureImportance); + break; case Include.Hyperparameters: - writer.WriteStringValue("hyperparameters"); - return; + writer.WriteStringValue(MemberHyperparameters); + break; case Include.FeatureImportanceBaseline: - writer.WriteStringValue("feature_importance_baseline"); - return; + writer.WriteStringValue(MemberFeatureImportanceBaseline); + break; case Include.DefinitionStatus: - writer.WriteStringValue("definition_status"); - return; + writer.WriteStringValue(MemberDefinitionStatus); + break; case Include.Definition: - writer.WriteStringValue("definition"); - return; + writer.WriteStringValue(MemberDefinition); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Include)}'."); } - - writer.WriteNullValue(); } } @@ -692,41 +808,49 @@ public enum JobBlockedReason Delete } -internal sealed class JobBlockedReasonConverter : JsonConverter +internal sealed partial class JobBlockedReasonConverter : System.Text.Json.Serialization.JsonConverter { - public override JobBlockedReason Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRevert = System.Text.Json.JsonEncodedText.Encode("revert"); + private static readonly System.Text.Json.JsonEncodedText MemberReset = System.Text.Json.JsonEncodedText.Encode("reset"); + private static readonly System.Text.Json.JsonEncodedText MemberDelete = System.Text.Json.JsonEncodedText.Encode("delete"); + + public override JobBlockedReason Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRevert)) { - case "revert": - return JobBlockedReason.Revert; - case "reset": - return JobBlockedReason.Reset; - case "delete": - return JobBlockedReason.Delete; + return JobBlockedReason.Revert; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberReset)) + { + return JobBlockedReason.Reset; + } + + if (reader.ValueTextEquals(MemberDelete)) + { + return JobBlockedReason.Delete; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JobBlockedReason)}'."); } - public override void Write(Utf8JsonWriter writer, JobBlockedReason value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JobBlockedReason value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JobBlockedReason.Revert: - writer.WriteStringValue("revert"); - return; + writer.WriteStringValue(MemberRevert); + break; case JobBlockedReason.Reset: - writer.WriteStringValue("reset"); - return; + writer.WriteStringValue(MemberReset); + break; case JobBlockedReason.Delete: - writer.WriteStringValue("delete"); - return; + writer.WriteStringValue(MemberDelete); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JobBlockedReason)}'."); } - - writer.WriteNullValue(); } } @@ -773,51 +897,67 @@ public enum JobState Closed } -internal sealed class JobStateConverter : JsonConverter +internal sealed partial class JobStateConverter : System.Text.Json.Serialization.JsonConverter { - public override JobState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpening = System.Text.Json.JsonEncodedText.Encode("opening"); + private static readonly System.Text.Json.JsonEncodedText MemberOpened = System.Text.Json.JsonEncodedText.Encode("opened"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + private static readonly System.Text.Json.JsonEncodedText MemberClosing = System.Text.Json.JsonEncodedText.Encode("closing"); + private static readonly System.Text.Json.JsonEncodedText MemberClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + + public override JobState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "opening": - return JobState.Opening; - case "opened": - return JobState.Opened; - case "failed": - return JobState.Failed; - case "closing": - return JobState.Closing; - case "closed": - return JobState.Closed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpening)) + { + return JobState.Opening; + } + + if (reader.ValueTextEquals(MemberOpened)) + { + return JobState.Opened; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return JobState.Failed; + } + + if (reader.ValueTextEquals(MemberClosing)) + { + return JobState.Closing; + } + + if (reader.ValueTextEquals(MemberClosed)) + { + return JobState.Closed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(JobState)}'."); } - public override void Write(Utf8JsonWriter writer, JobState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, JobState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case JobState.Opening: - writer.WriteStringValue("opening"); - return; + writer.WriteStringValue(MemberOpening); + break; case JobState.Opened: - writer.WriteStringValue("opened"); - return; + writer.WriteStringValue(MemberOpened); + break; case JobState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; case JobState.Closing: - writer.WriteStringValue("closing"); - return; + writer.WriteStringValue(MemberClosing); + break; case JobState.Closed: - writer.WriteStringValue("closed"); - return; + writer.WriteStringValue(MemberClosed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(JobState)}'."); } - - writer.WriteNullValue(); } } @@ -832,41 +972,49 @@ public enum MemoryStatus HardLimit } -internal sealed class MemoryStatusConverter : JsonConverter +internal sealed partial class MemoryStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override MemoryStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSoftLimit = System.Text.Json.JsonEncodedText.Encode("soft_limit"); + private static readonly System.Text.Json.JsonEncodedText MemberOk = System.Text.Json.JsonEncodedText.Encode("ok"); + private static readonly System.Text.Json.JsonEncodedText MemberHardLimit = System.Text.Json.JsonEncodedText.Encode("hard_limit"); + + public override MemoryStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSoftLimit)) + { + return MemoryStatus.SoftLimit; + } + + if (reader.ValueTextEquals(MemberOk)) + { + return MemoryStatus.Ok; + } + + if (reader.ValueTextEquals(MemberHardLimit)) { - case "soft_limit": - return MemoryStatus.SoftLimit; - case "ok": - return MemoryStatus.Ok; - case "hard_limit": - return MemoryStatus.HardLimit; + return MemoryStatus.HardLimit; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MemoryStatus)}'."); } - public override void Write(Utf8JsonWriter writer, MemoryStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MemoryStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MemoryStatus.SoftLimit: - writer.WriteStringValue("soft_limit"); - return; + writer.WriteStringValue(MemberSoftLimit); + break; case MemoryStatus.Ok: - writer.WriteStringValue("ok"); - return; + writer.WriteStringValue(MemberOk); + break; case MemoryStatus.HardLimit: - writer.WriteStringValue("hard_limit"); - return; + writer.WriteStringValue(MemberHardLimit); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MemoryStatus)}'."); } - - writer.WriteNullValue(); } } @@ -910,51 +1058,67 @@ public enum RoutingState Failed } -internal sealed class RoutingStateConverter : JsonConverter +internal sealed partial class RoutingStateConverter : System.Text.Json.Serialization.JsonConverter { - public override RoutingState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarting = System.Text.Json.JsonEncodedText.Encode("starting"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override RoutingState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "stopping": - return RoutingState.Stopping; - case "stopped": - return RoutingState.Stopped; - case "starting": - return RoutingState.Starting; - case "started": - return RoutingState.Started; - case "failed": - return RoutingState.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return RoutingState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return RoutingState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarting)) + { + return RoutingState.Starting; + } + + if (reader.ValueTextEquals(MemberStarted)) + { + return RoutingState.Started; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return RoutingState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RoutingState)}'."); } - public override void Write(Utf8JsonWriter writer, RoutingState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RoutingState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RoutingState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case RoutingState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case RoutingState.Starting: - writer.WriteStringValue("starting"); - return; + writer.WriteStringValue(MemberStarting); + break; case RoutingState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case RoutingState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RoutingState)}'."); } - - writer.WriteNullValue(); } } @@ -977,36 +1141,40 @@ public enum RuleAction SkipModelUpdate } -internal sealed class RuleActionConverter : JsonConverter +internal sealed partial class RuleActionConverter : System.Text.Json.Serialization.JsonConverter { - public override RuleAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSkipResult = System.Text.Json.JsonEncodedText.Encode("skip_result"); + private static readonly System.Text.Json.JsonEncodedText MemberSkipModelUpdate = System.Text.Json.JsonEncodedText.Encode("skip_model_update"); + + public override RuleAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSkipResult)) + { + return RuleAction.SkipResult; + } + + if (reader.ValueTextEquals(MemberSkipModelUpdate)) { - case "skip_result": - return RuleAction.SkipResult; - case "skip_model_update": - return RuleAction.SkipModelUpdate; + return RuleAction.SkipModelUpdate; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RuleAction)}'."); } - public override void Write(Utf8JsonWriter writer, RuleAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuleAction value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RuleAction.SkipResult: - writer.WriteStringValue("skip_result"); - return; + writer.WriteStringValue(MemberSkipResult); + break; case RuleAction.SkipModelUpdate: - writer.WriteStringValue("skip_model_update"); - return; + writer.WriteStringValue(MemberSkipModelUpdate); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RuleAction)}'."); } - - writer.WriteNullValue(); } } @@ -1023,46 +1191,58 @@ public enum SnapshotUpgradeState Failed } -internal sealed class SnapshotUpgradeStateConverter : JsonConverter +internal sealed partial class SnapshotUpgradeStateConverter : System.Text.Json.Serialization.JsonConverter { - public override SnapshotUpgradeState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberSavingNewState = System.Text.Json.JsonEncodedText.Encode("saving_new_state"); + private static readonly System.Text.Json.JsonEncodedText MemberLoadingOldState = System.Text.Json.JsonEncodedText.Encode("loading_old_state"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override SnapshotUpgradeState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopped)) + { + return SnapshotUpgradeState.Stopped; + } + + if (reader.ValueTextEquals(MemberSavingNewState)) + { + return SnapshotUpgradeState.SavingNewState; + } + + if (reader.ValueTextEquals(MemberLoadingOldState)) { - case "stopped": - return SnapshotUpgradeState.Stopped; - case "saving_new_state": - return SnapshotUpgradeState.SavingNewState; - case "loading_old_state": - return SnapshotUpgradeState.LoadingOldState; - case "failed": - return SnapshotUpgradeState.Failed; + return SnapshotUpgradeState.LoadingOldState; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFailed)) + { + return SnapshotUpgradeState.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnapshotUpgradeState)}'."); } - public override void Write(Utf8JsonWriter writer, SnapshotUpgradeState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotUpgradeState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnapshotUpgradeState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case SnapshotUpgradeState.SavingNewState: - writer.WriteStringValue("saving_new_state"); - return; + writer.WriteStringValue(MemberSavingNewState); + break; case SnapshotUpgradeState.LoadingOldState: - writer.WriteStringValue("loading_old_state"); - return; + writer.WriteStringValue(MemberLoadingOldState); + break; case SnapshotUpgradeState.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnapshotUpgradeState)}'."); } - - writer.WriteNullValue(); } } @@ -1077,41 +1257,49 @@ public enum TokenizationTruncate First } -internal sealed class TokenizationTruncateConverter : JsonConverter +internal sealed partial class TokenizationTruncateConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenizationTruncate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSecond = System.Text.Json.JsonEncodedText.Encode("second"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + + public override TokenizationTruncate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSecond)) { - case "second": - return TokenizationTruncate.Second; - case "none": - return TokenizationTruncate.None; - case "first": - return TokenizationTruncate.First; + return TokenizationTruncate.Second; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNone)) + { + return TokenizationTruncate.None; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return TokenizationTruncate.First; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TokenizationTruncate)}'."); } - public override void Write(Utf8JsonWriter writer, TokenizationTruncate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenizationTruncate value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TokenizationTruncate.Second: - writer.WriteStringValue("second"); - return; + writer.WriteStringValue(MemberSecond); + break; case TokenizationTruncate.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case TokenizationTruncate.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TokenizationTruncate)}'."); } - - writer.WriteNullValue(); } } @@ -1142,41 +1330,49 @@ public enum TrainedModelType LangIdent } -internal sealed class TrainedModelTypeConverter : JsonConverter +internal sealed partial class TrainedModelTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TrainedModelType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTreeEnsemble = System.Text.Json.JsonEncodedText.Encode("tree_ensemble"); + private static readonly System.Text.Json.JsonEncodedText MemberPytorch = System.Text.Json.JsonEncodedText.Encode("pytorch"); + private static readonly System.Text.Json.JsonEncodedText MemberLangIdent = System.Text.Json.JsonEncodedText.Encode("lang_ident"); + + public override TrainedModelType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTreeEnsemble)) { - case "tree_ensemble": - return TrainedModelType.TreeEnsemble; - case "pytorch": - return TrainedModelType.Pytorch; - case "lang_ident": - return TrainedModelType.LangIdent; + return TrainedModelType.TreeEnsemble; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberPytorch)) + { + return TrainedModelType.Pytorch; + } + + if (reader.ValueTextEquals(MemberLangIdent)) + { + return TrainedModelType.LangIdent; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TrainedModelType)}'."); } - public override void Write(Utf8JsonWriter writer, TrainedModelType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TrainedModelType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TrainedModelType.TreeEnsemble: - writer.WriteStringValue("tree_ensemble"); - return; + writer.WriteStringValue(MemberTreeEnsemble); + break; case TrainedModelType.Pytorch: - writer.WriteStringValue("pytorch"); - return; + writer.WriteStringValue(MemberPytorch); + break; case TrainedModelType.LangIdent: - writer.WriteStringValue("lang_ident"); - return; + writer.WriteStringValue(MemberLangIdent); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TrainedModelType)}'."); } - - writer.WriteNullValue(); } } @@ -1189,35 +1385,39 @@ public enum TrainingPriority Low } -internal sealed class TrainingPriorityConverter : JsonConverter +internal sealed partial class TrainingPriorityConverter : System.Text.Json.Serialization.JsonConverter { - public override TrainingPriority Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberLow = System.Text.Json.JsonEncodedText.Encode("low"); + + public override TrainingPriority Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNormal)) + { + return TrainingPriority.Normal; + } + + if (reader.ValueTextEquals(MemberLow)) { - case "normal": - return TrainingPriority.Normal; - case "low": - return TrainingPriority.Low; + return TrainingPriority.Low; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TrainingPriority)}'."); } - public override void Write(Utf8JsonWriter writer, TrainingPriority value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TrainingPriority value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TrainingPriority.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case TrainingPriority.Low: - writer.WriteStringValue("low"); - return; + writer.WriteStringValue(MemberLow); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TrainingPriority)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs index af9e0d808bf..a900ecb6c36 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Mapping.g.cs @@ -58,41 +58,49 @@ public enum DenseVectorElementType Bit } -internal sealed class DenseVectorElementTypeConverter : JsonConverter +internal sealed partial class DenseVectorElementTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorElementType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberByte = System.Text.Json.JsonEncodedText.Encode("byte"); + private static readonly System.Text.Json.JsonEncodedText MemberBit = System.Text.Json.JsonEncodedText.Encode("bit"); + + public override DenseVectorElementType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFloat)) + { + return DenseVectorElementType.Float; + } + + if (reader.ValueTextEquals(MemberByte)) + { + return DenseVectorElementType.Byte; + } + + if (reader.ValueTextEquals(MemberBit)) { - case "float": - return DenseVectorElementType.Float; - case "byte": - return DenseVectorElementType.Byte; - case "bit": - return DenseVectorElementType.Bit; + return DenseVectorElementType.Bit; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorElementType)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorElementType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorElementType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorElementType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case DenseVectorElementType.Byte: - writer.WriteStringValue("byte"); - return; + writer.WriteStringValue(MemberByte); + break; case DenseVectorElementType.Bit: - writer.WriteStringValue("bit"); - return; + writer.WriteStringValue(MemberBit); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorElementType)}'."); } - - writer.WriteNullValue(); } } @@ -153,56 +161,76 @@ public enum DenseVectorIndexOptionsType Flat } -internal sealed class DenseVectorIndexOptionsTypeConverter : JsonConverter +internal sealed partial class DenseVectorIndexOptionsTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorIndexOptionsType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInt8Hnsw = System.Text.Json.JsonEncodedText.Encode("int8_hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberInt8Flat = System.Text.Json.JsonEncodedText.Encode("int8_flat"); + private static readonly System.Text.Json.JsonEncodedText MemberInt4Hnsw = System.Text.Json.JsonEncodedText.Encode("int4_hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberInt4Flat = System.Text.Json.JsonEncodedText.Encode("int4_flat"); + private static readonly System.Text.Json.JsonEncodedText MemberHnsw = System.Text.Json.JsonEncodedText.Encode("hnsw"); + private static readonly System.Text.Json.JsonEncodedText MemberFlat = System.Text.Json.JsonEncodedText.Encode("flat"); + + public override DenseVectorIndexOptionsType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "int8_hnsw": - return DenseVectorIndexOptionsType.Int8Hnsw; - case "int8_flat": - return DenseVectorIndexOptionsType.Int8Flat; - case "int4_hnsw": - return DenseVectorIndexOptionsType.Int4Hnsw; - case "int4_flat": - return DenseVectorIndexOptionsType.Int4Flat; - case "hnsw": - return DenseVectorIndexOptionsType.Hnsw; - case "flat": - return DenseVectorIndexOptionsType.Flat; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInt8Hnsw)) + { + return DenseVectorIndexOptionsType.Int8Hnsw; + } + + if (reader.ValueTextEquals(MemberInt8Flat)) + { + return DenseVectorIndexOptionsType.Int8Flat; + } + + if (reader.ValueTextEquals(MemberInt4Hnsw)) + { + return DenseVectorIndexOptionsType.Int4Hnsw; + } + + if (reader.ValueTextEquals(MemberInt4Flat)) + { + return DenseVectorIndexOptionsType.Int4Flat; + } + + if (reader.ValueTextEquals(MemberHnsw)) + { + return DenseVectorIndexOptionsType.Hnsw; + } + + if (reader.ValueTextEquals(MemberFlat)) + { + return DenseVectorIndexOptionsType.Flat; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorIndexOptionsType)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorIndexOptionsType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorIndexOptionsType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorIndexOptionsType.Int8Hnsw: - writer.WriteStringValue("int8_hnsw"); - return; + writer.WriteStringValue(MemberInt8Hnsw); + break; case DenseVectorIndexOptionsType.Int8Flat: - writer.WriteStringValue("int8_flat"); - return; + writer.WriteStringValue(MemberInt8Flat); + break; case DenseVectorIndexOptionsType.Int4Hnsw: - writer.WriteStringValue("int4_hnsw"); - return; + writer.WriteStringValue(MemberInt4Hnsw); + break; case DenseVectorIndexOptionsType.Int4Flat: - writer.WriteStringValue("int4_flat"); - return; + writer.WriteStringValue(MemberInt4Flat); + break; case DenseVectorIndexOptionsType.Hnsw: - writer.WriteStringValue("hnsw"); - return; + writer.WriteStringValue(MemberHnsw); + break; case DenseVectorIndexOptionsType.Flat: - writer.WriteStringValue("flat"); - return; + writer.WriteStringValue(MemberFlat); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorIndexOptionsType)}'."); } - - writer.WriteNullValue(); } } @@ -277,46 +305,58 @@ public enum DenseVectorSimilarity Cosine } -internal sealed class DenseVectorSimilarityConverter : JsonConverter +internal sealed partial class DenseVectorSimilarityConverter : System.Text.Json.Serialization.JsonConverter { - public override DenseVectorSimilarity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMaxInnerProduct = System.Text.Json.JsonEncodedText.Encode("max_inner_product"); + private static readonly System.Text.Json.JsonEncodedText MemberL2Norm = System.Text.Json.JsonEncodedText.Encode("l2_norm"); + private static readonly System.Text.Json.JsonEncodedText MemberDotProduct = System.Text.Json.JsonEncodedText.Encode("dot_product"); + private static readonly System.Text.Json.JsonEncodedText MemberCosine = System.Text.Json.JsonEncodedText.Encode("cosine"); + + public override DenseVectorSimilarity Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMaxInnerProduct)) { - case "max_inner_product": - return DenseVectorSimilarity.MaxInnerProduct; - case "l2_norm": - return DenseVectorSimilarity.L2Norm; - case "dot_product": - return DenseVectorSimilarity.DotProduct; - case "cosine": - return DenseVectorSimilarity.Cosine; + return DenseVectorSimilarity.MaxInnerProduct; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberL2Norm)) + { + return DenseVectorSimilarity.L2Norm; + } + + if (reader.ValueTextEquals(MemberDotProduct)) + { + return DenseVectorSimilarity.DotProduct; + } + + if (reader.ValueTextEquals(MemberCosine)) + { + return DenseVectorSimilarity.Cosine; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DenseVectorSimilarity)}'."); } - public override void Write(Utf8JsonWriter writer, DenseVectorSimilarity value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DenseVectorSimilarity value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DenseVectorSimilarity.MaxInnerProduct: - writer.WriteStringValue("max_inner_product"); - return; + writer.WriteStringValue(MemberMaxInnerProduct); + break; case DenseVectorSimilarity.L2Norm: - writer.WriteStringValue("l2_norm"); - return; + writer.WriteStringValue(MemberL2Norm); + break; case DenseVectorSimilarity.DotProduct: - writer.WriteStringValue("dot_product"); - return; + writer.WriteStringValue(MemberDotProduct); + break; case DenseVectorSimilarity.Cosine: - writer.WriteStringValue("cosine"); - return; + writer.WriteStringValue(MemberCosine); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DenseVectorSimilarity)}'."); } - - writer.WriteNullValue(); } } @@ -333,46 +373,58 @@ public enum DynamicMapping False } -internal sealed class DynamicMappingConverter : JsonConverter +internal sealed partial class DynamicMappingConverter : System.Text.Json.Serialization.JsonConverter { - public override DynamicMapping Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTrue = System.Text.Json.JsonEncodedText.Encode("true"); + private static readonly System.Text.Json.JsonEncodedText MemberStrict = System.Text.Json.JsonEncodedText.Encode("strict"); + private static readonly System.Text.Json.JsonEncodedText MemberRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + private static readonly System.Text.Json.JsonEncodedText MemberFalse = System.Text.Json.JsonEncodedText.Encode("false"); + + public override DynamicMapping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTrue)) + { + return DynamicMapping.True; + } + + if (reader.ValueTextEquals(MemberStrict)) + { + return DynamicMapping.Strict; + } + + if (reader.ValueTextEquals(MemberRuntime)) + { + return DynamicMapping.Runtime; + } + + if (reader.ValueTextEquals(MemberFalse)) { - case "true": - return DynamicMapping.True; - case "strict": - return DynamicMapping.Strict; - case "runtime": - return DynamicMapping.Runtime; - case "false": - return DynamicMapping.False; + return DynamicMapping.False; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DynamicMapping)}'."); } - public override void Write(Utf8JsonWriter writer, DynamicMapping value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicMapping value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DynamicMapping.True: - writer.WriteStringValue("true"); - return; + writer.WriteStringValue(MemberTrue); + break; case DynamicMapping.Strict: - writer.WriteStringValue("strict"); - return; + writer.WriteStringValue(MemberStrict); + break; case DynamicMapping.Runtime: - writer.WriteStringValue("runtime"); - return; + writer.WriteStringValue(MemberRuntime); + break; case DynamicMapping.False: - writer.WriteStringValue("false"); - return; + writer.WriteStringValue(MemberFalse); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DynamicMapping)}'."); } - - writer.WriteNullValue(); } } @@ -475,261 +527,445 @@ public enum FieldType AggregateMetricDouble } -internal sealed class FieldTypeConverter : JsonConverter +internal sealed partial class FieldTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberTokenCount = System.Text.Json.JsonEncodedText.Encode("token_count"); + private static readonly System.Text.Json.JsonEncodedText MemberText = System.Text.Json.JsonEncodedText.Encode("text"); + private static readonly System.Text.Json.JsonEncodedText MemberSparseVector = System.Text.Json.JsonEncodedText.Encode("sparse_vector"); + private static readonly System.Text.Json.JsonEncodedText MemberShort = System.Text.Json.JsonEncodedText.Encode("short"); + private static readonly System.Text.Json.JsonEncodedText MemberShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText MemberSemanticText = System.Text.Json.JsonEncodedText.Encode("semantic_text"); + private static readonly System.Text.Json.JsonEncodedText MemberSearchAsYouType = System.Text.Json.JsonEncodedText.Encode("search_as_you_type"); + private static readonly System.Text.Json.JsonEncodedText MemberScaledFloat = System.Text.Json.JsonEncodedText.Encode("scaled_float"); + private static readonly System.Text.Json.JsonEncodedText MemberRankFeatures = System.Text.Json.JsonEncodedText.Encode("rank_features"); + private static readonly System.Text.Json.JsonEncodedText MemberRankFeature = System.Text.Json.JsonEncodedText.Encode("rank_feature"); + private static readonly System.Text.Json.JsonEncodedText MemberPercolator = System.Text.Json.JsonEncodedText.Encode("percolator"); + private static readonly System.Text.Json.JsonEncodedText MemberPassthrough = System.Text.Json.JsonEncodedText.Encode("passthrough"); + private static readonly System.Text.Json.JsonEncodedText MemberObject = System.Text.Json.JsonEncodedText.Encode("object"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText MemberMurmur3 = System.Text.Json.JsonEncodedText.Encode("murmur3"); + private static readonly System.Text.Json.JsonEncodedText MemberMatchOnlyText = System.Text.Json.JsonEncodedText.Encode("match_only_text"); + private static readonly System.Text.Json.JsonEncodedText MemberLongRange = System.Text.Json.JsonEncodedText.Encode("long_range"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberJoin = System.Text.Json.JsonEncodedText.Encode("join"); + private static readonly System.Text.Json.JsonEncodedText MemberIpRange = System.Text.Json.JsonEncodedText.Encode("ip_range"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberIntegerRange = System.Text.Json.JsonEncodedText.Encode("integer_range"); + private static readonly System.Text.Json.JsonEncodedText MemberInteger = System.Text.Json.JsonEncodedText.Encode("integer"); + private static readonly System.Text.Json.JsonEncodedText MemberIcuCollationKeyword = System.Text.Json.JsonEncodedText.Encode("icu_collation_keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText MemberHalfFloat = System.Text.Json.JsonEncodedText.Encode("half_float"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberFloatRange = System.Text.Json.JsonEncodedText.Encode("float_range"); + private static readonly System.Text.Json.JsonEncodedText MemberFloat = System.Text.Json.JsonEncodedText.Encode("float"); + private static readonly System.Text.Json.JsonEncodedText MemberFlattened = System.Text.Json.JsonEncodedText.Encode("flattened"); + private static readonly System.Text.Json.JsonEncodedText MemberDoubleRange = System.Text.Json.JsonEncodedText.Encode("double_range"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDenseVector = System.Text.Json.JsonEncodedText.Encode("dense_vector"); + private static readonly System.Text.Json.JsonEncodedText MemberDateRange = System.Text.Json.JsonEncodedText.Encode("date_range"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberConstantKeyword = System.Text.Json.JsonEncodedText.Encode("constant_keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberCompletion = System.Text.Json.JsonEncodedText.Encode("completion"); + private static readonly System.Text.Json.JsonEncodedText MemberByte = System.Text.Json.JsonEncodedText.Encode("byte"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + private static readonly System.Text.Json.JsonEncodedText MemberBinary = System.Text.Json.JsonEncodedText.Encode("binary"); + private static readonly System.Text.Json.JsonEncodedText MemberAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText MemberAggregateMetricDouble = System.Text.Json.JsonEncodedText.Encode("aggregate_metric_double"); + + public override FieldType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "version": - return FieldType.Version; - case "token_count": - return FieldType.TokenCount; - case "text": - return FieldType.Text; - case "sparse_vector": - return FieldType.SparseVector; - case "short": - return FieldType.Short; - case "shape": - return FieldType.Shape; - case "semantic_text": - return FieldType.SemanticText; - case "search_as_you_type": - return FieldType.SearchAsYouType; - case "scaled_float": - return FieldType.ScaledFloat; - case "rank_features": - return FieldType.RankFeatures; - case "rank_feature": - return FieldType.RankFeature; - case "percolator": - return FieldType.Percolator; - case "passthrough": - return FieldType.Passthrough; - case "object": - return FieldType.Object; - case "none": - return FieldType.None; - case "nested": - return FieldType.Nested; - case "murmur3": - return FieldType.Murmur3; - case "match_only_text": - return FieldType.MatchOnlyText; - case "long_range": - return FieldType.LongRange; - case "long": - return FieldType.Long; - case "keyword": - return FieldType.Keyword; - case "join": - return FieldType.Join; - case "ip_range": - return FieldType.IpRange; - case "ip": - return FieldType.Ip; - case "integer_range": - return FieldType.IntegerRange; - case "integer": - return FieldType.Integer; - case "icu_collation_keyword": - return FieldType.IcuCollationKeyword; - case "histogram": - return FieldType.Histogram; - case "half_float": - return FieldType.HalfFloat; - case "geo_shape": - return FieldType.GeoShape; - case "geo_point": - return FieldType.GeoPoint; - case "float_range": - return FieldType.FloatRange; - case "float": - return FieldType.Float; - case "flattened": - return FieldType.Flattened; - case "double_range": - return FieldType.DoubleRange; - case "double": - return FieldType.Double; - case "dense_vector": - return FieldType.DenseVector; - case "date_range": - return FieldType.DateRange; - case "date_nanos": - return FieldType.DateNanos; - case "date": - return FieldType.Date; - case "constant_keyword": - return FieldType.ConstantKeyword; - case "completion": - return FieldType.Completion; - case "byte": - return FieldType.Byte; - case "boolean": - return FieldType.Boolean; - case "binary": - return FieldType.Binary; - case "alias": - return FieldType.Alias; - case "aggregate_metric_double": - return FieldType.AggregateMetricDouble; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return FieldType.Version; + } + + if (reader.ValueTextEquals(MemberTokenCount)) + { + return FieldType.TokenCount; + } + + if (reader.ValueTextEquals(MemberText)) + { + return FieldType.Text; + } + + if (reader.ValueTextEquals(MemberSparseVector)) + { + return FieldType.SparseVector; + } + + if (reader.ValueTextEquals(MemberShort)) + { + return FieldType.Short; + } + + if (reader.ValueTextEquals(MemberShape)) + { + return FieldType.Shape; + } + + if (reader.ValueTextEquals(MemberSemanticText)) + { + return FieldType.SemanticText; + } + + if (reader.ValueTextEquals(MemberSearchAsYouType)) + { + return FieldType.SearchAsYouType; + } + + if (reader.ValueTextEquals(MemberScaledFloat)) + { + return FieldType.ScaledFloat; + } + + if (reader.ValueTextEquals(MemberRankFeatures)) + { + return FieldType.RankFeatures; + } + + if (reader.ValueTextEquals(MemberRankFeature)) + { + return FieldType.RankFeature; + } + + if (reader.ValueTextEquals(MemberPercolator)) + { + return FieldType.Percolator; + } + + if (reader.ValueTextEquals(MemberPassthrough)) + { + return FieldType.Passthrough; + } + + if (reader.ValueTextEquals(MemberObject)) + { + return FieldType.Object; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return FieldType.None; + } + + if (reader.ValueTextEquals(MemberNested)) + { + return FieldType.Nested; + } + + if (reader.ValueTextEquals(MemberMurmur3)) + { + return FieldType.Murmur3; + } + + if (reader.ValueTextEquals(MemberMatchOnlyText)) + { + return FieldType.MatchOnlyText; + } + + if (reader.ValueTextEquals(MemberLongRange)) + { + return FieldType.LongRange; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return FieldType.Long; + } + + if (reader.ValueTextEquals(MemberKeyword)) + { + return FieldType.Keyword; + } + + if (reader.ValueTextEquals(MemberJoin)) + { + return FieldType.Join; + } + + if (reader.ValueTextEquals(MemberIpRange)) + { + return FieldType.IpRange; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return FieldType.Ip; + } + + if (reader.ValueTextEquals(MemberIntegerRange)) + { + return FieldType.IntegerRange; + } + + if (reader.ValueTextEquals(MemberInteger)) + { + return FieldType.Integer; + } + + if (reader.ValueTextEquals(MemberIcuCollationKeyword)) + { + return FieldType.IcuCollationKeyword; + } + + if (reader.ValueTextEquals(MemberHistogram)) + { + return FieldType.Histogram; + } + + if (reader.ValueTextEquals(MemberHalfFloat)) + { + return FieldType.HalfFloat; + } + + if (reader.ValueTextEquals(MemberGeoShape)) + { + return FieldType.GeoShape; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return FieldType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberFloatRange)) + { + return FieldType.FloatRange; + } + + if (reader.ValueTextEquals(MemberFloat)) + { + return FieldType.Float; + } + + if (reader.ValueTextEquals(MemberFlattened)) + { + return FieldType.Flattened; + } + + if (reader.ValueTextEquals(MemberDoubleRange)) + { + return FieldType.DoubleRange; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return FieldType.Double; + } + + if (reader.ValueTextEquals(MemberDenseVector)) + { + return FieldType.DenseVector; + } + + if (reader.ValueTextEquals(MemberDateRange)) + { + return FieldType.DateRange; + } + + if (reader.ValueTextEquals(MemberDateNanos)) + { + return FieldType.DateNanos; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return FieldType.Date; + } + + if (reader.ValueTextEquals(MemberConstantKeyword)) + { + return FieldType.ConstantKeyword; + } + + if (reader.ValueTextEquals(MemberCompletion)) + { + return FieldType.Completion; + } + + if (reader.ValueTextEquals(MemberByte)) + { + return FieldType.Byte; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return FieldType.Boolean; + } + + if (reader.ValueTextEquals(MemberBinary)) + { + return FieldType.Binary; + } + + if (reader.ValueTextEquals(MemberAlias)) + { + return FieldType.Alias; + } + + if (reader.ValueTextEquals(MemberAggregateMetricDouble)) + { + return FieldType.AggregateMetricDouble; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldType)}'."); } - public override void Write(Utf8JsonWriter writer, FieldType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldType.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case FieldType.TokenCount: - writer.WriteStringValue("token_count"); - return; + writer.WriteStringValue(MemberTokenCount); + break; case FieldType.Text: - writer.WriteStringValue("text"); - return; + writer.WriteStringValue(MemberText); + break; case FieldType.SparseVector: - writer.WriteStringValue("sparse_vector"); - return; + writer.WriteStringValue(MemberSparseVector); + break; case FieldType.Short: - writer.WriteStringValue("short"); - return; + writer.WriteStringValue(MemberShort); + break; case FieldType.Shape: - writer.WriteStringValue("shape"); - return; + writer.WriteStringValue(MemberShape); + break; case FieldType.SemanticText: - writer.WriteStringValue("semantic_text"); - return; + writer.WriteStringValue(MemberSemanticText); + break; case FieldType.SearchAsYouType: - writer.WriteStringValue("search_as_you_type"); - return; + writer.WriteStringValue(MemberSearchAsYouType); + break; case FieldType.ScaledFloat: - writer.WriteStringValue("scaled_float"); - return; + writer.WriteStringValue(MemberScaledFloat); + break; case FieldType.RankFeatures: - writer.WriteStringValue("rank_features"); - return; + writer.WriteStringValue(MemberRankFeatures); + break; case FieldType.RankFeature: - writer.WriteStringValue("rank_feature"); - return; + writer.WriteStringValue(MemberRankFeature); + break; case FieldType.Percolator: - writer.WriteStringValue("percolator"); - return; + writer.WriteStringValue(MemberPercolator); + break; case FieldType.Passthrough: - writer.WriteStringValue("passthrough"); - return; + writer.WriteStringValue(MemberPassthrough); + break; case FieldType.Object: - writer.WriteStringValue("object"); - return; + writer.WriteStringValue(MemberObject); + break; case FieldType.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case FieldType.Nested: - writer.WriteStringValue("nested"); - return; + writer.WriteStringValue(MemberNested); + break; case FieldType.Murmur3: - writer.WriteStringValue("murmur3"); - return; + writer.WriteStringValue(MemberMurmur3); + break; case FieldType.MatchOnlyText: - writer.WriteStringValue("match_only_text"); - return; + writer.WriteStringValue(MemberMatchOnlyText); + break; case FieldType.LongRange: - writer.WriteStringValue("long_range"); - return; + writer.WriteStringValue(MemberLongRange); + break; case FieldType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case FieldType.Keyword: - writer.WriteStringValue("keyword"); - return; + writer.WriteStringValue(MemberKeyword); + break; case FieldType.Join: - writer.WriteStringValue("join"); - return; + writer.WriteStringValue(MemberJoin); + break; case FieldType.IpRange: - writer.WriteStringValue("ip_range"); - return; + writer.WriteStringValue(MemberIpRange); + break; case FieldType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case FieldType.IntegerRange: - writer.WriteStringValue("integer_range"); - return; + writer.WriteStringValue(MemberIntegerRange); + break; case FieldType.Integer: - writer.WriteStringValue("integer"); - return; + writer.WriteStringValue(MemberInteger); + break; case FieldType.IcuCollationKeyword: - writer.WriteStringValue("icu_collation_keyword"); - return; + writer.WriteStringValue(MemberIcuCollationKeyword); + break; case FieldType.Histogram: - writer.WriteStringValue("histogram"); - return; + writer.WriteStringValue(MemberHistogram); + break; case FieldType.HalfFloat: - writer.WriteStringValue("half_float"); - return; + writer.WriteStringValue(MemberHalfFloat); + break; case FieldType.GeoShape: - writer.WriteStringValue("geo_shape"); - return; + writer.WriteStringValue(MemberGeoShape); + break; case FieldType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case FieldType.FloatRange: - writer.WriteStringValue("float_range"); - return; + writer.WriteStringValue(MemberFloatRange); + break; case FieldType.Float: - writer.WriteStringValue("float"); - return; + writer.WriteStringValue(MemberFloat); + break; case FieldType.Flattened: - writer.WriteStringValue("flattened"); - return; + writer.WriteStringValue(MemberFlattened); + break; case FieldType.DoubleRange: - writer.WriteStringValue("double_range"); - return; + writer.WriteStringValue(MemberDoubleRange); + break; case FieldType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case FieldType.DenseVector: - writer.WriteStringValue("dense_vector"); - return; + writer.WriteStringValue(MemberDenseVector); + break; case FieldType.DateRange: - writer.WriteStringValue("date_range"); - return; + writer.WriteStringValue(MemberDateRange); + break; case FieldType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case FieldType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case FieldType.ConstantKeyword: - writer.WriteStringValue("constant_keyword"); - return; + writer.WriteStringValue(MemberConstantKeyword); + break; case FieldType.Completion: - writer.WriteStringValue("completion"); - return; + writer.WriteStringValue(MemberCompletion); + break; case FieldType.Byte: - writer.WriteStringValue("byte"); - return; + writer.WriteStringValue(MemberByte); + break; case FieldType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; case FieldType.Binary: - writer.WriteStringValue("binary"); - return; + writer.WriteStringValue(MemberBinary); + break; case FieldType.Alias: - writer.WriteStringValue("alias"); - return; + writer.WriteStringValue(MemberAlias); + break; case FieldType.AggregateMetricDouble: - writer.WriteStringValue("aggregate_metric_double"); - return; + writer.WriteStringValue(MemberAggregateMetricDouble); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldType)}'."); } - - writer.WriteNullValue(); } } @@ -742,42 +978,46 @@ public enum GeoOrientation Left } -internal sealed class GeoOrientationConverter : JsonConverter +internal sealed partial class GeoOrientationConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoOrientation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRight = System.Text.Json.JsonEncodedText.Encode("right"); + private static readonly System.Text.Json.JsonEncodedText MemberRight1 = System.Text.Json.JsonEncodedText.Encode("RIGHT"); + private static readonly System.Text.Json.JsonEncodedText MemberRight2 = System.Text.Json.JsonEncodedText.Encode("counterclockwise"); + private static readonly System.Text.Json.JsonEncodedText MemberRight3 = System.Text.Json.JsonEncodedText.Encode("ccw"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft = System.Text.Json.JsonEncodedText.Encode("left"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft1 = System.Text.Json.JsonEncodedText.Encode("LEFT"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft2 = System.Text.Json.JsonEncodedText.Encode("clockwise"); + private static readonly System.Text.Json.JsonEncodedText MemberLeft3 = System.Text.Json.JsonEncodedText.Encode("cw"); + + public override GeoOrientation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "right": - case "RIGHT": - case "counterclockwise": - case "ccw": - return GeoOrientation.Right; - case "left": - case "LEFT": - case "clockwise": - case "cw": - return GeoOrientation.Left; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRight) || reader.ValueTextEquals(MemberRight1) || reader.ValueTextEquals(MemberRight2) || reader.ValueTextEquals(MemberRight3)) + { + return GeoOrientation.Right; + } + + if (reader.ValueTextEquals(MemberLeft) || reader.ValueTextEquals(MemberLeft1) || reader.ValueTextEquals(MemberLeft2) || reader.ValueTextEquals(MemberLeft3)) + { + return GeoOrientation.Left; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoOrientation)}'."); } - public override void Write(Utf8JsonWriter writer, GeoOrientation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoOrientation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoOrientation.Right: - writer.WriteStringValue("right"); - return; + writer.WriteStringValue(MemberRight); + break; case GeoOrientation.Left: - writer.WriteStringValue("left"); - return; + writer.WriteStringValue(MemberLeft); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoOrientation)}'."); } - - writer.WriteNullValue(); } } @@ -790,36 +1030,40 @@ public enum GeoStrategy Recursive } -internal sealed class GeoStrategyConverter : JsonConverter +internal sealed partial class GeoStrategyConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoStrategy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTerm = System.Text.Json.JsonEncodedText.Encode("term"); + private static readonly System.Text.Json.JsonEncodedText MemberRecursive = System.Text.Json.JsonEncodedText.Encode("recursive"); + + public override GeoStrategy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTerm)) { - case "term": - return GeoStrategy.Term; - case "recursive": - return GeoStrategy.Recursive; + return GeoStrategy.Term; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRecursive)) + { + return GeoStrategy.Recursive; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoStrategy)}'."); } - public override void Write(Utf8JsonWriter writer, GeoStrategy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoStrategy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoStrategy.Term: - writer.WriteStringValue("term"); - return; + writer.WriteStringValue(MemberTerm); + break; case GeoStrategy.Recursive: - writer.WriteStringValue("recursive"); - return; + writer.WriteStringValue(MemberRecursive); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoStrategy)}'."); } - - writer.WriteNullValue(); } } @@ -836,46 +1080,58 @@ public enum IndexOptions Docs } -internal sealed class IndexOptionsConverter : JsonConverter +internal sealed partial class IndexOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPositions = System.Text.Json.JsonEncodedText.Encode("positions"); + private static readonly System.Text.Json.JsonEncodedText MemberOffsets = System.Text.Json.JsonEncodedText.Encode("offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberFreqs = System.Text.Json.JsonEncodedText.Encode("freqs"); + private static readonly System.Text.Json.JsonEncodedText MemberDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + + public override IndexOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPositions)) + { + return IndexOptions.Positions; + } + + if (reader.ValueTextEquals(MemberOffsets)) { - case "positions": - return IndexOptions.Positions; - case "offsets": - return IndexOptions.Offsets; - case "freqs": - return IndexOptions.Freqs; - case "docs": - return IndexOptions.Docs; + return IndexOptions.Offsets; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberFreqs)) + { + return IndexOptions.Freqs; + } + + if (reader.ValueTextEquals(MemberDocs)) + { + return IndexOptions.Docs; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexOptions)}'."); } - public override void Write(Utf8JsonWriter writer, IndexOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexOptions.Positions: - writer.WriteStringValue("positions"); - return; + writer.WriteStringValue(MemberPositions); + break; case IndexOptions.Offsets: - writer.WriteStringValue("offsets"); - return; + writer.WriteStringValue(MemberOffsets); + break; case IndexOptions.Freqs: - writer.WriteStringValue("freqs"); - return; + writer.WriteStringValue(MemberFreqs); + break; case IndexOptions.Docs: - writer.WriteStringValue("docs"); - return; + writer.WriteStringValue(MemberDocs); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexOptions)}'."); } - - writer.WriteNullValue(); } } @@ -888,36 +1144,40 @@ public enum MatchType Regex } -internal sealed class MatchTypeConverter : JsonConverter +internal sealed partial class MatchTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSimple = System.Text.Json.JsonEncodedText.Encode("simple"); + private static readonly System.Text.Json.JsonEncodedText MemberRegex = System.Text.Json.JsonEncodedText.Encode("regex"); + + public override MatchType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSimple)) + { + return MatchType.Simple; + } + + if (reader.ValueTextEquals(MemberRegex)) { - case "simple": - return MatchType.Simple; - case "regex": - return MatchType.Regex; + return MatchType.Regex; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MatchType)}'."); } - public override void Write(Utf8JsonWriter writer, MatchType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MatchType.Simple: - writer.WriteStringValue("simple"); - return; + writer.WriteStringValue(MemberSimple); + break; case MatchType.Regex: - writer.WriteStringValue("regex"); - return; + writer.WriteStringValue(MemberRegex); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MatchType)}'."); } - - writer.WriteNullValue(); } } @@ -930,36 +1190,40 @@ public enum OnScriptError Continue } -internal sealed class OnScriptErrorConverter : JsonConverter +internal sealed partial class OnScriptErrorConverter : System.Text.Json.Serialization.JsonConverter { - public override OnScriptError Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberFail = System.Text.Json.JsonEncodedText.Encode("fail"); + private static readonly System.Text.Json.JsonEncodedText MemberContinue = System.Text.Json.JsonEncodedText.Encode("continue"); + + public override OnScriptError Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberFail)) { - case "fail": - return OnScriptError.Fail; - case "continue": - return OnScriptError.Continue; + return OnScriptError.Fail; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberContinue)) + { + return OnScriptError.Continue; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(OnScriptError)}'."); } - public override void Write(Utf8JsonWriter writer, OnScriptError value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, OnScriptError value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case OnScriptError.Fail: - writer.WriteStringValue("fail"); - return; + writer.WriteStringValue(MemberFail); + break; case OnScriptError.Continue: - writer.WriteStringValue("continue"); - return; + writer.WriteStringValue(MemberContinue); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(OnScriptError)}'."); } - - writer.WriteNullValue(); } } @@ -986,71 +1250,103 @@ public enum RuntimeFieldType Boolean } -internal sealed class RuntimeFieldTypeConverter : JsonConverter +internal sealed partial class RuntimeFieldTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override RuntimeFieldType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLookup = System.Text.Json.JsonEncodedText.Encode("lookup"); + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText MemberIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText MemberGeoPoint = System.Text.Json.JsonEncodedText.Encode("geo_point"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText MemberComposite = System.Text.Json.JsonEncodedText.Encode("composite"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolean = System.Text.Json.JsonEncodedText.Encode("boolean"); + + public override RuntimeFieldType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "lookup": - return RuntimeFieldType.Lookup; - case "long": - return RuntimeFieldType.Long; - case "keyword": - return RuntimeFieldType.Keyword; - case "ip": - return RuntimeFieldType.Ip; - case "geo_point": - return RuntimeFieldType.GeoPoint; - case "double": - return RuntimeFieldType.Double; - case "date": - return RuntimeFieldType.Date; - case "composite": - return RuntimeFieldType.Composite; - case "boolean": - return RuntimeFieldType.Boolean; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLookup)) + { + return RuntimeFieldType.Lookup; + } + + if (reader.ValueTextEquals(MemberLong)) + { + return RuntimeFieldType.Long; + } + + if (reader.ValueTextEquals(MemberKeyword)) + { + return RuntimeFieldType.Keyword; + } + + if (reader.ValueTextEquals(MemberIp)) + { + return RuntimeFieldType.Ip; + } + + if (reader.ValueTextEquals(MemberGeoPoint)) + { + return RuntimeFieldType.GeoPoint; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return RuntimeFieldType.Double; + } + + if (reader.ValueTextEquals(MemberDate)) + { + return RuntimeFieldType.Date; + } + + if (reader.ValueTextEquals(MemberComposite)) + { + return RuntimeFieldType.Composite; + } + + if (reader.ValueTextEquals(MemberBoolean)) + { + return RuntimeFieldType.Boolean; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RuntimeFieldType)}'."); } - public override void Write(Utf8JsonWriter writer, RuntimeFieldType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuntimeFieldType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RuntimeFieldType.Lookup: - writer.WriteStringValue("lookup"); - return; + writer.WriteStringValue(MemberLookup); + break; case RuntimeFieldType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case RuntimeFieldType.Keyword: - writer.WriteStringValue("keyword"); - return; + writer.WriteStringValue(MemberKeyword); + break; case RuntimeFieldType.Ip: - writer.WriteStringValue("ip"); - return; + writer.WriteStringValue(MemberIp); + break; case RuntimeFieldType.GeoPoint: - writer.WriteStringValue("geo_point"); - return; + writer.WriteStringValue(MemberGeoPoint); + break; case RuntimeFieldType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case RuntimeFieldType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; case RuntimeFieldType.Composite: - writer.WriteStringValue("composite"); - return; + writer.WriteStringValue(MemberComposite); + break; case RuntimeFieldType.Boolean: - writer.WriteStringValue("boolean"); - return; + writer.WriteStringValue(MemberBoolean); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RuntimeFieldType)}'."); } - - writer.WriteNullValue(); } } @@ -1071,41 +1367,49 @@ public enum SourceFieldMode Disabled } -internal sealed class SourceFieldModeConverter : JsonConverter +internal sealed partial class SourceFieldModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SourceFieldMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSynthetic = System.Text.Json.JsonEncodedText.Encode("synthetic"); + private static readonly System.Text.Json.JsonEncodedText MemberStored = System.Text.Json.JsonEncodedText.Encode("stored"); + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + + public override SourceFieldMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSynthetic)) { - case "synthetic": - return SourceFieldMode.Synthetic; - case "stored": - return SourceFieldMode.Stored; - case "disabled": - return SourceFieldMode.Disabled; + return SourceFieldMode.Synthetic; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStored)) + { + return SourceFieldMode.Stored; + } + + if (reader.ValueTextEquals(MemberDisabled)) + { + return SourceFieldMode.Disabled; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SourceFieldMode)}'."); } - public override void Write(Utf8JsonWriter writer, SourceFieldMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SourceFieldMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SourceFieldMode.Synthetic: - writer.WriteStringValue("synthetic"); - return; + writer.WriteStringValue(MemberSynthetic); + break; case SourceFieldMode.Stored: - writer.WriteStringValue("stored"); - return; + writer.WriteStringValue(MemberStored); + break; case SourceFieldMode.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SourceFieldMode)}'."); } - - writer.WriteNullValue(); } } @@ -1128,61 +1432,85 @@ public enum TermVectorOption No } -internal sealed class TermVectorOptionConverter : JsonConverter +internal sealed partial class TermVectorOptionConverter : System.Text.Json.Serialization.JsonConverter { - public override TermVectorOption Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYes = System.Text.Json.JsonEncodedText.Encode("yes"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsPayloads = System.Text.Json.JsonEncodedText.Encode("with_positions_payloads"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsOffsetsPayloads = System.Text.Json.JsonEncodedText.Encode("with_positions_offsets_payloads"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositionsOffsets = System.Text.Json.JsonEncodedText.Encode("with_positions_offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberWithPositions = System.Text.Json.JsonEncodedText.Encode("with_positions"); + private static readonly System.Text.Json.JsonEncodedText MemberWithOffsets = System.Text.Json.JsonEncodedText.Encode("with_offsets"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + + public override TermVectorOption Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yes": - return TermVectorOption.Yes; - case "with_positions_payloads": - return TermVectorOption.WithPositionsPayloads; - case "with_positions_offsets_payloads": - return TermVectorOption.WithPositionsOffsetsPayloads; - case "with_positions_offsets": - return TermVectorOption.WithPositionsOffsets; - case "with_positions": - return TermVectorOption.WithPositions; - case "with_offsets": - return TermVectorOption.WithOffsets; - case "no": - return TermVectorOption.No; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYes)) + { + return TermVectorOption.Yes; + } + + if (reader.ValueTextEquals(MemberWithPositionsPayloads)) + { + return TermVectorOption.WithPositionsPayloads; + } + + if (reader.ValueTextEquals(MemberWithPositionsOffsetsPayloads)) + { + return TermVectorOption.WithPositionsOffsetsPayloads; + } + + if (reader.ValueTextEquals(MemberWithPositionsOffsets)) + { + return TermVectorOption.WithPositionsOffsets; + } + + if (reader.ValueTextEquals(MemberWithPositions)) + { + return TermVectorOption.WithPositions; + } + + if (reader.ValueTextEquals(MemberWithOffsets)) + { + return TermVectorOption.WithOffsets; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return TermVectorOption.No; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TermVectorOption)}'."); } - public override void Write(Utf8JsonWriter writer, TermVectorOption value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermVectorOption value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TermVectorOption.Yes: - writer.WriteStringValue("yes"); - return; + writer.WriteStringValue(MemberYes); + break; case TermVectorOption.WithPositionsPayloads: - writer.WriteStringValue("with_positions_payloads"); - return; + writer.WriteStringValue(MemberWithPositionsPayloads); + break; case TermVectorOption.WithPositionsOffsetsPayloads: - writer.WriteStringValue("with_positions_offsets_payloads"); - return; + writer.WriteStringValue(MemberWithPositionsOffsetsPayloads); + break; case TermVectorOption.WithPositionsOffsets: - writer.WriteStringValue("with_positions_offsets"); - return; + writer.WriteStringValue(MemberWithPositionsOffsets); + break; case TermVectorOption.WithPositions: - writer.WriteStringValue("with_positions"); - return; + writer.WriteStringValue(MemberWithPositions); + break; case TermVectorOption.WithOffsets: - writer.WriteStringValue("with_offsets"); - return; + writer.WriteStringValue(MemberWithOffsets); + break; case TermVectorOption.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TermVectorOption)}'."); } - - writer.WriteNullValue(); } } @@ -1201,50 +1529,66 @@ public enum TimeSeriesMetricType Counter } -internal sealed class TimeSeriesMetricTypeConverter : JsonConverter +internal sealed partial class TimeSeriesMetricTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeSeriesMetricType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSummary = System.Text.Json.JsonEncodedText.Encode("summary"); + private static readonly System.Text.Json.JsonEncodedText MemberPosition = System.Text.Json.JsonEncodedText.Encode("position"); + private static readonly System.Text.Json.JsonEncodedText MemberHistogram = System.Text.Json.JsonEncodedText.Encode("histogram"); + private static readonly System.Text.Json.JsonEncodedText MemberGauge = System.Text.Json.JsonEncodedText.Encode("gauge"); + private static readonly System.Text.Json.JsonEncodedText MemberCounter = System.Text.Json.JsonEncodedText.Encode("counter"); + + public override TimeSeriesMetricType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "summary": - return TimeSeriesMetricType.Summary; - case "position": - return TimeSeriesMetricType.Position; - case "histogram": - return TimeSeriesMetricType.Histogram; - case "gauge": - return TimeSeriesMetricType.Gauge; - case "counter": - return TimeSeriesMetricType.Counter; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSummary)) + { + return TimeSeriesMetricType.Summary; + } + + if (reader.ValueTextEquals(MemberPosition)) + { + return TimeSeriesMetricType.Position; + } + + if (reader.ValueTextEquals(MemberHistogram)) + { + return TimeSeriesMetricType.Histogram; + } + + if (reader.ValueTextEquals(MemberGauge)) + { + return TimeSeriesMetricType.Gauge; + } + + if (reader.ValueTextEquals(MemberCounter)) + { + return TimeSeriesMetricType.Counter; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TimeSeriesMetricType)}'."); } - public override void Write(Utf8JsonWriter writer, TimeSeriesMetricType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeSeriesMetricType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TimeSeriesMetricType.Summary: - writer.WriteStringValue("summary"); - return; + writer.WriteStringValue(MemberSummary); + break; case TimeSeriesMetricType.Position: - writer.WriteStringValue("position"); - return; + writer.WriteStringValue(MemberPosition); + break; case TimeSeriesMetricType.Histogram: - writer.WriteStringValue("histogram"); - return; + writer.WriteStringValue(MemberHistogram); + break; case TimeSeriesMetricType.Gauge: - writer.WriteStringValue("gauge"); - return; + writer.WriteStringValue(MemberGauge); + break; case TimeSeriesMetricType.Counter: - writer.WriteStringValue("counter"); - return; + writer.WriteStringValue(MemberCounter); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TimeSeriesMetricType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs index f2c5c6202bc..fffff208821 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.NoNamespace.g.cs @@ -43,51 +43,67 @@ public enum ClusterInfoTarget All } -internal sealed class ClusterInfoTargetConverter : JsonConverter +internal sealed partial class ClusterInfoTargetConverter : System.Text.Json.Serialization.JsonConverter { - public override ClusterInfoTarget Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + private static readonly System.Text.Json.JsonEncodedText MemberScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("_all"); + + public override ClusterInfoTarget Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "thread_pool": - return ClusterInfoTarget.ThreadPool; - case "script": - return ClusterInfoTarget.Script; - case "ingest": - return ClusterInfoTarget.Ingest; - case "http": - return ClusterInfoTarget.Http; - case "_all": - return ClusterInfoTarget.All; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberThreadPool)) + { + return ClusterInfoTarget.ThreadPool; + } + + if (reader.ValueTextEquals(MemberScript)) + { + return ClusterInfoTarget.Script; + } + + if (reader.ValueTextEquals(MemberIngest)) + { + return ClusterInfoTarget.Ingest; + } + + if (reader.ValueTextEquals(MemberHttp)) + { + return ClusterInfoTarget.Http; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ClusterInfoTarget.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ClusterInfoTarget)}'."); } - public override void Write(Utf8JsonWriter writer, ClusterInfoTarget value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterInfoTarget value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ClusterInfoTarget.ThreadPool: - writer.WriteStringValue("thread_pool"); - return; + writer.WriteStringValue(MemberThreadPool); + break; case ClusterInfoTarget.Script: - writer.WriteStringValue("script"); - return; + writer.WriteStringValue(MemberScript); + break; case ClusterInfoTarget.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case ClusterInfoTarget.Http: - writer.WriteStringValue("http"); - return; + writer.WriteStringValue(MemberHttp); + break; case ClusterInfoTarget.All: - writer.WriteStringValue("_all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ClusterInfoTarget)}'."); } - - writer.WriteNullValue(); } } @@ -106,51 +122,67 @@ public enum ClusterSearchStatus Failed } -internal sealed class ClusterSearchStatusConverter : JsonConverter +internal sealed partial class ClusterSearchStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override ClusterSearchStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSuccessful = System.Text.Json.JsonEncodedText.Encode("successful"); + private static readonly System.Text.Json.JsonEncodedText MemberSkipped = System.Text.Json.JsonEncodedText.Encode("skipped"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("running"); + private static readonly System.Text.Json.JsonEncodedText MemberPartial = System.Text.Json.JsonEncodedText.Encode("partial"); + private static readonly System.Text.Json.JsonEncodedText MemberFailed = System.Text.Json.JsonEncodedText.Encode("failed"); + + public override ClusterSearchStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "successful": - return ClusterSearchStatus.Successful; - case "skipped": - return ClusterSearchStatus.Skipped; - case "running": - return ClusterSearchStatus.Running; - case "partial": - return ClusterSearchStatus.Partial; - case "failed": - return ClusterSearchStatus.Failed; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSuccessful)) + { + return ClusterSearchStatus.Successful; + } + + if (reader.ValueTextEquals(MemberSkipped)) + { + return ClusterSearchStatus.Skipped; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return ClusterSearchStatus.Running; + } + + if (reader.ValueTextEquals(MemberPartial)) + { + return ClusterSearchStatus.Partial; + } + + if (reader.ValueTextEquals(MemberFailed)) + { + return ClusterSearchStatus.Failed; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ClusterSearchStatus)}'."); } - public override void Write(Utf8JsonWriter writer, ClusterSearchStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ClusterSearchStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ClusterSearchStatus.Successful: - writer.WriteStringValue("successful"); - return; + writer.WriteStringValue(MemberSuccessful); + break; case ClusterSearchStatus.Skipped: - writer.WriteStringValue("skipped"); - return; + writer.WriteStringValue(MemberSkipped); + break; case ClusterSearchStatus.Running: - writer.WriteStringValue("running"); - return; + writer.WriteStringValue(MemberRunning); + break; case ClusterSearchStatus.Partial: - writer.WriteStringValue("partial"); - return; + writer.WriteStringValue(MemberPartial); + break; case ClusterSearchStatus.Failed: - writer.WriteStringValue("failed"); - return; + writer.WriteStringValue(MemberFailed); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ClusterSearchStatus)}'."); } - - writer.WriteNullValue(); } } @@ -173,36 +205,40 @@ public enum Conflicts Abort } -internal sealed class ConflictsConverter : JsonConverter +internal sealed partial class ConflictsConverter : System.Text.Json.Serialization.JsonConverter { - public override Conflicts Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberProceed = System.Text.Json.JsonEncodedText.Encode("proceed"); + private static readonly System.Text.Json.JsonEncodedText MemberAbort = System.Text.Json.JsonEncodedText.Encode("abort"); + + public override Conflicts Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberProceed)) + { + return Conflicts.Proceed; + } + + if (reader.ValueTextEquals(MemberAbort)) { - case "proceed": - return Conflicts.Proceed; - case "abort": - return Conflicts.Abort; + return Conflicts.Abort; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Conflicts)}'."); } - public override void Write(Utf8JsonWriter writer, Conflicts value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Conflicts value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Conflicts.Proceed: - writer.WriteStringValue("proceed"); - return; + writer.WriteStringValue(MemberProceed); + break; case Conflicts.Abort: - writer.WriteStringValue("abort"); - return; + writer.WriteStringValue(MemberAbort); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Conflicts)}'."); } - - writer.WriteNullValue(); } } @@ -217,41 +253,49 @@ public enum DFIIndependenceMeasure Chisquared } -internal sealed class DFIIndependenceMeasureConverter : JsonConverter +internal sealed partial class DFIIndependenceMeasureConverter : System.Text.Json.Serialization.JsonConverter { - public override DFIIndependenceMeasure Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStandardized = System.Text.Json.JsonEncodedText.Encode("standardized"); + private static readonly System.Text.Json.JsonEncodedText MemberSaturated = System.Text.Json.JsonEncodedText.Encode("saturated"); + private static readonly System.Text.Json.JsonEncodedText MemberChisquared = System.Text.Json.JsonEncodedText.Encode("chisquared"); + + public override DFIIndependenceMeasure Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStandardized)) + { + return DFIIndependenceMeasure.Standardized; + } + + if (reader.ValueTextEquals(MemberSaturated)) + { + return DFIIndependenceMeasure.Saturated; + } + + if (reader.ValueTextEquals(MemberChisquared)) { - case "standardized": - return DFIIndependenceMeasure.Standardized; - case "saturated": - return DFIIndependenceMeasure.Saturated; - case "chisquared": - return DFIIndependenceMeasure.Chisquared; + return DFIIndependenceMeasure.Chisquared; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFIIndependenceMeasure)}'."); } - public override void Write(Utf8JsonWriter writer, DFIIndependenceMeasure value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFIIndependenceMeasure value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFIIndependenceMeasure.Standardized: - writer.WriteStringValue("standardized"); - return; + writer.WriteStringValue(MemberStandardized); + break; case DFIIndependenceMeasure.Saturated: - writer.WriteStringValue("saturated"); - return; + writer.WriteStringValue(MemberSaturated); + break; case DFIIndependenceMeasure.Chisquared: - writer.WriteStringValue("chisquared"); - return; + writer.WriteStringValue(MemberChisquared); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFIIndependenceMeasure)}'."); } - - writer.WriteNullValue(); } } @@ -266,41 +310,49 @@ public enum DFRAfterEffect b } -internal sealed class DFRAfterEffectConverter : JsonConverter +internal sealed partial class DFRAfterEffectConverter : System.Text.Json.Serialization.JsonConverter { - public override DFRAfterEffect Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText Memberl = System.Text.Json.JsonEncodedText.Encode("l"); + private static readonly System.Text.Json.JsonEncodedText Memberb = System.Text.Json.JsonEncodedText.Encode("b"); + + public override DFRAfterEffect Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNo)) { - case "no": - return DFRAfterEffect.No; - case "l": - return DFRAfterEffect.l; - case "b": - return DFRAfterEffect.b; + return DFRAfterEffect.No; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(Memberl)) + { + return DFRAfterEffect.l; + } + + if (reader.ValueTextEquals(Memberb)) + { + return DFRAfterEffect.b; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFRAfterEffect)}'."); } - public override void Write(Utf8JsonWriter writer, DFRAfterEffect value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFRAfterEffect value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFRAfterEffect.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case DFRAfterEffect.l: - writer.WriteStringValue("l"); - return; + writer.WriteStringValue(Memberl); + break; case DFRAfterEffect.b: - writer.WriteStringValue("b"); - return; + writer.WriteStringValue(Memberb); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFRAfterEffect)}'."); } - - writer.WriteNullValue(); } } @@ -323,61 +375,85 @@ public enum DFRBasicModel Be } -internal sealed class DFRBasicModelConverter : JsonConverter +internal sealed partial class DFRBasicModelConverter : System.Text.Json.Serialization.JsonConverter { - public override DFRBasicModel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText Memberp = System.Text.Json.JsonEncodedText.Encode("p"); + private static readonly System.Text.Json.JsonEncodedText MemberIne = System.Text.Json.JsonEncodedText.Encode("ine"); + private static readonly System.Text.Json.JsonEncodedText MemberIn = System.Text.Json.JsonEncodedText.Encode("in"); + private static readonly System.Text.Json.JsonEncodedText MemberIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText Memberg = System.Text.Json.JsonEncodedText.Encode("g"); + private static readonly System.Text.Json.JsonEncodedText Memberd = System.Text.Json.JsonEncodedText.Encode("d"); + private static readonly System.Text.Json.JsonEncodedText MemberBe = System.Text.Json.JsonEncodedText.Encode("be"); + + public override DFRBasicModel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "p": - return DFRBasicModel.p; - case "ine": - return DFRBasicModel.Ine; - case "in": - return DFRBasicModel.In; - case "if": - return DFRBasicModel.If; - case "g": - return DFRBasicModel.g; - case "d": - return DFRBasicModel.d; - case "be": - return DFRBasicModel.Be; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(Memberp)) + { + return DFRBasicModel.p; + } + + if (reader.ValueTextEquals(MemberIne)) + { + return DFRBasicModel.Ine; + } + + if (reader.ValueTextEquals(MemberIn)) + { + return DFRBasicModel.In; + } + + if (reader.ValueTextEquals(MemberIf)) + { + return DFRBasicModel.If; + } + + if (reader.ValueTextEquals(Memberg)) + { + return DFRBasicModel.g; + } + + if (reader.ValueTextEquals(Memberd)) + { + return DFRBasicModel.d; + } + + if (reader.ValueTextEquals(MemberBe)) + { + return DFRBasicModel.Be; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DFRBasicModel)}'."); } - public override void Write(Utf8JsonWriter writer, DFRBasicModel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DFRBasicModel value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DFRBasicModel.p: - writer.WriteStringValue("p"); - return; + writer.WriteStringValue(Memberp); + break; case DFRBasicModel.Ine: - writer.WriteStringValue("ine"); - return; + writer.WriteStringValue(MemberIne); + break; case DFRBasicModel.In: - writer.WriteStringValue("in"); - return; + writer.WriteStringValue(MemberIn); + break; case DFRBasicModel.If: - writer.WriteStringValue("if"); - return; + writer.WriteStringValue(MemberIf); + break; case DFRBasicModel.g: - writer.WriteStringValue("g"); - return; + writer.WriteStringValue(Memberg); + break; case DFRBasicModel.d: - writer.WriteStringValue("d"); - return; + writer.WriteStringValue(Memberd); + break; case DFRBasicModel.Be: - writer.WriteStringValue("be"); - return; + writer.WriteStringValue(MemberBe); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DFRBasicModel)}'."); } - - writer.WriteNullValue(); } } @@ -404,71 +480,103 @@ public enum DistanceUnit Centimeters } -internal sealed class DistanceUnitConverter : JsonConverter +internal sealed partial class DistanceUnitConverter : System.Text.Json.Serialization.JsonConverter { - public override DistanceUnit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYards = System.Text.Json.JsonEncodedText.Encode("yd"); + private static readonly System.Text.Json.JsonEncodedText MemberNauticMiles = System.Text.Json.JsonEncodedText.Encode("nmi"); + private static readonly System.Text.Json.JsonEncodedText MemberMillimeters = System.Text.Json.JsonEncodedText.Encode("mm"); + private static readonly System.Text.Json.JsonEncodedText MemberMiles = System.Text.Json.JsonEncodedText.Encode("mi"); + private static readonly System.Text.Json.JsonEncodedText MemberMeters = System.Text.Json.JsonEncodedText.Encode("m"); + private static readonly System.Text.Json.JsonEncodedText MemberKilometers = System.Text.Json.JsonEncodedText.Encode("km"); + private static readonly System.Text.Json.JsonEncodedText MemberInches = System.Text.Json.JsonEncodedText.Encode("in"); + private static readonly System.Text.Json.JsonEncodedText MemberFeet = System.Text.Json.JsonEncodedText.Encode("ft"); + private static readonly System.Text.Json.JsonEncodedText MemberCentimeters = System.Text.Json.JsonEncodedText.Encode("cm"); + + public override DistanceUnit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yd": - return DistanceUnit.Yards; - case "nmi": - return DistanceUnit.NauticMiles; - case "mm": - return DistanceUnit.Millimeters; - case "mi": - return DistanceUnit.Miles; - case "m": - return DistanceUnit.Meters; - case "km": - return DistanceUnit.Kilometers; - case "in": - return DistanceUnit.Inches; - case "ft": - return DistanceUnit.Feet; - case "cm": - return DistanceUnit.Centimeters; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYards)) + { + return DistanceUnit.Yards; + } + + if (reader.ValueTextEquals(MemberNauticMiles)) + { + return DistanceUnit.NauticMiles; + } + + if (reader.ValueTextEquals(MemberMillimeters)) + { + return DistanceUnit.Millimeters; + } + + if (reader.ValueTextEquals(MemberMiles)) + { + return DistanceUnit.Miles; + } + + if (reader.ValueTextEquals(MemberMeters)) + { + return DistanceUnit.Meters; + } + + if (reader.ValueTextEquals(MemberKilometers)) + { + return DistanceUnit.Kilometers; + } + + if (reader.ValueTextEquals(MemberInches)) + { + return DistanceUnit.Inches; + } + + if (reader.ValueTextEquals(MemberFeet)) + { + return DistanceUnit.Feet; + } + + if (reader.ValueTextEquals(MemberCentimeters)) + { + return DistanceUnit.Centimeters; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(DistanceUnit)}'."); } - public override void Write(Utf8JsonWriter writer, DistanceUnit value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DistanceUnit value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case DistanceUnit.Yards: - writer.WriteStringValue("yd"); - return; + writer.WriteStringValue(MemberYards); + break; case DistanceUnit.NauticMiles: - writer.WriteStringValue("nmi"); - return; + writer.WriteStringValue(MemberNauticMiles); + break; case DistanceUnit.Millimeters: - writer.WriteStringValue("mm"); - return; + writer.WriteStringValue(MemberMillimeters); + break; case DistanceUnit.Miles: - writer.WriteStringValue("mi"); - return; + writer.WriteStringValue(MemberMiles); + break; case DistanceUnit.Meters: - writer.WriteStringValue("m"); - return; + writer.WriteStringValue(MemberMeters); + break; case DistanceUnit.Kilometers: - writer.WriteStringValue("km"); - return; + writer.WriteStringValue(MemberKilometers); + break; case DistanceUnit.Inches: - writer.WriteStringValue("in"); - return; + writer.WriteStringValue(MemberInches); + break; case DistanceUnit.Feet: - writer.WriteStringValue("ft"); - return; + writer.WriteStringValue(MemberFeet); + break; case DistanceUnit.Centimeters: - writer.WriteStringValue("cm"); - return; + writer.WriteStringValue(MemberCentimeters); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(DistanceUnit)}'."); } - - writer.WriteNullValue(); } } @@ -512,51 +620,67 @@ public enum ExpandWildcard All } -internal sealed class ExpandWildcardConverter : JsonConverter +internal sealed partial class ExpandWildcardConverter : System.Text.Json.Serialization.JsonConverter { - public override ExpandWildcard Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOpen = System.Text.Json.JsonEncodedText.Encode("open"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberHidden = System.Text.Json.JsonEncodedText.Encode("hidden"); + private static readonly System.Text.Json.JsonEncodedText MemberClosed = System.Text.Json.JsonEncodedText.Encode("closed"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ExpandWildcard Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "open": - return ExpandWildcard.Open; - case "none": - return ExpandWildcard.None; - case "hidden": - return ExpandWildcard.Hidden; - case "closed": - return ExpandWildcard.Closed; - case "all": - return ExpandWildcard.All; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOpen)) + { + return ExpandWildcard.Open; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ExpandWildcard.None; + } + + if (reader.ValueTextEquals(MemberHidden)) + { + return ExpandWildcard.Hidden; + } + + if (reader.ValueTextEquals(MemberClosed)) + { + return ExpandWildcard.Closed; + } + + if (reader.ValueTextEquals(MemberAll)) + { + return ExpandWildcard.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ExpandWildcard)}'."); } - public override void Write(Utf8JsonWriter writer, ExpandWildcard value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExpandWildcard value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ExpandWildcard.Open: - writer.WriteStringValue("open"); - return; + writer.WriteStringValue(MemberOpen); + break; case ExpandWildcard.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ExpandWildcard.Hidden: - writer.WriteStringValue("hidden"); - return; + writer.WriteStringValue(MemberHidden); + break; case ExpandWildcard.Closed: - writer.WriteStringValue("closed"); - return; + writer.WriteStringValue(MemberClosed); + break; case ExpandWildcard.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ExpandWildcard)}'."); } - - writer.WriteNullValue(); } } @@ -573,46 +697,58 @@ public enum FieldSortNumericType Date } -internal sealed class FieldSortNumericTypeConverter : JsonConverter +internal sealed partial class FieldSortNumericTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldSortNumericType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLong = System.Text.Json.JsonEncodedText.Encode("long"); + private static readonly System.Text.Json.JsonEncodedText MemberDouble = System.Text.Json.JsonEncodedText.Encode("double"); + private static readonly System.Text.Json.JsonEncodedText MemberDateNanos = System.Text.Json.JsonEncodedText.Encode("date_nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberDate = System.Text.Json.JsonEncodedText.Encode("date"); + + public override FieldSortNumericType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLong)) + { + return FieldSortNumericType.Long; + } + + if (reader.ValueTextEquals(MemberDouble)) + { + return FieldSortNumericType.Double; + } + + if (reader.ValueTextEquals(MemberDateNanos)) { - case "long": - return FieldSortNumericType.Long; - case "double": - return FieldSortNumericType.Double; - case "date_nanos": - return FieldSortNumericType.DateNanos; - case "date": - return FieldSortNumericType.Date; + return FieldSortNumericType.DateNanos; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDate)) + { + return FieldSortNumericType.Date; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldSortNumericType)}'."); } - public override void Write(Utf8JsonWriter writer, FieldSortNumericType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSortNumericType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldSortNumericType.Long: - writer.WriteStringValue("long"); - return; + writer.WriteStringValue(MemberLong); + break; case FieldSortNumericType.Double: - writer.WriteStringValue("double"); - return; + writer.WriteStringValue(MemberDouble); + break; case FieldSortNumericType.DateNanos: - writer.WriteStringValue("date_nanos"); - return; + writer.WriteStringValue(MemberDateNanos); + break; case FieldSortNumericType.Date: - writer.WriteStringValue("date"); - return; + writer.WriteStringValue(MemberDate); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldSortNumericType)}'."); } - - writer.WriteNullValue(); } } @@ -635,36 +771,40 @@ public enum GeoDistanceType Arc } -internal sealed class GeoDistanceTypeConverter : JsonConverter +internal sealed partial class GeoDistanceTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPlane = System.Text.Json.JsonEncodedText.Encode("plane"); + private static readonly System.Text.Json.JsonEncodedText MemberArc = System.Text.Json.JsonEncodedText.Encode("arc"); + + public override GeoDistanceType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPlane)) + { + return GeoDistanceType.Plane; + } + + if (reader.ValueTextEquals(MemberArc)) { - case "plane": - return GeoDistanceType.Plane; - case "arc": - return GeoDistanceType.Arc; + return GeoDistanceType.Arc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoDistanceType)}'."); } - public override void Write(Utf8JsonWriter writer, GeoDistanceType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoDistanceType.Plane: - writer.WriteStringValue("plane"); - return; + writer.WriteStringValue(MemberPlane); + break; case GeoDistanceType.Arc: - writer.WriteStringValue("arc"); - return; + writer.WriteStringValue(MemberArc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoDistanceType)}'."); } - - writer.WriteNullValue(); } } @@ -702,46 +842,58 @@ public enum GeoShapeRelation Contains } -internal sealed class GeoShapeRelationConverter : JsonConverter +internal sealed partial class GeoShapeRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoShapeRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWithin = System.Text.Json.JsonEncodedText.Encode("within"); + private static readonly System.Text.Json.JsonEncodedText MemberIntersects = System.Text.Json.JsonEncodedText.Encode("intersects"); + private static readonly System.Text.Json.JsonEncodedText MemberDisjoint = System.Text.Json.JsonEncodedText.Encode("disjoint"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + + public override GeoShapeRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWithin)) + { + return GeoShapeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) { - case "within": - return GeoShapeRelation.Within; - case "intersects": - return GeoShapeRelation.Intersects; - case "disjoint": - return GeoShapeRelation.Disjoint; - case "contains": - return GeoShapeRelation.Contains; + return GeoShapeRelation.Intersects; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDisjoint)) + { + return GeoShapeRelation.Disjoint; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return GeoShapeRelation.Contains; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoShapeRelation)}'."); } - public override void Write(Utf8JsonWriter writer, GeoShapeRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoShapeRelation.Within: - writer.WriteStringValue("within"); - return; + writer.WriteStringValue(MemberWithin); + break; case GeoShapeRelation.Intersects: - writer.WriteStringValue("intersects"); - return; + writer.WriteStringValue(MemberIntersects); + break; case GeoShapeRelation.Disjoint: - writer.WriteStringValue("disjoint"); - return; + writer.WriteStringValue(MemberDisjoint); + break; case GeoShapeRelation.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoShapeRelation)}'."); } - - writer.WriteNullValue(); } } @@ -771,44 +923,52 @@ public enum HealthStatus Green } -internal sealed class HealthStatusConverter : JsonConverter +internal sealed partial class HealthStatusConverter : System.Text.Json.Serialization.JsonConverter { - public override HealthStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYellow = System.Text.Json.JsonEncodedText.Encode("yellow"); + private static readonly System.Text.Json.JsonEncodedText MemberYellow1 = System.Text.Json.JsonEncodedText.Encode("YELLOW"); + private static readonly System.Text.Json.JsonEncodedText MemberRed = System.Text.Json.JsonEncodedText.Encode("red"); + private static readonly System.Text.Json.JsonEncodedText MemberRed1 = System.Text.Json.JsonEncodedText.Encode("RED"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen = System.Text.Json.JsonEncodedText.Encode("green"); + private static readonly System.Text.Json.JsonEncodedText MemberGreen1 = System.Text.Json.JsonEncodedText.Encode("GREEN"); + + public override HealthStatus Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "yellow": - case "YELLOW": - return HealthStatus.Yellow; - case "red": - case "RED": - return HealthStatus.Red; - case "green": - case "GREEN": - return HealthStatus.Green; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYellow) || reader.ValueTextEquals(MemberYellow1)) + { + return HealthStatus.Yellow; + } + + if (reader.ValueTextEquals(MemberRed) || reader.ValueTextEquals(MemberRed1)) + { + return HealthStatus.Red; + } + + if (reader.ValueTextEquals(MemberGreen) || reader.ValueTextEquals(MemberGreen1)) + { + return HealthStatus.Green; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(HealthStatus)}'."); } - public override void Write(Utf8JsonWriter writer, HealthStatus value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, HealthStatus value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case HealthStatus.Yellow: - writer.WriteStringValue("yellow"); - return; + writer.WriteStringValue(MemberYellow); + break; case HealthStatus.Red: - writer.WriteStringValue("red"); - return; + writer.WriteStringValue(MemberRed); + break; case HealthStatus.Green: - writer.WriteStringValue("green"); - return; + writer.WriteStringValue(MemberGreen); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(HealthStatus)}'."); } - - writer.WriteNullValue(); } } @@ -821,36 +981,40 @@ public enum IBDistribution Ll } -internal sealed class IBDistributionConverter : JsonConverter +internal sealed partial class IBDistributionConverter : System.Text.Json.Serialization.JsonConverter { - public override IBDistribution Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSpl = System.Text.Json.JsonEncodedText.Encode("spl"); + private static readonly System.Text.Json.JsonEncodedText MemberLl = System.Text.Json.JsonEncodedText.Encode("ll"); + + public override IBDistribution Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSpl)) { - case "spl": - return IBDistribution.Spl; - case "ll": - return IBDistribution.Ll; + return IBDistribution.Spl; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberLl)) + { + return IBDistribution.Ll; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IBDistribution)}'."); } - public override void Write(Utf8JsonWriter writer, IBDistribution value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IBDistribution value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IBDistribution.Spl: - writer.WriteStringValue("spl"); - return; + writer.WriteStringValue(MemberSpl); + break; case IBDistribution.Ll: - writer.WriteStringValue("ll"); - return; + writer.WriteStringValue(MemberLl); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IBDistribution)}'."); } - - writer.WriteNullValue(); } } @@ -863,36 +1027,40 @@ public enum IBLambda Df } -internal sealed class IBLambdaConverter : JsonConverter +internal sealed partial class IBLambdaConverter : System.Text.Json.Serialization.JsonConverter { - public override IBLambda Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberTtf = System.Text.Json.JsonEncodedText.Encode("ttf"); + private static readonly System.Text.Json.JsonEncodedText MemberDf = System.Text.Json.JsonEncodedText.Encode("df"); + + public override IBLambda Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberTtf)) { - case "ttf": - return IBLambda.Ttf; - case "df": - return IBLambda.Df; + return IBLambda.Ttf; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDf)) + { + return IBLambda.Df; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IBLambda)}'."); } - public override void Write(Utf8JsonWriter writer, IBLambda value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IBLambda value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IBLambda.Ttf: - writer.WriteStringValue("ttf"); - return; + writer.WriteStringValue(MemberTtf); + break; case IBLambda.Df: - writer.WriteStringValue("df"); - return; + writer.WriteStringValue(MemberDf); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IBLambda)}'."); } - - writer.WriteNullValue(); } } @@ -907,41 +1075,49 @@ public enum Level Cluster } -internal sealed class LevelConverter : JsonConverter +internal sealed partial class LevelConverter : System.Text.Json.Serialization.JsonConverter { - public override Level Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShards = System.Text.Json.JsonEncodedText.Encode("shards"); + private static readonly System.Text.Json.JsonEncodedText MemberIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText MemberCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + + public override Level Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShards)) + { + return Level.Shards; + } + + if (reader.ValueTextEquals(MemberIndices)) + { + return Level.Indices; + } + + if (reader.ValueTextEquals(MemberCluster)) { - case "shards": - return Level.Shards; - case "indices": - return Level.Indices; - case "cluster": - return Level.Cluster; + return Level.Cluster; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Level)}'."); } - public override void Write(Utf8JsonWriter writer, Level value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Level value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Level.Shards: - writer.WriteStringValue("shards"); - return; + writer.WriteStringValue(MemberShards); + break; case Level.Indices: - writer.WriteStringValue("indices"); - return; + writer.WriteStringValue(MemberIndices); + break; case Level.Cluster: - writer.WriteStringValue("cluster"); - return; + writer.WriteStringValue(MemberCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Level)}'."); } - - writer.WriteNullValue(); } } @@ -956,41 +1132,49 @@ public enum LifecycleOperationMode Running } -internal sealed class LifecycleOperationModeConverter : JsonConverter +internal sealed partial class LifecycleOperationModeConverter : System.Text.Json.Serialization.JsonConverter { - public override LifecycleOperationMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("STOPPING"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("STOPPED"); + private static readonly System.Text.Json.JsonEncodedText MemberRunning = System.Text.Json.JsonEncodedText.Encode("RUNNING"); + + public override LifecycleOperationMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) { - case "STOPPING": - return LifecycleOperationMode.Stopping; - case "STOPPED": - return LifecycleOperationMode.Stopped; - case "RUNNING": - return LifecycleOperationMode.Running; + return LifecycleOperationMode.Stopping; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberStopped)) + { + return LifecycleOperationMode.Stopped; + } + + if (reader.ValueTextEquals(MemberRunning)) + { + return LifecycleOperationMode.Running; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(LifecycleOperationMode)}'."); } - public override void Write(Utf8JsonWriter writer, LifecycleOperationMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, LifecycleOperationMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case LifecycleOperationMode.Stopping: - writer.WriteStringValue("STOPPING"); - return; + writer.WriteStringValue(MemberStopping); + break; case LifecycleOperationMode.Stopped: - writer.WriteStringValue("STOPPED"); - return; + writer.WriteStringValue(MemberStopped); + break; case LifecycleOperationMode.Running: - writer.WriteStringValue("RUNNING"); - return; + writer.WriteStringValue(MemberRunning); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(LifecycleOperationMode)}'."); } - - writer.WriteNullValue(); } } @@ -1027,96 +1211,148 @@ public enum NodeRole Client } -internal sealed class NodeRoleConverter : JsonConverter +internal sealed partial class NodeRoleConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeRole Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVotingOnly = System.Text.Json.JsonEncodedText.Encode("voting_only"); + private static readonly System.Text.Json.JsonEncodedText MemberTransform = System.Text.Json.JsonEncodedText.Encode("transform"); + private static readonly System.Text.Json.JsonEncodedText MemberRemoteClusterClient = System.Text.Json.JsonEncodedText.Encode("remote_cluster_client"); + private static readonly System.Text.Json.JsonEncodedText MemberMl = System.Text.Json.JsonEncodedText.Encode("ml"); + private static readonly System.Text.Json.JsonEncodedText MemberMaster = System.Text.Json.JsonEncodedText.Encode("master"); + private static readonly System.Text.Json.JsonEncodedText MemberIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText MemberDataWarm = System.Text.Json.JsonEncodedText.Encode("data_warm"); + private static readonly System.Text.Json.JsonEncodedText MemberDataHot = System.Text.Json.JsonEncodedText.Encode("data_hot"); + private static readonly System.Text.Json.JsonEncodedText MemberDataFrozen = System.Text.Json.JsonEncodedText.Encode("data_frozen"); + private static readonly System.Text.Json.JsonEncodedText MemberDataContent = System.Text.Json.JsonEncodedText.Encode("data_content"); + private static readonly System.Text.Json.JsonEncodedText MemberDataCold = System.Text.Json.JsonEncodedText.Encode("data_cold"); + private static readonly System.Text.Json.JsonEncodedText MemberData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText MemberCoordinatingOnly = System.Text.Json.JsonEncodedText.Encode("coordinating_only"); + private static readonly System.Text.Json.JsonEncodedText MemberClient = System.Text.Json.JsonEncodedText.Encode("client"); + + public override NodeRole Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "voting_only": - return NodeRole.VotingOnly; - case "transform": - return NodeRole.Transform; - case "remote_cluster_client": - return NodeRole.RemoteClusterClient; - case "ml": - return NodeRole.Ml; - case "master": - return NodeRole.Master; - case "ingest": - return NodeRole.Ingest; - case "data_warm": - return NodeRole.DataWarm; - case "data_hot": - return NodeRole.DataHot; - case "data_frozen": - return NodeRole.DataFrozen; - case "data_content": - return NodeRole.DataContent; - case "data_cold": - return NodeRole.DataCold; - case "data": - return NodeRole.Data; - case "coordinating_only": - return NodeRole.CoordinatingOnly; - case "client": - return NodeRole.Client; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVotingOnly)) + { + return NodeRole.VotingOnly; + } + + if (reader.ValueTextEquals(MemberTransform)) + { + return NodeRole.Transform; + } + + if (reader.ValueTextEquals(MemberRemoteClusterClient)) + { + return NodeRole.RemoteClusterClient; + } + + if (reader.ValueTextEquals(MemberMl)) + { + return NodeRole.Ml; + } + + if (reader.ValueTextEquals(MemberMaster)) + { + return NodeRole.Master; + } + + if (reader.ValueTextEquals(MemberIngest)) + { + return NodeRole.Ingest; + } + + if (reader.ValueTextEquals(MemberDataWarm)) + { + return NodeRole.DataWarm; + } + + if (reader.ValueTextEquals(MemberDataHot)) + { + return NodeRole.DataHot; + } + + if (reader.ValueTextEquals(MemberDataFrozen)) + { + return NodeRole.DataFrozen; + } + + if (reader.ValueTextEquals(MemberDataContent)) + { + return NodeRole.DataContent; + } + + if (reader.ValueTextEquals(MemberDataCold)) + { + return NodeRole.DataCold; + } + + if (reader.ValueTextEquals(MemberData)) + { + return NodeRole.Data; + } + + if (reader.ValueTextEquals(MemberCoordinatingOnly)) + { + return NodeRole.CoordinatingOnly; + } + + if (reader.ValueTextEquals(MemberClient)) + { + return NodeRole.Client; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(NodeRole)}'."); } - public override void Write(Utf8JsonWriter writer, NodeRole value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeRole value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case NodeRole.VotingOnly: - writer.WriteStringValue("voting_only"); - return; + writer.WriteStringValue(MemberVotingOnly); + break; case NodeRole.Transform: - writer.WriteStringValue("transform"); - return; + writer.WriteStringValue(MemberTransform); + break; case NodeRole.RemoteClusterClient: - writer.WriteStringValue("remote_cluster_client"); - return; + writer.WriteStringValue(MemberRemoteClusterClient); + break; case NodeRole.Ml: - writer.WriteStringValue("ml"); - return; + writer.WriteStringValue(MemberMl); + break; case NodeRole.Master: - writer.WriteStringValue("master"); - return; + writer.WriteStringValue(MemberMaster); + break; case NodeRole.Ingest: - writer.WriteStringValue("ingest"); - return; + writer.WriteStringValue(MemberIngest); + break; case NodeRole.DataWarm: - writer.WriteStringValue("data_warm"); - return; + writer.WriteStringValue(MemberDataWarm); + break; case NodeRole.DataHot: - writer.WriteStringValue("data_hot"); - return; + writer.WriteStringValue(MemberDataHot); + break; case NodeRole.DataFrozen: - writer.WriteStringValue("data_frozen"); - return; + writer.WriteStringValue(MemberDataFrozen); + break; case NodeRole.DataContent: - writer.WriteStringValue("data_content"); - return; + writer.WriteStringValue(MemberDataContent); + break; case NodeRole.DataCold: - writer.WriteStringValue("data_cold"); - return; + writer.WriteStringValue(MemberDataCold); + break; case NodeRole.Data: - writer.WriteStringValue("data"); - return; + writer.WriteStringValue(MemberData); + break; case NodeRole.CoordinatingOnly: - writer.WriteStringValue("coordinating_only"); - return; + writer.WriteStringValue(MemberCoordinatingOnly); + break; case NodeRole.Client: - writer.WriteStringValue("client"); - return; + writer.WriteStringValue(MemberClient); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(NodeRole)}'."); } - - writer.WriteNullValue(); } } @@ -1135,51 +1371,67 @@ public enum Normalization H1 } -internal sealed class NormalizationConverter : JsonConverter +internal sealed partial class NormalizationConverter : System.Text.Json.Serialization.JsonConverter { - public override Normalization Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText Memberz = System.Text.Json.JsonEncodedText.Encode("z"); + private static readonly System.Text.Json.JsonEncodedText MemberNo = System.Text.Json.JsonEncodedText.Encode("no"); + private static readonly System.Text.Json.JsonEncodedText MemberH3 = System.Text.Json.JsonEncodedText.Encode("h3"); + private static readonly System.Text.Json.JsonEncodedText MemberH2 = System.Text.Json.JsonEncodedText.Encode("h2"); + private static readonly System.Text.Json.JsonEncodedText MemberH1 = System.Text.Json.JsonEncodedText.Encode("h1"); + + public override Normalization Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "z": - return Normalization.z; - case "no": - return Normalization.No; - case "h3": - return Normalization.H3; - case "h2": - return Normalization.H2; - case "h1": - return Normalization.H1; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(Memberz)) + { + return Normalization.z; + } + + if (reader.ValueTextEquals(MemberNo)) + { + return Normalization.No; + } + + if (reader.ValueTextEquals(MemberH3)) + { + return Normalization.H3; + } + + if (reader.ValueTextEquals(MemberH2)) + { + return Normalization.H2; + } + + if (reader.ValueTextEquals(MemberH1)) + { + return Normalization.H1; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Normalization)}'."); } - public override void Write(Utf8JsonWriter writer, Normalization value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Normalization value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Normalization.z: - writer.WriteStringValue("z"); - return; + writer.WriteStringValue(Memberz); + break; case Normalization.No: - writer.WriteStringValue("no"); - return; + writer.WriteStringValue(MemberNo); + break; case Normalization.H3: - writer.WriteStringValue("h3"); - return; + writer.WriteStringValue(MemberH3); + break; case Normalization.H2: - writer.WriteStringValue("h2"); - return; + writer.WriteStringValue(MemberH2); + break; case Normalization.H1: - writer.WriteStringValue("h1"); - return; + writer.WriteStringValue(MemberH1); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Normalization)}'."); } - - writer.WriteNullValue(); } } @@ -1198,51 +1450,67 @@ public enum Result Created } -internal sealed class ResultConverter : JsonConverter +internal sealed partial class ResultConverter : System.Text.Json.Serialization.JsonConverter { - public override Result Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUpdated = System.Text.Json.JsonEncodedText.Encode("updated"); + private static readonly System.Text.Json.JsonEncodedText MemberNotFound = System.Text.Json.JsonEncodedText.Encode("not_found"); + private static readonly System.Text.Json.JsonEncodedText MemberNoOp = System.Text.Json.JsonEncodedText.Encode("noop"); + private static readonly System.Text.Json.JsonEncodedText MemberDeleted = System.Text.Json.JsonEncodedText.Encode("deleted"); + private static readonly System.Text.Json.JsonEncodedText MemberCreated = System.Text.Json.JsonEncodedText.Encode("created"); + + public override Result Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "updated": - return Result.Updated; - case "not_found": - return Result.NotFound; - case "noop": - return Result.NoOp; - case "deleted": - return Result.Deleted; - case "created": - return Result.Created; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUpdated)) + { + return Result.Updated; + } + + if (reader.ValueTextEquals(MemberNotFound)) + { + return Result.NotFound; + } + + if (reader.ValueTextEquals(MemberNoOp)) + { + return Result.NoOp; + } + + if (reader.ValueTextEquals(MemberDeleted)) + { + return Result.Deleted; + } + + if (reader.ValueTextEquals(MemberCreated)) + { + return Result.Created; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Result)}'."); } - public override void Write(Utf8JsonWriter writer, Result value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Result value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Result.Updated: - writer.WriteStringValue("updated"); - return; + writer.WriteStringValue(MemberUpdated); + break; case Result.NotFound: - writer.WriteStringValue("not_found"); - return; + writer.WriteStringValue(MemberNotFound); + break; case Result.NoOp: - writer.WriteStringValue("noop"); - return; + writer.WriteStringValue(MemberNoOp); + break; case Result.Deleted: - writer.WriteStringValue("deleted"); - return; + writer.WriteStringValue(MemberDeleted); + break; case Result.Created: - writer.WriteStringValue("created"); - return; + writer.WriteStringValue(MemberCreated); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Result)}'."); } - - writer.WriteNullValue(); } } @@ -1250,9 +1518,11 @@ public override void Write(Utf8JsonWriter writer, Result value, JsonSerializerOp public readonly partial struct ScriptLanguage : IEnumStruct { public ScriptLanguage(string value) => Value = value; - +#if NET7_0_OR_GREATER + static ScriptLanguage IEnumStruct.Create(string value) => value; +#else ScriptLanguage IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } /// @@ -1307,41 +1577,49 @@ public enum ScriptSortType Number } -internal sealed class ScriptSortTypeConverter : JsonConverter +internal sealed partial class ScriptSortTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ScriptSortType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberNumber = System.Text.Json.JsonEncodedText.Encode("number"); + + public override ScriptSortType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberVersion)) + { + return ScriptSortType.Version; + } + + if (reader.ValueTextEquals(MemberString)) + { + return ScriptSortType.String; + } + + if (reader.ValueTextEquals(MemberNumber)) { - case "version": - return ScriptSortType.Version; - case "string": - return ScriptSortType.String; - case "number": - return ScriptSortType.Number; + return ScriptSortType.Number; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ScriptSortType)}'."); } - public override void Write(Utf8JsonWriter writer, ScriptSortType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScriptSortType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ScriptSortType.Version: - writer.WriteStringValue("version"); - return; + writer.WriteStringValue(MemberVersion); + break; case ScriptSortType.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case ScriptSortType.Number: - writer.WriteStringValue("number"); - return; + writer.WriteStringValue(MemberNumber); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ScriptSortType)}'."); } - - writer.WriteNullValue(); } } @@ -1364,36 +1642,40 @@ public enum SearchType DfsQueryThenFetch } -internal sealed class SearchTypeConverter : JsonConverter +internal sealed partial class SearchTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override SearchType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberQueryThenFetch = System.Text.Json.JsonEncodedText.Encode("query_then_fetch"); + private static readonly System.Text.Json.JsonEncodedText MemberDfsQueryThenFetch = System.Text.Json.JsonEncodedText.Encode("dfs_query_then_fetch"); + + public override SearchType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberQueryThenFetch)) { - case "query_then_fetch": - return SearchType.QueryThenFetch; - case "dfs_query_then_fetch": - return SearchType.DfsQueryThenFetch; + return SearchType.QueryThenFetch; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDfsQueryThenFetch)) + { + return SearchType.DfsQueryThenFetch; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SearchType)}'."); } - public override void Write(Utf8JsonWriter writer, SearchType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SearchType.QueryThenFetch: - writer.WriteStringValue("query_then_fetch"); - return; + writer.WriteStringValue(MemberQueryThenFetch); + break; case SearchType.DfsQueryThenFetch: - writer.WriteStringValue("dfs_query_then_fetch"); - return; + writer.WriteStringValue(MemberDfsQueryThenFetch); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SearchType)}'."); } - - writer.WriteNullValue(); } } @@ -1409,31 +1691,31 @@ public enum SlicesCalculation Auto } -internal sealed class SlicesCalculationConverter : JsonConverter +internal sealed partial class SlicesCalculationConverter : System.Text.Json.Serialization.JsonConverter { - public override SlicesCalculation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberAuto = System.Text.Json.JsonEncodedText.Encode("auto"); + + public override SlicesCalculation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberAuto)) { - case "auto": - return SlicesCalculation.Auto; + return SlicesCalculation.Auto; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SlicesCalculation)}'."); } - public override void Write(Utf8JsonWriter writer, SlicesCalculation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SlicesCalculation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SlicesCalculation.Auto: - writer.WriteStringValue("auto"); - return; + writer.WriteStringValue(MemberAuto); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SlicesCalculation)}'."); } - - writer.WriteNullValue(); } } @@ -1452,51 +1734,67 @@ public enum SortMode Avg } -internal sealed class SortModeConverter : JsonConverter +internal sealed partial class SortModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SortMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMedian = System.Text.Json.JsonEncodedText.Encode("median"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override SortMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return SortMode.Sum; - case "min": - return SortMode.Min; - case "median": - return SortMode.Median; - case "max": - return SortMode.Max; - case "avg": - return SortMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return SortMode.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return SortMode.Min; + } + + if (reader.ValueTextEquals(MemberMedian)) + { + return SortMode.Median; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return SortMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return SortMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SortMode)}'."); } - public override void Write(Utf8JsonWriter writer, SortMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SortMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SortMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case SortMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case SortMode.Median: - writer.WriteStringValue("median"); - return; + writer.WriteStringValue(MemberMedian); + break; case SortMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case SortMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SortMode)}'."); } - - writer.WriteNullValue(); } } @@ -1519,36 +1817,40 @@ public enum SortOrder Asc } -internal sealed class SortOrderConverter : JsonConverter +internal sealed partial class SortOrderConverter : System.Text.Json.Serialization.JsonConverter { - public override SortOrder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberDesc = System.Text.Json.JsonEncodedText.Encode("desc"); + private static readonly System.Text.Json.JsonEncodedText MemberAsc = System.Text.Json.JsonEncodedText.Encode("asc"); + + public override SortOrder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberDesc)) + { + return SortOrder.Desc; + } + + if (reader.ValueTextEquals(MemberAsc)) { - case "desc": - return SortOrder.Desc; - case "asc": - return SortOrder.Asc; + return SortOrder.Asc; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SortOrder)}'."); } - public override void Write(Utf8JsonWriter writer, SortOrder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SortOrder value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SortOrder.Desc: - writer.WriteStringValue("desc"); - return; + writer.WriteStringValue(MemberDesc); + break; case SortOrder.Asc: - writer.WriteStringValue("asc"); - return; + writer.WriteStringValue(MemberAsc); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SortOrder)}'."); } - - writer.WriteNullValue(); } } @@ -1578,41 +1880,49 @@ public enum SuggestMode Always } -internal sealed class SuggestModeConverter : JsonConverter +internal sealed partial class SuggestModeConverter : System.Text.Json.Serialization.JsonConverter { - public override SuggestMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPopular = System.Text.Json.JsonEncodedText.Encode("popular"); + private static readonly System.Text.Json.JsonEncodedText MemberMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("always"); + + public override SuggestMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPopular)) + { + return SuggestMode.Popular; + } + + if (reader.ValueTextEquals(MemberMissing)) + { + return SuggestMode.Missing; + } + + if (reader.ValueTextEquals(MemberAlways)) { - case "popular": - return SuggestMode.Popular; - case "missing": - return SuggestMode.Missing; - case "always": - return SuggestMode.Always; + return SuggestMode.Always; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SuggestMode)}'."); } - public override void Write(Utf8JsonWriter writer, SuggestMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SuggestMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SuggestMode.Popular: - writer.WriteStringValue("popular"); - return; + writer.WriteStringValue(MemberPopular); + break; case SuggestMode.Missing: - writer.WriteStringValue("missing"); - return; + writer.WriteStringValue(MemberMissing); + break; case SuggestMode.Always: - writer.WriteStringValue("always"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SuggestMode)}'."); } - - writer.WriteNullValue(); } } @@ -1631,51 +1941,67 @@ public enum ThreadType Block } -internal sealed class ThreadTypeConverter : JsonConverter +internal sealed partial class ThreadTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ThreadType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWait = System.Text.Json.JsonEncodedText.Encode("wait"); + private static readonly System.Text.Json.JsonEncodedText MemberMem = System.Text.Json.JsonEncodedText.Encode("mem"); + private static readonly System.Text.Json.JsonEncodedText MemberGpu = System.Text.Json.JsonEncodedText.Encode("gpu"); + private static readonly System.Text.Json.JsonEncodedText MemberCpu = System.Text.Json.JsonEncodedText.Encode("cpu"); + private static readonly System.Text.Json.JsonEncodedText MemberBlock = System.Text.Json.JsonEncodedText.Encode("block"); + + public override ThreadType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "wait": - return ThreadType.Wait; - case "mem": - return ThreadType.Mem; - case "gpu": - return ThreadType.Gpu; - case "cpu": - return ThreadType.Cpu; - case "block": - return ThreadType.Block; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWait)) + { + return ThreadType.Wait; + } + + if (reader.ValueTextEquals(MemberMem)) + { + return ThreadType.Mem; + } + + if (reader.ValueTextEquals(MemberGpu)) + { + return ThreadType.Gpu; + } + + if (reader.ValueTextEquals(MemberCpu)) + { + return ThreadType.Cpu; + } + + if (reader.ValueTextEquals(MemberBlock)) + { + return ThreadType.Block; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ThreadType)}'."); } - public override void Write(Utf8JsonWriter writer, ThreadType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ThreadType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ThreadType.Wait: - writer.WriteStringValue("wait"); - return; + writer.WriteStringValue(MemberWait); + break; case ThreadType.Mem: - writer.WriteStringValue("mem"); - return; + writer.WriteStringValue(MemberMem); + break; case ThreadType.Gpu: - writer.WriteStringValue("gpu"); - return; + writer.WriteStringValue(MemberGpu); + break; case ThreadType.Cpu: - writer.WriteStringValue("cpu"); - return; + writer.WriteStringValue(MemberCpu); + break; case ThreadType.Block: - writer.WriteStringValue("block"); - return; + writer.WriteStringValue(MemberBlock); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ThreadType)}'."); } - - writer.WriteNullValue(); } } @@ -1698,61 +2024,85 @@ public enum TimeUnit Days } -internal sealed class TimeUnitConverter : JsonConverter +internal sealed partial class TimeUnitConverter : System.Text.Json.Serialization.JsonConverter { - public override TimeUnit Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSeconds = System.Text.Json.JsonEncodedText.Encode("s"); + private static readonly System.Text.Json.JsonEncodedText MemberNanoseconds = System.Text.Json.JsonEncodedText.Encode("nanos"); + private static readonly System.Text.Json.JsonEncodedText MemberMinutes = System.Text.Json.JsonEncodedText.Encode("m"); + private static readonly System.Text.Json.JsonEncodedText MemberMilliseconds = System.Text.Json.JsonEncodedText.Encode("ms"); + private static readonly System.Text.Json.JsonEncodedText MemberMicroseconds = System.Text.Json.JsonEncodedText.Encode("micros"); + private static readonly System.Text.Json.JsonEncodedText MemberHours = System.Text.Json.JsonEncodedText.Encode("h"); + private static readonly System.Text.Json.JsonEncodedText MemberDays = System.Text.Json.JsonEncodedText.Encode("d"); + + public override TimeUnit Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "s": - return TimeUnit.Seconds; - case "nanos": - return TimeUnit.Nanoseconds; - case "m": - return TimeUnit.Minutes; - case "ms": - return TimeUnit.Milliseconds; - case "micros": - return TimeUnit.Microseconds; - case "h": - return TimeUnit.Hours; - case "d": - return TimeUnit.Days; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSeconds)) + { + return TimeUnit.Seconds; + } + + if (reader.ValueTextEquals(MemberNanoseconds)) + { + return TimeUnit.Nanoseconds; + } + + if (reader.ValueTextEquals(MemberMinutes)) + { + return TimeUnit.Minutes; + } + + if (reader.ValueTextEquals(MemberMilliseconds)) + { + return TimeUnit.Milliseconds; + } + + if (reader.ValueTextEquals(MemberMicroseconds)) + { + return TimeUnit.Microseconds; + } + + if (reader.ValueTextEquals(MemberHours)) + { + return TimeUnit.Hours; + } + + if (reader.ValueTextEquals(MemberDays)) + { + return TimeUnit.Days; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TimeUnit)}'."); } - public override void Write(Utf8JsonWriter writer, TimeUnit value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TimeUnit value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TimeUnit.Seconds: - writer.WriteStringValue("s"); - return; + writer.WriteStringValue(MemberSeconds); + break; case TimeUnit.Nanoseconds: - writer.WriteStringValue("nanos"); - return; + writer.WriteStringValue(MemberNanoseconds); + break; case TimeUnit.Minutes: - writer.WriteStringValue("m"); - return; + writer.WriteStringValue(MemberMinutes); + break; case TimeUnit.Milliseconds: - writer.WriteStringValue("ms"); - return; + writer.WriteStringValue(MemberMilliseconds); + break; case TimeUnit.Microseconds: - writer.WriteStringValue("micros"); - return; + writer.WriteStringValue(MemberMicroseconds); + break; case TimeUnit.Hours: - writer.WriteStringValue("h"); - return; + writer.WriteStringValue(MemberHours); + break; case TimeUnit.Days: - writer.WriteStringValue("d"); - return; + writer.WriteStringValue(MemberDays); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TimeUnit)}'."); } - - writer.WriteNullValue(); } } @@ -1786,46 +2136,58 @@ public enum VersionType External } -internal sealed class VersionTypeConverter : JsonConverter +internal sealed partial class VersionTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override VersionType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberInternal = System.Text.Json.JsonEncodedText.Encode("internal"); + private static readonly System.Text.Json.JsonEncodedText MemberForce = System.Text.Json.JsonEncodedText.Encode("force"); + private static readonly System.Text.Json.JsonEncodedText MemberExternalGte = System.Text.Json.JsonEncodedText.Encode("external_gte"); + private static readonly System.Text.Json.JsonEncodedText MemberExternal = System.Text.Json.JsonEncodedText.Encode("external"); + + public override VersionType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberInternal)) + { + return VersionType.Internal; + } + + if (reader.ValueTextEquals(MemberForce)) + { + return VersionType.Force; + } + + if (reader.ValueTextEquals(MemberExternalGte)) { - case "internal": - return VersionType.Internal; - case "force": - return VersionType.Force; - case "external_gte": - return VersionType.ExternalGte; - case "external": - return VersionType.External; + return VersionType.ExternalGte; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExternal)) + { + return VersionType.External; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(VersionType)}'."); } - public override void Write(Utf8JsonWriter writer, VersionType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, VersionType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case VersionType.Internal: - writer.WriteStringValue("internal"); - return; + writer.WriteStringValue(MemberInternal); + break; case VersionType.Force: - writer.WriteStringValue("force"); - return; + writer.WriteStringValue(MemberForce); + break; case VersionType.ExternalGte: - writer.WriteStringValue("external_gte"); - return; + writer.WriteStringValue(MemberExternalGte); + break; case VersionType.External: - writer.WriteStringValue("external"); - return; + writer.WriteStringValue(MemberExternal); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(VersionType)}'."); } - - writer.WriteNullValue(); } } @@ -1846,55 +2208,75 @@ public enum WaitForEvents High } -internal sealed class WaitForEventsConverter : JsonConverter +internal sealed partial class WaitForEventsConverter : System.Text.Json.Serialization.JsonConverter { - public override WaitForEvents Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberUrgent = System.Text.Json.JsonEncodedText.Encode("urgent"); + private static readonly System.Text.Json.JsonEncodedText MemberNormal = System.Text.Json.JsonEncodedText.Encode("normal"); + private static readonly System.Text.Json.JsonEncodedText MemberLow = System.Text.Json.JsonEncodedText.Encode("low"); + private static readonly System.Text.Json.JsonEncodedText MemberLanguid = System.Text.Json.JsonEncodedText.Encode("languid"); + private static readonly System.Text.Json.JsonEncodedText MemberImmediate = System.Text.Json.JsonEncodedText.Encode("immediate"); + private static readonly System.Text.Json.JsonEncodedText MemberHigh = System.Text.Json.JsonEncodedText.Encode("high"); + + public override WaitForEvents Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "urgent": - return WaitForEvents.Urgent; - case "normal": - return WaitForEvents.Normal; - case "low": - return WaitForEvents.Low; - case "languid": - return WaitForEvents.Languid; - case "immediate": - return WaitForEvents.Immediate; - case "high": - return WaitForEvents.High; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberUrgent)) + { + return WaitForEvents.Urgent; + } + + if (reader.ValueTextEquals(MemberNormal)) + { + return WaitForEvents.Normal; + } + + if (reader.ValueTextEquals(MemberLow)) + { + return WaitForEvents.Low; + } + + if (reader.ValueTextEquals(MemberLanguid)) + { + return WaitForEvents.Languid; + } + + if (reader.ValueTextEquals(MemberImmediate)) + { + return WaitForEvents.Immediate; + } + + if (reader.ValueTextEquals(MemberHigh)) + { + return WaitForEvents.High; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(WaitForEvents)}'."); } - public override void Write(Utf8JsonWriter writer, WaitForEvents value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, WaitForEvents value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case WaitForEvents.Urgent: - writer.WriteStringValue("urgent"); - return; + writer.WriteStringValue(MemberUrgent); + break; case WaitForEvents.Normal: - writer.WriteStringValue("normal"); - return; + writer.WriteStringValue(MemberNormal); + break; case WaitForEvents.Low: - writer.WriteStringValue("low"); - return; + writer.WriteStringValue(MemberLow); + break; case WaitForEvents.Languid: - writer.WriteStringValue("languid"); - return; + writer.WriteStringValue(MemberLanguid); + break; case WaitForEvents.Immediate: - writer.WriteStringValue("immediate"); - return; + writer.WriteStringValue(MemberImmediate); + break; case WaitForEvents.High: - writer.WriteStringValue("high"); - return; + writer.WriteStringValue(MemberHigh); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(WaitForEvents)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs index 3af92fe8e4b..a422a998ddb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryDsl.g.cs @@ -43,51 +43,67 @@ public enum ChildScoreMode Avg } -internal sealed class ChildScoreModeConverter : JsonConverter +internal sealed partial class ChildScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override ChildScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override ChildScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return ChildScoreMode.Sum; - case "none": - return ChildScoreMode.None; - case "min": - return ChildScoreMode.Min; - case "max": - return ChildScoreMode.Max; - case "avg": - return ChildScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return ChildScoreMode.Sum; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return ChildScoreMode.None; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return ChildScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return ChildScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return ChildScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ChildScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, ChildScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ChildScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ChildScoreMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case ChildScoreMode.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ChildScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case ChildScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case ChildScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ChildScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -100,36 +116,40 @@ public enum CombinedFieldsOperator And } -internal sealed class CombinedFieldsOperatorConverter : JsonConverter +internal sealed partial class CombinedFieldsOperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override CombinedFieldsOperator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOr = System.Text.Json.JsonEncodedText.Encode("or"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd = System.Text.Json.JsonEncodedText.Encode("and"); + + public override CombinedFieldsOperator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOr)) + { + return CombinedFieldsOperator.Or; + } + + if (reader.ValueTextEquals(MemberAnd)) { - case "or": - return CombinedFieldsOperator.Or; - case "and": - return CombinedFieldsOperator.And; + return CombinedFieldsOperator.And; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CombinedFieldsOperator)}'."); } - public override void Write(Utf8JsonWriter writer, CombinedFieldsOperator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsOperator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CombinedFieldsOperator.Or: - writer.WriteStringValue("or"); - return; + writer.WriteStringValue(MemberOr); + break; case CombinedFieldsOperator.And: - writer.WriteStringValue("and"); - return; + writer.WriteStringValue(MemberAnd); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CombinedFieldsOperator)}'."); } - - writer.WriteNullValue(); } } @@ -152,36 +172,40 @@ public enum CombinedFieldsZeroTerms All } -internal sealed class CombinedFieldsZeroTermsConverter : JsonConverter +internal sealed partial class CombinedFieldsZeroTermsConverter : System.Text.Json.Serialization.JsonConverter { - public override CombinedFieldsZeroTerms Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override CombinedFieldsZeroTerms Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) + { + return CombinedFieldsZeroTerms.None; + } + + if (reader.ValueTextEquals(MemberAll)) { - case "none": - return CombinedFieldsZeroTerms.None; - case "all": - return CombinedFieldsZeroTerms.All; + return CombinedFieldsZeroTerms.All; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(CombinedFieldsZeroTerms)}'."); } - public override void Write(Utf8JsonWriter writer, CombinedFieldsZeroTerms value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsZeroTerms value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case CombinedFieldsZeroTerms.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case CombinedFieldsZeroTerms.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(CombinedFieldsZeroTerms)}'."); } - - writer.WriteNullValue(); } } @@ -262,76 +286,112 @@ public enum FieldValueFactorModifier Ln } -internal sealed class FieldValueFactorModifierConverter : JsonConverter +internal sealed partial class FieldValueFactorModifierConverter : System.Text.Json.Serialization.JsonConverter { - public override FieldValueFactorModifier Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSquare = System.Text.Json.JsonEncodedText.Encode("square"); + private static readonly System.Text.Json.JsonEncodedText MemberSqrt = System.Text.Json.JsonEncodedText.Encode("sqrt"); + private static readonly System.Text.Json.JsonEncodedText MemberReciprocal = System.Text.Json.JsonEncodedText.Encode("reciprocal"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberLog2p = System.Text.Json.JsonEncodedText.Encode("log2p"); + private static readonly System.Text.Json.JsonEncodedText MemberLog1p = System.Text.Json.JsonEncodedText.Encode("log1p"); + private static readonly System.Text.Json.JsonEncodedText MemberLog = System.Text.Json.JsonEncodedText.Encode("log"); + private static readonly System.Text.Json.JsonEncodedText MemberLn2p = System.Text.Json.JsonEncodedText.Encode("ln2p"); + private static readonly System.Text.Json.JsonEncodedText MemberLn1p = System.Text.Json.JsonEncodedText.Encode("ln1p"); + private static readonly System.Text.Json.JsonEncodedText MemberLn = System.Text.Json.JsonEncodedText.Encode("ln"); + + public override FieldValueFactorModifier Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "square": - return FieldValueFactorModifier.Square; - case "sqrt": - return FieldValueFactorModifier.Sqrt; - case "reciprocal": - return FieldValueFactorModifier.Reciprocal; - case "none": - return FieldValueFactorModifier.None; - case "log2p": - return FieldValueFactorModifier.Log2p; - case "log1p": - return FieldValueFactorModifier.Log1p; - case "log": - return FieldValueFactorModifier.Log; - case "ln2p": - return FieldValueFactorModifier.Ln2p; - case "ln1p": - return FieldValueFactorModifier.Ln1p; - case "ln": - return FieldValueFactorModifier.Ln; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSquare)) + { + return FieldValueFactorModifier.Square; + } + + if (reader.ValueTextEquals(MemberSqrt)) + { + return FieldValueFactorModifier.Sqrt; + } + + if (reader.ValueTextEquals(MemberReciprocal)) + { + return FieldValueFactorModifier.Reciprocal; + } + + if (reader.ValueTextEquals(MemberNone)) + { + return FieldValueFactorModifier.None; + } + + if (reader.ValueTextEquals(MemberLog2p)) + { + return FieldValueFactorModifier.Log2p; + } + + if (reader.ValueTextEquals(MemberLog1p)) + { + return FieldValueFactorModifier.Log1p; + } + + if (reader.ValueTextEquals(MemberLog)) + { + return FieldValueFactorModifier.Log; + } + + if (reader.ValueTextEquals(MemberLn2p)) + { + return FieldValueFactorModifier.Ln2p; + } + + if (reader.ValueTextEquals(MemberLn1p)) + { + return FieldValueFactorModifier.Ln1p; + } + + if (reader.ValueTextEquals(MemberLn)) + { + return FieldValueFactorModifier.Ln; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FieldValueFactorModifier)}'."); } - public override void Write(Utf8JsonWriter writer, FieldValueFactorModifier value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldValueFactorModifier value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FieldValueFactorModifier.Square: - writer.WriteStringValue("square"); - return; + writer.WriteStringValue(MemberSquare); + break; case FieldValueFactorModifier.Sqrt: - writer.WriteStringValue("sqrt"); - return; + writer.WriteStringValue(MemberSqrt); + break; case FieldValueFactorModifier.Reciprocal: - writer.WriteStringValue("reciprocal"); - return; + writer.WriteStringValue(MemberReciprocal); + break; case FieldValueFactorModifier.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case FieldValueFactorModifier.Log2p: - writer.WriteStringValue("log2p"); - return; + writer.WriteStringValue(MemberLog2p); + break; case FieldValueFactorModifier.Log1p: - writer.WriteStringValue("log1p"); - return; + writer.WriteStringValue(MemberLog1p); + break; case FieldValueFactorModifier.Log: - writer.WriteStringValue("log"); - return; + writer.WriteStringValue(MemberLog); + break; case FieldValueFactorModifier.Ln2p: - writer.WriteStringValue("ln2p"); - return; + writer.WriteStringValue(MemberLn2p); + break; case FieldValueFactorModifier.Ln1p: - writer.WriteStringValue("ln1p"); - return; + writer.WriteStringValue(MemberLn1p); + break; case FieldValueFactorModifier.Ln: - writer.WriteStringValue("ln"); - return; + writer.WriteStringValue(MemberLn); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FieldValueFactorModifier)}'."); } - - writer.WriteNullValue(); } } @@ -383,56 +443,76 @@ public enum FunctionBoostMode Avg } -internal sealed class FunctionBoostModeConverter : JsonConverter +internal sealed partial class FunctionBoostModeConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionBoostMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberReplace = System.Text.Json.JsonEncodedText.Encode("replace"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override FunctionBoostMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return FunctionBoostMode.Sum; - case "replace": - return FunctionBoostMode.Replace; - case "multiply": - return FunctionBoostMode.Multiply; - case "min": - return FunctionBoostMode.Min; - case "max": - return FunctionBoostMode.Max; - case "avg": - return FunctionBoostMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return FunctionBoostMode.Sum; + } + + if (reader.ValueTextEquals(MemberReplace)) + { + return FunctionBoostMode.Replace; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return FunctionBoostMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return FunctionBoostMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return FunctionBoostMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return FunctionBoostMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FunctionBoostMode)}'."); } - public override void Write(Utf8JsonWriter writer, FunctionBoostMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionBoostMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FunctionBoostMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case FunctionBoostMode.Replace: - writer.WriteStringValue("replace"); - return; + writer.WriteStringValue(MemberReplace); + break; case FunctionBoostMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case FunctionBoostMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case FunctionBoostMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case FunctionBoostMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FunctionBoostMode)}'."); } - - writer.WriteNullValue(); } } @@ -483,56 +563,76 @@ public enum FunctionScoreMode Avg } -internal sealed class FunctionScoreModeConverter : JsonConverter +internal sealed partial class FunctionScoreModeConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionScoreMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMultiply = System.Text.Json.JsonEncodedText.Encode("multiply"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberFirst = System.Text.Json.JsonEncodedText.Encode("first"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override FunctionScoreMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "sum": - return FunctionScoreMode.Sum; - case "multiply": - return FunctionScoreMode.Multiply; - case "min": - return FunctionScoreMode.Min; - case "max": - return FunctionScoreMode.Max; - case "first": - return FunctionScoreMode.First; - case "avg": - return FunctionScoreMode.Avg; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return FunctionScoreMode.Sum; + } + + if (reader.ValueTextEquals(MemberMultiply)) + { + return FunctionScoreMode.Multiply; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return FunctionScoreMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return FunctionScoreMode.Max; + } + + if (reader.ValueTextEquals(MemberFirst)) + { + return FunctionScoreMode.First; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return FunctionScoreMode.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FunctionScoreMode)}'."); } - public override void Write(Utf8JsonWriter writer, FunctionScoreMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScoreMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FunctionScoreMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case FunctionScoreMode.Multiply: - writer.WriteStringValue("multiply"); - return; + writer.WriteStringValue(MemberMultiply); + break; case FunctionScoreMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case FunctionScoreMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case FunctionScoreMode.First: - writer.WriteStringValue("first"); - return; + writer.WriteStringValue(MemberFirst); + break; case FunctionScoreMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FunctionScoreMode)}'."); } - - writer.WriteNullValue(); } } @@ -557,41 +657,49 @@ public enum GeoValidationMethod Coerce } -internal sealed class GeoValidationMethodConverter : JsonConverter +internal sealed partial class GeoValidationMethodConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoValidationMethod Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStrict = System.Text.Json.JsonEncodedText.Encode("strict"); + private static readonly System.Text.Json.JsonEncodedText MemberIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText MemberCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + + public override GeoValidationMethod Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStrict)) + { + return GeoValidationMethod.Strict; + } + + if (reader.ValueTextEquals(MemberIgnoreMalformed)) { - case "strict": - return GeoValidationMethod.Strict; - case "ignore_malformed": - return GeoValidationMethod.IgnoreMalformed; - case "coerce": - return GeoValidationMethod.Coerce; + return GeoValidationMethod.IgnoreMalformed; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCoerce)) + { + return GeoValidationMethod.Coerce; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GeoValidationMethod)}'."); } - public override void Write(Utf8JsonWriter writer, GeoValidationMethod value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoValidationMethod value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GeoValidationMethod.Strict: - writer.WriteStringValue("strict"); - return; + writer.WriteStringValue(MemberStrict); + break; case GeoValidationMethod.IgnoreMalformed: - writer.WriteStringValue("ignore_malformed"); - return; + writer.WriteStringValue(MemberIgnoreMalformed); + break; case GeoValidationMethod.Coerce: - writer.WriteStringValue("coerce"); - return; + writer.WriteStringValue(MemberCoerce); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GeoValidationMethod)}'."); } - - writer.WriteNullValue(); } } @@ -628,46 +736,58 @@ public enum MultiValueMode Avg } -internal sealed class MultiValueModeConverter : JsonConverter +internal sealed partial class MultiValueModeConverter : System.Text.Json.Serialization.JsonConverter { - public override MultiValueMode Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override MultiValueMode Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSum)) + { + return MultiValueMode.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) + { + return MultiValueMode.Min; + } + + if (reader.ValueTextEquals(MemberMax)) + { + return MultiValueMode.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) { - case "sum": - return MultiValueMode.Sum; - case "min": - return MultiValueMode.Min; - case "max": - return MultiValueMode.Max; - case "avg": - return MultiValueMode.Avg; + return MultiValueMode.Avg; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(MultiValueMode)}'."); } - public override void Write(Utf8JsonWriter writer, MultiValueMode value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiValueMode value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case MultiValueMode.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case MultiValueMode.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case MultiValueMode.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case MultiValueMode.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(MultiValueMode)}'."); } - - writer.WriteNullValue(); } } @@ -680,38 +800,42 @@ public enum Operator And } -internal sealed class OperatorConverter : JsonConverter +internal sealed partial class OperatorConverter : System.Text.Json.Serialization.JsonConverter { - public override Operator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberOr = System.Text.Json.JsonEncodedText.Encode("or"); + private static readonly System.Text.Json.JsonEncodedText MemberOr1 = System.Text.Json.JsonEncodedText.Encode("OR"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd = System.Text.Json.JsonEncodedText.Encode("and"); + private static readonly System.Text.Json.JsonEncodedText MemberAnd1 = System.Text.Json.JsonEncodedText.Encode("AND"); + + public override Operator Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberOr) || reader.ValueTextEquals(MemberOr1)) + { + return Operator.Or; + } + + if (reader.ValueTextEquals(MemberAnd) || reader.ValueTextEquals(MemberAnd1)) { - case "or": - case "OR": - return Operator.Or; - case "and": - case "AND": - return Operator.And; + return Operator.And; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Operator)}'."); } - public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Operator value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Operator.Or: - writer.WriteStringValue("or"); - return; + writer.WriteStringValue(MemberOr); + break; case Operator.And: - writer.WriteStringValue("and"); - return; + writer.WriteStringValue(MemberAnd); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Operator)}'."); } - - writer.WriteNullValue(); } } @@ -741,41 +865,49 @@ public enum RangeRelation Contains } -internal sealed class RangeRelationConverter : JsonConverter +internal sealed partial class RangeRelationConverter : System.Text.Json.Serialization.JsonConverter { - public override RangeRelation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberWithin = System.Text.Json.JsonEncodedText.Encode("within"); + private static readonly System.Text.Json.JsonEncodedText MemberIntersects = System.Text.Json.JsonEncodedText.Encode("intersects"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + + public override RangeRelation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberWithin)) + { + return RangeRelation.Within; + } + + if (reader.ValueTextEquals(MemberIntersects)) { - case "within": - return RangeRelation.Within; - case "intersects": - return RangeRelation.Intersects; - case "contains": - return RangeRelation.Contains; + return RangeRelation.Intersects; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberContains)) + { + return RangeRelation.Contains; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RangeRelation)}'."); } - public override void Write(Utf8JsonWriter writer, RangeRelation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RangeRelation value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RangeRelation.Within: - writer.WriteStringValue("within"); - return; + writer.WriteStringValue(MemberWithin); + break; case RangeRelation.Intersects: - writer.WriteStringValue("intersects"); - return; + writer.WriteStringValue(MemberIntersects); + break; case RangeRelation.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RangeRelation)}'."); } - - writer.WriteNullValue(); } } @@ -1008,56 +1140,76 @@ public enum TextQueryType BestFields } -internal sealed class TextQueryTypeConverter : JsonConverter +internal sealed partial class TextQueryTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override TextQueryType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPhrasePrefix = System.Text.Json.JsonEncodedText.Encode("phrase_prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberPhrase = System.Text.Json.JsonEncodedText.Encode("phrase"); + private static readonly System.Text.Json.JsonEncodedText MemberMostFields = System.Text.Json.JsonEncodedText.Encode("most_fields"); + private static readonly System.Text.Json.JsonEncodedText MemberCrossFields = System.Text.Json.JsonEncodedText.Encode("cross_fields"); + private static readonly System.Text.Json.JsonEncodedText MemberBoolPrefix = System.Text.Json.JsonEncodedText.Encode("bool_prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberBestFields = System.Text.Json.JsonEncodedText.Encode("best_fields"); + + public override TextQueryType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "phrase_prefix": - return TextQueryType.PhrasePrefix; - case "phrase": - return TextQueryType.Phrase; - case "most_fields": - return TextQueryType.MostFields; - case "cross_fields": - return TextQueryType.CrossFields; - case "bool_prefix": - return TextQueryType.BoolPrefix; - case "best_fields": - return TextQueryType.BestFields; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPhrasePrefix)) + { + return TextQueryType.PhrasePrefix; + } + + if (reader.ValueTextEquals(MemberPhrase)) + { + return TextQueryType.Phrase; + } + + if (reader.ValueTextEquals(MemberMostFields)) + { + return TextQueryType.MostFields; + } + + if (reader.ValueTextEquals(MemberCrossFields)) + { + return TextQueryType.CrossFields; + } + + if (reader.ValueTextEquals(MemberBoolPrefix)) + { + return TextQueryType.BoolPrefix; + } + + if (reader.ValueTextEquals(MemberBestFields)) + { + return TextQueryType.BestFields; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TextQueryType)}'."); } - public override void Write(Utf8JsonWriter writer, TextQueryType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TextQueryType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TextQueryType.PhrasePrefix: - writer.WriteStringValue("phrase_prefix"); - return; + writer.WriteStringValue(MemberPhrasePrefix); + break; case TextQueryType.Phrase: - writer.WriteStringValue("phrase"); - return; + writer.WriteStringValue(MemberPhrase); + break; case TextQueryType.MostFields: - writer.WriteStringValue("most_fields"); - return; + writer.WriteStringValue(MemberMostFields); + break; case TextQueryType.CrossFields: - writer.WriteStringValue("cross_fields"); - return; + writer.WriteStringValue(MemberCrossFields); + break; case TextQueryType.BoolPrefix: - writer.WriteStringValue("bool_prefix"); - return; + writer.WriteStringValue(MemberBoolPrefix); + break; case TextQueryType.BestFields: - writer.WriteStringValue("best_fields"); - return; + writer.WriteStringValue(MemberBestFields); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TextQueryType)}'."); } - - writer.WriteNullValue(); } } @@ -1080,35 +1232,39 @@ public enum ZeroTermsQuery All } -internal sealed class ZeroTermsQueryConverter : JsonConverter +internal sealed partial class ZeroTermsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override ZeroTermsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("all"); + + public override ZeroTermsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberNone)) { - case "none": - return ZeroTermsQuery.None; - case "all": - return ZeroTermsQuery.All; + return ZeroTermsQuery.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAll)) + { + return ZeroTermsQuery.All; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ZeroTermsQuery)}'."); } - public override void Write(Utf8JsonWriter writer, ZeroTermsQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ZeroTermsQuery value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ZeroTermsQuery.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case ZeroTermsQuery.All: - writer.WriteStringValue("all"); - return; + writer.WriteStringValue(MemberAll); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ZeroTermsQuery)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs index 2a8f7fef228..a69d7825e9f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.QueryRules.g.cs @@ -57,86 +57,130 @@ public enum QueryRuleCriteriaType Always } -internal sealed class QueryRuleCriteriaTypeConverter : JsonConverter +internal sealed partial class QueryRuleCriteriaTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryRuleCriteriaType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberSuffix = System.Text.Json.JsonEncodedText.Encode("suffix"); + private static readonly System.Text.Json.JsonEncodedText MemberPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText MemberLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText MemberLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText MemberGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText MemberGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText MemberGlobal = System.Text.Json.JsonEncodedText.Encode("global"); + private static readonly System.Text.Json.JsonEncodedText MemberFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText MemberExactFuzzy = System.Text.Json.JsonEncodedText.Encode("exact_fuzzy"); + private static readonly System.Text.Json.JsonEncodedText MemberExact = System.Text.Json.JsonEncodedText.Encode("exact"); + private static readonly System.Text.Json.JsonEncodedText MemberContains = System.Text.Json.JsonEncodedText.Encode("contains"); + private static readonly System.Text.Json.JsonEncodedText MemberAlways = System.Text.Json.JsonEncodedText.Encode("always"); + + public override QueryRuleCriteriaType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) - { - case "suffix": - return QueryRuleCriteriaType.Suffix; - case "prefix": - return QueryRuleCriteriaType.Prefix; - case "lte": - return QueryRuleCriteriaType.Lte; - case "lt": - return QueryRuleCriteriaType.Lt; - case "gte": - return QueryRuleCriteriaType.Gte; - case "gt": - return QueryRuleCriteriaType.Gt; - case "global": - return QueryRuleCriteriaType.Global; - case "fuzzy": - return QueryRuleCriteriaType.Fuzzy; - case "exact_fuzzy": - return QueryRuleCriteriaType.ExactFuzzy; - case "exact": - return QueryRuleCriteriaType.Exact; - case "contains": - return QueryRuleCriteriaType.Contains; - case "always": - return QueryRuleCriteriaType.Always; - } - - ThrowHelper.ThrowJsonException(); - return default; + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberSuffix)) + { + return QueryRuleCriteriaType.Suffix; + } + + if (reader.ValueTextEquals(MemberPrefix)) + { + return QueryRuleCriteriaType.Prefix; + } + + if (reader.ValueTextEquals(MemberLte)) + { + return QueryRuleCriteriaType.Lte; + } + + if (reader.ValueTextEquals(MemberLt)) + { + return QueryRuleCriteriaType.Lt; + } + + if (reader.ValueTextEquals(MemberGte)) + { + return QueryRuleCriteriaType.Gte; + } + + if (reader.ValueTextEquals(MemberGt)) + { + return QueryRuleCriteriaType.Gt; + } + + if (reader.ValueTextEquals(MemberGlobal)) + { + return QueryRuleCriteriaType.Global; + } + + if (reader.ValueTextEquals(MemberFuzzy)) + { + return QueryRuleCriteriaType.Fuzzy; + } + + if (reader.ValueTextEquals(MemberExactFuzzy)) + { + return QueryRuleCriteriaType.ExactFuzzy; + } + + if (reader.ValueTextEquals(MemberExact)) + { + return QueryRuleCriteriaType.Exact; + } + + if (reader.ValueTextEquals(MemberContains)) + { + return QueryRuleCriteriaType.Contains; + } + + if (reader.ValueTextEquals(MemberAlways)) + { + return QueryRuleCriteriaType.Always; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(QueryRuleCriteriaType)}'."); } - public override void Write(Utf8JsonWriter writer, QueryRuleCriteriaType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRuleCriteriaType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case QueryRuleCriteriaType.Suffix: - writer.WriteStringValue("suffix"); - return; + writer.WriteStringValue(MemberSuffix); + break; case QueryRuleCriteriaType.Prefix: - writer.WriteStringValue("prefix"); - return; + writer.WriteStringValue(MemberPrefix); + break; case QueryRuleCriteriaType.Lte: - writer.WriteStringValue("lte"); - return; + writer.WriteStringValue(MemberLte); + break; case QueryRuleCriteriaType.Lt: - writer.WriteStringValue("lt"); - return; + writer.WriteStringValue(MemberLt); + break; case QueryRuleCriteriaType.Gte: - writer.WriteStringValue("gte"); - return; + writer.WriteStringValue(MemberGte); + break; case QueryRuleCriteriaType.Gt: - writer.WriteStringValue("gt"); - return; + writer.WriteStringValue(MemberGt); + break; case QueryRuleCriteriaType.Global: - writer.WriteStringValue("global"); - return; + writer.WriteStringValue(MemberGlobal); + break; case QueryRuleCriteriaType.Fuzzy: - writer.WriteStringValue("fuzzy"); - return; + writer.WriteStringValue(MemberFuzzy); + break; case QueryRuleCriteriaType.ExactFuzzy: - writer.WriteStringValue("exact_fuzzy"); - return; + writer.WriteStringValue(MemberExactFuzzy); + break; case QueryRuleCriteriaType.Exact: - writer.WriteStringValue("exact"); - return; + writer.WriteStringValue(MemberExact); + break; case QueryRuleCriteriaType.Contains: - writer.WriteStringValue("contains"); - return; + writer.WriteStringValue(MemberContains); + break; case QueryRuleCriteriaType.Always: - writer.WriteStringValue("always"); - return; + writer.WriteStringValue(MemberAlways); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(QueryRuleCriteriaType)}'."); } - - writer.WriteNullValue(); } } @@ -149,35 +193,39 @@ public enum QueryRuleType Exclude } -internal sealed class QueryRuleTypeConverter : JsonConverter +internal sealed partial class QueryRuleTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryRuleType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPinned = System.Text.Json.JsonEncodedText.Encode("pinned"); + private static readonly System.Text.Json.JsonEncodedText MemberExclude = System.Text.Json.JsonEncodedText.Encode("exclude"); + + public override QueryRuleType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPinned)) { - case "pinned": - return QueryRuleType.Pinned; - case "exclude": - return QueryRuleType.Exclude; + return QueryRuleType.Pinned; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberExclude)) + { + return QueryRuleType.Exclude; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(QueryRuleType)}'."); } - public override void Write(Utf8JsonWriter writer, QueryRuleType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRuleType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case QueryRuleType.Pinned: - writer.WriteStringValue("pinned"); - return; + writer.WriteStringValue(MemberPinned); + break; case QueryRuleType.Exclude: - writer.WriteStringValue("exclude"); - return; + writer.WriteStringValue(MemberExclude); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(QueryRuleType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs index 21d54ddc082..a8d9525520e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Rollup.g.cs @@ -43,51 +43,67 @@ public enum IndexingJobState Aborting } -internal sealed class IndexingJobStateConverter : JsonConverter +internal sealed partial class IndexingJobStateConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexingJobState Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStopping = System.Text.Json.JsonEncodedText.Encode("stopping"); + private static readonly System.Text.Json.JsonEncodedText MemberStopped = System.Text.Json.JsonEncodedText.Encode("stopped"); + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("started"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexing = System.Text.Json.JsonEncodedText.Encode("indexing"); + private static readonly System.Text.Json.JsonEncodedText MemberAborting = System.Text.Json.JsonEncodedText.Encode("aborting"); + + public override IndexingJobState Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStopping)) + { + return IndexingJobState.Stopping; + } + + if (reader.ValueTextEquals(MemberStopped)) + { + return IndexingJobState.Stopped; + } + + if (reader.ValueTextEquals(MemberStarted)) { - case "stopping": - return IndexingJobState.Stopping; - case "stopped": - return IndexingJobState.Stopped; - case "started": - return IndexingJobState.Started; - case "indexing": - return IndexingJobState.Indexing; - case "aborting": - return IndexingJobState.Aborting; + return IndexingJobState.Started; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberIndexing)) + { + return IndexingJobState.Indexing; + } + + if (reader.ValueTextEquals(MemberAborting)) + { + return IndexingJobState.Aborting; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(IndexingJobState)}'."); } - public override void Write(Utf8JsonWriter writer, IndexingJobState value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexingJobState value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case IndexingJobState.Stopping: - writer.WriteStringValue("stopping"); - return; + writer.WriteStringValue(MemberStopping); + break; case IndexingJobState.Stopped: - writer.WriteStringValue("stopped"); - return; + writer.WriteStringValue(MemberStopped); + break; case IndexingJobState.Started: - writer.WriteStringValue("started"); - return; + writer.WriteStringValue(MemberStarted); + break; case IndexingJobState.Indexing: - writer.WriteStringValue("indexing"); - return; + writer.WriteStringValue(MemberIndexing); + break; case IndexingJobState.Aborting: - writer.WriteStringValue("aborting"); - return; + writer.WriteStringValue(MemberAborting); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(IndexingJobState)}'."); } - - writer.WriteNullValue(); } } @@ -106,50 +122,66 @@ public enum Metric Avg } -internal sealed class MetricConverter : JsonConverter +internal sealed partial class MetricConverter : System.Text.Json.Serialization.JsonConverter { - public override Metric Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberValueCount = System.Text.Json.JsonEncodedText.Encode("value_count"); + private static readonly System.Text.Json.JsonEncodedText MemberSum = System.Text.Json.JsonEncodedText.Encode("sum"); + private static readonly System.Text.Json.JsonEncodedText MemberMin = System.Text.Json.JsonEncodedText.Encode("min"); + private static readonly System.Text.Json.JsonEncodedText MemberMax = System.Text.Json.JsonEncodedText.Encode("max"); + private static readonly System.Text.Json.JsonEncodedText MemberAvg = System.Text.Json.JsonEncodedText.Encode("avg"); + + public override Metric Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberValueCount)) + { + return Metric.ValueCount; + } + + if (reader.ValueTextEquals(MemberSum)) + { + return Metric.Sum; + } + + if (reader.ValueTextEquals(MemberMin)) { - case "value_count": - return Metric.ValueCount; - case "sum": - return Metric.Sum; - case "min": - return Metric.Min; - case "max": - return Metric.Max; - case "avg": - return Metric.Avg; + return Metric.Min; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberMax)) + { + return Metric.Max; + } + + if (reader.ValueTextEquals(MemberAvg)) + { + return Metric.Avg; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(Metric)}'."); } - public override void Write(Utf8JsonWriter writer, Metric value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Metric value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case Metric.ValueCount: - writer.WriteStringValue("value_count"); - return; + writer.WriteStringValue(MemberValueCount); + break; case Metric.Sum: - writer.WriteStringValue("sum"); - return; + writer.WriteStringValue(MemberSum); + break; case Metric.Min: - writer.WriteStringValue("min"); - return; + writer.WriteStringValue(MemberMin); + break; case Metric.Max: - writer.WriteStringValue("max"); - return; + writer.WriteStringValue(MemberMax); + break; case Metric.Avg: - writer.WriteStringValue("avg"); - return; + writer.WriteStringValue(MemberAvg); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Metric)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs index 347c56fa44b..0f6983345be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.SearchableSnapshots.g.cs @@ -39,40 +39,48 @@ public enum StatsLevel Cluster } -internal sealed class StatsLevelConverter : JsonConverter +internal sealed partial class StatsLevelConverter : System.Text.Json.Serialization.JsonConverter { - public override StatsLevel Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberShards = System.Text.Json.JsonEncodedText.Encode("shards"); + private static readonly System.Text.Json.JsonEncodedText MemberIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText MemberCluster = System.Text.Json.JsonEncodedText.Encode("cluster"); + + public override StatsLevel Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberShards)) + { + return StatsLevel.Shards; + } + + if (reader.ValueTextEquals(MemberIndices)) { - case "shards": - return StatsLevel.Shards; - case "indices": - return StatsLevel.Indices; - case "cluster": - return StatsLevel.Cluster; + return StatsLevel.Indices; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCluster)) + { + return StatsLevel.Cluster; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(StatsLevel)}'."); } - public override void Write(Utf8JsonWriter writer, StatsLevel value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, StatsLevel value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case StatsLevel.Shards: - writer.WriteStringValue("shards"); - return; + writer.WriteStringValue(MemberShards); + break; case StatsLevel.Indices: - writer.WriteStringValue("indices"); - return; + writer.WriteStringValue(MemberIndices); + break; case StatsLevel.Cluster: - writer.WriteStringValue("cluster"); - return; + writer.WriteStringValue(MemberCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(StatsLevel)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs index a73a00e061d..49191c0c76b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Security.g.cs @@ -41,46 +41,58 @@ public enum AccessTokenGrantType ClientCredentials } -internal sealed class AccessTokenGrantTypeConverter : JsonConverter +internal sealed partial class AccessTokenGrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override AccessTokenGrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRefreshToken = System.Text.Json.JsonEncodedText.Encode("refresh_token"); + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberKerberos = System.Text.Json.JsonEncodedText.Encode("_kerberos"); + private static readonly System.Text.Json.JsonEncodedText MemberClientCredentials = System.Text.Json.JsonEncodedText.Encode("client_credentials"); + + public override AccessTokenGrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRefreshToken)) + { + return AccessTokenGrantType.RefreshToken; + } + + if (reader.ValueTextEquals(MemberPassword)) { - case "refresh_token": - return AccessTokenGrantType.RefreshToken; - case "password": - return AccessTokenGrantType.Password; - case "_kerberos": - return AccessTokenGrantType.Kerberos; - case "client_credentials": - return AccessTokenGrantType.ClientCredentials; + return AccessTokenGrantType.Password; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberKerberos)) + { + return AccessTokenGrantType.Kerberos; + } + + if (reader.ValueTextEquals(MemberClientCredentials)) + { + return AccessTokenGrantType.ClientCredentials; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(AccessTokenGrantType)}'."); } - public override void Write(Utf8JsonWriter writer, AccessTokenGrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, AccessTokenGrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case AccessTokenGrantType.RefreshToken: - writer.WriteStringValue("refresh_token"); - return; + writer.WriteStringValue(MemberRefreshToken); + break; case AccessTokenGrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case AccessTokenGrantType.Kerberos: - writer.WriteStringValue("_kerberos"); - return; + writer.WriteStringValue(MemberKerberos); + break; case AccessTokenGrantType.ClientCredentials: - writer.WriteStringValue("client_credentials"); - return; + writer.WriteStringValue(MemberClientCredentials); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(AccessTokenGrantType)}'."); } - - writer.WriteNullValue(); } } @@ -93,36 +105,40 @@ public enum ApiKeyGrantType AccessToken } -internal sealed class ApiKeyGrantTypeConverter : JsonConverter +internal sealed partial class ApiKeyGrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ApiKeyGrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + + public override ApiKeyGrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPassword)) { - case "password": - return ApiKeyGrantType.Password; - case "access_token": - return ApiKeyGrantType.AccessToken; + return ApiKeyGrantType.Password; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberAccessToken)) + { + return ApiKeyGrantType.AccessToken; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ApiKeyGrantType)}'."); } - public override void Write(Utf8JsonWriter writer, ApiKeyGrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ApiKeyGrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ApiKeyGrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case ApiKeyGrantType.AccessToken: - writer.WriteStringValue("access_token"); - return; + writer.WriteStringValue(MemberAccessToken); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ApiKeyGrantType)}'."); } - - writer.WriteNullValue(); } } @@ -135,36 +151,40 @@ public enum ApiKeyType CrossCluster } -internal sealed class ApiKeyTypeConverter : JsonConverter +internal sealed partial class ApiKeyTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override ApiKeyType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberRest = System.Text.Json.JsonEncodedText.Encode("rest"); + private static readonly System.Text.Json.JsonEncodedText MemberCrossCluster = System.Text.Json.JsonEncodedText.Encode("cross_cluster"); + + public override ApiKeyType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberRest)) { - case "rest": - return ApiKeyType.Rest; - case "cross_cluster": - return ApiKeyType.CrossCluster; + return ApiKeyType.Rest; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberCrossCluster)) + { + return ApiKeyType.CrossCluster; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ApiKeyType)}'."); } - public override void Write(Utf8JsonWriter writer, ApiKeyType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ApiKeyType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ApiKeyType.Rest: - writer.WriteStringValue("rest"); - return; + writer.WriteStringValue(MemberRest); + break; case ApiKeyType.CrossCluster: - writer.WriteStringValue("cross_cluster"); - return; + writer.WriteStringValue(MemberCrossCluster); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ApiKeyType)}'."); } - - writer.WriteNullValue(); } } @@ -172,9 +192,11 @@ public override void Write(Utf8JsonWriter writer, ApiKeyType value, JsonSerializ public readonly partial struct ClusterPrivilege : IEnumStruct { public ClusterPrivilege(string value) => Value = value; - +#if NET7_0_OR_GREATER + static ClusterPrivilege IEnumStruct.Create(string value) => value; +#else ClusterPrivilege IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static ClusterPrivilege WriteFleetSecrets { get; } = new ClusterPrivilege("write_fleet_secrets"); public static ClusterPrivilege WriteConnectorSecrets { get; } = new ClusterPrivilege("write_connector_secrets"); @@ -268,36 +290,40 @@ public enum GrantType AccessToken } -internal sealed class GrantTypeConverter : JsonConverter +internal sealed partial class GrantTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override GrantType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberPassword = System.Text.Json.JsonEncodedText.Encode("password"); + private static readonly System.Text.Json.JsonEncodedText MemberAccessToken = System.Text.Json.JsonEncodedText.Encode("access_token"); + + public override GrantType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberPassword)) + { + return GrantType.Password; + } + + if (reader.ValueTextEquals(MemberAccessToken)) { - case "password": - return GrantType.Password; - case "access_token": - return GrantType.AccessToken; + return GrantType.AccessToken; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GrantType)}'."); } - public override void Write(Utf8JsonWriter writer, GrantType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GrantType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GrantType.Password: - writer.WriteStringValue("password"); - return; + writer.WriteStringValue(MemberPassword); + break; case GrantType.AccessToken: - writer.WriteStringValue("access_token"); - return; + writer.WriteStringValue(MemberAccessToken); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GrantType)}'."); } - - writer.WriteNullValue(); } } @@ -305,9 +331,11 @@ public override void Write(Utf8JsonWriter writer, GrantType value, JsonSerialize public readonly partial struct IndexPrivilege : IEnumStruct { public IndexPrivilege(string value) => Value = value; - +#if NET7_0_OR_GREATER + static IndexPrivilege IEnumStruct.Create(string value) => value; +#else IndexPrivilege IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static IndexPrivilege Write { get; } = new IndexPrivilege("write"); public static IndexPrivilege ViewIndexMetadata { get; } = new IndexPrivilege("view_index_metadata"); @@ -354,36 +382,40 @@ public enum RemoteClusterPrivilege MonitorEnrich } -internal sealed class RemoteClusterPrivilegeConverter : JsonConverter +internal sealed partial class RemoteClusterPrivilegeConverter : System.Text.Json.Serialization.JsonConverter { - public override RemoteClusterPrivilege Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberMonitorStats = System.Text.Json.JsonEncodedText.Encode("monitor_stats"); + private static readonly System.Text.Json.JsonEncodedText MemberMonitorEnrich = System.Text.Json.JsonEncodedText.Encode("monitor_enrich"); + + public override RemoteClusterPrivilege Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberMonitorStats)) { - case "monitor_stats": - return RemoteClusterPrivilege.MonitorStats; - case "monitor_enrich": - return RemoteClusterPrivilege.MonitorEnrich; + return RemoteClusterPrivilege.MonitorStats; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberMonitorEnrich)) + { + return RemoteClusterPrivilege.MonitorEnrich; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(RemoteClusterPrivilege)}'."); } - public override void Write(Utf8JsonWriter writer, RemoteClusterPrivilege value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoteClusterPrivilege value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case RemoteClusterPrivilege.MonitorStats: - writer.WriteStringValue("monitor_stats"); - return; + writer.WriteStringValue(MemberMonitorStats); + break; case RemoteClusterPrivilege.MonitorEnrich: - writer.WriteStringValue("monitor_enrich"); - return; + writer.WriteStringValue(MemberMonitorEnrich); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(RemoteClusterPrivilege)}'."); } - - writer.WriteNullValue(); } } @@ -391,9 +423,11 @@ public override void Write(Utf8JsonWriter writer, RemoteClusterPrivilege value, public readonly partial struct RestrictionWorkflow : IEnumStruct { public RestrictionWorkflow(string value) => Value = value; - +#if NET7_0_OR_GREATER + static RestrictionWorkflow IEnumStruct.Create(string value) => value; +#else RestrictionWorkflow IEnumStruct.Create(string value) => value; - +#endif public readonly string Value { get; } public static RestrictionWorkflow SearchApplicationQuery { get; } = new RestrictionWorkflow("search_application_query"); @@ -419,35 +453,39 @@ public enum TemplateFormat Json } -internal sealed class TemplateFormatConverter : JsonConverter +internal sealed partial class TemplateFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override TemplateFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberString = System.Text.Json.JsonEncodedText.Encode("string"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + + public override TemplateFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberString)) { - case "string": - return TemplateFormat.String; - case "json": - return TemplateFormat.Json; + return TemplateFormat.String; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return TemplateFormat.Json; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(TemplateFormat)}'."); } - public override void Write(Utf8JsonWriter writer, TemplateFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TemplateFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case TemplateFormat.String: - writer.WriteStringValue("string"); - return; + writer.WriteStringValue(MemberString); + break; case TemplateFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(TemplateFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs index f6ecd4edf17..bdb58976b9a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Snapshot.g.cs @@ -68,51 +68,67 @@ public enum ShardsStatsStage Done } -internal sealed class ShardsStatsStageConverter : JsonConverter +internal sealed partial class ShardsStatsStageConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardsStatsStage Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStarted = System.Text.Json.JsonEncodedText.Encode("STARTED"); + private static readonly System.Text.Json.JsonEncodedText MemberInit = System.Text.Json.JsonEncodedText.Encode("INIT"); + private static readonly System.Text.Json.JsonEncodedText MemberFinalize = System.Text.Json.JsonEncodedText.Encode("FINALIZE"); + private static readonly System.Text.Json.JsonEncodedText MemberFailure = System.Text.Json.JsonEncodedText.Encode("FAILURE"); + private static readonly System.Text.Json.JsonEncodedText MemberDone = System.Text.Json.JsonEncodedText.Encode("DONE"); + + public override ShardsStatsStage Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStarted)) { - case "STARTED": - return ShardsStatsStage.Started; - case "INIT": - return ShardsStatsStage.Init; - case "FINALIZE": - return ShardsStatsStage.Finalize; - case "FAILURE": - return ShardsStatsStage.Failure; - case "DONE": - return ShardsStatsStage.Done; + return ShardsStatsStage.Started; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberInit)) + { + return ShardsStatsStage.Init; + } + + if (reader.ValueTextEquals(MemberFinalize)) + { + return ShardsStatsStage.Finalize; + } + + if (reader.ValueTextEquals(MemberFailure)) + { + return ShardsStatsStage.Failure; + } + + if (reader.ValueTextEquals(MemberDone)) + { + return ShardsStatsStage.Done; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ShardsStatsStage)}'."); } - public override void Write(Utf8JsonWriter writer, ShardsStatsStage value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardsStatsStage value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ShardsStatsStage.Started: - writer.WriteStringValue("STARTED"); - return; + writer.WriteStringValue(MemberStarted); + break; case ShardsStatsStage.Init: - writer.WriteStringValue("INIT"); - return; + writer.WriteStringValue(MemberInit); + break; case ShardsStatsStage.Finalize: - writer.WriteStringValue("FINALIZE"); - return; + writer.WriteStringValue(MemberFinalize); + break; case ShardsStatsStage.Failure: - writer.WriteStringValue("FAILURE"); - return; + writer.WriteStringValue(MemberFailure); + break; case ShardsStatsStage.Done: - writer.WriteStringValue("DONE"); - return; + writer.WriteStringValue(MemberDone); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ShardsStatsStage)}'."); } - - writer.WriteNullValue(); } } @@ -135,60 +151,84 @@ public enum SnapshotSort Duration } -internal sealed class SnapshotSortConverter : JsonConverter +internal sealed partial class SnapshotSortConverter : System.Text.Json.Serialization.JsonConverter { - public override SnapshotSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberStartTime = System.Text.Json.JsonEncodedText.Encode("start_time"); + private static readonly System.Text.Json.JsonEncodedText MemberShardCount = System.Text.Json.JsonEncodedText.Encode("shard_count"); + private static readonly System.Text.Json.JsonEncodedText MemberRepository = System.Text.Json.JsonEncodedText.Encode("repository"); + private static readonly System.Text.Json.JsonEncodedText MemberName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText MemberIndexCount = System.Text.Json.JsonEncodedText.Encode("index_count"); + private static readonly System.Text.Json.JsonEncodedText MemberFailedShardCount = System.Text.Json.JsonEncodedText.Encode("failed_shard_count"); + private static readonly System.Text.Json.JsonEncodedText MemberDuration = System.Text.Json.JsonEncodedText.Encode("duration"); + + public override SnapshotSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberStartTime)) + { + return SnapshotSort.StartTime; + } + + if (reader.ValueTextEquals(MemberShardCount)) { - case "start_time": - return SnapshotSort.StartTime; - case "shard_count": - return SnapshotSort.ShardCount; - case "repository": - return SnapshotSort.Repository; - case "name": - return SnapshotSort.Name; - case "index_count": - return SnapshotSort.IndexCount; - case "failed_shard_count": - return SnapshotSort.FailedShardCount; - case "duration": - return SnapshotSort.Duration; + return SnapshotSort.ShardCount; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberRepository)) + { + return SnapshotSort.Repository; + } + + if (reader.ValueTextEquals(MemberName)) + { + return SnapshotSort.Name; + } + + if (reader.ValueTextEquals(MemberIndexCount)) + { + return SnapshotSort.IndexCount; + } + + if (reader.ValueTextEquals(MemberFailedShardCount)) + { + return SnapshotSort.FailedShardCount; + } + + if (reader.ValueTextEquals(MemberDuration)) + { + return SnapshotSort.Duration; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SnapshotSort)}'."); } - public override void Write(Utf8JsonWriter writer, SnapshotSort value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SnapshotSort value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SnapshotSort.StartTime: - writer.WriteStringValue("start_time"); - return; + writer.WriteStringValue(MemberStartTime); + break; case SnapshotSort.ShardCount: - writer.WriteStringValue("shard_count"); - return; + writer.WriteStringValue(MemberShardCount); + break; case SnapshotSort.Repository: - writer.WriteStringValue("repository"); - return; + writer.WriteStringValue(MemberRepository); + break; case SnapshotSort.Name: - writer.WriteStringValue("name"); - return; + writer.WriteStringValue(MemberName); + break; case SnapshotSort.IndexCount: - writer.WriteStringValue("index_count"); - return; + writer.WriteStringValue(MemberIndexCount); + break; case SnapshotSort.FailedShardCount: - writer.WriteStringValue("failed_shard_count"); - return; + writer.WriteStringValue(MemberFailedShardCount); + break; case SnapshotSort.Duration: - writer.WriteStringValue("duration"); - return; + writer.WriteStringValue(MemberDuration); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SnapshotSort)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs index 5b2210e7a2a..a9c9d41bb46 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Sql.g.cs @@ -47,60 +47,84 @@ public enum SqlFormat Cbor } -internal sealed class SqlFormatConverter : JsonConverter +internal sealed partial class SqlFormatConverter : System.Text.Json.Serialization.JsonConverter { - public override SqlFormat Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberYaml = System.Text.Json.JsonEncodedText.Encode("yaml"); + private static readonly System.Text.Json.JsonEncodedText MemberTxt = System.Text.Json.JsonEncodedText.Encode("txt"); + private static readonly System.Text.Json.JsonEncodedText MemberTsv = System.Text.Json.JsonEncodedText.Encode("tsv"); + private static readonly System.Text.Json.JsonEncodedText MemberSmile = System.Text.Json.JsonEncodedText.Encode("smile"); + private static readonly System.Text.Json.JsonEncodedText MemberJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText MemberCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText MemberCbor = System.Text.Json.JsonEncodedText.Encode("cbor"); + + public override SqlFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberYaml)) + { + return SqlFormat.Yaml; + } + + if (reader.ValueTextEquals(MemberTxt)) + { + return SqlFormat.Txt; + } + + if (reader.ValueTextEquals(MemberTsv)) + { + return SqlFormat.Tsv; + } + + if (reader.ValueTextEquals(MemberSmile)) { - case "yaml": - return SqlFormat.Yaml; - case "txt": - return SqlFormat.Txt; - case "tsv": - return SqlFormat.Tsv; - case "smile": - return SqlFormat.Smile; - case "json": - return SqlFormat.Json; - case "csv": - return SqlFormat.Csv; - case "cbor": - return SqlFormat.Cbor; + return SqlFormat.Smile; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberJson)) + { + return SqlFormat.Json; + } + + if (reader.ValueTextEquals(MemberCsv)) + { + return SqlFormat.Csv; + } + + if (reader.ValueTextEquals(MemberCbor)) + { + return SqlFormat.Cbor; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(SqlFormat)}'."); } - public override void Write(Utf8JsonWriter writer, SqlFormat value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SqlFormat value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case SqlFormat.Yaml: - writer.WriteStringValue("yaml"); - return; + writer.WriteStringValue(MemberYaml); + break; case SqlFormat.Txt: - writer.WriteStringValue("txt"); - return; + writer.WriteStringValue(MemberTxt); + break; case SqlFormat.Tsv: - writer.WriteStringValue("tsv"); - return; + writer.WriteStringValue(MemberTsv); + break; case SqlFormat.Smile: - writer.WriteStringValue("smile"); - return; + writer.WriteStringValue(MemberSmile); + break; case SqlFormat.Json: - writer.WriteStringValue("json"); - return; + writer.WriteStringValue(MemberJson); + break; case SqlFormat.Csv: - writer.WriteStringValue("csv"); - return; + writer.WriteStringValue(MemberCsv); + break; case SqlFormat.Cbor: - writer.WriteStringValue("cbor"); - return; + writer.WriteStringValue(MemberCbor); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(SqlFormat)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs index 23950271dfa..0ef47dfa638 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Tasks.g.cs @@ -54,40 +54,48 @@ public enum GroupBy Nodes } -internal sealed class GroupByConverter : JsonConverter +internal sealed partial class GroupByConverter : System.Text.Json.Serialization.JsonConverter { - public override GroupBy Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberParents = System.Text.Json.JsonEncodedText.Encode("parents"); + private static readonly System.Text.Json.JsonEncodedText MemberNone = System.Text.Json.JsonEncodedText.Encode("none"); + private static readonly System.Text.Json.JsonEncodedText MemberNodes = System.Text.Json.JsonEncodedText.Encode("nodes"); + + public override GroupBy Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberParents)) + { + return GroupBy.Parents; + } + + if (reader.ValueTextEquals(MemberNone)) { - case "parents": - return GroupBy.Parents; - case "none": - return GroupBy.None; - case "nodes": - return GroupBy.Nodes; + return GroupBy.None; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberNodes)) + { + return GroupBy.Nodes; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(GroupBy)}'."); } - public override void Write(Utf8JsonWriter writer, GroupBy value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, GroupBy value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case GroupBy.Parents: - writer.WriteStringValue("parents"); - return; + writer.WriteStringValue(MemberParents); + break; case GroupBy.None: - writer.WriteStringValue("none"); - return; + writer.WriteStringValue(MemberNone); + break; case GroupBy.Nodes: - writer.WriteStringValue("nodes"); - return; + writer.WriteStringValue(MemberNodes); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(GroupBy)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs index 3fc28166b89..2d25d0d723c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.TextStructure.g.cs @@ -37,36 +37,40 @@ public enum EcsCompatibilityType Disabled } -internal sealed class EcsCompatibilityTypeConverter : JsonConverter +internal sealed partial class EcsCompatibilityTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override EcsCompatibilityType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberV1 = System.Text.Json.JsonEncodedText.Encode("v1"); + private static readonly System.Text.Json.JsonEncodedText MemberDisabled = System.Text.Json.JsonEncodedText.Encode("disabled"); + + public override EcsCompatibilityType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberV1)) + { + return EcsCompatibilityType.V1; + } + + if (reader.ValueTextEquals(MemberDisabled)) { - case "v1": - return EcsCompatibilityType.V1; - case "disabled": - return EcsCompatibilityType.Disabled; + return EcsCompatibilityType.Disabled; } - ThrowHelper.ThrowJsonException(); - return default; + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(EcsCompatibilityType)}'."); } - public override void Write(Utf8JsonWriter writer, EcsCompatibilityType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, EcsCompatibilityType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case EcsCompatibilityType.V1: - writer.WriteStringValue("v1"); - return; + writer.WriteStringValue(MemberV1); + break; case EcsCompatibilityType.Disabled: - writer.WriteStringValue("disabled"); - return; + writer.WriteStringValue(MemberDisabled); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(EcsCompatibilityType)}'."); } - - writer.WriteNullValue(); } } @@ -83,45 +87,57 @@ public enum FormatType Delimited } -internal sealed class FormatTypeConverter : JsonConverter +internal sealed partial class FormatTypeConverter : System.Text.Json.Serialization.JsonConverter { - public override FormatType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberXml = System.Text.Json.JsonEncodedText.Encode("xml"); + private static readonly System.Text.Json.JsonEncodedText MemberSemiStructuredText = System.Text.Json.JsonEncodedText.Encode("semi_structured_text"); + private static readonly System.Text.Json.JsonEncodedText MemberNdjson = System.Text.Json.JsonEncodedText.Encode("ndjson"); + private static readonly System.Text.Json.JsonEncodedText MemberDelimited = System.Text.Json.JsonEncodedText.Encode("delimited"); + + public override FormatType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberXml)) + { + return FormatType.Xml; + } + + if (reader.ValueTextEquals(MemberSemiStructuredText)) + { + return FormatType.SemiStructuredText; + } + + if (reader.ValueTextEquals(MemberNdjson)) { - case "xml": - return FormatType.Xml; - case "semi_structured_text": - return FormatType.SemiStructuredText; - case "ndjson": - return FormatType.Ndjson; - case "delimited": - return FormatType.Delimited; + return FormatType.Ndjson; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberDelimited)) + { + return FormatType.Delimited; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(FormatType)}'."); } - public override void Write(Utf8JsonWriter writer, FormatType value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FormatType value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case FormatType.Xml: - writer.WriteStringValue("xml"); - return; + writer.WriteStringValue(MemberXml); + break; case FormatType.SemiStructuredText: - writer.WriteStringValue("semi_structured_text"); - return; + writer.WriteStringValue(MemberSemiStructuredText); + break; case FormatType.Ndjson: - writer.WriteStringValue("ndjson"); - return; + writer.WriteStringValue(MemberNdjson); + break; case FormatType.Delimited: - writer.WriteStringValue("delimited"); - return; + writer.WriteStringValue(MemberDelimited); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(FormatType)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs index fdb9af07820..fdf56427b20 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Watcher.g.cs @@ -41,45 +41,57 @@ public enum ActionStatusOptions Failure } -internal sealed class ActionStatusOptionsConverter : JsonConverter +internal sealed partial class ActionStatusOptionsConverter : System.Text.Json.Serialization.JsonConverter { - public override ActionStatusOptions Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberThrottled = System.Text.Json.JsonEncodedText.Encode("throttled"); + private static readonly System.Text.Json.JsonEncodedText MemberSuccess = System.Text.Json.JsonEncodedText.Encode("success"); + private static readonly System.Text.Json.JsonEncodedText MemberSimulated = System.Text.Json.JsonEncodedText.Encode("simulated"); + private static readonly System.Text.Json.JsonEncodedText MemberFailure = System.Text.Json.JsonEncodedText.Encode("failure"); + + public override ActionStatusOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberThrottled)) + { + return ActionStatusOptions.Throttled; + } + + if (reader.ValueTextEquals(MemberSuccess)) { - case "throttled": - return ActionStatusOptions.Throttled; - case "success": - return ActionStatusOptions.Success; - case "simulated": - return ActionStatusOptions.Simulated; - case "failure": - return ActionStatusOptions.Failure; + return ActionStatusOptions.Success; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberSimulated)) + { + return ActionStatusOptions.Simulated; + } + + if (reader.ValueTextEquals(MemberFailure)) + { + return ActionStatusOptions.Failure; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(ActionStatusOptions)}'."); } - public override void Write(Utf8JsonWriter writer, ActionStatusOptions value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ActionStatusOptions value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case ActionStatusOptions.Throttled: - writer.WriteStringValue("throttled"); - return; + writer.WriteStringValue(MemberThrottled); + break; case ActionStatusOptions.Success: - writer.WriteStringValue("success"); - return; + writer.WriteStringValue(MemberSuccess); + break; case ActionStatusOptions.Simulated: - writer.WriteStringValue("simulated"); - return; + writer.WriteStringValue(MemberSimulated); + break; case ActionStatusOptions.Failure: - writer.WriteStringValue("failure"); - return; + writer.WriteStringValue(MemberFailure); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(ActionStatusOptions)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs index 36d2bdbd1e9..1bdb4ded446 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Enums/Enums.Xpack.g.cs @@ -39,40 +39,48 @@ public enum XPackCategory Build } -internal sealed class XPackCategoryConverter : JsonConverter +internal sealed partial class XPackCategoryConverter : System.Text.Json.Serialization.JsonConverter { - public override XPackCategory Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText MemberLicense = System.Text.Json.JsonEncodedText.Encode("license"); + private static readonly System.Text.Json.JsonEncodedText MemberFeatures = System.Text.Json.JsonEncodedText.Encode("features"); + private static readonly System.Text.Json.JsonEncodedText MemberBuild = System.Text.Json.JsonEncodedText.Encode("build"); + + public override XPackCategory Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var enumString = reader.GetString(); - switch (enumString) + reader.ValidateToken(System.Text.Json.JsonTokenType.String); + if (reader.ValueTextEquals(MemberLicense)) + { + return XPackCategory.License; + } + + if (reader.ValueTextEquals(MemberFeatures)) { - case "license": - return XPackCategory.License; - case "features": - return XPackCategory.Features; - case "build": - return XPackCategory.Build; + return XPackCategory.Features; } - ThrowHelper.ThrowJsonException(); - return default; + if (reader.ValueTextEquals(MemberBuild)) + { + return XPackCategory.Build; + } + + throw new System.Text.Json.JsonException($"Unknown value '{reader.GetString()}' for enum '{nameof(XPackCategory)}'."); } - public override void Write(Utf8JsonWriter writer, XPackCategory value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, XPackCategory value, System.Text.Json.JsonSerializerOptions options) { switch (value) { case XPackCategory.License: - writer.WriteStringValue("license"); - return; + writer.WriteStringValue(MemberLicense); + break; case XPackCategory.Features: - writer.WriteStringValue("features"); - return; + writer.WriteStringValue(MemberFeatures); + break; case XPackCategory.Build: - writer.WriteStringValue("build"); - return; + writer.WriteStringValue(MemberBuild); + break; + default: + throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(XPackCategory)}'."); } - - writer.WriteNullValue(); } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs index 87713b7a04f..8141f40c2f7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/EqlHits.g.cs @@ -27,6 +27,77 @@ namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class EqlHitsConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + private static readonly System.Text.Json.JsonEncodedText PropSequences = System.Text.Json.JsonEncodedText.Encode("sequences"); + private static readonly System.Text.Json.JsonEncodedText PropTotal = System.Text.Json.JsonEncodedText.Encode("total"); + + public override EqlHits Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>?> propEvents = default; + LocalJsonValue>?> propSequences = default; + LocalJsonValue propTotal = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + if (propSequences.TryRead(ref reader, options, PropSequences)) + { + continue; + } + + if (propTotal.TryRead(ref reader, options, PropTotal)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new EqlHits + { + Events = propEvents.Value +, + Sequences = propSequences.Value +, + Total = propTotal.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, EqlHits value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteProperty(options, PropSequences, value.Sequences); + writer.WriteProperty(options, PropTotal, value.Total); + writer.WriteEndObject(); + } +} + +internal sealed partial class EqlHitsConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(EqlHits<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(EqlHitsConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(EqlHitsConverterFactory))] public sealed partial class EqlHits { /// @@ -34,7 +105,6 @@ public sealed partial class EqlHits /// Contains events matching the query. Each object represents a matching event. /// /// - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection>? Events { get; init; } /// @@ -42,7 +112,6 @@ public sealed partial class EqlHits /// Contains event sequences matching the query. Each object represents a matching sequence. This parameter is only returned for EQL queries containing a sequence. /// /// - [JsonInclude, JsonPropertyName("sequences")] public IReadOnlyCollection>? Sequences { get; init; } /// @@ -50,6 +119,5 @@ public sealed partial class EqlHits /// Metadata about the number of matching events or sequences. /// /// - [JsonInclude, JsonPropertyName("total")] public Elastic.Clients.Elasticsearch.Core.Search.TotalHits? Total { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs index 6ec2792b4d5..d2cbf19a03c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsEvent.g.cs @@ -27,10 +27,99 @@ namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class HitsEventConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override HitsEvent Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>?> propFields = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propMissing = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsEvent + { + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + Missing = propMissing.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsEvent value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsEventConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsEvent<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitsEventConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitsEventConverterFactory))] public sealed partial class HitsEvent { - [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary>? Fields { get; init; } /// @@ -38,7 +127,6 @@ public sealed partial class HitsEvent /// Unique identifier for the event. This ID is only unique within the index. /// /// - [JsonInclude, JsonPropertyName("_id")] public string Id { get; init; } /// @@ -46,7 +134,6 @@ public sealed partial class HitsEvent /// Name of the index containing the event. /// /// - [JsonInclude, JsonPropertyName("_index")] public string Index { get; init; } /// @@ -54,7 +141,6 @@ public sealed partial class HitsEvent /// Set to true for events in a timespan-constrained sequence that do not meet a given condition. /// /// - [JsonInclude, JsonPropertyName("missing")] public bool? Missing { get; init; } /// @@ -62,7 +148,5 @@ public sealed partial class HitsEvent /// Original JSON body passed for the event at index time. /// /// - [JsonInclude, JsonPropertyName("_source")] - [SourceConverter] public TEvent Source { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs index a2f67ae5619..3355c218306 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Eql/HitsSequence.g.cs @@ -27,6 +27,67 @@ namespace Elastic.Clients.Elasticsearch.Eql; +internal sealed partial class HitsSequenceConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropEvents = System.Text.Json.JsonEncodedText.Encode("events"); + private static readonly System.Text.Json.JsonEncodedText PropJoinKeys = System.Text.Json.JsonEncodedText.Encode("join_keys"); + + public override HitsSequence Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue>> propEvents = default; + LocalJsonValue?> propJoinKeys = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEvents.TryRead(ref reader, options, PropEvents)) + { + continue; + } + + if (propJoinKeys.TryRead(ref reader, options, PropJoinKeys)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HitsSequence + { + Events = propEvents.Value +, + JoinKeys = propJoinKeys.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HitsSequence value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEvents, value.Events); + writer.WriteProperty(options, PropJoinKeys, value.JoinKeys); + writer.WriteEndObject(); + } +} + +internal sealed partial class HitsSequenceConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(HitsSequence<>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(HitsSequenceConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(HitsSequenceConverterFactory))] public sealed partial class HitsSequence { /// @@ -34,7 +95,6 @@ public sealed partial class HitsSequence /// Contains events matching the query. Each object represents a matching event. /// /// - [JsonInclude, JsonPropertyName("events")] public IReadOnlyCollection> Events { get; init; } /// @@ -42,6 +102,5 @@ public sealed partial class HitsSequence /// Shared field values used to constrain matches in the sequence. These are defined using the by keyword in the EQL query syntax. /// /// - [JsonInclude, JsonPropertyName("join_keys")] public IReadOnlyCollection? JoinKeys { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs index 55ae6e38d10..01d36a637c5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/ErrorCause.g.cs @@ -27,72 +27,100 @@ namespace Elastic.Clients.Elasticsearch; -internal sealed partial class ErrorCauseConverter : JsonConverter +internal sealed partial class ErrorCauseConverter : System.Text.Json.Serialization.JsonConverter { - public override ErrorCause Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropCausedBy = System.Text.Json.JsonEncodedText.Encode("caused_by"); + private static readonly System.Text.Json.JsonEncodedText PropReason = System.Text.Json.JsonEncodedText.Encode("reason"); + private static readonly System.Text.Json.JsonEncodedText PropRootCause = System.Text.Json.JsonEncodedText.Encode("root_cause"); + private static readonly System.Text.Json.JsonEncodedText PropStackTrace = System.Text.Json.JsonEncodedText.Encode("stack_trace"); + private static readonly System.Text.Json.JsonEncodedText PropSuppressed = System.Text.Json.JsonEncodedText.Encode("suppressed"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ErrorCause Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - Elastic.Clients.Elasticsearch.ErrorCause? causedBy = default; - string? reason = default; - IReadOnlyCollection? rootCause = default; - string? stackTrace = default; - IReadOnlyCollection? suppressed = default; - string type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonValue propCausedBy = default; + LocalJsonValue propReason = default; + LocalJsonValue?> propRootCause = default; + LocalJsonValue propStackTrace = default; + LocalJsonValue?> propSuppressed = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propCausedBy.TryRead(ref reader, options, PropCausedBy)) { - var property = reader.GetString(); - if (property == "caused_by") - { - causedBy = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "reason") - { - reason = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "root_cause") - { - rootCause = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "stack_trace") - { - stackTrace = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "suppressed") - { - suppressed = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propReason.TryRead(ref reader, options, PropReason)) + { + continue; + } + + if (propRootCause.TryRead(ref reader, options, PropRootCause)) + { + continue; + } + + if (propStackTrace.TryRead(ref reader, options, PropStackTrace)) + { + continue; + } + + if (propSuppressed.TryRead(ref reader, options, PropSuppressed)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propMetadata[key] = value; } - return new ErrorCause { CausedBy = causedBy, Metadata = additionalProperties, Reason = reason, RootCause = rootCause, StackTrace = stackTrace, Suppressed = suppressed, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ErrorCause + { + Metadata = propMetadata +, + CausedBy = propCausedBy.Value +, + Reason = propReason.Value +, + RootCause = propRootCause.Value +, + StackTrace = propStackTrace.Value +, + Suppressed = propSuppressed.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, ErrorCause value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ErrorCause value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ErrorCause' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropCausedBy, value.CausedBy); + writer.WriteProperty(options, PropReason, value.Reason); + writer.WriteProperty(options, PropRootCause, value.RootCause); + writer.WriteProperty(options, PropStackTrace, value.StackTrace); + writer.WriteProperty(options, PropSuppressed, value.Suppressed); + writer.WriteProperty(options, PropType, value.Type); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs index 669d99a22ce..78e2a762e16 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FieldSort.g.cs @@ -27,21 +27,114 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class FieldSortConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText PropNumericType = System.Text.Json.JsonEncodedText.Encode("numeric_type"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropUnmappedType = System.Text.Json.JsonEncodedText.Encode("unmapped_type"); + + public override FieldSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new FieldSort { Order = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFormat = default; + LocalJsonValue propMissing = default; + LocalJsonValue propMode = default; + LocalJsonValue propNested = default; + LocalJsonValue propNumericType = default; + LocalJsonValue propOrder = default; + LocalJsonValue propUnmappedType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing)) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } + + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } + + if (propNumericType.TryRead(ref reader, options, PropNumericType)) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } + + if (propUnmappedType.TryRead(ref reader, options, PropUnmappedType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldSort + { + Format = propFormat.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value +, + Nested = propNested.Value +, + NumericType = propNumericType.Value +, + Order = propOrder.Value +, + UnmappedType = propUnmappedType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropMissing, value.Missing); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropNumericType, value.NumericType); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropUnmappedType, value.UnmappedType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FieldSortConverter))] public sealed partial class FieldSort { - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("missing")] public Elastic.Clients.Elasticsearch.FieldValue? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] public Elastic.Clients.Elasticsearch.SortMode? Mode { get; set; } - [JsonInclude, JsonPropertyName("nested")] public Elastic.Clients.Elasticsearch.NestedSortValue? Nested { get; set; } - [JsonInclude, JsonPropertyName("numeric_type")] public Elastic.Clients.Elasticsearch.FieldSortNumericType? NumericType { get; set; } - [JsonInclude, JsonPropertyName("order")] public Elastic.Clients.Elasticsearch.SortOrder? Order { get; set; } - [JsonInclude, JsonPropertyName("unmapped_type")] public Elastic.Clients.Elasticsearch.Mapping.FieldType? UnmappedType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs index f3328e0464e..996b1bef0cf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/FielddataStats.g.cs @@ -32,7 +32,6 @@ public sealed partial class FielddataStats [JsonInclude, JsonPropertyName("evictions")] public long? Evictions { get; init; } [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.FieldMemoryUsage))] public IReadOnlyDictionary? Fields { get; init; } [JsonInclude, JsonPropertyName("memory_size")] public Elastic.Clients.Elasticsearch.ByteSize? MemorySize { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs index d3eaa418c60..1763a9b5000 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/GeoDistanceSort.g.cs @@ -27,114 +27,95 @@ namespace Elastic.Clients.Elasticsearch; -internal sealed partial class GeoDistanceSortConverter : JsonConverter +internal sealed partial class GeoDistanceSortConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceSort Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropDistanceType = System.Text.Json.JsonEncodedText.Encode("distance_type"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + private static readonly System.Text.Json.JsonEncodedText PropUnit = System.Text.Json.JsonEncodedText.Encode("unit"); + + public override GeoDistanceSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDistanceSort(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue> propLocation = default; + LocalJsonValue propDistanceType = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propMode = default; + LocalJsonValue propNested = default; + LocalJsonValue propOrder = default; + LocalJsonValue propUnit = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propDistanceType.TryRead(ref reader, options, PropDistanceType)) { - var property = reader.GetString(); - if (property == "distance_type") - { - variant.DistanceType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mode") - { - variant.Mode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "nested") - { - variant.Nested = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "order") - { - variant.Order = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "unit") - { - variant.Unit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Location = JsonSerializer.Deserialize>(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoDistanceSort value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Location is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Location, options); - } - - if (value.DistanceType is not null) - { - writer.WritePropertyName("distance_type"); - JsonSerializer.Serialize(writer, value.DistanceType, options); - } + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propNested.TryRead(ref reader, options, PropNested)) + { + continue; + } - if (value.Mode is not null) - { - writer.WritePropertyName("mode"); - JsonSerializer.Serialize(writer, value.Mode, options); - } + if (propOrder.TryRead(ref reader, options, PropOrder)) + { + continue; + } - if (value.Nested is not null) - { - writer.WritePropertyName("nested"); - JsonSerializer.Serialize(writer, value.Nested, options); - } + if (propUnit.TryRead(ref reader, options, PropUnit)) + { + continue; + } - if (value.Order is not null) - { - writer.WritePropertyName("order"); - JsonSerializer.Serialize(writer, value.Order, options); + propField.Initialized = propLocation.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propLocation.Value, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.GeoLocation>)); } - if (value.Unit is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDistanceSort { - writer.WritePropertyName("unit"); - JsonSerializer.Serialize(writer, value.Unit, options); - } + Field = propField.Value +, + Location = propLocation.Value +, + DistanceType = propDistanceType.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + Mode = propMode.Value +, + Nested = propNested.Value +, + Order = propOrder.Value +, + Unit = propUnit.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDistanceType, value.DistanceType); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNested, value.Nested); + writer.WriteProperty(options, PropOrder, value.Order); + writer.WriteProperty(options, PropUnit, value.Unit); + writer.WriteProperty(options, value.Field, value.Location, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.GeoLocation>)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs index b2238856538..8f4d891a6bc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/AddAction.g.cs @@ -27,6 +27,140 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class AddActionConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexRouting = System.Text.Json.JsonEncodedText.Encode("index_routing"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIsHidden = System.Text.Json.JsonEncodedText.Encode("is_hidden"); + private static readonly System.Text.Json.JsonEncodedText PropIsWriteIndex = System.Text.Json.JsonEncodedText.Encode("is_write_index"); + private static readonly System.Text.Json.JsonEncodedText PropMustExist = System.Text.Json.JsonEncodedText.Encode("must_exist"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropSearchRouting = System.Text.Json.JsonEncodedText.Encode("search_routing"); + + public override AddAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAlias = default; + LocalJsonValue?> propAliases = default; + LocalJsonValue propFilter = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexRouting = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIsHidden = default; + LocalJsonValue propIsWriteIndex = default; + LocalJsonValue propMustExist = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSearchRouting = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryRead(ref reader, options, PropAlias)) + { + continue; + } + + if (propAliases.TryRead(ref reader, options, PropAliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexAlias>))) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexRouting.TryRead(ref reader, options, PropIndexRouting)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIsHidden.TryRead(ref reader, options, PropIsHidden)) + { + continue; + } + + if (propIsWriteIndex.TryRead(ref reader, options, PropIsWriteIndex)) + { + continue; + } + + if (propMustExist.TryRead(ref reader, options, PropMustExist)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSearchRouting.TryRead(ref reader, options, PropSearchRouting)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AddAction + { + Alias = propAlias.Value +, + Aliases = propAliases.Value +, + Filter = propFilter.Value +, + Index = propIndex.Value +, + IndexRouting = propIndexRouting.Value +, + Indices = propIndices.Value +, + IsHidden = propIsHidden.Value +, + IsWriteIndex = propIsWriteIndex.Value +, + MustExist = propMustExist.Value +, + Routing = propRouting.Value +, + SearchRouting = propSearchRouting.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AddAction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlias, value.Alias); + writer.WriteProperty(options, PropAliases, value.Aliases, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexAlias>)); + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexRouting, value.IndexRouting); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIsHidden, value.IsHidden); + writer.WriteProperty(options, PropIsWriteIndex, value.IsWriteIndex); + writer.WriteProperty(options, PropMustExist, value.MustExist); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSearchRouting, value.SearchRouting); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AddActionConverter))] public sealed partial class AddAction { /// @@ -35,7 +169,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.IndexAlias? Alias { get; set; } /// @@ -44,8 +177,6 @@ public sealed partial class AddAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -53,7 +184,6 @@ public sealed partial class AddAction /// Query used to limit documents the alias can access. /// /// - [JsonInclude, JsonPropertyName("filter")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Filter { get; set; } /// @@ -62,7 +192,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -72,7 +201,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("index_routing")] public Elastic.Clients.Elasticsearch.Routing? IndexRouting { get; set; } /// @@ -81,7 +209,6 @@ public sealed partial class AddAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -89,7 +216,6 @@ public sealed partial class AddAction /// If true, the alias is hidden. /// /// - [JsonInclude, JsonPropertyName("is_hidden")] public bool? IsHidden { get; set; } /// @@ -97,7 +223,6 @@ public sealed partial class AddAction /// If true, sets the write index or data stream for the alias. /// /// - [JsonInclude, JsonPropertyName("is_write_index")] public bool? IsWriteIndex { get; set; } /// @@ -105,7 +230,6 @@ public sealed partial class AddAction /// If true, the alias must exist to perform the action. /// /// - [JsonInclude, JsonPropertyName("must_exist")] public bool? MustExist { get; set; } /// @@ -114,7 +238,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -124,7 +247,6 @@ public sealed partial class AddAction /// Data stream aliases don’t support this parameter. /// /// - [JsonInclude, JsonPropertyName("search_routing")] public Elastic.Clients.Elasticsearch.Routing? SearchRouting { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction(AddAction addAction) => Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction.Add(addAction); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs index 266cfa6e3c0..ab464db3021 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ExplainAnalyzeToken.g.cs @@ -27,93 +27,130 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; -internal sealed partial class ExplainAnalyzeTokenConverter : JsonConverter +internal sealed partial class ExplainAnalyzeTokenConverter : System.Text.Json.Serialization.JsonConverter { - public override ExplainAnalyzeToken Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropBytes = System.Text.Json.JsonEncodedText.Encode("bytes"); + private static readonly System.Text.Json.JsonEncodedText PropEndOffset = System.Text.Json.JsonEncodedText.Encode("end_offset"); + private static readonly System.Text.Json.JsonEncodedText PropKeyword = System.Text.Json.JsonEncodedText.Encode("keyword"); + private static readonly System.Text.Json.JsonEncodedText PropPosition = System.Text.Json.JsonEncodedText.Encode("position"); + private static readonly System.Text.Json.JsonEncodedText PropPositionlength = System.Text.Json.JsonEncodedText.Encode("positionLength"); + private static readonly System.Text.Json.JsonEncodedText PropStartOffset = System.Text.Json.JsonEncodedText.Encode("start_offset"); + private static readonly System.Text.Json.JsonEncodedText PropTermfrequency = System.Text.Json.JsonEncodedText.Encode("termFrequency"); + private static readonly System.Text.Json.JsonEncodedText PropToken = System.Text.Json.JsonEncodedText.Encode("token"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ExplainAnalyzeToken Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - string bytes = default; - long endOffset = default; - bool? keyword = default; - long position = default; - long positionlength = default; - long startOffset = default; - long termfrequency = default; - string token = default; - string type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propAttributes = default; + LocalJsonValue propBytes = default; + LocalJsonValue propEndOffset = default; + LocalJsonValue propKeyword = default; + LocalJsonValue propPosition = default; + LocalJsonValue propPositionlength = default; + LocalJsonValue propStartOffset = default; + LocalJsonValue propTermfrequency = default; + LocalJsonValue propToken = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBytes.TryRead(ref reader, options, PropBytes)) { - var property = reader.GetString(); - if (property == "bytes") - { - bytes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "end_offset") - { - endOffset = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "keyword") - { - keyword = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "position") - { - position = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "positionLength") - { - positionlength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "start_offset") - { - startOffset = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "termFrequency") - { - termfrequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "token") - { - token = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propEndOffset.TryRead(ref reader, options, PropEndOffset)) + { + continue; + } + + if (propKeyword.TryRead(ref reader, options, PropKeyword)) + { + continue; + } + + if (propPosition.TryRead(ref reader, options, PropPosition)) + { + continue; + } + + if (propPositionlength.TryRead(ref reader, options, PropPositionlength)) + { + continue; + } + + if (propStartOffset.TryRead(ref reader, options, PropStartOffset)) + { + continue; + } + + if (propTermfrequency.TryRead(ref reader, options, PropTermfrequency)) + { + continue; + } + + if (propToken.TryRead(ref reader, options, PropToken)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + propAttributes ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propAttributes[key] = value; } - return new ExplainAnalyzeToken { Attributes = additionalProperties, Bytes = bytes, EndOffset = endOffset, Keyword = keyword, Position = position, Positionlength = positionlength, StartOffset = startOffset, Termfrequency = termfrequency, Token = token, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ExplainAnalyzeToken + { + Attributes = propAttributes +, + Bytes = propBytes.Value +, + EndOffset = propEndOffset.Value +, + Keyword = propKeyword.Value +, + Position = propPosition.Value +, + Positionlength = propPositionlength.Value +, + StartOffset = propStartOffset.Value +, + Termfrequency = propTermfrequency.Value +, + Token = propToken.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, ExplainAnalyzeToken value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ExplainAnalyzeToken value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ExplainAnalyzeToken' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBytes, value.Bytes); + writer.WriteProperty(options, PropEndOffset, value.EndOffset); + writer.WriteProperty(options, PropKeyword, value.Keyword); + writer.WriteProperty(options, PropPosition, value.Position); + writer.WriteProperty(options, PropPositionlength, value.Positionlength); + writer.WriteProperty(options, PropStartOffset, value.StartOffset); + writer.WriteProperty(options, PropTermfrequency, value.Termfrequency); + writer.WriteProperty(options, PropToken, value.Token); + writer.WriteProperty(options, PropType, value.Type); + if (value.Attributes is not null) + { + foreach (var item in value.Attributes) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs index e8b87c850cc..c11dd9634d3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexModifyDataStreamAction.g.cs @@ -39,12 +39,16 @@ internal IndexModifyDataStreamAction(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IndexModifyDataStreamAction() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IndexModifyDataStreamAction AddBackingIndex(Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("add_backing_index", indexAndDataStreamAction); public static IndexModifyDataStreamAction RemoveBackingIndex(Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction indexAndDataStreamAction) => new IndexModifyDataStreamAction("remove_backing_index", indexAndDataStreamAction); @@ -62,67 +66,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IndexModifyDataStreamActionConverter : JsonConverter +internal sealed partial class IndexModifyDataStreamActionConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexModifyDataStreamAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantAddBackingIndex = System.Text.Json.JsonEncodedText.Encode("add_backing_index"); + private static readonly System.Text.Json.JsonEncodedText VariantRemoveBackingIndex = System.Text.Json.JsonEncodedText.Encode("remove_backing_index"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override IndexModifyDataStreamAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAddBackingIndex)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add_backing_index") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAddBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove_backing_index") + if (reader.ValueTextEquals(VariantRemoveBackingIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveBackingIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IndexModifyDataStreamAction' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IndexModifyDataStreamAction(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexModifyDataStreamAction { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IndexModifyDataStreamAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexModifyDataStreamAction value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "add_backing_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - case "remove_backing_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction)value.Variant, options); - break; - } + case "": + break; + case "add_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction?)value.Variant); + break; + case "remove_backing_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.IndexAndDataStreamAction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IndexModifyDataStreamAction)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs index 41e475ffda0..cd832d0035a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSegmentSort.g.cs @@ -27,19 +27,75 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class IndexSegmentSortConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMissing = System.Text.Json.JsonEncodedText.Encode("missing"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropOrder = System.Text.Json.JsonEncodedText.Encode("order"); + + public override IndexSegmentSort Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue?> propMissing = default; + LocalJsonValue?> propMode = default; + LocalJsonValue?> propOrder = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propMissing.TryRead(ref reader, options, PropMissing, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMissing>))) + { + continue; + } + + if (propMode.TryRead(ref reader, options, PropMode, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMode>))) + { + continue; + } + + if (propOrder.TryRead(ref reader, options, PropOrder, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortOrder>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexSegmentSort + { + Field = propField.Value +, + Missing = propMissing.Value +, + Mode = propMode.Value +, + Order = propOrder.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexSegmentSort value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropMissing, value.Missing, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMissing>)); + writer.WriteProperty(options, PropMode, value.Mode, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMode>)); + writer.WriteProperty(options, PropOrder, value.Order, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortOrder>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexSegmentSortConverter))] public sealed partial class IndexSegmentSort { - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Field { get; set; } - [JsonInclude, JsonPropertyName("missing")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMissing))] public ICollection? Missing { get; set; } - [JsonInclude, JsonPropertyName("mode")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortMode))] public ICollection? Mode { get; set; } - [JsonInclude, JsonPropertyName("order")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.SegmentSortOrder))] public ICollection? Order { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs index 85cb6c2f4ac..0523310d2ef 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexSettings.g.cs @@ -27,711 +27,597 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; -internal sealed partial class IndexSettingsConverter : JsonConverter +internal sealed partial class IndexSettingsConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexSettings Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new IndexSettings(); - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + private static readonly System.Text.Json.JsonEncodedText PropOtherSettings = System.Text.Json.JsonEncodedText.Encode("other_settings"); + private static readonly System.Text.Json.JsonEncodedText PropAnalysis = System.Text.Json.JsonEncodedText.Encode("analysis"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyze = System.Text.Json.JsonEncodedText.Encode("analyze"); + private static readonly System.Text.Json.JsonEncodedText PropAutoExpandReplicas = System.Text.Json.JsonEncodedText.Encode("auto_expand_replicas"); + private static readonly System.Text.Json.JsonEncodedText PropBlocks = System.Text.Json.JsonEncodedText.Encode("blocks"); + private static readonly System.Text.Json.JsonEncodedText PropCheckOnStartup = System.Text.Json.JsonEncodedText.Encode("check_on_startup"); + private static readonly System.Text.Json.JsonEncodedText PropCodec = System.Text.Json.JsonEncodedText.Encode("codec"); + private static readonly System.Text.Json.JsonEncodedText PropCreationDate = System.Text.Json.JsonEncodedText.Encode("creation_date"); + private static readonly System.Text.Json.JsonEncodedText PropCreationDateString = System.Text.Json.JsonEncodedText.Encode("creation_date_string"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultPipeline = System.Text.Json.JsonEncodedText.Encode("default_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropFinalPipeline = System.Text.Json.JsonEncodedText.Encode("final_pipeline"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGcDeletes = System.Text.Json.JsonEncodedText.Encode("gc_deletes"); + private static readonly System.Text.Json.JsonEncodedText PropHidden = System.Text.Json.JsonEncodedText.Encode("hidden"); + private static readonly System.Text.Json.JsonEncodedText PropHighlight = System.Text.Json.JsonEncodedText.Encode("highlight"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingPressure = System.Text.Json.JsonEncodedText.Encode("indexing_pressure"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingSlowlog = System.Text.Json.JsonEncodedText.Encode("indexing.slowlog"); + private static readonly System.Text.Json.JsonEncodedText PropLifecycle = System.Text.Json.JsonEncodedText.Encode("lifecycle"); + private static readonly System.Text.Json.JsonEncodedText PropLoadFixedBitsetFiltersEagerly = System.Text.Json.JsonEncodedText.Encode("load_fixed_bitset_filters_eagerly"); + private static readonly System.Text.Json.JsonEncodedText PropMapping = System.Text.Json.JsonEncodedText.Encode("mapping"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDocvalueFieldsSearch = System.Text.Json.JsonEncodedText.Encode("max_docvalue_fields_search"); + private static readonly System.Text.Json.JsonEncodedText PropMaxInnerResultWindow = System.Text.Json.JsonEncodedText.Encode("max_inner_result_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxNgramDiff = System.Text.Json.JsonEncodedText.Encode("max_ngram_diff"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRefreshListeners = System.Text.Json.JsonEncodedText.Encode("max_refresh_listeners"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRegexLength = System.Text.Json.JsonEncodedText.Encode("max_regex_length"); + private static readonly System.Text.Json.JsonEncodedText PropMaxRescoreWindow = System.Text.Json.JsonEncodedText.Encode("max_rescore_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxResultWindow = System.Text.Json.JsonEncodedText.Encode("max_result_window"); + private static readonly System.Text.Json.JsonEncodedText PropMaxScriptFields = System.Text.Json.JsonEncodedText.Encode("max_script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropMaxShingleDiff = System.Text.Json.JsonEncodedText.Encode("max_shingle_diff"); + private static readonly System.Text.Json.JsonEncodedText PropMaxSlicesPerScroll = System.Text.Json.JsonEncodedText.Encode("max_slices_per_scroll"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTermsCount = System.Text.Json.JsonEncodedText.Encode("max_terms_count"); + private static readonly System.Text.Json.JsonEncodedText PropMerge = System.Text.Json.JsonEncodedText.Encode("merge"); + private static readonly System.Text.Json.JsonEncodedText PropMode = System.Text.Json.JsonEncodedText.Encode("mode"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfReplicas = System.Text.Json.JsonEncodedText.Encode("number_of_replicas"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfRoutingShards = System.Text.Json.JsonEncodedText.Encode("number_of_routing_shards"); + private static readonly System.Text.Json.JsonEncodedText PropNumberOfShards = System.Text.Json.JsonEncodedText.Encode("number_of_shards"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropProvidedName = System.Text.Json.JsonEncodedText.Encode("provided_name"); + private static readonly System.Text.Json.JsonEncodedText PropQueries = System.Text.Json.JsonEncodedText.Encode("queries"); + private static readonly System.Text.Json.JsonEncodedText PropQueryString = System.Text.Json.JsonEncodedText.Encode("query_string"); + private static readonly System.Text.Json.JsonEncodedText PropRefreshInterval = System.Text.Json.JsonEncodedText.Encode("refresh_interval"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropRoutingPartitionSize = System.Text.Json.JsonEncodedText.Encode("routing_partition_size"); + private static readonly System.Text.Json.JsonEncodedText PropRoutingPath = System.Text.Json.JsonEncodedText.Encode("routing_path"); + private static readonly System.Text.Json.JsonEncodedText PropSearch = System.Text.Json.JsonEncodedText.Encode("search"); + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropSoftDeletes = System.Text.Json.JsonEncodedText.Encode("soft_deletes"); + private static readonly System.Text.Json.JsonEncodedText PropSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeries = System.Text.Json.JsonEncodedText.Encode("time_series"); + private static readonly System.Text.Json.JsonEncodedText PropTopMetricsMaxSize = System.Text.Json.JsonEncodedText.Encode("top_metrics_max_size"); + private static readonly System.Text.Json.JsonEncodedText PropTranslog = System.Text.Json.JsonEncodedText.Encode("translog"); + private static readonly System.Text.Json.JsonEncodedText PropUuid = System.Text.Json.JsonEncodedText.Encode("uuid"); + private static readonly System.Text.Json.JsonEncodedText PropVerifiedBeforeClose = System.Text.Json.JsonEncodedText.Encode("verified_before_close"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override IndexSettings Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propOtherSettings = default; + LocalJsonValue propAnalysis = default; + LocalJsonValue propAnalyze = default; + LocalJsonValue propAutoExpandReplicas = default; + LocalJsonValue propBlocks = default; + LocalJsonValue propCheckOnStartup = default; + LocalJsonValue propCodec = default; + LocalJsonValue propCreationDate = default; + LocalJsonValue propCreationDateString = default; + LocalJsonValue propDefaultPipeline = default; + LocalJsonValue propFinalPipeline = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGcDeletes = default; + LocalJsonValue propHidden = default; + LocalJsonValue propHighlight = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexingPressure = default; + LocalJsonValue propIndexingSlowlog = default; + LocalJsonValue propLifecycle = default; + LocalJsonValue propLoadFixedBitsetFiltersEagerly = default; + LocalJsonValue propMapping = default; + LocalJsonValue propMaxDocvalueFieldsSearch = default; + LocalJsonValue propMaxInnerResultWindow = default; + LocalJsonValue propMaxNgramDiff = default; + LocalJsonValue propMaxRefreshListeners = default; + LocalJsonValue propMaxRegexLength = default; + LocalJsonValue propMaxRescoreWindow = default; + LocalJsonValue propMaxResultWindow = default; + LocalJsonValue propMaxScriptFields = default; + LocalJsonValue propMaxShingleDiff = default; + LocalJsonValue propMaxSlicesPerScroll = default; + LocalJsonValue propMaxTermsCount = default; + LocalJsonValue propMerge = default; + LocalJsonValue propMode = default; + LocalJsonValue propNumberOfReplicas = default; + LocalJsonValue propNumberOfRoutingShards = default; + LocalJsonValue propNumberOfShards = default; + LocalJsonValue propPriority = default; + LocalJsonValue propProvidedName = default; + LocalJsonValue propQueries = default; + LocalJsonValue propQueryString = default; + LocalJsonValue propRefreshInterval = default; + LocalJsonValue propRouting = default; + LocalJsonValue propRoutingPartitionSize = default; + LocalJsonValue?> propRoutingPath = default; + LocalJsonValue propSearch = default; + LocalJsonValue propSettings = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propSoftDeletes = default; + LocalJsonValue propSort = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeries = default; + LocalJsonValue propTopMetricsMaxSize = default; + LocalJsonValue propTranslog = default; + LocalJsonValue propUuid = default; + LocalJsonValue propVerifiedBeforeClose = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalysis.TryRead(ref reader, options, PropAnalysis)) { - var property = reader.GetString(); - if (property == "analysis") - { - variant.Analysis = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "analyze") - { - variant.Analyze = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "auto_expand_replicas") - { - variant.AutoExpandReplicas = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "blocks") - { - variant.Blocks = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "check_on_startup") - { - variant.CheckOnStartup = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "codec") - { - variant.Codec = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "creation_date") - { - variant.CreationDate = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "creation_date_string") - { - variant.CreationDateString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "default_pipeline") - { - variant.DefaultPipeline = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "final_pipeline") - { - variant.FinalPipeline = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gc_deletes") - { - variant.GcDeletes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "hidden") - { - variant.Hidden = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "highlight") - { - variant.Highlight = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "index") - { - variant.Index = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexing_pressure") - { - variant.IndexingPressure = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexing.slowlog") - { - variant.IndexingSlowlog = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lifecycle") - { - variant.Lifecycle = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "load_fixed_bitset_filters_eagerly") - { - variant.LoadFixedBitsetFiltersEagerly = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mapping") - { - variant.Mapping = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_docvalue_fields_search") - { - variant.MaxDocvalueFieldsSearch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_inner_result_window") - { - variant.MaxInnerResultWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_ngram_diff") - { - variant.MaxNgramDiff = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_refresh_listeners") - { - variant.MaxRefreshListeners = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_regex_length") - { - variant.MaxRegexLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_rescore_window") - { - variant.MaxRescoreWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_result_window") - { - variant.MaxResultWindow = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_script_fields") - { - variant.MaxScriptFields = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_shingle_diff") - { - variant.MaxShingleDiff = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_slices_per_scroll") - { - variant.MaxSlicesPerScroll = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_terms_count") - { - variant.MaxTermsCount = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "merge") - { - variant.Merge = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "mode") - { - variant.Mode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_replicas") - { - variant.NumberOfReplicas = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_routing_shards") - { - variant.NumberOfRoutingShards = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "number_of_shards") - { - variant.NumberOfShards = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "priority") - { - variant.Priority = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "provided_name") - { - variant.ProvidedName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "queries") - { - variant.Queries = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_string") - { - variant.QueryString = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "refresh_interval") - { - variant.RefreshInterval = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing") - { - variant.Routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing_partition_size") - { - variant.RoutingPartitionSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "routing_path") - { - variant.RoutingPath = SingleOrManySerializationHelper.Deserialize(ref reader, options); - continue; - } - - if (property == "search") - { - variant.Search = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "settings") - { - variant.Settings = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "similarity") - { - variant.Similarity = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_deletes") - { - variant.SoftDeletes = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "sort") - { - variant.Sort = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "store") - { - variant.Store = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_series") - { - variant.TimeSeries = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "top_metrics_max_size") - { - variant.TopMetricsMaxSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "translog") - { - variant.Translog = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "uuid") - { - variant.Uuid = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "verified_before_close") - { - variant.VerifiedBeforeClose = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - variant.Version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } - } - - variant.OtherSettings = additionalProperties; - return variant; - } - public override void Write(Utf8JsonWriter writer, IndexSettings value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.OtherSettings is not null) - { - foreach (var additionalProperty in value.OtherSettings) + if (propAnalyze.TryRead(ref reader, options, PropAnalyze)) { - writer.WritePropertyName(additionalProperty.Key); - JsonSerializer.Serialize(writer, additionalProperty.Value, options); + continue; } - } - if (value.Analysis is not null) - { - writer.WritePropertyName("analysis"); - JsonSerializer.Serialize(writer, value.Analysis, options); - } - - if (value.Analyze is not null) - { - writer.WritePropertyName("analyze"); - JsonSerializer.Serialize(writer, value.Analyze, options); - } + if (propAutoExpandReplicas.TryRead(ref reader, options, PropAutoExpandReplicas)) + { + continue; + } - if (!string.IsNullOrEmpty(value.AutoExpandReplicas)) - { - writer.WritePropertyName("auto_expand_replicas"); - writer.WriteStringValue(value.AutoExpandReplicas); - } + if (propBlocks.TryRead(ref reader, options, PropBlocks)) + { + continue; + } - if (value.Blocks is not null) - { - writer.WritePropertyName("blocks"); - JsonSerializer.Serialize(writer, value.Blocks, options); - } + if (propCheckOnStartup.TryRead(ref reader, options, PropCheckOnStartup)) + { + continue; + } - if (value.CheckOnStartup is not null) - { - writer.WritePropertyName("check_on_startup"); - JsonSerializer.Serialize(writer, value.CheckOnStartup, options); - } + if (propCodec.TryRead(ref reader, options, PropCodec)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Codec)) - { - writer.WritePropertyName("codec"); - writer.WriteStringValue(value.Codec); - } + if (propCreationDate.TryRead(ref reader, options, PropCreationDate)) + { + continue; + } - if (value.CreationDate.HasValue) - { - writer.WritePropertyName("creation_date"); - writer.WriteNumberValue(value.CreationDate.Value); - } + if (propCreationDateString.TryRead(ref reader, options, PropCreationDateString)) + { + continue; + } - if (value.CreationDateString is not null) - { - writer.WritePropertyName("creation_date_string"); - JsonSerializer.Serialize(writer, value.CreationDateString, options); - } + if (propDefaultPipeline.TryRead(ref reader, options, PropDefaultPipeline)) + { + continue; + } - if (!string.IsNullOrEmpty(value.DefaultPipeline)) - { - writer.WritePropertyName("default_pipeline"); - writer.WriteStringValue(value.DefaultPipeline); - } + if (propFinalPipeline.TryRead(ref reader, options, PropFinalPipeline)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FinalPipeline)) - { - writer.WritePropertyName("final_pipeline"); - writer.WriteStringValue(value.FinalPipeline); - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - if (value.Format is not null) - { - writer.WritePropertyName("format"); - JsonSerializer.Serialize(writer, value.Format, options); - } + if (propGcDeletes.TryRead(ref reader, options, PropGcDeletes)) + { + continue; + } - if (value.GcDeletes is not null) - { - writer.WritePropertyName("gc_deletes"); - JsonSerializer.Serialize(writer, value.GcDeletes, options); - } + if (propHidden.TryRead(ref reader, options, PropHidden)) + { + continue; + } - if (value.Hidden is not null) - { - writer.WritePropertyName("hidden"); - JsonSerializer.Serialize(writer, value.Hidden, options); - } + if (propHighlight.TryRead(ref reader, options, PropHighlight)) + { + continue; + } - if (value.Highlight is not null) - { - writer.WritePropertyName("highlight"); - JsonSerializer.Serialize(writer, value.Highlight, options); - } + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } - if (value.Index is not null) - { - writer.WritePropertyName("index"); - JsonSerializer.Serialize(writer, value.Index, options); - } + if (propIndexingPressure.TryRead(ref reader, options, PropIndexingPressure)) + { + continue; + } - if (value.IndexingPressure is not null) - { - writer.WritePropertyName("indexing_pressure"); - JsonSerializer.Serialize(writer, value.IndexingPressure, options); - } + if (propIndexingSlowlog.TryRead(ref reader, options, PropIndexingSlowlog)) + { + continue; + } - if (value.IndexingSlowlog is not null) - { - writer.WritePropertyName("indexing.slowlog"); - JsonSerializer.Serialize(writer, value.IndexingSlowlog, options); - } + if (propLifecycle.TryRead(ref reader, options, PropLifecycle)) + { + continue; + } - if (value.Lifecycle is not null) - { - writer.WritePropertyName("lifecycle"); - JsonSerializer.Serialize(writer, value.Lifecycle, options); - } + if (propLoadFixedBitsetFiltersEagerly.TryRead(ref reader, options, PropLoadFixedBitsetFiltersEagerly)) + { + continue; + } - if (value.LoadFixedBitsetFiltersEagerly.HasValue) - { - writer.WritePropertyName("load_fixed_bitset_filters_eagerly"); - writer.WriteBooleanValue(value.LoadFixedBitsetFiltersEagerly.Value); - } + if (propMapping.TryRead(ref reader, options, PropMapping)) + { + continue; + } - if (value.Mapping is not null) - { - writer.WritePropertyName("mapping"); - JsonSerializer.Serialize(writer, value.Mapping, options); - } + if (propMaxDocvalueFieldsSearch.TryRead(ref reader, options, PropMaxDocvalueFieldsSearch)) + { + continue; + } - if (value.MaxDocvalueFieldsSearch.HasValue) - { - writer.WritePropertyName("max_docvalue_fields_search"); - writer.WriteNumberValue(value.MaxDocvalueFieldsSearch.Value); - } + if (propMaxInnerResultWindow.TryRead(ref reader, options, PropMaxInnerResultWindow)) + { + continue; + } - if (value.MaxInnerResultWindow.HasValue) - { - writer.WritePropertyName("max_inner_result_window"); - writer.WriteNumberValue(value.MaxInnerResultWindow.Value); - } + if (propMaxNgramDiff.TryRead(ref reader, options, PropMaxNgramDiff)) + { + continue; + } - if (value.MaxNgramDiff.HasValue) - { - writer.WritePropertyName("max_ngram_diff"); - writer.WriteNumberValue(value.MaxNgramDiff.Value); - } + if (propMaxRefreshListeners.TryRead(ref reader, options, PropMaxRefreshListeners)) + { + continue; + } - if (value.MaxRefreshListeners.HasValue) - { - writer.WritePropertyName("max_refresh_listeners"); - writer.WriteNumberValue(value.MaxRefreshListeners.Value); - } + if (propMaxRegexLength.TryRead(ref reader, options, PropMaxRegexLength)) + { + continue; + } - if (value.MaxRegexLength.HasValue) - { - writer.WritePropertyName("max_regex_length"); - writer.WriteNumberValue(value.MaxRegexLength.Value); - } + if (propMaxRescoreWindow.TryRead(ref reader, options, PropMaxRescoreWindow)) + { + continue; + } - if (value.MaxRescoreWindow.HasValue) - { - writer.WritePropertyName("max_rescore_window"); - writer.WriteNumberValue(value.MaxRescoreWindow.Value); - } + if (propMaxResultWindow.TryRead(ref reader, options, PropMaxResultWindow)) + { + continue; + } - if (value.MaxResultWindow.HasValue) - { - writer.WritePropertyName("max_result_window"); - writer.WriteNumberValue(value.MaxResultWindow.Value); - } + if (propMaxScriptFields.TryRead(ref reader, options, PropMaxScriptFields)) + { + continue; + } - if (value.MaxScriptFields.HasValue) - { - writer.WritePropertyName("max_script_fields"); - writer.WriteNumberValue(value.MaxScriptFields.Value); - } + if (propMaxShingleDiff.TryRead(ref reader, options, PropMaxShingleDiff)) + { + continue; + } - if (value.MaxShingleDiff.HasValue) - { - writer.WritePropertyName("max_shingle_diff"); - writer.WriteNumberValue(value.MaxShingleDiff.Value); - } + if (propMaxSlicesPerScroll.TryRead(ref reader, options, PropMaxSlicesPerScroll)) + { + continue; + } - if (value.MaxSlicesPerScroll.HasValue) - { - writer.WritePropertyName("max_slices_per_scroll"); - writer.WriteNumberValue(value.MaxSlicesPerScroll.Value); - } + if (propMaxTermsCount.TryRead(ref reader, options, PropMaxTermsCount)) + { + continue; + } - if (value.MaxTermsCount.HasValue) - { - writer.WritePropertyName("max_terms_count"); - writer.WriteNumberValue(value.MaxTermsCount.Value); - } + if (propMerge.TryRead(ref reader, options, PropMerge)) + { + continue; + } - if (value.Merge is not null) - { - writer.WritePropertyName("merge"); - JsonSerializer.Serialize(writer, value.Merge, options); - } + if (propMode.TryRead(ref reader, options, PropMode)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Mode)) - { - writer.WritePropertyName("mode"); - writer.WriteStringValue(value.Mode); - } + if (propNumberOfReplicas.TryRead(ref reader, options, PropNumberOfReplicas)) + { + continue; + } - if (value.NumberOfReplicas is not null) - { - writer.WritePropertyName("number_of_replicas"); - JsonSerializer.Serialize(writer, value.NumberOfReplicas, options); - } + if (propNumberOfRoutingShards.TryRead(ref reader, options, PropNumberOfRoutingShards)) + { + continue; + } - if (value.NumberOfRoutingShards.HasValue) - { - writer.WritePropertyName("number_of_routing_shards"); - writer.WriteNumberValue(value.NumberOfRoutingShards.Value); - } + if (propNumberOfShards.TryRead(ref reader, options, PropNumberOfShards)) + { + continue; + } - if (value.NumberOfShards is not null) - { - writer.WritePropertyName("number_of_shards"); - JsonSerializer.Serialize(writer, value.NumberOfShards, options); - } + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } - if (value.Priority is not null) - { - writer.WritePropertyName("priority"); - JsonSerializer.Serialize(writer, value.Priority, options); - } + if (propProvidedName.TryRead(ref reader, options, PropProvidedName)) + { + continue; + } - if (value.ProvidedName is not null) - { - writer.WritePropertyName("provided_name"); - JsonSerializer.Serialize(writer, value.ProvidedName, options); - } + if (propQueries.TryRead(ref reader, options, PropQueries)) + { + continue; + } - if (value.Queries is not null) - { - writer.WritePropertyName("queries"); - JsonSerializer.Serialize(writer, value.Queries, options); - } + if (propQueryString.TryRead(ref reader, options, PropQueryString)) + { + continue; + } - if (value.QueryString is not null) - { - writer.WritePropertyName("query_string"); - JsonSerializer.Serialize(writer, value.QueryString, options); - } + if (propRefreshInterval.TryRead(ref reader, options, PropRefreshInterval)) + { + continue; + } - if (value.RefreshInterval is not null) - { - writer.WritePropertyName("refresh_interval"); - JsonSerializer.Serialize(writer, value.RefreshInterval, options); - } + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } - if (value.Routing is not null) - { - writer.WritePropertyName("routing"); - JsonSerializer.Serialize(writer, value.Routing, options); - } + if (propRoutingPartitionSize.TryRead(ref reader, options, PropRoutingPartitionSize)) + { + continue; + } - if (value.RoutingPartitionSize.HasValue) - { - writer.WritePropertyName("routing_partition_size"); - writer.WriteNumberValue(value.RoutingPartitionSize.Value); - } + if (propRoutingPath.TryRead(ref reader, options, PropRoutingPath, typeof(SingleOrManyMarker?, string>))) + { + continue; + } - if (value.RoutingPath is not null) - { - writer.WritePropertyName("routing_path"); - JsonSerializer.Serialize(writer, value.RoutingPath, options); - } + if (propSearch.TryRead(ref reader, options, PropSearch)) + { + continue; + } - if (value.Search is not null) - { - writer.WritePropertyName("search"); - JsonSerializer.Serialize(writer, value.Search, options); - } + if (propSettings.TryRead(ref reader, options, PropSettings)) + { + continue; + } - if (value.Settings is not null) - { - writer.WritePropertyName("settings"); - JsonSerializer.Serialize(writer, value.Settings, options); - } + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } - if (value.Similarity is not null) - { - writer.WritePropertyName("similarity"); - JsonSerializer.Serialize(writer, value.Similarity, options); - } + if (propSoftDeletes.TryRead(ref reader, options, PropSoftDeletes)) + { + continue; + } - if (value.SoftDeletes is not null) - { - writer.WritePropertyName("soft_deletes"); - JsonSerializer.Serialize(writer, value.SoftDeletes, options); - } + if (propSort.TryRead(ref reader, options, PropSort)) + { + continue; + } - if (value.Sort is not null) - { - writer.WritePropertyName("sort"); - JsonSerializer.Serialize(writer, value.Sort, options); - } + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } - if (value.Store is not null) - { - writer.WritePropertyName("store"); - JsonSerializer.Serialize(writer, value.Store, options); - } + if (propTimeSeries.TryRead(ref reader, options, PropTimeSeries)) + { + continue; + } - if (value.TimeSeries is not null) - { - writer.WritePropertyName("time_series"); - JsonSerializer.Serialize(writer, value.TimeSeries, options); - } + if (propTopMetricsMaxSize.TryRead(ref reader, options, PropTopMetricsMaxSize)) + { + continue; + } - if (value.TopMetricsMaxSize.HasValue) - { - writer.WritePropertyName("top_metrics_max_size"); - writer.WriteNumberValue(value.TopMetricsMaxSize.Value); - } + if (propTranslog.TryRead(ref reader, options, PropTranslog)) + { + continue; + } - if (value.Translog is not null) - { - writer.WritePropertyName("translog"); - JsonSerializer.Serialize(writer, value.Translog, options); - } + if (propUuid.TryRead(ref reader, options, PropUuid)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Uuid)) - { - writer.WritePropertyName("uuid"); - writer.WriteStringValue(value.Uuid); - } + if (propVerifiedBeforeClose.TryRead(ref reader, options, PropVerifiedBeforeClose)) + { + continue; + } - if (value.VerifiedBeforeClose is not null) - { - writer.WritePropertyName("verified_before_close"); - JsonSerializer.Serialize(writer, value.VerifiedBeforeClose, options); - } + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } - if (value.Version is not null) + propOtherSettings ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propOtherSettings[key] = value; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexSettings + { + OtherSettings = propOtherSettings +, + Analysis = propAnalysis.Value +, + Analyze = propAnalyze.Value +, + AutoExpandReplicas = propAutoExpandReplicas.Value +, + Blocks = propBlocks.Value +, + CheckOnStartup = propCheckOnStartup.Value +, + Codec = propCodec.Value +, + CreationDate = propCreationDate.Value +, + CreationDateString = propCreationDateString.Value +, + DefaultPipeline = propDefaultPipeline.Value +, + FinalPipeline = propFinalPipeline.Value +, + Format = propFormat.Value +, + GcDeletes = propGcDeletes.Value +, + Hidden = propHidden.Value +, + Highlight = propHighlight.Value +, + Index = propIndex.Value +, + IndexingPressure = propIndexingPressure.Value +, + IndexingSlowlog = propIndexingSlowlog.Value +, + Lifecycle = propLifecycle.Value +, + LoadFixedBitsetFiltersEagerly = propLoadFixedBitsetFiltersEagerly.Value +, + Mapping = propMapping.Value +, + MaxDocvalueFieldsSearch = propMaxDocvalueFieldsSearch.Value +, + MaxInnerResultWindow = propMaxInnerResultWindow.Value +, + MaxNgramDiff = propMaxNgramDiff.Value +, + MaxRefreshListeners = propMaxRefreshListeners.Value +, + MaxRegexLength = propMaxRegexLength.Value +, + MaxRescoreWindow = propMaxRescoreWindow.Value +, + MaxResultWindow = propMaxResultWindow.Value +, + MaxScriptFields = propMaxScriptFields.Value +, + MaxShingleDiff = propMaxShingleDiff.Value +, + MaxSlicesPerScroll = propMaxSlicesPerScroll.Value +, + MaxTermsCount = propMaxTermsCount.Value +, + Merge = propMerge.Value +, + Mode = propMode.Value +, + NumberOfReplicas = propNumberOfReplicas.Value +, + NumberOfRoutingShards = propNumberOfRoutingShards.Value +, + NumberOfShards = propNumberOfShards.Value +, + Priority = propPriority.Value +, + ProvidedName = propProvidedName.Value +, + Queries = propQueries.Value +, + QueryString = propQueryString.Value +, + RefreshInterval = propRefreshInterval.Value +, + Routing = propRouting.Value +, + RoutingPartitionSize = propRoutingPartitionSize.Value +, + RoutingPath = propRoutingPath.Value +, + Search = propSearch.Value +, + Settings = propSettings.Value +, + Similarity = propSimilarity.Value +, + SoftDeletes = propSoftDeletes.Value +, + Sort = propSort.Value +, + Store = propStore.Value +, + TimeSeries = propTimeSeries.Value +, + TopMetricsMaxSize = propTopMetricsMaxSize.Value +, + Translog = propTranslog.Value +, + Uuid = propUuid.Value +, + VerifiedBeforeClose = propVerifiedBeforeClose.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexSettings value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalysis, value.Analysis); + writer.WriteProperty(options, PropAnalyze, value.Analyze); + writer.WriteProperty(options, PropAutoExpandReplicas, value.AutoExpandReplicas); + writer.WriteProperty(options, PropBlocks, value.Blocks); + writer.WriteProperty(options, PropCheckOnStartup, value.CheckOnStartup); + writer.WriteProperty(options, PropCodec, value.Codec); + writer.WriteProperty(options, PropCreationDate, value.CreationDate); + writer.WriteProperty(options, PropCreationDateString, value.CreationDateString); + writer.WriteProperty(options, PropDefaultPipeline, value.DefaultPipeline); + writer.WriteProperty(options, PropFinalPipeline, value.FinalPipeline); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGcDeletes, value.GcDeletes); + writer.WriteProperty(options, PropHidden, value.Hidden); + writer.WriteProperty(options, PropHighlight, value.Highlight); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure); + writer.WriteProperty(options, PropIndexingSlowlog, value.IndexingSlowlog); + writer.WriteProperty(options, PropLifecycle, value.Lifecycle); + writer.WriteProperty(options, PropLoadFixedBitsetFiltersEagerly, value.LoadFixedBitsetFiltersEagerly); + writer.WriteProperty(options, PropMapping, value.Mapping); + writer.WriteProperty(options, PropMaxDocvalueFieldsSearch, value.MaxDocvalueFieldsSearch); + writer.WriteProperty(options, PropMaxInnerResultWindow, value.MaxInnerResultWindow); + writer.WriteProperty(options, PropMaxNgramDiff, value.MaxNgramDiff); + writer.WriteProperty(options, PropMaxRefreshListeners, value.MaxRefreshListeners); + writer.WriteProperty(options, PropMaxRegexLength, value.MaxRegexLength); + writer.WriteProperty(options, PropMaxRescoreWindow, value.MaxRescoreWindow); + writer.WriteProperty(options, PropMaxResultWindow, value.MaxResultWindow); + writer.WriteProperty(options, PropMaxScriptFields, value.MaxScriptFields); + writer.WriteProperty(options, PropMaxShingleDiff, value.MaxShingleDiff); + writer.WriteProperty(options, PropMaxSlicesPerScroll, value.MaxSlicesPerScroll); + writer.WriteProperty(options, PropMaxTermsCount, value.MaxTermsCount); + writer.WriteProperty(options, PropMerge, value.Merge); + writer.WriteProperty(options, PropMode, value.Mode); + writer.WriteProperty(options, PropNumberOfReplicas, value.NumberOfReplicas); + writer.WriteProperty(options, PropNumberOfRoutingShards, value.NumberOfRoutingShards); + writer.WriteProperty(options, PropNumberOfShards, value.NumberOfShards); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropProvidedName, value.ProvidedName); + writer.WriteProperty(options, PropQueries, value.Queries); + writer.WriteProperty(options, PropQueryString, value.QueryString); + writer.WriteProperty(options, PropRefreshInterval, value.RefreshInterval); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropRoutingPartitionSize, value.RoutingPartitionSize); + writer.WriteProperty(options, PropRoutingPath, value.RoutingPath, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropSearch, value.Search); + writer.WriteProperty(options, PropSettings, value.Settings); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropSoftDeletes, value.SoftDeletes); + writer.WriteProperty(options, PropSort, value.Sort); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeries, value.TimeSeries); + writer.WriteProperty(options, PropTopMetricsMaxSize, value.TopMetricsMaxSize); + writer.WriteProperty(options, PropTranslog, value.Translog); + writer.WriteProperty(options, PropUuid, value.Uuid); + writer.WriteProperty(options, PropVerifiedBeforeClose, value.VerifiedBeforeClose); + writer.WriteProperty(options, PropVersion, value.Version); + if (value.OtherSettings is not null) { - writer.WritePropertyName("version"); - JsonSerializer.Serialize(writer, value.Version, options); + foreach (var item in value.OtherSettings) + { + writer.WriteProperty(options, item.Key, item.Value); + } } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs index f66dc302ac4..8fbda406b8a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplate.g.cs @@ -27,9 +27,132 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class IndexTemplateConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowAutoCreate = System.Text.Json.JsonEncodedText.Encode("allow_auto_create"); + private static readonly System.Text.Json.JsonEncodedText PropComposedOf = System.Text.Json.JsonEncodedText.Encode("composed_of"); + private static readonly System.Text.Json.JsonEncodedText PropDataStream = System.Text.Json.JsonEncodedText.Encode("data_stream"); + private static readonly System.Text.Json.JsonEncodedText PropDeprecated = System.Text.Json.JsonEncodedText.Encode("deprecated"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissingComponentTemplates = System.Text.Json.JsonEncodedText.Encode("ignore_missing_component_templates"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPatterns = System.Text.Json.JsonEncodedText.Encode("index_patterns"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("_meta"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropTemplate = System.Text.Json.JsonEncodedText.Encode("template"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + + public override IndexTemplate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowAutoCreate = default; + LocalJsonValue> propComposedOf = default; + LocalJsonValue propDataStream = default; + LocalJsonValue propDeprecated = default; + LocalJsonValue?> propIgnoreMissingComponentTemplates = default; + LocalJsonValue> propIndexPatterns = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPriority = default; + LocalJsonValue propTemplate = default; + LocalJsonValue propVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowAutoCreate.TryRead(ref reader, options, PropAllowAutoCreate)) + { + continue; + } + + if (propComposedOf.TryRead(ref reader, options, PropComposedOf)) + { + continue; + } + + if (propDataStream.TryRead(ref reader, options, PropDataStream)) + { + continue; + } + + if (propDeprecated.TryRead(ref reader, options, PropDeprecated)) + { + continue; + } + + if (propIgnoreMissingComponentTemplates.TryRead(ref reader, options, PropIgnoreMissingComponentTemplates, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propIndexPatterns.TryRead(ref reader, options, PropIndexPatterns, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propTemplate.TryRead(ref reader, options, PropTemplate)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexTemplate + { + AllowAutoCreate = propAllowAutoCreate.Value +, + ComposedOf = propComposedOf.Value +, + DataStream = propDataStream.Value +, + Deprecated = propDeprecated.Value +, + IgnoreMissingComponentTemplates = propIgnoreMissingComponentTemplates.Value +, + IndexPatterns = propIndexPatterns.Value +, + Meta = propMeta.Value +, + Priority = propPriority.Value +, + Template = propTemplate.Value +, + Version = propVersion.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexTemplate value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowAutoCreate, value.AllowAutoCreate); + writer.WriteProperty(options, PropComposedOf, value.ComposedOf); + writer.WriteProperty(options, PropDataStream, value.DataStream); + writer.WriteProperty(options, PropDeprecated, value.Deprecated); + writer.WriteProperty(options, PropIgnoreMissingComponentTemplates, value.IgnoreMissingComponentTemplates, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropIndexPatterns, value.IndexPatterns, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropTemplate, value.Template); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IndexTemplateConverter))] public sealed partial class IndexTemplate { - [JsonInclude, JsonPropertyName("allow_auto_create")] public bool? AllowAutoCreate { get; init; } /// @@ -38,7 +161,6 @@ public sealed partial class IndexTemplate /// Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence. /// /// - [JsonInclude, JsonPropertyName("composed_of")] public IReadOnlyCollection ComposedOf { get; init; } /// @@ -48,7 +170,6 @@ public sealed partial class IndexTemplate /// Data streams require a matching index template with a data_stream object. /// /// - [JsonInclude, JsonPropertyName("data_stream")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexTemplateDataStreamConfiguration? DataStream { get; init; } /// @@ -58,7 +179,6 @@ public sealed partial class IndexTemplate /// Elasticsearch will emit a deprecation warning. /// /// - [JsonInclude, JsonPropertyName("deprecated")] public bool? Deprecated { get; init; } /// @@ -66,8 +186,6 @@ public sealed partial class IndexTemplate /// A list of component template names that are allowed to be absent. /// /// - [JsonInclude, JsonPropertyName("ignore_missing_component_templates")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? IgnoreMissingComponentTemplates { get; init; } /// @@ -75,8 +193,6 @@ public sealed partial class IndexTemplate /// Name of the index template. /// /// - [JsonInclude, JsonPropertyName("index_patterns")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection IndexPatterns { get; init; } /// @@ -85,7 +201,6 @@ public sealed partial class IndexTemplate /// This map is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("_meta")] public IReadOnlyDictionary? Meta { get; init; } /// @@ -96,7 +211,6 @@ public sealed partial class IndexTemplate /// This number is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("priority")] public long? Priority { get; init; } /// @@ -105,7 +219,6 @@ public sealed partial class IndexTemplate /// It may optionally include an aliases, mappings, or settings configuration. /// /// - [JsonInclude, JsonPropertyName("template")] public Elastic.Clients.Elasticsearch.IndexManagement.IndexTemplateSummary? Template { get; init; } /// @@ -114,6 +227,5 @@ public sealed partial class IndexTemplate /// This number is not automatically generated by Elasticsearch. /// /// - [JsonInclude, JsonPropertyName("version")] public long? Version { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs index be455d697cb..16857c36703 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexTemplateSummary.g.cs @@ -38,7 +38,6 @@ public sealed partial class IndexTemplateSummary /// /// [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary? Aliases { get; init; } [JsonInclude, JsonPropertyName("lifecycle")] public Elastic.Clients.Elasticsearch.IndexManagement.DataStreamLifecycleWithRollover? Lifecycle { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs index df29e80b76f..5721e47dcdf 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/IndexUpdateAliasesAction.g.cs @@ -39,12 +39,16 @@ internal IndexUpdateAliasesAction(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IndexUpdateAliasesAction() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IndexUpdateAliasesAction Add(Elastic.Clients.Elasticsearch.IndexManagement.AddAction addAction) => new IndexUpdateAliasesAction("add", addAction); public static IndexUpdateAliasesAction Remove(Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction removeAction) => new IndexUpdateAliasesAction("remove", removeAction); @@ -63,77 +67,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IndexUpdateAliasesActionConverter : JsonConverter +internal sealed partial class IndexUpdateAliasesActionConverter : System.Text.Json.Serialization.JsonConverter { - public override IndexUpdateAliasesAction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantAdd = System.Text.Json.JsonEncodedText.Encode("add"); + private static readonly System.Text.Json.JsonEncodedText VariantRemove = System.Text.Json.JsonEncodedText.Encode("remove"); + private static readonly System.Text.Json.JsonEncodedText VariantRemoveIndex = System.Text.Json.JsonEncodedText.Encode("remove_index"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override IndexUpdateAliasesAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAdd)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "add") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAdd.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove_index") + if (reader.ValueTextEquals(VariantRemoveIndex)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemoveIndex.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IndexUpdateAliasesAction' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IndexUpdateAliasesAction(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndexUpdateAliasesAction { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IndexUpdateAliasesAction value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndexUpdateAliasesAction value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "add": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.AddAction)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction)value.Variant, options); - break; - case "remove_index": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveIndexAction)value.Variant, options); - break; - } + case "": + break; + case "add": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.AddAction?)value.Variant); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveAction?)value.Variant); + break; + case "remove_index": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.IndexManagement.RemoveIndexAction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IndexUpdateAliasesAction)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs index fc2de9dd136..f5065e2be63 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/RemoveAction.g.cs @@ -27,6 +27,80 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class RemoveActionConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlias = System.Text.Json.JsonEncodedText.Encode("alias"); + private static readonly System.Text.Json.JsonEncodedText PropAliases = System.Text.Json.JsonEncodedText.Encode("aliases"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropMustExist = System.Text.Json.JsonEncodedText.Encode("must_exist"); + + public override RemoveAction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAlias = default; + LocalJsonValue?> propAliases = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndices = default; + LocalJsonValue propMustExist = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlias.TryRead(ref reader, options, PropAlias)) + { + continue; + } + + if (propAliases.TryRead(ref reader, options, PropAliases, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexAlias>))) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propMustExist.TryRead(ref reader, options, PropMustExist)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemoveAction + { + Alias = propAlias.Value +, + Aliases = propAliases.Value +, + Index = propIndex.Value +, + Indices = propIndices.Value +, + MustExist = propMustExist.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoveAction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlias, value.Alias); + writer.WriteProperty(options, PropAliases, value.Aliases, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.IndexAlias>)); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropMustExist, value.MustExist); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveActionConverter))] public sealed partial class RemoveAction { /// @@ -35,7 +109,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("alias")] public Elastic.Clients.Elasticsearch.IndexAlias? Alias { get; set; } /// @@ -44,8 +117,6 @@ public sealed partial class RemoveAction /// Index alias names support date math. /// /// - [JsonInclude, JsonPropertyName("aliases")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.IndexAlias))] public ICollection? Aliases { get; set; } /// @@ -54,7 +125,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -63,7 +133,6 @@ public sealed partial class RemoveAction /// Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.Indices? Indices { get; set; } /// @@ -71,7 +140,6 @@ public sealed partial class RemoveAction /// If true, the alias must exist to perform the action. /// /// - [JsonInclude, JsonPropertyName("must_exist")] public bool? MustExist { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction(RemoveAction removeAction) => Elastic.Clients.Elasticsearch.IndexManagement.IndexUpdateAliasesAction.Remove(removeAction); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs index fee1e4ee883..5ec2f359a6a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexAliasItem.g.cs @@ -27,11 +27,52 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ResolveIndexAliasItemConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + + public override ResolveIndexAliasItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propIndices = default; + LocalJsonValue propName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propIndices.TryRead(ref reader, options, PropIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexAliasItem + { + Indices = propIndices.Value +, + Name = propName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexAliasItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropIndices, value.Indices, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexAliasItemConverter))] public sealed partial class ResolveIndexAliasItem { - [JsonInclude, JsonPropertyName("indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection Indices { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs index bde3f17ffea..f08e92a288c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ResolveIndexDataStreamsItem.g.cs @@ -27,13 +27,63 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; +internal sealed partial class ResolveIndexDataStreamsItemConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBackingIndices = System.Text.Json.JsonEncodedText.Encode("backing_indices"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropTimestampField = System.Text.Json.JsonEncodedText.Encode("timestamp_field"); + + public override ResolveIndexDataStreamsItem Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propBackingIndices = default; + LocalJsonValue propName = default; + LocalJsonValue propTimestampField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBackingIndices.TryRead(ref reader, options, PropBackingIndices, typeof(SingleOrManyMarker, string>))) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propTimestampField.TryRead(ref reader, options, PropTimestampField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ResolveIndexDataStreamsItem + { + BackingIndices = propBackingIndices.Value +, + Name = propName.Value +, + TimestampField = propTimestampField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ResolveIndexDataStreamsItem value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBackingIndices, value.BackingIndices, null, typeof(SingleOrManyMarker, string>)); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropTimestampField, value.TimestampField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ResolveIndexDataStreamsItemConverter))] public sealed partial class ResolveIndexDataStreamsItem { - [JsonInclude, JsonPropertyName("backing_indices")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection BackingIndices { get; init; } - [JsonInclude, JsonPropertyName("name")] public string Name { get; init; } - [JsonInclude, JsonPropertyName("timestamp_field")] public string TimestampField { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs index 49db5a56af3..ccf65e10543 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/SettingsSimilarities.g.cs @@ -92,80 +92,70 @@ public SettingsSimilaritiesDescriptor() : base(new SettingsSimilarities()) public SettingsSimilaritiesDescriptor Scripted(string settingsSimilarityName, SettingsSimilarityScripted settingsSimilarityScripted) => AssignVariant(settingsSimilarityName, settingsSimilarityScripted); } -internal sealed partial class SettingsSimilarityInterfaceConverter : JsonConverter +internal sealed partial class SettingsSimilarityInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override ISettingsSimilarity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ISettingsSimilarity Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "BM25": - return JsonSerializer.Deserialize(ref reader, options); - case "boolean": - return JsonSerializer.Deserialize(ref reader, options); - case "DFI": - return JsonSerializer.Deserialize(ref reader, options); - case "DFR": - return JsonSerializer.Deserialize(ref reader, options); - case "IB": - return JsonSerializer.Deserialize(ref reader, options); - case "LMDirichlet": - return JsonSerializer.Deserialize(ref reader, options); - case "LMJelinekMercer": - return JsonSerializer.Deserialize(ref reader, options); - case "scripted": - return JsonSerializer.Deserialize(ref reader, options); - default: - ThrowHelper.ThrowUnknownTaggedUnionVariantJsonException(type, typeof(ISettingsSimilarity)); - return null; - } + "BM25" => reader.ReadValue(options), + "boolean" => reader.ReadValue(options), + "DFI" => reader.ReadValue(options), + "DFR" => reader.ReadValue(options), + "IB" => reader.ReadValue(options), + "LMDirichlet" => reader.ReadValue(options), + "LMJelinekMercer" => reader.ReadValue(options), + "scripted" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(ISettingsSimilarity)}'.") + }; } - public override void Write(Utf8JsonWriter writer, ISettingsSimilarity value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ISettingsSimilarity value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "BM25": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBm25), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBm25)value); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBoolean), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityBoolean)value); + break; case "DFI": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfi), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfi)value); + break; case "DFR": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfr), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityDfr)value); + break; case "IB": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityIb), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityIb)value); + break; case "LMDirichlet": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmd), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmd)value); + break; case "LMJelinekMercer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmj), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityLmj)value); + break; case "scripted": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityScripted), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.IndexManagement.SettingsSimilarityScripted)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(ISettingsSimilarity)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs index 76c31252cf3..445425e2872 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStats.g.cs @@ -72,7 +72,6 @@ public sealed partial class ShardStats [JsonInclude, JsonPropertyName("shard_path")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardPath? ShardPath { get; init; } [JsonInclude, JsonPropertyName("shards")] - [ReadOnlyIndexNameDictionaryConverter(typeof(object))] public IReadOnlyDictionary? Shards { get; init; } [JsonInclude, JsonPropertyName("shard_stats")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardsTotalStats? ShardStats2 { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs index 45555b85e60..6cd8399e987 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/ShardStore.g.cs @@ -27,52 +27,66 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; -internal sealed partial class ShardStoreConverter : JsonConverter +internal sealed partial class ShardStoreConverter : System.Text.Json.Serialization.JsonConverter { - public override ShardStore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropNode = System.Text.Json.JsonEncodedText.Encode("node"); + private static readonly System.Text.Json.JsonEncodedText PropNodeId = System.Text.Json.JsonEncodedText.Encode("node_id"); + private static readonly System.Text.Json.JsonEncodedText PropAllocation = System.Text.Json.JsonEncodedText.Encode("allocation"); + private static readonly System.Text.Json.JsonEncodedText PropAllocationId = System.Text.Json.JsonEncodedText.Encode("allocation_id"); + private static readonly System.Text.Json.JsonEncodedText PropStoreException = System.Text.Json.JsonEncodedText.Encode("store_exception"); + + public override ShardStore Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - Elastic.Clients.Elasticsearch.IndexManagement.ShardStoreAllocation allocation = default; - string? allocationId = default; - Elastic.Clients.Elasticsearch.IndexManagement.ShardStoreException? storeException = default; - string nodeId = default; - Elastic.Clients.Elasticsearch.IndexManagement.ShardStoreNode node = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propNode = default; + LocalJsonValue propNodeId = default; + LocalJsonValue propAllocation = default; + LocalJsonValue propAllocationId = default; + LocalJsonValue propStoreException = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAllocation.TryRead(ref reader, options, PropAllocation)) { - var property = reader.GetString(); - if (property == "allocation") - { - allocation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "allocation_id") - { - allocationId = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; + } - if (property == "store_exception") - { - storeException = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propAllocationId.TryRead(ref reader, options, PropAllocationId)) + { + continue; + } - nodeId = property; - reader.Read(); - node = JsonSerializer.Deserialize(ref reader, options); + if (propStoreException.TryRead(ref reader, options, PropStoreException)) + { + continue; } + + propNodeId.Initialized = propNode.Initialized = true; + reader.ReadProperty(options, out propNodeId.Value, out propNode.Value); } - return new ShardStore { Allocation = allocation, AllocationId = allocationId, Node = node, NodeId = nodeId, StoreException = storeException }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShardStore + { + Node = propNode.Value +, + NodeId = propNodeId.Value +, + Allocation = propAllocation.Value +, + AllocationId = propAllocationId.Value +, + StoreException = propStoreException.Value + }; } - public override void Write(Utf8JsonWriter writer, ShardStore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShardStore value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'ShardStore' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllocation, value.Allocation); + writer.WriteProperty(options, PropAllocationId, value.AllocationId); + writer.WriteProperty(options, PropStoreException, value.StoreException); + writer.WriteProperty(options, value.NodeId, value.Node); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs index fbbf7a1f103..98603afb8a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/Template.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class Template { [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary Aliases { get; init; } [JsonInclude, JsonPropertyName("mappings")] public Elastic.Clients.Elasticsearch.Mapping.TypeMapping Mappings { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs index a64d9721337..c636d280745 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TemplateMapping.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class TemplateMapping { [JsonInclude, JsonPropertyName("aliases")] - [ReadOnlyIndexNameDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.IndexManagement.Alias))] public IReadOnlyDictionary Aliases { get; init; } [JsonInclude, JsonPropertyName("index_patterns")] public IReadOnlyCollection IndexPatterns { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs index c21918185ba..4f835d9ac41 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndexManagement/TypeFieldMappings.g.cs @@ -30,6 +30,5 @@ namespace Elastic.Clients.Elasticsearch.IndexManagement; public sealed partial class TypeFieldMappings { [JsonInclude, JsonPropertyName("mappings")] - [ReadOnlyFieldDictionaryConverter(typeof(Elastic.Clients.Elasticsearch.Mapping.FieldMapping))] public IReadOnlyDictionary Mappings { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs index 39dafca28b2..434f48fd816 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/IndicesOptions.g.cs @@ -27,12 +27,76 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class IndicesOptionsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowNoIndices = System.Text.Json.JsonEncodedText.Encode("allow_no_indices"); + private static readonly System.Text.Json.JsonEncodedText PropExpandWildcards = System.Text.Json.JsonEncodedText.Encode("expand_wildcards"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreThrottled = System.Text.Json.JsonEncodedText.Encode("ignore_throttled"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnavailable = System.Text.Json.JsonEncodedText.Encode("ignore_unavailable"); + + public override IndicesOptions Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowNoIndices = default; + LocalJsonValue?> propExpandWildcards = default; + LocalJsonValue propIgnoreThrottled = default; + LocalJsonValue propIgnoreUnavailable = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowNoIndices.TryRead(ref reader, options, PropAllowNoIndices)) + { + continue; + } + + if (propExpandWildcards.TryRead(ref reader, options, PropExpandWildcards, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.ExpandWildcard>))) + { + continue; + } + + if (propIgnoreThrottled.TryRead(ref reader, options, PropIgnoreThrottled)) + { + continue; + } + + if (propIgnoreUnavailable.TryRead(ref reader, options, PropIgnoreUnavailable)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IndicesOptions + { + AllowNoIndices = propAllowNoIndices.Value +, + ExpandWildcards = propExpandWildcards.Value +, + IgnoreThrottled = propIgnoreThrottled.Value +, + IgnoreUnavailable = propIgnoreUnavailable.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IndicesOptions value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowNoIndices, value.AllowNoIndices); + writer.WriteProperty(options, PropExpandWildcards, value.ExpandWildcards, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.ExpandWildcard>)); + writer.WriteProperty(options, PropIgnoreThrottled, value.IgnoreThrottled); + writer.WriteProperty(options, PropIgnoreUnavailable, value.IgnoreUnavailable); + writer.WriteEndObject(); + } +} + /// /// /// Controls how to deal with unavailable concrete indices (closed or missing), how wildcard expressions are expanded /// to actual indices (all, closed or open indices) and how to deal with wildcard expressions that resolve to no indices. /// /// +[JsonConverter(typeof(IndicesOptionsConverter))] public sealed partial class IndicesOptions { /// @@ -42,7 +106,6 @@ public sealed partial class IndicesOptions /// a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar. /// /// - [JsonInclude, JsonPropertyName("allow_no_indices")] public bool? AllowNoIndices { get; set; } /// @@ -52,8 +115,6 @@ public sealed partial class IndicesOptions /// such as open,hidden. /// /// - [JsonInclude, JsonPropertyName("expand_wildcards")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.ExpandWildcard))] public ICollection? ExpandWildcards { get; set; } /// @@ -61,7 +122,6 @@ public sealed partial class IndicesOptions /// If true, concrete, expanded or aliased indices are ignored when frozen. /// /// - [JsonInclude, JsonPropertyName("ignore_throttled")] public bool? IgnoreThrottled { get; set; } /// @@ -69,7 +129,6 @@ public sealed partial class IndicesOptions /// If true, missing or closed indices are not included in the response. /// /// - [JsonInclude, JsonPropertyName("ignore_unavailable")] public bool? IgnoreUnavailable { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs index b609af8460c..bad69f8a4b8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/AppendProcessor.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class AppendProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowDuplicates = System.Text.Json.JsonEncodedText.Encode("allow_duplicates"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override AppendProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowDuplicates = default; + LocalJsonValue propDescription = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + LocalJsonValue> propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowDuplicates.TryRead(ref reader, options, PropAllowDuplicates)) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue, typeof(SingleOrManyMarker, object>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AppendProcessor + { + AllowDuplicates = propAllowDuplicates.Value +, + Description = propDescription.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value +, + Value = propValue.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AppendProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowDuplicates, value.AllowDuplicates); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropValue, value.Value, null, typeof(SingleOrManyMarker, object>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AppendProcessorConverter))] public sealed partial class AppendProcessor { /// @@ -34,7 +138,6 @@ public sealed partial class AppendProcessor /// If false, the processor does not append values already present in the field. /// /// - [JsonInclude, JsonPropertyName("allow_duplicates")] public bool? AllowDuplicates { get; set; } /// @@ -43,7 +146,6 @@ public sealed partial class AppendProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -52,7 +154,6 @@ public sealed partial class AppendProcessor /// Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -60,7 +161,6 @@ public sealed partial class AppendProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -68,7 +168,6 @@ public sealed partial class AppendProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -76,7 +175,6 @@ public sealed partial class AppendProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -85,7 +183,6 @@ public sealed partial class AppendProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -93,8 +190,6 @@ public sealed partial class AppendProcessor /// The value to be appended. Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("value")] - [SingleOrManyCollectionConverter(typeof(object))] public ICollection Value { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(AppendProcessor appendProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Append(appendProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs index a5d99c2209f..b1e530055c1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/CsvProcessor.g.cs @@ -27,6 +27,150 @@ namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class CsvProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropEmptyValue = System.Text.Json.JsonEncodedText.Encode("empty_value"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropQuote = System.Text.Json.JsonEncodedText.Encode("quote"); + private static readonly System.Text.Json.JsonEncodedText PropSeparator = System.Text.Json.JsonEncodedText.Encode("separator"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropTargetFields = System.Text.Json.JsonEncodedText.Encode("target_fields"); + private static readonly System.Text.Json.JsonEncodedText PropTrim = System.Text.Json.JsonEncodedText.Encode("trim"); + + public override CsvProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDescription = default; + LocalJsonValue propEmptyValue = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propQuote = default; + LocalJsonValue propSeparator = default; + LocalJsonValue propTag = default; + LocalJsonValue propTargetFields = default; + LocalJsonValue propTrim = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propEmptyValue.TryRead(ref reader, options, PropEmptyValue)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propQuote.TryRead(ref reader, options, PropQuote)) + { + continue; + } + + if (propSeparator.TryRead(ref reader, options, PropSeparator)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propTargetFields.TryRead(ref reader, options, PropTargetFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propTrim.TryRead(ref reader, options, PropTrim)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CsvProcessor + { + Description = propDescription.Value +, + EmptyValue = propEmptyValue.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + OnFailure = propOnFailure.Value +, + Quote = propQuote.Value +, + Separator = propSeparator.Value +, + Tag = propTag.Value +, + TargetFields = propTargetFields.Value +, + Trim = propTrim.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CsvProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropEmptyValue, value.EmptyValue); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropQuote, value.Quote); + writer.WriteProperty(options, PropSeparator, value.Separator); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropTargetFields, value.TargetFields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropTrim, value.Trim); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CsvProcessorConverter))] public sealed partial class CsvProcessor { /// @@ -35,7 +179,6 @@ public sealed partial class CsvProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -45,7 +188,6 @@ public sealed partial class CsvProcessor /// An empty field is one with no value (2 consecutive separators) or empty quotes (""). /// /// - [JsonInclude, JsonPropertyName("empty_value")] public object? EmptyValue { get; set; } /// @@ -53,7 +195,6 @@ public sealed partial class CsvProcessor /// The field to extract data from. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -61,7 +202,6 @@ public sealed partial class CsvProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -69,7 +209,6 @@ public sealed partial class CsvProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -77,7 +216,6 @@ public sealed partial class CsvProcessor /// If true and field does not exist, the processor quietly exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -85,7 +223,6 @@ public sealed partial class CsvProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -93,7 +230,6 @@ public sealed partial class CsvProcessor /// Quote used in CSV, has to be single character string. /// /// - [JsonInclude, JsonPropertyName("quote")] public string? Quote { get; set; } /// @@ -101,7 +237,6 @@ public sealed partial class CsvProcessor /// Separator used in CSV, has to be single character string. /// /// - [JsonInclude, JsonPropertyName("separator")] public string? Separator { get; set; } /// @@ -110,7 +245,6 @@ public sealed partial class CsvProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -118,8 +252,6 @@ public sealed partial class CsvProcessor /// The array of fields to assign extracted values to. /// /// - [JsonInclude, JsonPropertyName("target_fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields TargetFields { get; set; } /// @@ -127,7 +259,6 @@ public sealed partial class CsvProcessor /// Trim whitespaces in unquoted fields. /// /// - [JsonInclude, JsonPropertyName("trim")] public bool? Trim { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(CsvProcessor csvProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Csv(csvProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs index 0ee2cf7640a..22cacbf08c9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfiguration.g.cs @@ -46,12 +46,16 @@ internal DatabaseConfiguration(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DatabaseConfiguration() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DatabaseConfiguration Ipinfo(Elastic.Clients.Elasticsearch.Ingest.Ipinfo ipinfo) => new DatabaseConfiguration("ipinfo", ipinfo); public static DatabaseConfiguration Maxmind(Elastic.Clients.Elasticsearch.Ingest.Maxmind maxmind) => new DatabaseConfiguration("maxmind", maxmind); @@ -77,83 +81,71 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DatabaseConfigurationConverter : JsonConverter +internal sealed partial class DatabaseConfigurationConverter : System.Text.Json.Serialization.JsonConverter { - public override DatabaseConfiguration Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText VariantIpinfo = System.Text.Json.JsonEncodedText.Encode("ipinfo"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxmind = System.Text.Json.JsonEncodedText.Encode("maxmind"); - object? variantValue = default; - string? variantNameValue = default; - Elastic.Clients.Elasticsearch.Name nameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DatabaseConfiguration Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propName.TryRead(ref reader, options, PropName)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") - { - nameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantIpinfo)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "maxmind") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DatabaseConfiguration' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DatabaseConfiguration(variantNameValue, variantValue); - result.Name = nameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatabaseConfiguration + { + VariantType = variantType, + Variant = variant, + Name = propName.Value + }; } - public override void Write(Utf8JsonWriter writer, DatabaseConfiguration value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatabaseConfiguration value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Name is not null) - { - writer.WritePropertyName("name"); - JsonSerializer.Serialize(writer, value.Name, options); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Maxmind)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo?)value.Variant); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Maxmind?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfiguration)}'."); } + writer.WriteProperty(options, PropName, value.Name); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs index 153f4bd724b..603157f1334 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DatabaseConfigurationFull.g.cs @@ -39,12 +39,16 @@ internal DatabaseConfigurationFull(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DatabaseConfigurationFull() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DatabaseConfigurationFull Ipinfo(Elastic.Clients.Elasticsearch.Ingest.Ipinfo ipinfo) => new DatabaseConfigurationFull("ipinfo", ipinfo); public static DatabaseConfigurationFull Local(Elastic.Clients.Elasticsearch.Ingest.Local local) => new DatabaseConfigurationFull("local", local); @@ -72,103 +76,95 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DatabaseConfigurationFullConverter : JsonConverter +internal sealed partial class DatabaseConfigurationFullConverter : System.Text.Json.Serialization.JsonConverter { - public override DatabaseConfigurationFull Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText VariantIpinfo = System.Text.Json.JsonEncodedText.Encode("ipinfo"); + private static readonly System.Text.Json.JsonEncodedText VariantLocal = System.Text.Json.JsonEncodedText.Encode("local"); + private static readonly System.Text.Json.JsonEncodedText VariantMaxmind = System.Text.Json.JsonEncodedText.Encode("maxmind"); + private static readonly System.Text.Json.JsonEncodedText VariantWeb = System.Text.Json.JsonEncodedText.Encode("web"); - object? variantValue = default; - string? variantNameValue = default; - string nameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DatabaseConfigurationFull Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (propName.TryRead(ref reader, options, PropName)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "name") - { - nameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "ipinfo") + if (reader.ValueTextEquals(VariantIpinfo)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpinfo.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "local") + if (reader.ValueTextEquals(VariantLocal)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLocal.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "maxmind") + if (reader.ValueTextEquals(VariantMaxmind)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMaxmind.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "web") + if (reader.ValueTextEquals(VariantWeb)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWeb.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DatabaseConfigurationFull' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DatabaseConfigurationFull(variantNameValue, variantValue); - result.Name = nameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatabaseConfigurationFull + { + VariantType = variantType, + Variant = variant, + Name = propName.Value + }; } - public override void Write(Utf8JsonWriter writer, DatabaseConfigurationFull value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatabaseConfigurationFull value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Name)) - { - writer.WritePropertyName("name"); - writer.WriteStringValue(value.Name); - } - - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "ipinfo": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo)value.Variant, options); - break; - case "local": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Local)value.Variant, options); - break; - case "maxmind": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Maxmind)value.Variant, options); - break; - case "web": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.Web)value.Variant, options); - break; - } + case "": + break; + case "ipinfo": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Ipinfo?)value.Variant); + break; + case "local": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Local?)value.Variant); + break; + case "maxmind": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Maxmind?)value.Variant); + break; + case "web": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.Web?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DatabaseConfigurationFull)}'."); } + writer.WriteProperty(options, PropName, value.Name); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs index 8d048ce6754..2cdcbaf9d2a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/DocumentSimulation.g.cs @@ -27,79 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Ingest; -internal sealed partial class DocumentSimulationConverter : JsonConverter +internal sealed partial class DocumentSimulationConverter : System.Text.Json.Serialization.JsonConverter { - public override DocumentSimulation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("_ingest"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("_version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("_version_type"); + + public override DocumentSimulation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - string id = default; - string index = default; - Elastic.Clients.Elasticsearch.Ingest.IngestInfo ingest = default; - string? routing = default; - IReadOnlyDictionary source = default; - long? version = default; - Elastic.Clients.Elasticsearch.VersionType? versionType = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIngest = default; + LocalJsonValue propRouting = default; + LocalJsonValue> propSource = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propId.TryRead(ref reader, options, PropId)) { - var property = reader.GetString(); - if (property == "_id") - { - id = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_index") - { - index = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_ingest") - { - ingest = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_routing") - { - routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - source = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "_version") - { - version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_version_type") - { - versionType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out string value); + propMetadata[key] = value; } - return new DocumentSimulation { Id = id, Index = index, Ingest = ingest, Metadata = additionalProperties, Routing = routing, Source = source, Version = version, VersionType = versionType }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DocumentSimulation + { + Metadata = propMetadata +, + Id = propId.Value +, + Index = propIndex.Value +, + Ingest = propIngest.Value +, + Routing = propRouting.Value +, + Source = propSource.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; } - public override void Write(Utf8JsonWriter writer, DocumentSimulation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DocumentSimulation value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'DocumentSimulation' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSource, value.Source); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs index 1242f11c013..f6fef807499 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/FingerprintProcessor.g.cs @@ -27,6 +27,130 @@ namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class FingerprintProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropMethod = System.Text.Json.JsonEncodedText.Encode("method"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropSalt = System.Text.Json.JsonEncodedText.Encode("salt"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + private static readonly System.Text.Json.JsonEncodedText PropTargetField = System.Text.Json.JsonEncodedText.Encode("target_field"); + + public override FingerprintProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDescription = default; + LocalJsonValue propFields = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue propMethod = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propSalt = default; + LocalJsonValue propTag = default; + LocalJsonValue propTargetField = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propMethod.TryRead(ref reader, options, PropMethod)) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propSalt.TryRead(ref reader, options, PropSalt)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + if (propTargetField.TryRead(ref reader, options, PropTargetField)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FingerprintProcessor + { + Description = propDescription.Value +, + Fields = propFields.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + Method = propMethod.Value +, + OnFailure = propOnFailure.Value +, + Salt = propSalt.Value +, + Tag = propTag.Value +, + TargetField = propTargetField.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FingerprintProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropMethod, value.Method); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropSalt, value.Salt); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteProperty(options, PropTargetField, value.TargetField); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FingerprintProcessorConverter))] public sealed partial class FingerprintProcessor { /// @@ -35,7 +159,6 @@ public sealed partial class FingerprintProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -45,8 +168,6 @@ public sealed partial class FingerprintProcessor /// only the field value. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// @@ -54,7 +175,6 @@ public sealed partial class FingerprintProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -62,7 +182,6 @@ public sealed partial class FingerprintProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -71,7 +190,6 @@ public sealed partial class FingerprintProcessor /// missing, the processor silently exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -80,7 +198,6 @@ public sealed partial class FingerprintProcessor /// SHA-256, SHA-512, or MurmurHash3. /// /// - [JsonInclude, JsonPropertyName("method")] public Elastic.Clients.Elasticsearch.Ingest.FingerprintDigest? Method { get; set; } /// @@ -88,7 +205,6 @@ public sealed partial class FingerprintProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -96,7 +212,6 @@ public sealed partial class FingerprintProcessor /// Salt value for the hash function. /// /// - [JsonInclude, JsonPropertyName("salt")] public string? Salt { get; set; } /// @@ -105,7 +220,6 @@ public sealed partial class FingerprintProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } /// @@ -113,7 +227,6 @@ public sealed partial class FingerprintProcessor /// Output field for the fingerprint. /// /// - [JsonInclude, JsonPropertyName("target_field")] public Elastic.Clients.Elasticsearch.Field? TargetField { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(FingerprintProcessor fingerprintProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Fingerprint(fingerprintProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs index ffa884fd3af..b6456d49a92 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/InferenceConfig.g.cs @@ -39,12 +39,16 @@ internal InferenceConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfig Classification(Elastic.Clients.Elasticsearch.Ingest.InferenceConfigClassification inferenceConfigClassification) => new InferenceConfig("classification", inferenceConfigClassification); public static InferenceConfig Regression(Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression inferenceConfigRegression) => new InferenceConfig("regression", inferenceConfigRegression); @@ -62,67 +66,56 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigConverter : JsonConverter +internal sealed partial class InferenceConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override InferenceConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigClassification)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigClassification?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceConfigRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs index b7020c13d1a..ed531f89739 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/Processor.g.cs @@ -39,12 +39,16 @@ internal Processor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Processor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Processor Append(Elastic.Clients.Elasticsearch.Ingest.AppendProcessor appendProcessor) => new Processor("append", appendProcessor); public static Processor Attachment(Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor attachmentProcessor) => new Processor("attachment", attachmentProcessor); @@ -105,497 +109,572 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class ProcessorConverter : JsonConverter +internal sealed partial class ProcessorConverter : System.Text.Json.Serialization.JsonConverter { - public override Processor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAppend = System.Text.Json.JsonEncodedText.Encode("append"); + private static readonly System.Text.Json.JsonEncodedText VariantAttachment = System.Text.Json.JsonEncodedText.Encode("attachment"); + private static readonly System.Text.Json.JsonEncodedText VariantBytes = System.Text.Json.JsonEncodedText.Encode("bytes"); + private static readonly System.Text.Json.JsonEncodedText VariantCircle = System.Text.Json.JsonEncodedText.Encode("circle"); + private static readonly System.Text.Json.JsonEncodedText VariantCommunityId = System.Text.Json.JsonEncodedText.Encode("community_id"); + private static readonly System.Text.Json.JsonEncodedText VariantConvert = System.Text.Json.JsonEncodedText.Encode("convert"); + private static readonly System.Text.Json.JsonEncodedText VariantCsv = System.Text.Json.JsonEncodedText.Encode("csv"); + private static readonly System.Text.Json.JsonEncodedText VariantDate = System.Text.Json.JsonEncodedText.Encode("date"); + private static readonly System.Text.Json.JsonEncodedText VariantDateIndexName = System.Text.Json.JsonEncodedText.Encode("date_index_name"); + private static readonly System.Text.Json.JsonEncodedText VariantDissect = System.Text.Json.JsonEncodedText.Encode("dissect"); + private static readonly System.Text.Json.JsonEncodedText VariantDotExpander = System.Text.Json.JsonEncodedText.Encode("dot_expander"); + private static readonly System.Text.Json.JsonEncodedText VariantDrop = System.Text.Json.JsonEncodedText.Encode("drop"); + private static readonly System.Text.Json.JsonEncodedText VariantEnrich = System.Text.Json.JsonEncodedText.Encode("enrich"); + private static readonly System.Text.Json.JsonEncodedText VariantFail = System.Text.Json.JsonEncodedText.Encode("fail"); + private static readonly System.Text.Json.JsonEncodedText VariantFingerprint = System.Text.Json.JsonEncodedText.Encode("fingerprint"); + private static readonly System.Text.Json.JsonEncodedText VariantForeach = System.Text.Json.JsonEncodedText.Encode("foreach"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoGrid = System.Text.Json.JsonEncodedText.Encode("geo_grid"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoip = System.Text.Json.JsonEncodedText.Encode("geoip"); + private static readonly System.Text.Json.JsonEncodedText VariantGrok = System.Text.Json.JsonEncodedText.Encode("grok"); + private static readonly System.Text.Json.JsonEncodedText VariantGsub = System.Text.Json.JsonEncodedText.Encode("gsub"); + private static readonly System.Text.Json.JsonEncodedText VariantHtmlStrip = System.Text.Json.JsonEncodedText.Encode("html_strip"); + private static readonly System.Text.Json.JsonEncodedText VariantInference = System.Text.Json.JsonEncodedText.Encode("inference"); + private static readonly System.Text.Json.JsonEncodedText VariantIpLocation = System.Text.Json.JsonEncodedText.Encode("ip_location"); + private static readonly System.Text.Json.JsonEncodedText VariantJoin = System.Text.Json.JsonEncodedText.Encode("join"); + private static readonly System.Text.Json.JsonEncodedText VariantJson = System.Text.Json.JsonEncodedText.Encode("json"); + private static readonly System.Text.Json.JsonEncodedText VariantKv = System.Text.Json.JsonEncodedText.Encode("kv"); + private static readonly System.Text.Json.JsonEncodedText VariantLowercase = System.Text.Json.JsonEncodedText.Encode("lowercase"); + private static readonly System.Text.Json.JsonEncodedText VariantNetworkDirection = System.Text.Json.JsonEncodedText.Encode("network_direction"); + private static readonly System.Text.Json.JsonEncodedText VariantPipeline = System.Text.Json.JsonEncodedText.Encode("pipeline"); + private static readonly System.Text.Json.JsonEncodedText VariantRedact = System.Text.Json.JsonEncodedText.Encode("redact"); + private static readonly System.Text.Json.JsonEncodedText VariantRegisteredDomain = System.Text.Json.JsonEncodedText.Encode("registered_domain"); + private static readonly System.Text.Json.JsonEncodedText VariantRemove = System.Text.Json.JsonEncodedText.Encode("remove"); + private static readonly System.Text.Json.JsonEncodedText VariantRename = System.Text.Json.JsonEncodedText.Encode("rename"); + private static readonly System.Text.Json.JsonEncodedText VariantReroute = System.Text.Json.JsonEncodedText.Encode("reroute"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText VariantSet = System.Text.Json.JsonEncodedText.Encode("set"); + private static readonly System.Text.Json.JsonEncodedText VariantSetSecurityUser = System.Text.Json.JsonEncodedText.Encode("set_security_user"); + private static readonly System.Text.Json.JsonEncodedText VariantSort = System.Text.Json.JsonEncodedText.Encode("sort"); + private static readonly System.Text.Json.JsonEncodedText VariantSplit = System.Text.Json.JsonEncodedText.Encode("split"); + private static readonly System.Text.Json.JsonEncodedText VariantTerminate = System.Text.Json.JsonEncodedText.Encode("terminate"); + private static readonly System.Text.Json.JsonEncodedText VariantTrim = System.Text.Json.JsonEncodedText.Encode("trim"); + private static readonly System.Text.Json.JsonEncodedText VariantUppercase = System.Text.Json.JsonEncodedText.Encode("uppercase"); + private static readonly System.Text.Json.JsonEncodedText VariantUriParts = System.Text.Json.JsonEncodedText.Encode("uri_parts"); + private static readonly System.Text.Json.JsonEncodedText VariantUrlDecode = System.Text.Json.JsonEncodedText.Encode("urldecode"); + private static readonly System.Text.Json.JsonEncodedText VariantUserAgent = System.Text.Json.JsonEncodedText.Encode("user_agent"); + + public override Processor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAppend)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "append") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAppend.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "attachment") + if (reader.ValueTextEquals(VariantAttachment)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAttachment.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bytes") + if (reader.ValueTextEquals(VariantBytes)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBytes.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "circle") + if (reader.ValueTextEquals(VariantCircle)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCircle.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "community_id") + if (reader.ValueTextEquals(VariantCommunityId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCommunityId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "convert") + if (reader.ValueTextEquals(VariantConvert)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConvert.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "csv") + if (reader.ValueTextEquals(VariantCsv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCsv.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date") + if (reader.ValueTextEquals(VariantDate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "date_index_name") + if (reader.ValueTextEquals(VariantDateIndexName)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDateIndexName.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dissect") + if (reader.ValueTextEquals(VariantDissect)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDissect.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dot_expander") + if (reader.ValueTextEquals(VariantDotExpander)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDotExpander.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "drop") + if (reader.ValueTextEquals(VariantDrop)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDrop.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "enrich") + if (reader.ValueTextEquals(VariantEnrich)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantEnrich.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fail") + if (reader.ValueTextEquals(VariantFail)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFail.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fingerprint") + if (reader.ValueTextEquals(VariantFingerprint)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFingerprint.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "foreach") + if (reader.ValueTextEquals(VariantForeach)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantForeach.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_grid") + if (reader.ValueTextEquals(VariantGeoGrid)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoGrid.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geoip") + if (reader.ValueTextEquals(VariantGeoip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoip.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "grok") + if (reader.ValueTextEquals(VariantGrok)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGrok.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "gsub") + if (reader.ValueTextEquals(VariantGsub)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGsub.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "html_strip") + if (reader.ValueTextEquals(VariantHtmlStrip)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHtmlStrip.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "inference") + if (reader.ValueTextEquals(VariantInference)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInference.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ip_location") + if (reader.ValueTextEquals(VariantIpLocation)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIpLocation.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "join") + if (reader.ValueTextEquals(VariantJoin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJoin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "json") + if (reader.ValueTextEquals(VariantJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantJson.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "kv") + if (reader.ValueTextEquals(VariantKv)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKv.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "lowercase") + if (reader.ValueTextEquals(VariantLowercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLowercase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "network_direction") + if (reader.ValueTextEquals(VariantNetworkDirection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNetworkDirection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pipeline") + if (reader.ValueTextEquals(VariantPipeline)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPipeline.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "redact") + if (reader.ValueTextEquals(VariantRedact)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRedact.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "registered_domain") + if (reader.ValueTextEquals(VariantRegisteredDomain)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegisteredDomain.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "remove") + if (reader.ValueTextEquals(VariantRemove)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRemove.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rename") + if (reader.ValueTextEquals(VariantRename)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRename.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "reroute") + if (reader.ValueTextEquals(VariantReroute)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantReroute.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "set") + if (reader.ValueTextEquals(VariantSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "set_security_user") + if (reader.ValueTextEquals(VariantSetSecurityUser)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSetSecurityUser.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sort") + if (reader.ValueTextEquals(VariantSort)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSort.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "split") + if (reader.ValueTextEquals(VariantSplit)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSplit.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terminate") + if (reader.ValueTextEquals(VariantTerminate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerminate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "trim") + if (reader.ValueTextEquals(VariantTrim)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTrim.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "uppercase") + if (reader.ValueTextEquals(VariantUppercase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUppercase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "uri_parts") + if (reader.ValueTextEquals(VariantUriParts)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUriParts.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "urldecode") + if (reader.ValueTextEquals(VariantUrlDecode)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUrlDecode.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "user_agent") + if (reader.ValueTextEquals(VariantUserAgent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantUserAgent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Processor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Processor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Processor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Processor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Processor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "append": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.AppendProcessor)value.Variant, options); - break; - case "attachment": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor)value.Variant, options); - break; - case "bytes": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.BytesProcessor)value.Variant, options); - break; - case "circle": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CircleProcessor)value.Variant, options); - break; - case "community_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CommunityIDProcessor)value.Variant, options); - break; - case "convert": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ConvertProcessor)value.Variant, options); - break; - case "csv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.CsvProcessor)value.Variant, options); - break; - case "date": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DateProcessor)value.Variant, options); - break; - case "date_index_name": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DateIndexNameProcessor)value.Variant, options); - break; - case "dissect": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DissectProcessor)value.Variant, options); - break; - case "dot_expander": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DotExpanderProcessor)value.Variant, options); - break; - case "drop": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.DropProcessor)value.Variant, options); - break; - case "enrich": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.EnrichProcessor)value.Variant, options); - break; - case "fail": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.FailProcessor)value.Variant, options); - break; - case "fingerprint": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.FingerprintProcessor)value.Variant, options); - break; - case "foreach": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ForeachProcessor)value.Variant, options); - break; - case "geo_grid": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GeoGridProcessor)value.Variant, options); - break; - case "geoip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GeoIpProcessor)value.Variant, options); - break; - case "grok": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GrokProcessor)value.Variant, options); - break; - case "gsub": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.GsubProcessor)value.Variant, options); - break; - case "html_strip": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.HtmlStripProcessor)value.Variant, options); - break; - case "inference": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.InferenceProcessor)value.Variant, options); - break; - case "ip_location": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.IpLocationProcessor)value.Variant, options); - break; - case "join": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.JoinProcessor)value.Variant, options); - break; - case "json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.JsonProcessor)value.Variant, options); - break; - case "kv": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.KeyValueProcessor)value.Variant, options); - break; - case "lowercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.LowercaseProcessor)value.Variant, options); - break; - case "network_direction": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.NetworkDirectionProcessor)value.Variant, options); - break; - case "pipeline": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.PipelineProcessor)value.Variant, options); - break; - case "redact": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RedactProcessor)value.Variant, options); - break; - case "registered_domain": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RegisteredDomainProcessor)value.Variant, options); - break; - case "remove": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RemoveProcessor)value.Variant, options); - break; - case "rename": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RenameProcessor)value.Variant, options); - break; - case "reroute": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.RerouteProcessor)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.ScriptProcessor)value.Variant, options); - break; - case "set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SetProcessor)value.Variant, options); - break; - case "set_security_user": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SetSecurityUserProcessor)value.Variant, options); - break; - case "sort": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SortProcessor)value.Variant, options); - break; - case "split": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.SplitProcessor)value.Variant, options); - break; - case "terminate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.TerminateProcessor)value.Variant, options); - break; - case "trim": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.TrimProcessor)value.Variant, options); - break; - case "uppercase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UppercaseProcessor)value.Variant, options); - break; - case "uri_parts": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UriPartsProcessor)value.Variant, options); - break; - case "urldecode": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UrlDecodeProcessor)value.Variant, options); - break; - case "user_agent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Ingest.UserAgentProcessor)value.Variant, options); - break; - } + case "": + break; + case "append": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.AppendProcessor?)value.Variant); + break; + case "attachment": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.AttachmentProcessor?)value.Variant); + break; + case "bytes": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.BytesProcessor?)value.Variant); + break; + case "circle": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CircleProcessor?)value.Variant); + break; + case "community_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CommunityIDProcessor?)value.Variant); + break; + case "convert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ConvertProcessor?)value.Variant); + break; + case "csv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.CsvProcessor?)value.Variant); + break; + case "date": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DateProcessor?)value.Variant); + break; + case "date_index_name": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DateIndexNameProcessor?)value.Variant); + break; + case "dissect": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DissectProcessor?)value.Variant); + break; + case "dot_expander": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DotExpanderProcessor?)value.Variant); + break; + case "drop": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.DropProcessor?)value.Variant); + break; + case "enrich": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.EnrichProcessor?)value.Variant); + break; + case "fail": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.FailProcessor?)value.Variant); + break; + case "fingerprint": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.FingerprintProcessor?)value.Variant); + break; + case "foreach": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ForeachProcessor?)value.Variant); + break; + case "geo_grid": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GeoGridProcessor?)value.Variant); + break; + case "geoip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GeoIpProcessor?)value.Variant); + break; + case "grok": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GrokProcessor?)value.Variant); + break; + case "gsub": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.GsubProcessor?)value.Variant); + break; + case "html_strip": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.HtmlStripProcessor?)value.Variant); + break; + case "inference": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.InferenceProcessor?)value.Variant); + break; + case "ip_location": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.IpLocationProcessor?)value.Variant); + break; + case "join": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.JoinProcessor?)value.Variant); + break; + case "json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.JsonProcessor?)value.Variant); + break; + case "kv": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.KeyValueProcessor?)value.Variant); + break; + case "lowercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.LowercaseProcessor?)value.Variant); + break; + case "network_direction": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.NetworkDirectionProcessor?)value.Variant); + break; + case "pipeline": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.PipelineProcessor?)value.Variant); + break; + case "redact": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RedactProcessor?)value.Variant); + break; + case "registered_domain": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RegisteredDomainProcessor?)value.Variant); + break; + case "remove": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RemoveProcessor?)value.Variant); + break; + case "rename": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RenameProcessor?)value.Variant); + break; + case "reroute": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.RerouteProcessor?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.ScriptProcessor?)value.Variant); + break; + case "set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SetProcessor?)value.Variant); + break; + case "set_security_user": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SetSecurityUserProcessor?)value.Variant); + break; + case "sort": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SortProcessor?)value.Variant); + break; + case "split": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.SplitProcessor?)value.Variant); + break; + case "terminate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.TerminateProcessor?)value.Variant); + break; + case "trim": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.TrimProcessor?)value.Variant); + break; + case "uppercase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UppercaseProcessor?)value.Variant); + break; + case "uri_parts": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UriPartsProcessor?)value.Variant); + break; + case "urldecode": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UrlDecodeProcessor?)value.Variant); + break; + case "user_agent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Ingest.UserAgentProcessor?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Processor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs index 33124de7f4a..557ae5e07c0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RemoveProcessor.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class RemoveProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMissing = System.Text.Json.JsonEncodedText.Encode("ignore_missing"); + private static readonly System.Text.Json.JsonEncodedText PropKeep = System.Text.Json.JsonEncodedText.Encode("keep"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + + public override RemoveProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDescription = default; + LocalJsonValue propField = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue propIgnoreMissing = default; + LocalJsonValue propKeep = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propIgnoreMissing.TryRead(ref reader, options, PropIgnoreMissing)) + { + continue; + } + + if (propKeep.TryRead(ref reader, options, PropKeep, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RemoveProcessor + { + Description = propDescription.Value +, + Field = propField.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + IgnoreMissing = propIgnoreMissing.Value +, + Keep = propKeep.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RemoveProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropField, value.Field, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropIgnoreMissing, value.IgnoreMissing); + writer.WriteProperty(options, PropKeep, value.Keep, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RemoveProcessorConverter))] public sealed partial class RemoveProcessor { /// @@ -35,7 +139,6 @@ public sealed partial class RemoveProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -43,8 +146,6 @@ public sealed partial class RemoveProcessor /// Fields to be removed. Supports template snippets. /// /// - [JsonInclude, JsonPropertyName("field")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Field { get; set; } /// @@ -52,7 +153,6 @@ public sealed partial class RemoveProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -60,7 +160,6 @@ public sealed partial class RemoveProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -68,7 +167,6 @@ public sealed partial class RemoveProcessor /// If true and field does not exist or is null, the processor quietly exits without modifying the document. /// /// - [JsonInclude, JsonPropertyName("ignore_missing")] public bool? IgnoreMissing { get; set; } /// @@ -76,8 +174,6 @@ public sealed partial class RemoveProcessor /// Fields to be kept. When set, all fields other than those specified are removed. /// /// - [JsonInclude, JsonPropertyName("keep")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Keep { get; set; } /// @@ -85,7 +181,6 @@ public sealed partial class RemoveProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -94,7 +189,6 @@ public sealed partial class RemoveProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(RemoveProcessor removeProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Remove(removeProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs index 2f92c5c108e..c25cad514c2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Ingest/RerouteProcessor.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.Ingest; +internal sealed partial class RerouteProcessorConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDataset = System.Text.Json.JsonEncodedText.Encode("dataset"); + private static readonly System.Text.Json.JsonEncodedText PropDescription = System.Text.Json.JsonEncodedText.Encode("description"); + private static readonly System.Text.Json.JsonEncodedText PropDestination = System.Text.Json.JsonEncodedText.Encode("destination"); + private static readonly System.Text.Json.JsonEncodedText PropIf = System.Text.Json.JsonEncodedText.Encode("if"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreFailure = System.Text.Json.JsonEncodedText.Encode("ignore_failure"); + private static readonly System.Text.Json.JsonEncodedText PropNamespace = System.Text.Json.JsonEncodedText.Encode("namespace"); + private static readonly System.Text.Json.JsonEncodedText PropOnFailure = System.Text.Json.JsonEncodedText.Encode("on_failure"); + private static readonly System.Text.Json.JsonEncodedText PropTag = System.Text.Json.JsonEncodedText.Encode("tag"); + + public override RerouteProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propDataset = default; + LocalJsonValue propDescription = default; + LocalJsonValue propDestination = default; + LocalJsonValue propIf = default; + LocalJsonValue propIgnoreFailure = default; + LocalJsonValue?> propNamespace = default; + LocalJsonValue?> propOnFailure = default; + LocalJsonValue propTag = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDataset.TryRead(ref reader, options, PropDataset, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propDescription.TryRead(ref reader, options, PropDescription)) + { + continue; + } + + if (propDestination.TryRead(ref reader, options, PropDestination)) + { + continue; + } + + if (propIf.TryRead(ref reader, options, PropIf)) + { + continue; + } + + if (propIgnoreFailure.TryRead(ref reader, options, PropIgnoreFailure)) + { + continue; + } + + if (propNamespace.TryRead(ref reader, options, PropNamespace, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propOnFailure.TryRead(ref reader, options, PropOnFailure)) + { + continue; + } + + if (propTag.TryRead(ref reader, options, PropTag)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RerouteProcessor + { + Dataset = propDataset.Value +, + Description = propDescription.Value +, + Destination = propDestination.Value +, + If = propIf.Value +, + IgnoreFailure = propIgnoreFailure.Value +, + Namespace = propNamespace.Value +, + OnFailure = propOnFailure.Value +, + Tag = propTag.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RerouteProcessor value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDataset, value.Dataset, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropDescription, value.Description); + writer.WriteProperty(options, PropDestination, value.Destination); + writer.WriteProperty(options, PropIf, value.If); + writer.WriteProperty(options, PropIgnoreFailure, value.IgnoreFailure); + writer.WriteProperty(options, PropNamespace, value.Namespace, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropOnFailure, value.OnFailure); + writer.WriteProperty(options, PropTag, value.Tag); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RerouteProcessorConverter))] public sealed partial class RerouteProcessor { /// @@ -44,8 +148,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.dataset}} /// /// - [JsonInclude, JsonPropertyName("dataset")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Dataset { get; set; } /// @@ -54,7 +156,6 @@ public sealed partial class RerouteProcessor /// Useful for describing the purpose of the processor or its configuration. /// /// - [JsonInclude, JsonPropertyName("description")] public string? Description { get; set; } /// @@ -62,7 +163,6 @@ public sealed partial class RerouteProcessor /// A static value for the target. Can’t be set when the dataset or namespace option is set. /// /// - [JsonInclude, JsonPropertyName("destination")] public string? Destination { get; set; } /// @@ -70,7 +170,6 @@ public sealed partial class RerouteProcessor /// Conditionally execute the processor. /// /// - [JsonInclude, JsonPropertyName("if")] public string? If { get; set; } /// @@ -78,7 +177,6 @@ public sealed partial class RerouteProcessor /// Ignore failures for the processor. /// /// - [JsonInclude, JsonPropertyName("ignore_failure")] public bool? IgnoreFailure { get; set; } /// @@ -95,8 +193,6 @@ public sealed partial class RerouteProcessor /// default {{data_stream.namespace}} /// /// - [JsonInclude, JsonPropertyName("namespace")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? Namespace { get; set; } /// @@ -104,7 +200,6 @@ public sealed partial class RerouteProcessor /// Handle failures for the processor. /// /// - [JsonInclude, JsonPropertyName("on_failure")] public ICollection? OnFailure { get; set; } /// @@ -113,7 +208,6 @@ public sealed partial class RerouteProcessor /// Useful for debugging and metrics. /// /// - [JsonInclude, JsonPropertyName("tag")] public string? Tag { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Ingest.Processor(RerouteProcessor rerouteProcessor) => Elastic.Clients.Elasticsearch.Ingest.Processor.Reroute(rerouteProcessor); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs index 8a7a7d95cd3..8772f9c7be3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/InlineGet.g.cs @@ -27,76 +27,121 @@ namespace Elastic.Clients.Elasticsearch; -internal sealed partial class InlineGetConverter : JsonConverter> +internal sealed partial class InlineGetConverter : System.Text.Json.Serialization.JsonConverter> { - public override InlineGet Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMetadata = System.Text.Json.JsonEncodedText.Encode("metadata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFound = System.Text.Json.JsonEncodedText.Encode("found"); + private static readonly System.Text.Json.JsonEncodedText PropPrimaryTerm = System.Text.Json.JsonEncodedText.Encode("_primary_term"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("_routing"); + private static readonly System.Text.Json.JsonEncodedText PropSeqNo = System.Text.Json.JsonEncodedText.Encode("_seq_no"); + private static readonly System.Text.Json.JsonEncodedText PropSource = System.Text.Json.JsonEncodedText.Encode("_source"); + + public override InlineGet Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? fields = default; - bool found = default; - long? primaryTerm = default; - string? routing = default; - long? seqNo = default; - TDocument? source = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propMetadata = default; + LocalJsonValue?> propFields = default; + LocalJsonValue propFound = default; + LocalJsonValue propPrimaryTerm = default; + LocalJsonValue propRouting = default; + LocalJsonValue propSeqNo = default; + LocalJsonValue propSource = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFound.TryRead(ref reader, options, PropFound)) + { + continue; + } + + if (propPrimaryTerm.TryRead(ref reader, options, PropPrimaryTerm)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propSeqNo.TryRead(ref reader, options, PropSeqNo)) + { + continue; + } + + if (propSource.TryRead(ref reader, options, PropSource, typeof(SourceMarker))) { - var property = reader.GetString(); - if (property == "fields") - { - fields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "found") - { - found = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_primary_term") - { - primaryTerm = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_routing") - { - routing = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_seq_no") - { - seqNo = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_source") - { - source = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + continue; } + + propMetadata ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propMetadata[key] = value; } - return new InlineGet { Fields = fields, Found = found, Metadata = additionalProperties, PrimaryTerm = primaryTerm, Routing = routing, SeqNo = seqNo, Source = source }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InlineGet + { + Metadata = propMetadata +, + Fields = propFields.Value +, + Found = propFound.Value +, + PrimaryTerm = propPrimaryTerm.Value +, + Routing = propRouting.Value +, + SeqNo = propSeqNo.Value +, + Source = propSource.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InlineGet value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFound, value.Found); + writer.WriteProperty(options, PropPrimaryTerm, value.PrimaryTerm); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropSeqNo, value.SeqNo); + writer.WriteProperty(options, PropSource, value.Source, null, typeof(SourceMarker)); + if (value.Metadata is not null) + { + foreach (var item in value.Metadata) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); + } +} + +internal sealed partial class InlineGetConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(InlineGet<>); } - public override void Write(Utf8JsonWriter writer, InlineGet value, JsonSerializerOptions options) + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'InlineGet' is a readonly type, used only on responses and does not support being written to JSON."); + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(InlineGetConverter<>).MakeGenericType(args[0]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; } } -[GenericConverter(typeof(InlineGetConverter<>), unwrap: true)] +[JsonConverter(typeof(InlineGetConverterFactory))] public sealed partial class InlineGet { public IReadOnlyDictionary? Fields { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs index 8ef6b7429e7..d08e79b00be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnQuery.g.cs @@ -27,6 +27,120 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class KnnQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propk = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue propQueryName = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + k = propk.Value +, + NumCandidates = propNumCandidates.Value +, + QueryName = propQueryName.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnQueryConverter))] public sealed partial class KnnQuery { /// @@ -37,7 +151,6 @@ public sealed partial class KnnQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -45,7 +158,6 @@ public sealed partial class KnnQuery /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -53,8 +165,6 @@ public sealed partial class KnnQuery /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -62,7 +172,6 @@ public sealed partial class KnnQuery /// The final number of nearest neighbors to return as top hits /// /// - [JsonInclude, JsonPropertyName("k")] public int? k { get; set; } /// @@ -70,9 +179,7 @@ public sealed partial class KnnQuery /// The number of nearest neighbor candidates to consider per shard /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int? NumCandidates { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -80,7 +187,6 @@ public sealed partial class KnnQuery /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -88,7 +194,6 @@ public sealed partial class KnnQuery /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -96,7 +201,6 @@ public sealed partial class KnnQuery /// The minimum similarity for a vector to be considered a match /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(KnnQuery knnQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.Knn(knnQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs index effdb6f24c5..671de82ce6f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnRetriever.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class KnnRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propk = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnRetriever + { + Field = propField.Value +, + Filter = propFilter.Value +, + k = propk.Value +, + MinScore = propMinScore.Value +, + NumCandidates = propNumCandidates.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnRetrieverConverter))] public sealed partial class KnnRetriever { /// @@ -34,7 +138,6 @@ public sealed partial class KnnRetriever /// The name of the vector field to search against. /// /// - [JsonInclude, JsonPropertyName("field")] public string Field { get; set; } /// @@ -42,8 +145,6 @@ public sealed partial class KnnRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -51,7 +152,6 @@ public sealed partial class KnnRetriever /// Number of nearest neighbors to return as top hits. /// /// - [JsonInclude, JsonPropertyName("k")] public int k { get; set; } /// @@ -59,7 +159,6 @@ public sealed partial class KnnRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -67,7 +166,6 @@ public sealed partial class KnnRetriever /// Number of nearest neighbor candidates to consider per shard. /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int NumCandidates { get; set; } /// @@ -75,7 +173,6 @@ public sealed partial class KnnRetriever /// Query vector. Must have the same number of dimensions as the vector field you are searching against. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -83,7 +180,6 @@ public sealed partial class KnnRetriever /// Defines a model to build a query vector. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -91,7 +187,6 @@ public sealed partial class KnnRetriever /// The minimum similarity required for a document to be considered a match. /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Retriever(KnnRetriever knnRetriever) => Elastic.Clients.Elasticsearch.Retriever.Knn(knnRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs index a3a664f8101..236801a10be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/KnnSearch.g.cs @@ -27,6 +27,120 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class KnnSearchConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropInnerHits = System.Text.Json.JsonEncodedText.Encode("inner_hits"); + private static readonly System.Text.Json.JsonEncodedText Propk = System.Text.Json.JsonEncodedText.Encode("k"); + private static readonly System.Text.Json.JsonEncodedText PropNumCandidates = System.Text.Json.JsonEncodedText.Encode("num_candidates"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVector = System.Text.Json.JsonEncodedText.Encode("query_vector"); + private static readonly System.Text.Json.JsonEncodedText PropQueryVectorBuilder = System.Text.Json.JsonEncodedText.Encode("query_vector_builder"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + + public override KnnSearch Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propInnerHits = default; + LocalJsonValue propk = default; + LocalJsonValue propNumCandidates = default; + LocalJsonValue?> propQueryVector = default; + LocalJsonValue propQueryVectorBuilder = default; + LocalJsonValue propSimilarity = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propInnerHits.TryRead(ref reader, options, PropInnerHits)) + { + continue; + } + + if (propk.TryRead(ref reader, options, Propk)) + { + continue; + } + + if (propNumCandidates.TryRead(ref reader, options, PropNumCandidates)) + { + continue; + } + + if (propQueryVector.TryRead(ref reader, options, PropQueryVector)) + { + continue; + } + + if (propQueryVectorBuilder.TryRead(ref reader, options, PropQueryVectorBuilder)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KnnSearch + { + Boost = propBoost.Value +, + Field = propField.Value +, + Filter = propFilter.Value +, + InnerHits = propInnerHits.Value +, + k = propk.Value +, + NumCandidates = propNumCandidates.Value +, + QueryVector = propQueryVector.Value +, + QueryVectorBuilder = propQueryVectorBuilder.Value +, + Similarity = propSimilarity.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KnnSearch value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropInnerHits, value.InnerHits); + writer.WriteProperty(options, Propk, value.k); + writer.WriteProperty(options, PropNumCandidates, value.NumCandidates); + writer.WriteProperty(options, PropQueryVector, value.QueryVector); + writer.WriteProperty(options, PropQueryVectorBuilder, value.QueryVectorBuilder); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KnnSearchConverter))] public sealed partial class KnnSearch { /// @@ -34,7 +148,6 @@ public sealed partial class KnnSearch /// Boost value to apply to kNN scores /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -42,7 +155,6 @@ public sealed partial class KnnSearch /// The name of the vector field to search against /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -50,8 +162,6 @@ public sealed partial class KnnSearch /// Filters for the kNN search query /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -59,7 +169,6 @@ public sealed partial class KnnSearch /// If defined, each search hit will contain inner hits. /// /// - [JsonInclude, JsonPropertyName("inner_hits")] public Elastic.Clients.Elasticsearch.Core.Search.InnerHits? InnerHits { get; set; } /// @@ -67,7 +176,6 @@ public sealed partial class KnnSearch /// The final number of nearest neighbors to return as top hits /// /// - [JsonInclude, JsonPropertyName("k")] public int? k { get; set; } /// @@ -75,7 +183,6 @@ public sealed partial class KnnSearch /// The number of nearest neighbor candidates to consider per shard /// /// - [JsonInclude, JsonPropertyName("num_candidates")] public int? NumCandidates { get; set; } /// @@ -83,7 +190,6 @@ public sealed partial class KnnSearch /// The query vector /// /// - [JsonInclude, JsonPropertyName("query_vector")] public ICollection? QueryVector { get; set; } /// @@ -91,7 +197,6 @@ public sealed partial class KnnSearch /// The query vector builder. You must provide a query_vector_builder or query_vector, but not both. /// /// - [JsonInclude, JsonPropertyName("query_vector_builder")] public Elastic.Clients.Elasticsearch.QueryVectorBuilder? QueryVectorBuilder { get; set; } /// @@ -99,7 +204,6 @@ public sealed partial class KnnSearch /// The minimum similarity for a vector to be considered a match /// /// - [JsonInclude, JsonPropertyName("similarity")] public float? Similarity { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs index 317b1ad5cbb..4b8a6833734 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/AnalysisConfig.g.cs @@ -27,6 +27,140 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class AnalysisConfigConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBucketSpan = System.Text.Json.JsonEncodedText.Encode("bucket_span"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationAnalyzer = System.Text.Json.JsonEncodedText.Encode("categorization_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationFieldName = System.Text.Json.JsonEncodedText.Encode("categorization_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropCategorizationFilters = System.Text.Json.JsonEncodedText.Encode("categorization_filters"); + private static readonly System.Text.Json.JsonEncodedText PropDetectors = System.Text.Json.JsonEncodedText.Encode("detectors"); + private static readonly System.Text.Json.JsonEncodedText PropInfluencers = System.Text.Json.JsonEncodedText.Encode("influencers"); + private static readonly System.Text.Json.JsonEncodedText PropLatency = System.Text.Json.JsonEncodedText.Encode("latency"); + private static readonly System.Text.Json.JsonEncodedText PropModelPruneWindow = System.Text.Json.JsonEncodedText.Encode("model_prune_window"); + private static readonly System.Text.Json.JsonEncodedText PropMultivariateByFields = System.Text.Json.JsonEncodedText.Encode("multivariate_by_fields"); + private static readonly System.Text.Json.JsonEncodedText PropPerPartitionCategorization = System.Text.Json.JsonEncodedText.Encode("per_partition_categorization"); + private static readonly System.Text.Json.JsonEncodedText PropSummaryCountFieldName = System.Text.Json.JsonEncodedText.Encode("summary_count_field_name"); + + public override AnalysisConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBucketSpan = default; + LocalJsonValue propCategorizationAnalyzer = default; + LocalJsonValue propCategorizationFieldName = default; + LocalJsonValue?> propCategorizationFilters = default; + LocalJsonValue> propDetectors = default; + LocalJsonValue propInfluencers = default; + LocalJsonValue propLatency = default; + LocalJsonValue propModelPruneWindow = default; + LocalJsonValue propMultivariateByFields = default; + LocalJsonValue propPerPartitionCategorization = default; + LocalJsonValue propSummaryCountFieldName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBucketSpan.TryRead(ref reader, options, PropBucketSpan)) + { + continue; + } + + if (propCategorizationAnalyzer.TryRead(ref reader, options, PropCategorizationAnalyzer)) + { + continue; + } + + if (propCategorizationFieldName.TryRead(ref reader, options, PropCategorizationFieldName)) + { + continue; + } + + if (propCategorizationFilters.TryRead(ref reader, options, PropCategorizationFilters)) + { + continue; + } + + if (propDetectors.TryRead(ref reader, options, PropDetectors)) + { + continue; + } + + if (propInfluencers.TryRead(ref reader, options, PropInfluencers, typeof(FieldsMarker))) + { + continue; + } + + if (propLatency.TryRead(ref reader, options, PropLatency)) + { + continue; + } + + if (propModelPruneWindow.TryRead(ref reader, options, PropModelPruneWindow)) + { + continue; + } + + if (propMultivariateByFields.TryRead(ref reader, options, PropMultivariateByFields)) + { + continue; + } + + if (propPerPartitionCategorization.TryRead(ref reader, options, PropPerPartitionCategorization)) + { + continue; + } + + if (propSummaryCountFieldName.TryRead(ref reader, options, PropSummaryCountFieldName)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new AnalysisConfig + { + BucketSpan = propBucketSpan.Value +, + CategorizationAnalyzer = propCategorizationAnalyzer.Value +, + CategorizationFieldName = propCategorizationFieldName.Value +, + CategorizationFilters = propCategorizationFilters.Value +, + Detectors = propDetectors.Value +, + Influencers = propInfluencers.Value +, + Latency = propLatency.Value +, + ModelPruneWindow = propModelPruneWindow.Value +, + MultivariateByFields = propMultivariateByFields.Value +, + PerPartitionCategorization = propPerPartitionCategorization.Value +, + SummaryCountFieldName = propSummaryCountFieldName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, AnalysisConfig value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBucketSpan, value.BucketSpan); + writer.WriteProperty(options, PropCategorizationAnalyzer, value.CategorizationAnalyzer); + writer.WriteProperty(options, PropCategorizationFieldName, value.CategorizationFieldName); + writer.WriteProperty(options, PropCategorizationFilters, value.CategorizationFilters); + writer.WriteProperty(options, PropDetectors, value.Detectors); + writer.WriteProperty(options, PropInfluencers, value.Influencers, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropLatency, value.Latency); + writer.WriteProperty(options, PropModelPruneWindow, value.ModelPruneWindow); + writer.WriteProperty(options, PropMultivariateByFields, value.MultivariateByFields); + writer.WriteProperty(options, PropPerPartitionCategorization, value.PerPartitionCategorization); + writer.WriteProperty(options, PropSummaryCountFieldName, value.SummaryCountFieldName); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(AnalysisConfigConverter))] public sealed partial class AnalysisConfig { /// @@ -35,7 +169,6 @@ public sealed partial class AnalysisConfig /// whole number of buckets in one day. If the anomaly detection job uses a datafeed with aggregations, this value must also be divisible by the interval of the date histogram aggregation. /// /// - [JsonInclude, JsonPropertyName("bucket_span")] public Elastic.Clients.Elasticsearch.Duration? BucketSpan { get; set; } /// @@ -43,7 +176,6 @@ public sealed partial class AnalysisConfig /// If categorization_field_name is specified, you can also define the analyzer that is used to interpret the categorization field. This property cannot be used at the same time as categorization_filters. The categorization analyzer specifies how the categorization_field is interpreted by the categorization process. The categorization_analyzer field can be specified either as a string or as an object. If it is a string, it must refer to a built-in analyzer or one added by another plugin. /// /// - [JsonInclude, JsonPropertyName("categorization_analyzer")] public Elastic.Clients.Elasticsearch.MachineLearning.CategorizationAnalyzer? CategorizationAnalyzer { get; set; } /// @@ -51,7 +183,6 @@ public sealed partial class AnalysisConfig /// If this property is specified, the values of the specified field will be categorized. The resulting categories must be used in a detector by setting by_field_name, over_field_name, or partition_field_name to the keyword mlcategory. /// /// - [JsonInclude, JsonPropertyName("categorization_field_name")] public Elastic.Clients.Elasticsearch.Field? CategorizationFieldName { get; set; } /// @@ -59,7 +190,6 @@ public sealed partial class AnalysisConfig /// If categorization_field_name is specified, you can also define optional filters. This property expects an array of regular expressions. The expressions are used to filter out matching sequences from the categorization field values. You can use this functionality to fine tune the categorization by excluding sequences from consideration when categories are defined. For example, you can exclude SQL statements that appear in your log files. This property cannot be used at the same time as categorization_analyzer. If you only want to define simple regular expression filters that are applied prior to tokenization, setting this property is the easiest method. If you also want to customize the tokenizer or post-tokenization filtering, use the categorization_analyzer property instead and include the filters as pattern_replace character filters. The effect is exactly the same. /// /// - [JsonInclude, JsonPropertyName("categorization_filters")] public ICollection? CategorizationFilters { get; set; } /// @@ -67,7 +197,6 @@ public sealed partial class AnalysisConfig /// Detector configuration objects specify which data fields a job analyzes. They also specify which analytical functions are used. You can specify multiple detectors for a job. If the detectors array does not contain at least one detector, no analysis can occur and an error is returned. /// /// - [JsonInclude, JsonPropertyName("detectors")] public ICollection Detectors { get; set; } /// @@ -75,8 +204,6 @@ public sealed partial class AnalysisConfig /// A comma separated list of influencer field names. Typically these can be the by, over, or partition fields that are used in the detector configuration. You might also want to use a field name that is not specifically named in a detector, but is available as part of the input data. When you use multiple detectors, the use of influencers is recommended as it aggregates results for each influencer entity. /// /// - [JsonInclude, JsonPropertyName("influencers")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Influencers { get; set; } /// @@ -84,7 +211,6 @@ public sealed partial class AnalysisConfig /// The size of the window in which to expect data that is out of time order. If you specify a non-zero value, it must be greater than or equal to one second. NOTE: Latency is applicable only when you send data by using the post data API. /// /// - [JsonInclude, JsonPropertyName("latency")] public Elastic.Clients.Elasticsearch.Duration? Latency { get; set; } /// @@ -92,7 +218,6 @@ public sealed partial class AnalysisConfig /// Advanced configuration option. Affects the pruning of models that have not been updated for the given time duration. The value must be set to a multiple of the bucket_span. If set too low, important information may be removed from the model. For jobs created in 8.1 and later, the default value is the greater of 30d or 20 times bucket_span. /// /// - [JsonInclude, JsonPropertyName("model_prune_window")] public Elastic.Clients.Elasticsearch.Duration? ModelPruneWindow { get; set; } /// @@ -100,7 +225,6 @@ public sealed partial class AnalysisConfig /// This functionality is reserved for internal use. It is not supported for use in customer environments and is not subject to the support SLA of official GA features. If set to true, the analysis will automatically find correlations between metrics for a given by field value and report anomalies when those correlations cease to hold. For example, suppose CPU and memory usage on host A is usually highly correlated with the same metrics on host B. Perhaps this correlation occurs because they are running a load-balanced application. If you enable this property, anomalies will be reported when, for example, CPU usage on host A is high and the value of CPU usage on host B is low. That is to say, you’ll see an anomaly when the CPU of host A is unusual given the CPU of host B. To use the multivariate_by_fields property, you must also specify by_field_name in your detector. /// /// - [JsonInclude, JsonPropertyName("multivariate_by_fields")] public bool? MultivariateByFields { get; set; } /// @@ -108,7 +232,6 @@ public sealed partial class AnalysisConfig /// Settings related to how categorization interacts with partition fields. /// /// - [JsonInclude, JsonPropertyName("per_partition_categorization")] public Elastic.Clients.Elasticsearch.MachineLearning.PerPartitionCategorization? PerPartitionCategorization { get; set; } /// @@ -116,7 +239,6 @@ public sealed partial class AnalysisConfig /// If this property is specified, the data that is fed to the job is expected to be pre-summarized. This property value is the name of the field that contains the count of raw data points that have been summarized. The same summary_count_field_name applies to all detectors in the job. NOTE: The summary_count_field_name property cannot be used with the metric function. /// /// - [JsonInclude, JsonPropertyName("summary_count_field_name")] public Elastic.Clients.Elasticsearch.Field? SummaryCountFieldName { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs index 399bbc72bc7..ed5db155267 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Datafeed.g.cs @@ -27,137 +27,187 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; -internal sealed partial class DatafeedConverter : JsonConverter +internal sealed partial class DatafeedConverter : System.Text.Json.Serialization.JsonConverter { - public override Datafeed Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropAuthorization = System.Text.Json.JsonEncodedText.Encode("authorization"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndexes = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override Datafeed Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyDictionary? aggregations = default; - Elastic.Clients.Elasticsearch.MachineLearning.DatafeedAuthorization? authorization = default; - Elastic.Clients.Elasticsearch.MachineLearning.ChunkingConfig? chunkingConfig = default; - string datafeedId = default; - Elastic.Clients.Elasticsearch.MachineLearning.DelayedDataCheckConfig delayedDataCheckConfig = default; - Elastic.Clients.Elasticsearch.Duration? frequency = default; - IReadOnlyCollection? indexes = default; - IReadOnlyCollection indices = default; - Elastic.Clients.Elasticsearch.IndicesOptions? indicesOptions = default; - string jobId = default; - int? maxEmptySearches = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query query = default; - Elastic.Clients.Elasticsearch.Duration? queryDelay = default; - IReadOnlyDictionary? runtimeMappings = default; - IReadOnlyDictionary? scriptFields = default; - int? scrollSize = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propAuthorization = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue?> propIndexes = default; + LocalJsonValue> propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "authorization") - { - authorization = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - chunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "datafeed_id") - { - datafeedId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - delayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indexes") - { - indexes = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "indices") - { - indices = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "indices_options") - { - indicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - jobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - maxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - queryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - runtimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - scriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - scrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) + { + continue; + } + + if (propAuthorization.TryRead(ref reader, options, PropAuthorization)) + { + continue; + } + + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } + + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } + + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } + + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } + + if (propIndexes.TryRead(ref reader, options, PropIndexes)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } + + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } + + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } + + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } + + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } + + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - return new Datafeed { Aggregations = aggregations, Authorization = authorization, ChunkingConfig = chunkingConfig, DatafeedId = datafeedId, DelayedDataCheckConfig = delayedDataCheckConfig, Frequency = frequency, Indexes = indexes, Indices = indices, IndicesOptions = indicesOptions, JobId = jobId, MaxEmptySearches = maxEmptySearches, Query = query, QueryDelay = queryDelay, RuntimeMappings = runtimeMappings, ScriptFields = scriptFields, ScrollSize = scrollSize }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Datafeed + { + Aggregations = propAggregations.Value +, + Authorization = propAuthorization.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indexes = propIndexes.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; } - public override void Write(Utf8JsonWriter writer, Datafeed value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Datafeed value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'Datafeed' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropAuthorization, value.Authorization); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndexes, value.Indexes); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs index 0402dcefb43..ecddc2ad99e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DatafeedConfig.g.cs @@ -27,194 +27,167 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; -internal sealed partial class DatafeedConfigConverter : JsonConverter +internal sealed partial class DatafeedConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override DatafeedConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAggregations = System.Text.Json.JsonEncodedText.Encode("aggregations"); + private static readonly System.Text.Json.JsonEncodedText PropAggregations1 = System.Text.Json.JsonEncodedText.Encode("aggs"); + private static readonly System.Text.Json.JsonEncodedText PropChunkingConfig = System.Text.Json.JsonEncodedText.Encode("chunking_config"); + private static readonly System.Text.Json.JsonEncodedText PropDatafeedId = System.Text.Json.JsonEncodedText.Encode("datafeed_id"); + private static readonly System.Text.Json.JsonEncodedText PropDelayedDataCheckConfig = System.Text.Json.JsonEncodedText.Encode("delayed_data_check_config"); + private static readonly System.Text.Json.JsonEncodedText PropFrequency = System.Text.Json.JsonEncodedText.Encode("frequency"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIndices1 = System.Text.Json.JsonEncodedText.Encode("indexes"); + private static readonly System.Text.Json.JsonEncodedText PropIndicesOptions = System.Text.Json.JsonEncodedText.Encode("indices_options"); + private static readonly System.Text.Json.JsonEncodedText PropJobId = System.Text.Json.JsonEncodedText.Encode("job_id"); + private static readonly System.Text.Json.JsonEncodedText PropMaxEmptySearches = System.Text.Json.JsonEncodedText.Encode("max_empty_searches"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryDelay = System.Text.Json.JsonEncodedText.Encode("query_delay"); + private static readonly System.Text.Json.JsonEncodedText PropRuntimeMappings = System.Text.Json.JsonEncodedText.Encode("runtime_mappings"); + private static readonly System.Text.Json.JsonEncodedText PropScriptFields = System.Text.Json.JsonEncodedText.Encode("script_fields"); + private static readonly System.Text.Json.JsonEncodedText PropScrollSize = System.Text.Json.JsonEncodedText.Encode("scroll_size"); + + public override DatafeedConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DatafeedConfig(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAggregations = default; + LocalJsonValue propChunkingConfig = default; + LocalJsonValue propDatafeedId = default; + LocalJsonValue propDelayedDataCheckConfig = default; + LocalJsonValue propFrequency = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIndicesOptions = default; + LocalJsonValue propJobId = default; + LocalJsonValue propMaxEmptySearches = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryDelay = default; + LocalJsonValue?> propRuntimeMappings = default; + LocalJsonValue?> propScriptFields = default; + LocalJsonValue propScrollSize = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propAggregations.TryRead(ref reader, options, PropAggregations) || propAggregations.TryRead(ref reader, options, PropAggregations1)) { - var property = reader.GetString(); - if (property == "aggregations" || property == "aggs") - { - variant.Aggregations = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "chunking_config") - { - variant.ChunkingConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "datafeed_id") - { - variant.DatafeedId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "delayed_data_check_config") - { - variant.DelayedDataCheckConfig = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "frequency") - { - variant.Frequency = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices" || property == "indexes") - { - variant.Indices = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "indices_options") - { - variant.IndicesOptions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "job_id") - { - variant.JobId = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_empty_searches") - { - variant.MaxEmptySearches = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query_delay") - { - variant.QueryDelay = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "runtime_mappings") - { - variant.RuntimeMappings = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "script_fields") - { - variant.ScriptFields = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "scroll_size") - { - variant.ScrollSize = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propChunkingConfig.TryRead(ref reader, options, PropChunkingConfig)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DatafeedConfig value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Aggregations is not null) - { - writer.WritePropertyName("aggregations"); - JsonSerializer.Serialize(writer, value.Aggregations, options); - } + if (propDatafeedId.TryRead(ref reader, options, PropDatafeedId)) + { + continue; + } - if (value.ChunkingConfig is not null) - { - writer.WritePropertyName("chunking_config"); - JsonSerializer.Serialize(writer, value.ChunkingConfig, options); - } + if (propDelayedDataCheckConfig.TryRead(ref reader, options, PropDelayedDataCheckConfig)) + { + continue; + } - if (value.DatafeedId is not null) - { - writer.WritePropertyName("datafeed_id"); - JsonSerializer.Serialize(writer, value.DatafeedId, options); - } + if (propFrequency.TryRead(ref reader, options, PropFrequency)) + { + continue; + } - if (value.DelayedDataCheckConfig is not null) - { - writer.WritePropertyName("delayed_data_check_config"); - JsonSerializer.Serialize(writer, value.DelayedDataCheckConfig, options); - } + if (propIndices.TryRead(ref reader, options, PropIndices) || propIndices.TryRead(ref reader, options, PropIndices1)) + { + continue; + } - if (value.Frequency is not null) - { - writer.WritePropertyName("frequency"); - JsonSerializer.Serialize(writer, value.Frequency, options); - } + if (propIndicesOptions.TryRead(ref reader, options, PropIndicesOptions)) + { + continue; + } - if (value.Indices is not null) - { - writer.WritePropertyName("indices"); - JsonSerializer.Serialize(writer, value.Indices, options); - } + if (propJobId.TryRead(ref reader, options, PropJobId)) + { + continue; + } - if (value.IndicesOptions is not null) - { - writer.WritePropertyName("indices_options"); - JsonSerializer.Serialize(writer, value.IndicesOptions, options); - } + if (propMaxEmptySearches.TryRead(ref reader, options, PropMaxEmptySearches)) + { + continue; + } - if (value.JobId is not null) - { - writer.WritePropertyName("job_id"); - JsonSerializer.Serialize(writer, value.JobId, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxEmptySearches.HasValue) - { - writer.WritePropertyName("max_empty_searches"); - writer.WriteNumberValue(value.MaxEmptySearches.Value); - } + if (propQueryDelay.TryRead(ref reader, options, PropQueryDelay)) + { + continue; + } - if (value.Query is not null) - { - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - } + if (propRuntimeMappings.TryRead(ref reader, options, PropRuntimeMappings)) + { + continue; + } - if (value.QueryDelay is not null) - { - writer.WritePropertyName("query_delay"); - JsonSerializer.Serialize(writer, value.QueryDelay, options); - } + if (propScriptFields.TryRead(ref reader, options, PropScriptFields)) + { + continue; + } - if (value.RuntimeMappings is not null) - { - writer.WritePropertyName("runtime_mappings"); - JsonSerializer.Serialize(writer, value.RuntimeMappings, options); - } + if (propScrollSize.TryRead(ref reader, options, PropScrollSize)) + { + continue; + } - if (value.ScriptFields is not null) - { - writer.WritePropertyName("script_fields"); - JsonSerializer.Serialize(writer, value.ScriptFields, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ScrollSize.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DatafeedConfig { - writer.WritePropertyName("scroll_size"); - writer.WriteNumberValue(value.ScrollSize.Value); - } + Aggregations = propAggregations.Value +, + ChunkingConfig = propChunkingConfig.Value +, + DatafeedId = propDatafeedId.Value +, + DelayedDataCheckConfig = propDelayedDataCheckConfig.Value +, + Frequency = propFrequency.Value +, + Indices = propIndices.Value +, + IndicesOptions = propIndicesOptions.Value +, + JobId = propJobId.Value +, + MaxEmptySearches = propMaxEmptySearches.Value +, + Query = propQuery.Value +, + QueryDelay = propQueryDelay.Value +, + RuntimeMappings = propRuntimeMappings.Value +, + ScriptFields = propScriptFields.Value +, + ScrollSize = propScrollSize.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DatafeedConfig value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAggregations, value.Aggregations); + writer.WriteProperty(options, PropChunkingConfig, value.ChunkingConfig); + writer.WriteProperty(options, PropDatafeedId, value.DatafeedId); + writer.WriteProperty(options, PropDelayedDataCheckConfig, value.DelayedDataCheckConfig); + writer.WriteProperty(options, PropFrequency, value.Frequency); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIndicesOptions, value.IndicesOptions); + writer.WriteProperty(options, PropJobId, value.JobId); + writer.WriteProperty(options, PropMaxEmptySearches, value.MaxEmptySearches); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryDelay, value.QueryDelay); + writer.WriteProperty(options, PropRuntimeMappings, value.RuntimeMappings); + writer.WriteProperty(options, PropScriptFields, value.ScriptFields); + writer.WriteProperty(options, PropScrollSize, value.ScrollSize); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs index f7a17f76691..d64bb9fdfae 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysis.g.cs @@ -39,12 +39,16 @@ internal DataframeAnalysis(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeAnalysis() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeAnalysis Classification(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisClassification dataframeAnalysisClassification) => new DataframeAnalysis("classification", dataframeAnalysisClassification); public static DataframeAnalysis OutlierDetection(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection dataframeAnalysisOutlierDetection) => new DataframeAnalysis("outlier_detection", dataframeAnalysisOutlierDetection); @@ -63,77 +67,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeAnalysisConverter : JsonConverter +internal sealed partial class DataframeAnalysisConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysis Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeAnalysis Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeAnalysis' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeAnalysis(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysis { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeAnalysis value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysis value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisClassification?)value.Variant); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisOutlierDetection?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeAnalysis)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs index 0ceb9b0f4e9..59a0a06ff15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisAnalyzedFields.g.cs @@ -27,6 +27,56 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class DataframeAnalysisAnalyzedFieldsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropExcludes = System.Text.Json.JsonEncodedText.Encode("excludes"); + private static readonly System.Text.Json.JsonEncodedText PropIncludes = System.Text.Json.JsonEncodedText.Encode("includes"); + + public override DataframeAnalysisAnalyzedFields Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue>(options); + return new DataframeAnalysisAnalyzedFields { Includes = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propExcludes = default; + LocalJsonValue> propIncludes = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propExcludes.TryRead(ref reader, options, PropExcludes)) + { + continue; + } + + if (propIncludes.TryRead(ref reader, options, PropIncludes)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisAnalyzedFields + { + Excludes = propExcludes.Value +, + Includes = propIncludes.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisAnalyzedFields value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropExcludes, value.Excludes); + writer.WriteProperty(options, PropIncludes, value.Includes); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DataframeAnalysisAnalyzedFieldsConverter))] public sealed partial class DataframeAnalysisAnalyzedFields { /// @@ -34,7 +84,6 @@ public sealed partial class DataframeAnalysisAnalyzedFields /// An array of strings that defines the fields that will be included in the analysis. /// /// - [JsonInclude, JsonPropertyName("excludes")] public ICollection Excludes { get; set; } /// @@ -42,7 +91,6 @@ public sealed partial class DataframeAnalysisAnalyzedFields /// An array of strings that defines the fields that will be excluded from the analysis. You do not need to add fields with unsupported data types to excludes, these fields are excluded from the analysis automatically. /// /// - [JsonInclude, JsonPropertyName("includes")] public ICollection Includes { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs index 06504695f4c..5e87ea4ed0c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisClassification.g.cs @@ -27,262 +27,226 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; -internal sealed partial class DataframeAnalysisClassificationConverter : JsonConverter +internal sealed partial class DataframeAnalysisClassificationConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisClassification Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAlpha = System.Text.Json.JsonEncodedText.Encode("alpha"); + private static readonly System.Text.Json.JsonEncodedText PropClassAssignmentObjective = System.Text.Json.JsonEncodedText.Encode("class_assignment_objective"); + private static readonly System.Text.Json.JsonEncodedText PropDependentVariable = System.Text.Json.JsonEncodedText.Encode("dependent_variable"); + private static readonly System.Text.Json.JsonEncodedText PropDownsampleFactor = System.Text.Json.JsonEncodedText.Encode("downsample_factor"); + private static readonly System.Text.Json.JsonEncodedText PropEarlyStoppingEnabled = System.Text.Json.JsonEncodedText.Encode("early_stopping_enabled"); + private static readonly System.Text.Json.JsonEncodedText PropEta = System.Text.Json.JsonEncodedText.Encode("eta"); + private static readonly System.Text.Json.JsonEncodedText PropEtaGrowthRatePerTree = System.Text.Json.JsonEncodedText.Encode("eta_growth_rate_per_tree"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureBagFraction = System.Text.Json.JsonEncodedText.Encode("feature_bag_fraction"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureProcessors = System.Text.Json.JsonEncodedText.Encode("feature_processors"); + private static readonly System.Text.Json.JsonEncodedText PropGamma = System.Text.Json.JsonEncodedText.Encode("gamma"); + private static readonly System.Text.Json.JsonEncodedText PropLambda = System.Text.Json.JsonEncodedText.Encode("lambda"); + private static readonly System.Text.Json.JsonEncodedText PropMaxOptimizationRoundsPerHyperparameter = System.Text.Json.JsonEncodedText.Encode("max_optimization_rounds_per_hyperparameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees = System.Text.Json.JsonEncodedText.Encode("max_trees"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees1 = System.Text.Json.JsonEncodedText.Encode("maximum_number_trees"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopClasses = System.Text.Json.JsonEncodedText.Encode("num_top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopFeatureImportanceValues = System.Text.Json.JsonEncodedText.Encode("num_top_feature_importance_values"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionFieldName = System.Text.Json.JsonEncodedText.Encode("prediction_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropRandomizeSeed = System.Text.Json.JsonEncodedText.Encode("randomize_seed"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthLimit = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthTolerance = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_tolerance"); + private static readonly System.Text.Json.JsonEncodedText PropTrainingPercent = System.Text.Json.JsonEncodedText.Encode("training_percent"); + + public override DataframeAnalysisClassification Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DataframeAnalysisClassification(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAlpha = default; + LocalJsonValue propClassAssignmentObjective = default; + LocalJsonValue propDependentVariable = default; + LocalJsonValue propDownsampleFactor = default; + LocalJsonValue propEarlyStoppingEnabled = default; + LocalJsonValue propEta = default; + LocalJsonValue propEtaGrowthRatePerTree = default; + LocalJsonValue propFeatureBagFraction = default; + LocalJsonValue?> propFeatureProcessors = default; + LocalJsonValue propGamma = default; + LocalJsonValue propLambda = default; + LocalJsonValue propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonValue propMaxTrees = default; + LocalJsonValue propNumTopClasses = default; + LocalJsonValue propNumTopFeatureImportanceValues = default; + LocalJsonValue propPredictionFieldName = default; + LocalJsonValue propRandomizeSeed = default; + LocalJsonValue propSoftTreeDepthLimit = default; + LocalJsonValue propSoftTreeDepthTolerance = default; + LocalJsonValue propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryRead(ref reader, options, PropAlpha)) { - var property = reader.GetString(); - if (property == "alpha") - { - variant.Alpha = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "class_assignment_objective") - { - variant.ClassAssignmentObjective = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "dependent_variable") - { - variant.DependentVariable = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "downsample_factor") - { - variant.DownsampleFactor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "early_stopping_enabled") - { - variant.EarlyStoppingEnabled = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta") - { - variant.Eta = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta_growth_rate_per_tree") - { - variant.EtaGrowthRatePerTree = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_bag_fraction") - { - variant.FeatureBagFraction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_processors") - { - variant.FeatureProcessors = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "gamma") - { - variant.Gamma = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lambda") - { - variant.Lambda = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_optimization_rounds_per_hyperparameter") - { - variant.MaxOptimizationRoundsPerHyperparameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_trees" || property == "maximum_number_trees") - { - variant.MaxTrees = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_classes") - { - variant.NumTopClasses = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_feature_importance_values") - { - variant.NumTopFeatureImportanceValues = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prediction_field_name") - { - variant.PredictionFieldName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "randomize_seed") - { - variant.RandomizeSeed = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_limit") - { - variant.SoftTreeDepthLimit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_tolerance") - { - variant.SoftTreeDepthTolerance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "training_percent") - { - variant.TrainingPercent = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propClassAssignmentObjective.TryRead(ref reader, options, PropClassAssignmentObjective)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisClassification value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Alpha.HasValue) - { - writer.WritePropertyName("alpha"); - writer.WriteNumberValue(value.Alpha.Value); - } + if (propDependentVariable.TryRead(ref reader, options, PropDependentVariable)) + { + continue; + } - if (!string.IsNullOrEmpty(value.ClassAssignmentObjective)) - { - writer.WritePropertyName("class_assignment_objective"); - writer.WriteStringValue(value.ClassAssignmentObjective); - } + if (propDownsampleFactor.TryRead(ref reader, options, PropDownsampleFactor)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryRead(ref reader, options, PropEarlyStoppingEnabled)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryRead(ref reader, options, PropEta)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryRead(ref reader, options, PropEtaGrowthRatePerTree)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryRead(ref reader, options, PropFeatureBagFraction)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryRead(ref reader, options, PropFeatureProcessors)) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryRead(ref reader, options, PropGamma)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryRead(ref reader, options, PropLambda)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryRead(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryRead(ref reader, options, PropMaxTrees) || propMaxTrees.TryRead(ref reader, options, PropMaxTrees1)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopClasses.TryRead(ref reader, options, PropNumTopClasses)) + { + continue; + } - if (value.NumTopClasses.HasValue) - { - writer.WritePropertyName("num_top_classes"); - writer.WriteNumberValue(value.NumTopClasses.Value); - } + if (propNumTopFeatureImportanceValues.TryRead(ref reader, options, PropNumTopFeatureImportanceValues)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryRead(ref reader, options, PropPredictionFieldName)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryRead(ref reader, options, PropRandomizeSeed)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryRead(ref reader, options, PropSoftTreeDepthLimit)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryRead(ref reader, options, PropSoftTreeDepthTolerance)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryRead(ref reader, options, PropTrainingPercent)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisClassification + { + Alpha = propAlpha.Value +, + ClassAssignmentObjective = propClassAssignmentObjective.Value +, + DependentVariable = propDependentVariable.Value +, + DownsampleFactor = propDownsampleFactor.Value +, + EarlyStoppingEnabled = propEarlyStoppingEnabled.Value +, + Eta = propEta.Value +, + EtaGrowthRatePerTree = propEtaGrowthRatePerTree.Value +, + FeatureBagFraction = propFeatureBagFraction.Value +, + FeatureProcessors = propFeatureProcessors.Value +, + Gamma = propGamma.Value +, + Lambda = propLambda.Value +, + MaxOptimizationRoundsPerHyperparameter = propMaxOptimizationRoundsPerHyperparameter.Value +, + MaxTrees = propMaxTrees.Value +, + NumTopClasses = propNumTopClasses.Value +, + NumTopFeatureImportanceValues = propNumTopFeatureImportanceValues.Value +, + PredictionFieldName = propPredictionFieldName.Value +, + RandomizeSeed = propRandomizeSeed.Value +, + SoftTreeDepthLimit = propSoftTreeDepthLimit.Value +, + SoftTreeDepthTolerance = propSoftTreeDepthTolerance.Value +, + TrainingPercent = propTrainingPercent.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisClassification value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlpha, value.Alpha); + writer.WriteProperty(options, PropClassAssignmentObjective, value.ClassAssignmentObjective); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled); + writer.WriteProperty(options, PropEta, value.Eta); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors); + writer.WriteProperty(options, PropGamma, value.Gamma); + writer.WriteProperty(options, PropLambda, value.Lambda); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees); + writer.WriteProperty(options, PropNumTopClasses, value.NumTopClasses); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs index 68a0de314d1..248ff0b3a66 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisFeatureProcessor.g.cs @@ -39,12 +39,16 @@ internal DataframeAnalysisFeatureProcessor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeAnalysisFeatureProcessor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeAnalysisFeatureProcessor FrequencyEncoding(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding dataframeAnalysisFeatureProcessorFrequencyEncoding) => new DataframeAnalysisFeatureProcessor("frequency_encoding", dataframeAnalysisFeatureProcessorFrequencyEncoding); public static DataframeAnalysisFeatureProcessor MultiEncoding(Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding dataframeAnalysisFeatureProcessorMultiEncoding) => new DataframeAnalysisFeatureProcessor("multi_encoding", dataframeAnalysisFeatureProcessorMultiEncoding); @@ -65,97 +69,92 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeAnalysisFeatureProcessorConverter : JsonConverter +internal sealed partial class DataframeAnalysisFeatureProcessorConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisFeatureProcessor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantFrequencyEncoding = System.Text.Json.JsonEncodedText.Encode("frequency_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiEncoding = System.Text.Json.JsonEncodedText.Encode("multi_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantNGramEncoding = System.Text.Json.JsonEncodedText.Encode("n_gram_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantOneHotEncoding = System.Text.Json.JsonEncodedText.Encode("one_hot_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantTargetMeanEncoding = System.Text.Json.JsonEncodedText.Encode("target_mean_encoding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeAnalysisFeatureProcessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantFrequencyEncoding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_encoding") + if (reader.ValueTextEquals(VariantMultiEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "n_gram_encoding") + if (reader.ValueTextEquals(VariantNGramEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNGramEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "target_mean_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeAnalysisFeatureProcessor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeAnalysisFeatureProcessor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisFeatureProcessor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisFeatureProcessor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisFeatureProcessor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "frequency_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding)value.Variant, options); - break; - case "multi_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding)value.Variant, options); - break; - case "n_gram_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorFrequencyEncoding?)value.Variant); + break; + case "multi_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorMultiEncoding?)value.Variant); + break; + case "n_gram_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorNGramEncoding?)value.Variant); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorOneHotEncoding?)value.Variant); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeAnalysisFeatureProcessorTargetMeanEncoding?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeAnalysisFeatureProcessor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs index 33f1f359972..2e76fd3748d 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeAnalysisRegression.g.cs @@ -27,262 +27,226 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; -internal sealed partial class DataframeAnalysisRegressionConverter : JsonConverter +internal sealed partial class DataframeAnalysisRegressionConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeAnalysisRegression Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAlpha = System.Text.Json.JsonEncodedText.Encode("alpha"); + private static readonly System.Text.Json.JsonEncodedText PropDependentVariable = System.Text.Json.JsonEncodedText.Encode("dependent_variable"); + private static readonly System.Text.Json.JsonEncodedText PropDownsampleFactor = System.Text.Json.JsonEncodedText.Encode("downsample_factor"); + private static readonly System.Text.Json.JsonEncodedText PropEarlyStoppingEnabled = System.Text.Json.JsonEncodedText.Encode("early_stopping_enabled"); + private static readonly System.Text.Json.JsonEncodedText PropEta = System.Text.Json.JsonEncodedText.Encode("eta"); + private static readonly System.Text.Json.JsonEncodedText PropEtaGrowthRatePerTree = System.Text.Json.JsonEncodedText.Encode("eta_growth_rate_per_tree"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureBagFraction = System.Text.Json.JsonEncodedText.Encode("feature_bag_fraction"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureProcessors = System.Text.Json.JsonEncodedText.Encode("feature_processors"); + private static readonly System.Text.Json.JsonEncodedText PropGamma = System.Text.Json.JsonEncodedText.Encode("gamma"); + private static readonly System.Text.Json.JsonEncodedText PropLambda = System.Text.Json.JsonEncodedText.Encode("lambda"); + private static readonly System.Text.Json.JsonEncodedText PropLossFunction = System.Text.Json.JsonEncodedText.Encode("loss_function"); + private static readonly System.Text.Json.JsonEncodedText PropLossFunctionParameter = System.Text.Json.JsonEncodedText.Encode("loss_function_parameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxOptimizationRoundsPerHyperparameter = System.Text.Json.JsonEncodedText.Encode("max_optimization_rounds_per_hyperparameter"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees = System.Text.Json.JsonEncodedText.Encode("max_trees"); + private static readonly System.Text.Json.JsonEncodedText PropMaxTrees1 = System.Text.Json.JsonEncodedText.Encode("maximum_number_trees"); + private static readonly System.Text.Json.JsonEncodedText PropNumTopFeatureImportanceValues = System.Text.Json.JsonEncodedText.Encode("num_top_feature_importance_values"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionFieldName = System.Text.Json.JsonEncodedText.Encode("prediction_field_name"); + private static readonly System.Text.Json.JsonEncodedText PropRandomizeSeed = System.Text.Json.JsonEncodedText.Encode("randomize_seed"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthLimit = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_limit"); + private static readonly System.Text.Json.JsonEncodedText PropSoftTreeDepthTolerance = System.Text.Json.JsonEncodedText.Encode("soft_tree_depth_tolerance"); + private static readonly System.Text.Json.JsonEncodedText PropTrainingPercent = System.Text.Json.JsonEncodedText.Encode("training_percent"); + + public override DataframeAnalysisRegression Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DataframeAnalysisRegression(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAlpha = default; + LocalJsonValue propDependentVariable = default; + LocalJsonValue propDownsampleFactor = default; + LocalJsonValue propEarlyStoppingEnabled = default; + LocalJsonValue propEta = default; + LocalJsonValue propEtaGrowthRatePerTree = default; + LocalJsonValue propFeatureBagFraction = default; + LocalJsonValue?> propFeatureProcessors = default; + LocalJsonValue propGamma = default; + LocalJsonValue propLambda = default; + LocalJsonValue propLossFunction = default; + LocalJsonValue propLossFunctionParameter = default; + LocalJsonValue propMaxOptimizationRoundsPerHyperparameter = default; + LocalJsonValue propMaxTrees = default; + LocalJsonValue propNumTopFeatureImportanceValues = default; + LocalJsonValue propPredictionFieldName = default; + LocalJsonValue propRandomizeSeed = default; + LocalJsonValue propSoftTreeDepthLimit = default; + LocalJsonValue propSoftTreeDepthTolerance = default; + LocalJsonValue propTrainingPercent = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlpha.TryRead(ref reader, options, PropAlpha)) { - var property = reader.GetString(); - if (property == "alpha") - { - variant.Alpha = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "dependent_variable") - { - variant.DependentVariable = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "downsample_factor") - { - variant.DownsampleFactor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "early_stopping_enabled") - { - variant.EarlyStoppingEnabled = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta") - { - variant.Eta = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "eta_growth_rate_per_tree") - { - variant.EtaGrowthRatePerTree = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_bag_fraction") - { - variant.FeatureBagFraction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "feature_processors") - { - variant.FeatureProcessors = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "gamma") - { - variant.Gamma = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lambda") - { - variant.Lambda = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "loss_function") - { - variant.LossFunction = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "loss_function_parameter") - { - variant.LossFunctionParameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_optimization_rounds_per_hyperparameter") - { - variant.MaxOptimizationRoundsPerHyperparameter = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_trees" || property == "maximum_number_trees") - { - variant.MaxTrees = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "num_top_feature_importance_values") - { - variant.NumTopFeatureImportanceValues = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prediction_field_name") - { - variant.PredictionFieldName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "randomize_seed") - { - variant.RandomizeSeed = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_limit") - { - variant.SoftTreeDepthLimit = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "soft_tree_depth_tolerance") - { - variant.SoftTreeDepthTolerance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "training_percent") - { - variant.TrainingPercent = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - return variant; - } + if (propDependentVariable.TryRead(ref reader, options, PropDependentVariable)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DataframeAnalysisRegression value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Alpha.HasValue) - { - writer.WritePropertyName("alpha"); - writer.WriteNumberValue(value.Alpha.Value); - } + if (propDownsampleFactor.TryRead(ref reader, options, PropDownsampleFactor)) + { + continue; + } - writer.WritePropertyName("dependent_variable"); - writer.WriteStringValue(value.DependentVariable); - if (value.DownsampleFactor.HasValue) - { - writer.WritePropertyName("downsample_factor"); - writer.WriteNumberValue(value.DownsampleFactor.Value); - } + if (propEarlyStoppingEnabled.TryRead(ref reader, options, PropEarlyStoppingEnabled)) + { + continue; + } - if (value.EarlyStoppingEnabled.HasValue) - { - writer.WritePropertyName("early_stopping_enabled"); - writer.WriteBooleanValue(value.EarlyStoppingEnabled.Value); - } + if (propEta.TryRead(ref reader, options, PropEta)) + { + continue; + } - if (value.Eta.HasValue) - { - writer.WritePropertyName("eta"); - writer.WriteNumberValue(value.Eta.Value); - } + if (propEtaGrowthRatePerTree.TryRead(ref reader, options, PropEtaGrowthRatePerTree)) + { + continue; + } - if (value.EtaGrowthRatePerTree.HasValue) - { - writer.WritePropertyName("eta_growth_rate_per_tree"); - writer.WriteNumberValue(value.EtaGrowthRatePerTree.Value); - } + if (propFeatureBagFraction.TryRead(ref reader, options, PropFeatureBagFraction)) + { + continue; + } - if (value.FeatureBagFraction.HasValue) - { - writer.WritePropertyName("feature_bag_fraction"); - writer.WriteNumberValue(value.FeatureBagFraction.Value); - } + if (propFeatureProcessors.TryRead(ref reader, options, PropFeatureProcessors)) + { + continue; + } - if (value.FeatureProcessors is not null) - { - writer.WritePropertyName("feature_processors"); - JsonSerializer.Serialize(writer, value.FeatureProcessors, options); - } + if (propGamma.TryRead(ref reader, options, PropGamma)) + { + continue; + } - if (value.Gamma.HasValue) - { - writer.WritePropertyName("gamma"); - writer.WriteNumberValue(value.Gamma.Value); - } + if (propLambda.TryRead(ref reader, options, PropLambda)) + { + continue; + } - if (value.Lambda.HasValue) - { - writer.WritePropertyName("lambda"); - writer.WriteNumberValue(value.Lambda.Value); - } + if (propLossFunction.TryRead(ref reader, options, PropLossFunction)) + { + continue; + } - if (!string.IsNullOrEmpty(value.LossFunction)) - { - writer.WritePropertyName("loss_function"); - writer.WriteStringValue(value.LossFunction); - } + if (propLossFunctionParameter.TryRead(ref reader, options, PropLossFunctionParameter)) + { + continue; + } - if (value.LossFunctionParameter.HasValue) - { - writer.WritePropertyName("loss_function_parameter"); - writer.WriteNumberValue(value.LossFunctionParameter.Value); - } + if (propMaxOptimizationRoundsPerHyperparameter.TryRead(ref reader, options, PropMaxOptimizationRoundsPerHyperparameter)) + { + continue; + } - if (value.MaxOptimizationRoundsPerHyperparameter.HasValue) - { - writer.WritePropertyName("max_optimization_rounds_per_hyperparameter"); - writer.WriteNumberValue(value.MaxOptimizationRoundsPerHyperparameter.Value); - } + if (propMaxTrees.TryRead(ref reader, options, PropMaxTrees) || propMaxTrees.TryRead(ref reader, options, PropMaxTrees1)) + { + continue; + } - if (value.MaxTrees.HasValue) - { - writer.WritePropertyName("max_trees"); - writer.WriteNumberValue(value.MaxTrees.Value); - } + if (propNumTopFeatureImportanceValues.TryRead(ref reader, options, PropNumTopFeatureImportanceValues)) + { + continue; + } - if (value.NumTopFeatureImportanceValues.HasValue) - { - writer.WritePropertyName("num_top_feature_importance_values"); - writer.WriteNumberValue(value.NumTopFeatureImportanceValues.Value); - } + if (propPredictionFieldName.TryRead(ref reader, options, PropPredictionFieldName)) + { + continue; + } - if (value.PredictionFieldName is not null) - { - writer.WritePropertyName("prediction_field_name"); - JsonSerializer.Serialize(writer, value.PredictionFieldName, options); - } + if (propRandomizeSeed.TryRead(ref reader, options, PropRandomizeSeed)) + { + continue; + } - if (value.RandomizeSeed.HasValue) - { - writer.WritePropertyName("randomize_seed"); - writer.WriteNumberValue(value.RandomizeSeed.Value); - } + if (propSoftTreeDepthLimit.TryRead(ref reader, options, PropSoftTreeDepthLimit)) + { + continue; + } - if (value.SoftTreeDepthLimit.HasValue) - { - writer.WritePropertyName("soft_tree_depth_limit"); - writer.WriteNumberValue(value.SoftTreeDepthLimit.Value); - } + if (propSoftTreeDepthTolerance.TryRead(ref reader, options, PropSoftTreeDepthTolerance)) + { + continue; + } - if (value.SoftTreeDepthTolerance.HasValue) - { - writer.WritePropertyName("soft_tree_depth_tolerance"); - writer.WriteNumberValue(value.SoftTreeDepthTolerance.Value); - } + if (propTrainingPercent.TryRead(ref reader, options, PropTrainingPercent)) + { + continue; + } - if (value.TrainingPercent.HasValue) - { - writer.WritePropertyName("training_percent"); - writer.WriteNumberValue(value.TrainingPercent.Value); - } + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeAnalysisRegression + { + Alpha = propAlpha.Value +, + DependentVariable = propDependentVariable.Value +, + DownsampleFactor = propDownsampleFactor.Value +, + EarlyStoppingEnabled = propEarlyStoppingEnabled.Value +, + Eta = propEta.Value +, + EtaGrowthRatePerTree = propEtaGrowthRatePerTree.Value +, + FeatureBagFraction = propFeatureBagFraction.Value +, + FeatureProcessors = propFeatureProcessors.Value +, + Gamma = propGamma.Value +, + Lambda = propLambda.Value +, + LossFunction = propLossFunction.Value +, + LossFunctionParameter = propLossFunctionParameter.Value +, + MaxOptimizationRoundsPerHyperparameter = propMaxOptimizationRoundsPerHyperparameter.Value +, + MaxTrees = propMaxTrees.Value +, + NumTopFeatureImportanceValues = propNumTopFeatureImportanceValues.Value +, + PredictionFieldName = propPredictionFieldName.Value +, + RandomizeSeed = propRandomizeSeed.Value +, + SoftTreeDepthLimit = propSoftTreeDepthLimit.Value +, + SoftTreeDepthTolerance = propSoftTreeDepthTolerance.Value +, + TrainingPercent = propTrainingPercent.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeAnalysisRegression value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlpha, value.Alpha); + writer.WriteProperty(options, PropDependentVariable, value.DependentVariable); + writer.WriteProperty(options, PropDownsampleFactor, value.DownsampleFactor); + writer.WriteProperty(options, PropEarlyStoppingEnabled, value.EarlyStoppingEnabled); + writer.WriteProperty(options, PropEta, value.Eta); + writer.WriteProperty(options, PropEtaGrowthRatePerTree, value.EtaGrowthRatePerTree); + writer.WriteProperty(options, PropFeatureBagFraction, value.FeatureBagFraction); + writer.WriteProperty(options, PropFeatureProcessors, value.FeatureProcessors); + writer.WriteProperty(options, PropGamma, value.Gamma); + writer.WriteProperty(options, PropLambda, value.Lambda); + writer.WriteProperty(options, PropLossFunction, value.LossFunction); + writer.WriteProperty(options, PropLossFunctionParameter, value.LossFunctionParameter); + writer.WriteProperty(options, PropMaxOptimizationRoundsPerHyperparameter, value.MaxOptimizationRoundsPerHyperparameter); + writer.WriteProperty(options, PropMaxTrees, value.MaxTrees); + writer.WriteProperty(options, PropNumTopFeatureImportanceValues, value.NumTopFeatureImportanceValues); + writer.WriteProperty(options, PropPredictionFieldName, value.PredictionFieldName); + writer.WriteProperty(options, PropRandomizeSeed, value.RandomizeSeed); + writer.WriteProperty(options, PropSoftTreeDepthLimit, value.SoftTreeDepthLimit); + writer.WriteProperty(options, PropSoftTreeDepthTolerance, value.SoftTreeDepthTolerance); + writer.WriteProperty(options, PropTrainingPercent, value.TrainingPercent); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs index 28d0462487e..297616d9ae1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/DataframeEvaluation.g.cs @@ -39,12 +39,16 @@ internal DataframeEvaluation(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DataframeEvaluation() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DataframeEvaluation Classification(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassification dataframeEvaluationClassification) => new DataframeEvaluation("classification", dataframeEvaluationClassification); public static DataframeEvaluation OutlierDetection(Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection dataframeEvaluationOutlierDetection) => new DataframeEvaluation("outlier_detection", dataframeEvaluationOutlierDetection); @@ -63,77 +67,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DataframeEvaluationConverter : JsonConverter +internal sealed partial class DataframeEvaluationConverter : System.Text.Json.Serialization.JsonConverter { - public override DataframeEvaluation Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantOutlierDetection = System.Text.Json.JsonEncodedText.Encode("outlier_detection"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override DataframeEvaluation Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "outlier_detection") + if (reader.ValueTextEquals(VariantOutlierDetection)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOutlierDetection.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DataframeEvaluation' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DataframeEvaluation(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DataframeEvaluation { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, DataframeEvaluation value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DataframeEvaluation value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassification)value.Variant, options); - break; - case "outlier_detection": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationRegression)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationClassification?)value.Variant); + break; + case "outlier_detection": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationOutlierDetection?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.DataframeEvaluationRegression?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DataframeEvaluation)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs index 7521192e9fc..eb7b873bd00 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigCreate.g.cs @@ -44,12 +44,16 @@ internal InferenceConfigCreate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfigCreate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfigCreate Classification(Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigCreate("classification", classificationInferenceOptions); public static InferenceConfigCreate FillMask(Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions fillMaskInferenceOptions) => new InferenceConfigCreate("fill_mask", fillMaskInferenceOptions); @@ -75,147 +79,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigCreateConverter : JsonConverter +internal sealed partial class InferenceConfigCreateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfigCreate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantFillMask = System.Text.Json.JsonEncodedText.Encode("fill_mask"); + private static readonly System.Text.Json.JsonEncodedText VariantNer = System.Text.Json.JsonEncodedText.Encode("ner"); + private static readonly System.Text.Json.JsonEncodedText VariantPassThrough = System.Text.Json.JsonEncodedText.Encode("pass_through"); + private static readonly System.Text.Json.JsonEncodedText VariantQuestionAnswering = System.Text.Json.JsonEncodedText.Encode("question_answering"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + private static readonly System.Text.Json.JsonEncodedText VariantTextClassification = System.Text.Json.JsonEncodedText.Encode("text_classification"); + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText VariantTextExpansion = System.Text.Json.JsonEncodedText.Encode("text_expansion"); + private static readonly System.Text.Json.JsonEncodedText VariantZeroShotClassification = System.Text.Json.JsonEncodedText.Encode("zero_shot_classification"); + + public override InferenceConfigCreate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "zero_shot_classification") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfigCreate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfigCreate(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfigCreate { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfigCreate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfigCreate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceOptions?)value.Variant); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceOptions?)value.Variant); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceOptions?)value.Variant); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceOptions?)value.Variant); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceOptions?)value.Variant); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceOptions?)value.Variant); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfigCreate)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs index fea26716443..6669dc939e6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceConfigUpdate.g.cs @@ -39,12 +39,16 @@ internal InferenceConfigUpdate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal InferenceConfigUpdate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static InferenceConfigUpdate Classification(Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions classificationInferenceOptions) => new InferenceConfigUpdate("classification", classificationInferenceOptions); public static InferenceConfigUpdate FillMask(Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions fillMaskInferenceUpdateOptions) => new InferenceConfigUpdate("fill_mask", fillMaskInferenceUpdateOptions); @@ -70,147 +74,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class InferenceConfigUpdateConverter : JsonConverter +internal sealed partial class InferenceConfigUpdateConverter : System.Text.Json.Serialization.JsonConverter { - public override InferenceConfigUpdate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantClassification = System.Text.Json.JsonEncodedText.Encode("classification"); + private static readonly System.Text.Json.JsonEncodedText VariantFillMask = System.Text.Json.JsonEncodedText.Encode("fill_mask"); + private static readonly System.Text.Json.JsonEncodedText VariantNer = System.Text.Json.JsonEncodedText.Encode("ner"); + private static readonly System.Text.Json.JsonEncodedText VariantPassThrough = System.Text.Json.JsonEncodedText.Encode("pass_through"); + private static readonly System.Text.Json.JsonEncodedText VariantQuestionAnswering = System.Text.Json.JsonEncodedText.Encode("question_answering"); + private static readonly System.Text.Json.JsonEncodedText VariantRegression = System.Text.Json.JsonEncodedText.Encode("regression"); + private static readonly System.Text.Json.JsonEncodedText VariantTextClassification = System.Text.Json.JsonEncodedText.Encode("text_classification"); + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); + private static readonly System.Text.Json.JsonEncodedText VariantTextExpansion = System.Text.Json.JsonEncodedText.Encode("text_expansion"); + private static readonly System.Text.Json.JsonEncodedText VariantZeroShotClassification = System.Text.Json.JsonEncodedText.Encode("zero_shot_classification"); + + public override InferenceConfigUpdate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantClassification)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "classification") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fill_mask") + if (reader.ValueTextEquals(VariantFillMask)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFillMask.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ner") + if (reader.ValueTextEquals(VariantNer)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNer.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pass_through") + if (reader.ValueTextEquals(VariantPassThrough)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPassThrough.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "question_answering") + if (reader.ValueTextEquals(VariantQuestionAnswering)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQuestionAnswering.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regression") + if (reader.ValueTextEquals(VariantRegression)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegression.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_classification") + if (reader.ValueTextEquals(VariantTextClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_embedding") + if (reader.ValueTextEquals(VariantTextEmbedding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_expansion") + if (reader.ValueTextEquals(VariantTextExpansion)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextExpansion.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "zero_shot_classification") + if (reader.ValueTextEquals(VariantZeroShotClassification)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantZeroShotClassification.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'InferenceConfigUpdate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new InferenceConfigUpdate(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceConfigUpdate { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, InferenceConfigUpdate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceConfigUpdate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions)value.Variant, options); - break; - case "fill_mask": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions)value.Variant, options); - break; - case "ner": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceUpdateOptions)value.Variant, options); - break; - case "pass_through": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceUpdateOptions)value.Variant, options); - break; - case "question_answering": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceUpdateOptions)value.Variant, options); - break; - case "regression": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions)value.Variant, options); - break; - case "text_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceUpdateOptions)value.Variant, options); - break; - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceUpdateOptions)value.Variant, options); - break; - case "text_expansion": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceUpdateOptions)value.Variant, options); - break; - case "zero_shot_classification": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceUpdateOptions)value.Variant, options); - break; - } + case "": + break; + case "classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ClassificationInferenceOptions?)value.Variant); + break; + case "fill_mask": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FillMaskInferenceUpdateOptions?)value.Variant); + break; + case "ner": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NerInferenceUpdateOptions?)value.Variant); + break; + case "pass_through": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.PassThroughInferenceUpdateOptions?)value.Variant); + break; + case "question_answering": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.QuestionAnsweringInferenceUpdateOptions?)value.Variant); + break; + case "regression": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.RegressionInferenceOptions?)value.Variant); + break; + case "text_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextClassificationInferenceUpdateOptions?)value.Variant); + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextEmbeddingInferenceUpdateOptions?)value.Variant); + break; + case "text_expansion": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TextExpansionInferenceUpdateOptions?)value.Variant); + break; + case "zero_shot_classification": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.ZeroShotClassificationInferenceUpdateOptions?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(InferenceConfigUpdate)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs index afa959c72f1..d80a8cb21eb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/InferenceResponseResult.g.cs @@ -27,6 +27,120 @@ namespace Elastic.Clients.Elasticsearch.MachineLearning; +internal sealed partial class InferenceResponseResultConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropEntities = System.Text.Json.JsonEncodedText.Encode("entities"); + private static readonly System.Text.Json.JsonEncodedText PropFeatureImportance = System.Text.Json.JsonEncodedText.Encode("feature_importance"); + private static readonly System.Text.Json.JsonEncodedText PropIsTruncated = System.Text.Json.JsonEncodedText.Encode("is_truncated"); + private static readonly System.Text.Json.JsonEncodedText PropPredictedValue = System.Text.Json.JsonEncodedText.Encode("predicted_value"); + private static readonly System.Text.Json.JsonEncodedText PropPredictedValueSequence = System.Text.Json.JsonEncodedText.Encode("predicted_value_sequence"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionProbability = System.Text.Json.JsonEncodedText.Encode("prediction_probability"); + private static readonly System.Text.Json.JsonEncodedText PropPredictionScore = System.Text.Json.JsonEncodedText.Encode("prediction_score"); + private static readonly System.Text.Json.JsonEncodedText PropTopClasses = System.Text.Json.JsonEncodedText.Encode("top_classes"); + private static readonly System.Text.Json.JsonEncodedText PropWarning = System.Text.Json.JsonEncodedText.Encode("warning"); + + public override InferenceResponseResult Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propEntities = default; + LocalJsonValue?> propFeatureImportance = default; + LocalJsonValue propIsTruncated = default; + LocalJsonValue?> propPredictedValue = default; + LocalJsonValue propPredictedValueSequence = default; + LocalJsonValue propPredictionProbability = default; + LocalJsonValue propPredictionScore = default; + LocalJsonValue?> propTopClasses = default; + LocalJsonValue propWarning = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propEntities.TryRead(ref reader, options, PropEntities)) + { + continue; + } + + if (propFeatureImportance.TryRead(ref reader, options, PropFeatureImportance)) + { + continue; + } + + if (propIsTruncated.TryRead(ref reader, options, PropIsTruncated)) + { + continue; + } + + if (propPredictedValue.TryRead(ref reader, options, PropPredictedValue, typeof(SingleOrManyMarker?, object>))) + { + continue; + } + + if (propPredictedValueSequence.TryRead(ref reader, options, PropPredictedValueSequence)) + { + continue; + } + + if (propPredictionProbability.TryRead(ref reader, options, PropPredictionProbability)) + { + continue; + } + + if (propPredictionScore.TryRead(ref reader, options, PropPredictionScore)) + { + continue; + } + + if (propTopClasses.TryRead(ref reader, options, PropTopClasses)) + { + continue; + } + + if (propWarning.TryRead(ref reader, options, PropWarning)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new InferenceResponseResult + { + Entities = propEntities.Value +, + FeatureImportance = propFeatureImportance.Value +, + IsTruncated = propIsTruncated.Value +, + PredictedValue = propPredictedValue.Value +, + PredictedValueSequence = propPredictedValueSequence.Value +, + PredictionProbability = propPredictionProbability.Value +, + PredictionScore = propPredictionScore.Value +, + TopClasses = propTopClasses.Value +, + Warning = propWarning.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, InferenceResponseResult value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropEntities, value.Entities); + writer.WriteProperty(options, PropFeatureImportance, value.FeatureImportance); + writer.WriteProperty(options, PropIsTruncated, value.IsTruncated); + writer.WriteProperty(options, PropPredictedValue, value.PredictedValue, null, typeof(SingleOrManyMarker?, object>)); + writer.WriteProperty(options, PropPredictedValueSequence, value.PredictedValueSequence); + writer.WriteProperty(options, PropPredictionProbability, value.PredictionProbability); + writer.WriteProperty(options, PropPredictionScore, value.PredictionScore); + writer.WriteProperty(options, PropTopClasses, value.TopClasses); + writer.WriteProperty(options, PropWarning, value.Warning); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(InferenceResponseResultConverter))] public sealed partial class InferenceResponseResult { /// @@ -34,7 +148,6 @@ public sealed partial class InferenceResponseResult /// If the model is trained for named entity recognition (NER) tasks, the response contains the recognized entities. /// /// - [JsonInclude, JsonPropertyName("entities")] public IReadOnlyCollection? Entities { get; init; } /// @@ -42,7 +155,6 @@ public sealed partial class InferenceResponseResult /// The feature importance for the inference results. Relevant only for classification or regression models /// /// - [JsonInclude, JsonPropertyName("feature_importance")] public IReadOnlyCollection? FeatureImportance { get; init; } /// @@ -51,7 +163,6 @@ public sealed partial class InferenceResponseResult /// is present only when it is true. /// /// - [JsonInclude, JsonPropertyName("is_truncated")] public bool? IsTruncated { get; init; } /// @@ -65,8 +176,6 @@ public sealed partial class InferenceResponseResult /// For classification models, it may be an integer, double, boolean or string depending on prediction type /// /// - [JsonInclude, JsonPropertyName("predicted_value")] - [SingleOrManyCollectionConverter(typeof(object))] public IReadOnlyCollection? PredictedValue { get; init; } /// @@ -76,7 +185,6 @@ public sealed partial class InferenceResponseResult /// Additionally /// /// - [JsonInclude, JsonPropertyName("predicted_value_sequence")] public string? PredictedValueSequence { get; init; } /// @@ -84,7 +192,6 @@ public sealed partial class InferenceResponseResult /// Specifies a probability for the predicted value. /// /// - [JsonInclude, JsonPropertyName("prediction_probability")] public double? PredictionProbability { get; init; } /// @@ -92,7 +199,6 @@ public sealed partial class InferenceResponseResult /// Specifies a confidence score for the predicted value. /// /// - [JsonInclude, JsonPropertyName("prediction_score")] public double? PredictionScore { get; init; } /// @@ -101,7 +207,6 @@ public sealed partial class InferenceResponseResult /// class entries. /// /// - [JsonInclude, JsonPropertyName("top_classes")] public IReadOnlyCollection? TopClasses { get; init; } /// @@ -109,6 +214,5 @@ public sealed partial class InferenceResponseResult /// If the request failed, the response contains the reason for the failure. /// /// - [JsonInclude, JsonPropertyName("warning")] public string? Warning { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs index c20929f486d..9bfb41f2fb1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/Preprocessor.g.cs @@ -39,12 +39,16 @@ internal Preprocessor(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Preprocessor() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Preprocessor FrequencyEncoding(Elastic.Clients.Elasticsearch.MachineLearning.FrequencyEncodingPreprocessor frequencyEncodingPreprocessor) => new Preprocessor("frequency_encoding", frequencyEncodingPreprocessor); public static Preprocessor OneHotEncoding(Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor oneHotEncodingPreprocessor) => new Preprocessor("one_hot_encoding", oneHotEncodingPreprocessor); @@ -63,77 +67,68 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class PreprocessorConverter : JsonConverter +internal sealed partial class PreprocessorConverter : System.Text.Json.Serialization.JsonConverter { - public override Preprocessor Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantFrequencyEncoding = System.Text.Json.JsonEncodedText.Encode("frequency_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantOneHotEncoding = System.Text.Json.JsonEncodedText.Encode("one_hot_encoding"); + private static readonly System.Text.Json.JsonEncodedText VariantTargetMeanEncoding = System.Text.Json.JsonEncodedText.Encode("target_mean_encoding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Preprocessor Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantFrequencyEncoding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "frequency_encoding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFrequencyEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "one_hot_encoding") + if (reader.ValueTextEquals(VariantOneHotEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOneHotEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "target_mean_encoding") + if (reader.ValueTextEquals(VariantTargetMeanEncoding)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTargetMeanEncoding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Preprocessor' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Preprocessor(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Preprocessor { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Preprocessor value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Preprocessor value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "frequency_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.FrequencyEncodingPreprocessor)value.Variant, options); - break; - case "one_hot_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor)value.Variant, options); - break; - case "target_mean_encoding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.TargetMeanEncodingPreprocessor)value.Variant, options); - break; - } + case "": + break; + case "frequency_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.FrequencyEncodingPreprocessor?)value.Variant); + break; + case "one_hot_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.OneHotEncodingPreprocessor?)value.Variant); + break; + case "target_mean_encoding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.TargetMeanEncodingPreprocessor?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Preprocessor)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs index e3dc630aebf..2ce0eb632d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/MachineLearning/TokenizationConfig.g.cs @@ -44,12 +44,16 @@ internal TokenizationConfig(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal TokenizationConfig() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static TokenizationConfig Bert(Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert", nlpBertTokenizationConfig); public static TokenizationConfig BertJa(Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig nlpBertTokenizationConfig) => new TokenizationConfig("bert_ja", nlpBertTokenizationConfig); @@ -69,87 +73,80 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class TokenizationConfigConverter : JsonConverter +internal sealed partial class TokenizationConfigConverter : System.Text.Json.Serialization.JsonConverter { - public override TokenizationConfig Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantBert = System.Text.Json.JsonEncodedText.Encode("bert"); + private static readonly System.Text.Json.JsonEncodedText VariantBertJa = System.Text.Json.JsonEncodedText.Encode("bert_ja"); + private static readonly System.Text.Json.JsonEncodedText VariantMpnet = System.Text.Json.JsonEncodedText.Encode("mpnet"); + private static readonly System.Text.Json.JsonEncodedText VariantRoberta = System.Text.Json.JsonEncodedText.Encode("roberta"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override TokenizationConfig Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantBert)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bert") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBert.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "bert_ja") + if (reader.ValueTextEquals(VariantBertJa)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBertJa.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "mpnet") + if (reader.ValueTextEquals(VariantMpnet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMpnet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "roberta") + if (reader.ValueTextEquals(VariantRoberta)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRoberta.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'TokenizationConfig' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new TokenizationConfig(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TokenizationConfig { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, TokenizationConfig value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenizationConfig value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "bert": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "bert_ja": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "mpnet": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig)value.Variant, options); - break; - case "roberta": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.MachineLearning.NlpRobertaTokenizationConfig)value.Variant, options); - break; - } + case "": + break; + case "bert": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "bert_ja": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "mpnet": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpBertTokenizationConfig?)value.Variant); + break; + case "roberta": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.MachineLearning.NlpRobertaTokenizationConfig?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(TokenizationConfig)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs index a27bb3c9071..91d8d285087 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BinaryProperty.g.cs @@ -27,18 +27,124 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class BinaryPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BinaryProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BinaryProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BinaryProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BinaryPropertyConverter))] public sealed partial class BinaryProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +152,10 @@ public sealed partial class BinaryProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "binary"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs index f0f377e59a1..772f489d408 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/BooleanProperty.g.cs @@ -27,24 +27,167 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class BooleanPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override BooleanProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BooleanProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fielddata = propFielddata.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BooleanProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BooleanPropertyConverter))] public sealed partial class BooleanProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,16 +195,11 @@ public sealed partial class BooleanProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public bool? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "boolean"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs index 71d104cab4c..d13cec1153f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ByteNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class ByteNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ByteNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ByteNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ByteNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ByteNumberPropertyConverter))] public sealed partial class ByteNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class ByteNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public byte? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class ByteNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class ByteNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "byte"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs index c0074fde8a4..f9ab35df7ce 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/CompletionProperty.g.cs @@ -27,24 +27,187 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class CompletionPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropContexts = System.Text.Json.JsonEncodedText.Encode("contexts"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMaxInputLength = System.Text.Json.JsonEncodedText.Encode("max_input_length"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropPreservePositionIncrements = System.Text.Json.JsonEncodedText.Encode("preserve_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropPreserveSeparators = System.Text.Json.JsonEncodedText.Encode("preserve_separators"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override CompletionProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue?> propContexts = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propMaxInputLength = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPreservePositionIncrements = default; + LocalJsonValue propPreserveSeparators = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propContexts.TryRead(ref reader, options, PropContexts)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMaxInputLength.TryRead(ref reader, options, PropMaxInputLength)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPreservePositionIncrements.TryRead(ref reader, options, PropPreservePositionIncrements)) + { + continue; + } + + if (propPreserveSeparators.TryRead(ref reader, options, PropPreserveSeparators)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CompletionProperty + { + Analyzer = propAnalyzer.Value +, + Contexts = propContexts.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + MaxInputLength = propMaxInputLength.Value +, + Meta = propMeta.Value +, + PreservePositionIncrements = propPreservePositionIncrements.Value +, + PreserveSeparators = propPreserveSeparators.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CompletionProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropContexts, value.Contexts); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMaxInputLength, value.MaxInputLength); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPreservePositionIncrements, value.PreservePositionIncrements); + writer.WriteProperty(options, PropPreserveSeparators, value.PreserveSeparators); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CompletionPropertyConverter))] public sealed partial class CompletionProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("contexts")] public ICollection? Contexts { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("max_input_length")] public int? MaxInputLength { get; set; } /// @@ -52,20 +215,13 @@ public sealed partial class CompletionProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("preserve_position_increments")] public bool? PreservePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("preserve_separators")] public bool? PreserveSeparators { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "completion"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs index fab89d7abb4..75200efa6f7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateNanosProperty.g.cs @@ -27,26 +27,188 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DateNanosPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateNanosProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateNanosProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateNanosProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateNanosPropertyConverter))] public sealed partial class DateNanosProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,18 +216,12 @@ public sealed partial class DateNanosProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public DateTimeOffset? NullValue { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date_nanos"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs index 39b0ac3fdaa..fce1561a280 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateProperty.g.cs @@ -27,30 +27,210 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DatePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropLocale = System.Text.Json.JsonEncodedText.Encode("locale"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue propLocale = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propLocale.TryRead(ref reader, options, PropLocale)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fielddata = propFielddata.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Locale = propLocale.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropLocale, value.Locale); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DatePropertyConverter))] public sealed partial class DateProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public Elastic.Clients.Elasticsearch.IndexManagement.NumericFielddata? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("locale")] public string? Locale { get; set; } /// @@ -58,18 +238,12 @@ public sealed partial class DateProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public DateTimeOffset? NullValue { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs index bb5b8d54471..99348490c4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DateRangeProperty.g.cs @@ -27,26 +27,168 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DateRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DateRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DateRangePropertyConverter))] public sealed partial class DateRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,14 +196,10 @@ public sealed partial class DateRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "date_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs index 923e630d9fa..330f5abc868 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DoubleNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DoubleNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DoubleNumberPropertyConverter))] public sealed partial class DoubleNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class DoubleNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class DoubleNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class DoubleNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "double"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs index 4c0c6868967..4262e523988 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DoubleRangeProperty.g.cs @@ -27,24 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DoubleRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DoubleRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DoubleRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DoubleRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DoubleRangePropertyConverter))] public sealed partial class DoubleRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +185,10 @@ public sealed partial class DoubleRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "double_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs index e44d585e58d..4ca48fb1efb 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicProperty.g.cs @@ -27,42 +27,356 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class DynamicPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPhrases = System.Text.Json.JsonEncodedText.Encode("index_phrases"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPrefixes = System.Text.Json.JsonEncodedText.Encode("index_prefixes"); + private static readonly System.Text.Json.JsonEncodedText PropLocale = System.Text.Json.JsonEncodedText.Encode("locale"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropPrecisionStep = System.Text.Json.JsonEncodedText.Encode("precision_step"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override DynamicProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propIndexPhrases = default; + LocalJsonValue propIndexPrefixes = default; + LocalJsonValue propLocale = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propPrecisionStep = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propIndexPhrases.TryRead(ref reader, options, PropIndexPhrases)) + { + continue; + } + + if (propIndexPrefixes.TryRead(ref reader, options, PropIndexPrefixes)) + { + continue; + } + + if (propLocale.TryRead(ref reader, options, PropLocale)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propPrecisionStep.TryRead(ref reader, options, PropPrecisionStep)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DynamicProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + Format = propFormat.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + IndexPhrases = propIndexPhrases.Value +, + IndexPrefixes = propIndexPrefixes.Value +, + Locale = propLocale.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + PrecisionStep = propPrecisionStep.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes); + writer.WriteProperty(options, PropLocale, value.Locale); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropPrecisionStep, value.PrecisionStep); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(DynamicPropertyConverter))] public sealed partial class DynamicProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } - [JsonInclude, JsonPropertyName("locale")] public string? Locale { get; set; } /// @@ -70,34 +384,20 @@ public sealed partial class DynamicProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public Elastic.Clients.Elasticsearch.FieldValue? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("precision_step")] public int? PrecisionStep { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "{dynamic_type}"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs index fa40241afaa..63f6dcfe5ec 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/DynamicTemplate.g.cs @@ -39,12 +39,16 @@ internal DynamicTemplate(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal DynamicTemplate() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static DynamicTemplate Mapping(Elastic.Clients.Elasticsearch.Mapping.IProperty property) => new DynamicTemplate("mapping", property); public static DynamicTemplate Runtime(Elastic.Clients.Elasticsearch.Mapping.IProperty property) => new DynamicTemplate("runtime", property); @@ -77,167 +81,131 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class DynamicTemplateConverter : JsonConverter +internal sealed partial class DynamicTemplateConverter : System.Text.Json.Serialization.JsonConverter { - public override DynamicTemplate Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText PropMatchMappingType = System.Text.Json.JsonEncodedText.Encode("match_mapping_type"); + private static readonly System.Text.Json.JsonEncodedText PropMatchPattern = System.Text.Json.JsonEncodedText.Encode("match_pattern"); + private static readonly System.Text.Json.JsonEncodedText PropPathMatch = System.Text.Json.JsonEncodedText.Encode("path_match"); + private static readonly System.Text.Json.JsonEncodedText PropPathUnmatch = System.Text.Json.JsonEncodedText.Encode("path_unmatch"); + private static readonly System.Text.Json.JsonEncodedText PropUnmatch = System.Text.Json.JsonEncodedText.Encode("unmatch"); + private static readonly System.Text.Json.JsonEncodedText PropUnmatchMappingType = System.Text.Json.JsonEncodedText.Encode("unmatch_mapping_type"); + private static readonly System.Text.Json.JsonEncodedText VariantMapping = System.Text.Json.JsonEncodedText.Encode("mapping"); + private static readonly System.Text.Json.JsonEncodedText VariantRuntime = System.Text.Json.JsonEncodedText.Encode("runtime"); + + public override DynamicTemplate Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - ICollection? matchValue = default; - ICollection? matchMappingTypeValue = default; - Elastic.Clients.Elasticsearch.Mapping.MatchType? matchPatternValue = default; - ICollection? pathMatchValue = default; - ICollection? pathUnmatchValue = default; - ICollection? unmatchValue = default; - ICollection? unmatchMappingTypeValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propMatch = default; + LocalJsonValue?> propMatchMappingType = default; + LocalJsonValue propMatchPattern = default; + LocalJsonValue?> propPathMatch = default; + LocalJsonValue?> propPathUnmatch = default; + LocalJsonValue?> propUnmatch = default; + LocalJsonValue?> propUnmatchMappingType = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "match") + if (propMatch.TryRead(ref reader, options, PropMatch, typeof(SingleOrManyMarker?, string>))) { - matchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_mapping_type") + if (propMatchMappingType.TryRead(ref reader, options, PropMatchMappingType, typeof(SingleOrManyMarker?, string>))) { - matchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "match_pattern") + if (propMatchPattern.TryRead(ref reader, options, PropMatchPattern)) { - matchPatternValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "path_match") + if (propPathMatch.TryRead(ref reader, options, PropPathMatch, typeof(SingleOrManyMarker?, string>))) { - pathMatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "path_unmatch") + if (propPathUnmatch.TryRead(ref reader, options, PropPathUnmatch, typeof(SingleOrManyMarker?, string>))) { - pathUnmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch") + if (propUnmatch.TryRead(ref reader, options, PropUnmatch, typeof(SingleOrManyMarker?, string>))) { - unmatchValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "unmatch_mapping_type") + if (propUnmatchMappingType.TryRead(ref reader, options, PropUnmatchMappingType, typeof(SingleOrManyMarker?, string>))) { - unmatchMappingTypeValue = SingleOrManySerializationHelper.Deserialize(ref reader, options); continue; } - if (propertyName == "mapping") + if (reader.ValueTextEquals(VariantMapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "runtime") + if (reader.ValueTextEquals(VariantRuntime)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRuntime.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'DynamicTemplate' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new DynamicTemplate(variantNameValue, variantValue); - result.Match = matchValue; - result.MatchMappingType = matchMappingTypeValue; - result.MatchPattern = matchPatternValue; - result.PathMatch = pathMatchValue; - result.PathUnmatch = pathUnmatchValue; - result.Unmatch = unmatchValue; - result.UnmatchMappingType = unmatchMappingTypeValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DynamicTemplate + { + VariantType = variantType, + Variant = variant, + Match = propMatch.Value +, + MatchMappingType = propMatchMappingType.Value +, + MatchPattern = propMatchPattern.Value +, + PathMatch = propPathMatch.Value +, + PathUnmatch = propPathUnmatch.Value +, + Unmatch = propUnmatch.Value +, + UnmatchMappingType = propUnmatchMappingType.Value + }; } - public override void Write(Utf8JsonWriter writer, DynamicTemplate value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, DynamicTemplate value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Match is not null) - { - writer.WritePropertyName("match"); - SingleOrManySerializationHelper.Serialize(value.Match, writer, options); - } - - if (value.MatchMappingType is not null) + switch (value.VariantType) { - writer.WritePropertyName("match_mapping_type"); - SingleOrManySerializationHelper.Serialize(value.MatchMappingType, writer, options); - } - - if (value.MatchPattern is not null) - { - writer.WritePropertyName("match_pattern"); - JsonSerializer.Serialize(writer, value.MatchPattern, options); - } - - if (value.PathMatch is not null) - { - writer.WritePropertyName("path_match"); - SingleOrManySerializationHelper.Serialize(value.PathMatch, writer, options); - } - - if (value.PathUnmatch is not null) - { - writer.WritePropertyName("path_unmatch"); - SingleOrManySerializationHelper.Serialize(value.PathUnmatch, writer, options); - } - - if (value.Unmatch is not null) - { - writer.WritePropertyName("unmatch"); - SingleOrManySerializationHelper.Serialize(value.Unmatch, writer, options); - } - - if (value.UnmatchMappingType is not null) - { - writer.WritePropertyName("unmatch_mapping_type"); - SingleOrManySerializationHelper.Serialize(value.UnmatchMappingType, writer, options); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "mapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Mapping.IProperty)value.Variant, options); - break; - case "runtime": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Mapping.IProperty)value.Variant, options); - break; - } + case "": + break; + case "mapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Mapping.IProperty?)value.Variant); + break; + case "runtime": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Mapping.IProperty?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(DynamicTemplate)}'."); } + writer.WriteProperty(options, PropMatch, value.Match, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMatchMappingType, value.MatchMappingType, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropMatchPattern, value.MatchPattern); + writer.WriteProperty(options, PropPathMatch, value.PathMatch, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropPathUnmatch, value.PathUnmatch, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnmatch, value.Unmatch, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnmatchMappingType, value.UnmatchMappingType, null, typeof(SingleOrManyMarker?, string>)); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs index 78b51afb62b..2d0d0c269ff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class FloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FloatNumberPropertyConverter))] public sealed partial class FloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class FloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public float? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class FloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class FloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs index baba3f12be0..869453c9788 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/FloatRangeProperty.g.cs @@ -27,24 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class FloatRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override FloatRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FloatRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FloatRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FloatRangePropertyConverter))] public sealed partial class FloatRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +185,10 @@ public sealed partial class FloatRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "float_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs index 8151792a3a9..ebde09aa985 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoPointProperty.g.cs @@ -27,24 +27,187 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class GeoPointPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GeoPointProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoPointProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoPointProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(GeoPointPropertyConverter))] public sealed partial class GeoPointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,20 +215,13 @@ public sealed partial class GeoPointProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public Elastic.Clients.Elasticsearch.GeoLocation? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "geo_point"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs index 0563e2b83b6..5dfc2f33673 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/GeoShapeProperty.g.cs @@ -27,6 +27,167 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class GeoShapePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropOrientation = System.Text.Json.JsonEncodedText.Encode("orientation"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropStrategy = System.Text.Json.JsonEncodedText.Encode("strategy"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override GeoShapeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propOrientation = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propStrategy = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propOrientation.TryRead(ref reader, options, PropOrientation)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propStrategy.TryRead(ref reader, options, PropStrategy)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoShapeProperty + { + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + Orientation = propOrientation.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + Strategy = propStrategy.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropOrientation, value.Orientation); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropStrategy, value.Strategy); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// The geo_shape data type facilitates the indexing of and searching with arbitrary geo shapes such as rectangles @@ -34,24 +195,16 @@ namespace Elastic.Clients.Elasticsearch.Mapping; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(GeoShapePropertyConverter))] public sealed partial class GeoShapeProperty : IProperty { - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -59,18 +212,12 @@ public sealed partial class GeoShapeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("orientation")] public Elastic.Clients.Elasticsearch.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("strategy")] public Elastic.Clients.Elasticsearch.Mapping.GeoStrategy? Strategy { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "geo_shape"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs index 5dadc17bb15..a742f089505 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/HalfFloatNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class HalfFloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override HalfFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HalfFloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HalfFloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HalfFloatNumberPropertyConverter))] public sealed partial class HalfFloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public float? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class HalfFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "half_float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs index 5acfa164441..48f84bd3d60 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IcuCollationProperty.g.cs @@ -27,30 +27,290 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class IcuCollationPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAlternate = System.Text.Json.JsonEncodedText.Encode("alternate"); + private static readonly System.Text.Json.JsonEncodedText PropCaseFirst = System.Text.Json.JsonEncodedText.Encode("case_first"); + private static readonly System.Text.Json.JsonEncodedText PropCaseLevel = System.Text.Json.JsonEncodedText.Encode("case_level"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropCountry = System.Text.Json.JsonEncodedText.Encode("country"); + private static readonly System.Text.Json.JsonEncodedText PropDecomposition = System.Text.Json.JsonEncodedText.Encode("decomposition"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropHiraganaQuaternaryMode = System.Text.Json.JsonEncodedText.Encode("hiragana_quaternary_mode"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropLanguage = System.Text.Json.JsonEncodedText.Encode("language"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropNumeric = System.Text.Json.JsonEncodedText.Encode("numeric"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropRules = System.Text.Json.JsonEncodedText.Encode("rules"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropStrength = System.Text.Json.JsonEncodedText.Encode("strength"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropVariableTop = System.Text.Json.JsonEncodedText.Encode("variable_top"); + private static readonly System.Text.Json.JsonEncodedText PropVariant = System.Text.Json.JsonEncodedText.Encode("variant"); + + public override IcuCollationProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAlternate = default; + LocalJsonValue propCaseFirst = default; + LocalJsonValue propCaseLevel = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propCountry = default; + LocalJsonValue propDecomposition = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propHiraganaQuaternaryMode = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propLanguage = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propNumeric = default; + LocalJsonValue propProperties = default; + LocalJsonValue propRules = default; + LocalJsonValue propStore = default; + LocalJsonValue propStrength = default; + LocalJsonValue propVariableTop = default; + LocalJsonValue propVariant = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAlternate.TryRead(ref reader, options, PropAlternate)) + { + continue; + } + + if (propCaseFirst.TryRead(ref reader, options, PropCaseFirst)) + { + continue; + } + + if (propCaseLevel.TryRead(ref reader, options, PropCaseLevel)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propCountry.TryRead(ref reader, options, PropCountry)) + { + continue; + } + + if (propDecomposition.TryRead(ref reader, options, PropDecomposition)) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propHiraganaQuaternaryMode.TryRead(ref reader, options, PropHiraganaQuaternaryMode)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propLanguage.TryRead(ref reader, options, PropLanguage)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propNumeric.TryRead(ref reader, options, PropNumeric)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propRules.TryRead(ref reader, options, PropRules)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propStrength.TryRead(ref reader, options, PropStrength)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + if (propVariableTop.TryRead(ref reader, options, PropVariableTop)) + { + continue; + } + + if (propVariant.TryRead(ref reader, options, PropVariant)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IcuCollationProperty + { + Alternate = propAlternate.Value +, + CaseFirst = propCaseFirst.Value +, + CaseLevel = propCaseLevel.Value +, + CopyTo = propCopyTo.Value +, + Country = propCountry.Value +, + Decomposition = propDecomposition.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + HiraganaQuaternaryMode = propHiraganaQuaternaryMode.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + Language = propLanguage.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + Numeric = propNumeric.Value +, + Properties = propProperties.Value +, + Rules = propRules.Value +, + Store = propStore.Value +, + Strength = propStrength.Value +, + VariableTop = propVariableTop.Value +, + Variant = propVariant.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IcuCollationProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAlternate, value.Alternate); + writer.WriteProperty(options, PropCaseFirst, value.CaseFirst); + writer.WriteProperty(options, PropCaseLevel, value.CaseLevel); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropCountry, value.Country); + writer.WriteProperty(options, PropDecomposition, value.Decomposition); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropHiraganaQuaternaryMode, value.HiraganaQuaternaryMode); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropLanguage, value.Language); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropNumeric, value.Numeric); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropRules, value.Rules); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropStrength, value.Strength); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropVariableTop, value.VariableTop); + writer.WriteProperty(options, PropVariant, value.Variant); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IcuCollationPropertyConverter))] public sealed partial class IcuCollationProperty : IProperty { - [JsonInclude, JsonPropertyName("alternate")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? Alternate { get; set; } - [JsonInclude, JsonPropertyName("case_first")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? CaseFirst { get; set; } - [JsonInclude, JsonPropertyName("case_level")] public bool? CaseLevel { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("country")] public string? Country { get; set; } - [JsonInclude, JsonPropertyName("decomposition")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? Decomposition { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("hiragana_quaternary_mode")] public bool? HiraganaQuaternaryMode { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -58,11 +318,8 @@ public sealed partial class IcuCollationProperty : IProperty /// Should the field be searchable? /// /// - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("language")] public string? Language { get; set; } /// @@ -70,9 +327,7 @@ public sealed partial class IcuCollationProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } /// @@ -80,25 +335,16 @@ public sealed partial class IcuCollationProperty : IProperty /// Accepts a string value which is substituted for any explicit null values. Defaults to null, which means the field is treated as missing. /// /// - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("numeric")] public bool? Numeric { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("rules")] public string? Rules { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("strength")] public Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? Strength { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "icu_collation_keyword"; - [JsonInclude, JsonPropertyName("variable_top")] public string? VariableTop { get; set; } - [JsonInclude, JsonPropertyName("variant")] public string? Variant { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs index 8d2512bed63..b44ae1898f0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class IntegerNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IntegerNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntegerNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntegerNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IntegerNumberPropertyConverter))] public sealed partial class IntegerNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class IntegerNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public int? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class IntegerNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class IntegerNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "integer"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs index 47b66fc7aaf..363239caf0a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IntegerRangeProperty.g.cs @@ -27,24 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class IntegerRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IntegerRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntegerRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntegerRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IntegerRangePropertyConverter))] public sealed partial class IntegerRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +185,10 @@ public sealed partial class IntegerRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "integer_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs index 8a4ebec39cb..a1823457a83 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpProperty.g.cs @@ -27,24 +27,197 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class IpPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IpProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IpPropertyConverter))] public sealed partial class IpProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,17 +225,11 @@ public sealed partial class IpProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -70,10 +237,8 @@ public sealed partial class IpProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "ip"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs index d714a86ad87..0d550f57f9f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/IpRangeProperty.g.cs @@ -27,24 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class IpRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IpRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IpRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IpRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(IpRangePropertyConverter))] public sealed partial class IpRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +185,10 @@ public sealed partial class IpRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "ip_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs index 8b3f61ce264..993b9286702 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/KeywordProperty.g.cs @@ -27,26 +27,248 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class KeywordPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNormalizer = System.Text.Json.JsonEncodedText.Encode("normalizer"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropSplitQueriesOnWhitespace = System.Text.Json.JsonEncodedText.Encode("split_queries_on_whitespace"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override KeywordProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNormalizer = default; + LocalJsonValue propNorms = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propSplitQueriesOnWhitespace = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNormalizer.TryRead(ref reader, options, PropNormalizer)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propSplitQueriesOnWhitespace.TryRead(ref reader, options, PropSplitQueriesOnWhitespace)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new KeywordProperty + { + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + Meta = propMeta.Value +, + Normalizer = propNormalizer.Value +, + Norms = propNorms.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Similarity = propSimilarity.Value +, + SplitQueriesOnWhitespace = propSplitQueriesOnWhitespace.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, KeywordProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNormalizer, value.Normalizer); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropSplitQueriesOnWhitespace, value.SplitQueriesOnWhitespace); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(KeywordPropertyConverter))] public sealed partial class KeywordProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Mapping.IndexOptions? IndexOptions { get; set; } /// @@ -54,25 +276,15 @@ public sealed partial class KeywordProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("normalizer")] public string? Normalizer { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("split_queries_on_whitespace")] public bool? SplitQueriesOnWhitespace { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -80,10 +292,8 @@ public sealed partial class KeywordProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "keyword"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs index e2454a28973..65abfda4149 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class LongNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LongNumberPropertyConverter))] public sealed partial class LongNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class LongNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public long? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class LongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class LongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "long"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs index 301a1c2d56a..e8103f4f78e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/LongRangeProperty.g.cs @@ -27,24 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class LongRangePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override LongRangeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LongRangeProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LongRangeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LongRangePropertyConverter))] public sealed partial class LongRangeProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -52,14 +185,10 @@ public sealed partial class LongRangeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "long_range"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs index 4f7566ec1b8..02026da912a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/MatchOnlyTextProperty.g.cs @@ -27,6 +27,67 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class MatchOnlyTextPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override MatchOnlyTextProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propFields = default; + LocalJsonValue?> propMeta = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchOnlyTextProperty + { + CopyTo = propCopyTo.Value +, + Fields = propFields.Value +, + Meta = propMeta.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchOnlyTextProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// A variant of text that trades scoring and efficiency of positional queries for space efficiency. This field @@ -36,6 +97,7 @@ namespace Elastic.Clients.Elasticsearch.Mapping; /// to verify whether a phrase matches. All queries return constant scores that are equal to 1.0. /// /// +[JsonConverter(typeof(MatchOnlyTextPropertyConverter))] public sealed partial class MatchOnlyTextProperty : IProperty { /// @@ -44,8 +106,6 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// field, which can then be queried as a single field. /// /// - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } /// @@ -54,7 +114,6 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// field for search and a multi-field for sorting and aggregations, or the same string value analyzed by different analyzers. /// /// - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } /// @@ -62,10 +121,8 @@ public sealed partial class MatchOnlyTextProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "match_only_text"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs index 13bf5f0c702..89e0fe2beb0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Murmur3HashProperty.g.cs @@ -27,18 +27,124 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class Murmur3HashPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override Murmur3HashProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Murmur3HashProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Murmur3HashProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(Murmur3HashPropertyConverter))] public sealed partial class Murmur3HashProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +152,10 @@ public sealed partial class Murmur3HashProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "murmur3"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs index 959c90ccf45..d61d5d1c5dd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/NestedProperty.g.cs @@ -27,22 +27,146 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class NestedPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeInParent = System.Text.Json.JsonEncodedText.Encode("include_in_parent"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeInRoot = System.Text.Json.JsonEncodedText.Encode("include_in_root"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NestedProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIncludeInParent = default; + LocalJsonValue propIncludeInRoot = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIncludeInParent.TryRead(ref reader, options, PropIncludeInParent)) + { + continue; + } + + if (propIncludeInRoot.TryRead(ref reader, options, PropIncludeInRoot)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NestedProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IncludeInParent = propIncludeInParent.Value +, + IncludeInRoot = propIncludeInRoot.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NestedProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIncludeInParent, value.IncludeInParent); + writer.WriteProperty(options, PropIncludeInRoot, value.IncludeInRoot); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NestedPropertyConverter))] public sealed partial class NestedProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("include_in_parent")] public bool? IncludeInParent { get; set; } - [JsonInclude, JsonPropertyName("include_in_root")] public bool? IncludeInRoot { get; set; } /// @@ -50,14 +174,10 @@ public sealed partial class NestedProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "nested"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs index 72b364f5dea..af89f403681 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ObjectProperty.g.cs @@ -27,18 +27,134 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class ObjectPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropSubobjects = System.Text.Json.JsonEncodedText.Encode("subobjects"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ObjectProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propSubobjects = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propSubobjects.TryRead(ref reader, options, PropSubobjects)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ObjectProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + Subobjects = propSubobjects.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ObjectProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropSubobjects, value.Subobjects); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ObjectPropertyConverter))] public sealed partial class ObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +162,11 @@ public sealed partial class ObjectProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("subobjects")] public bool? Subobjects { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "object"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs index db4a8355410..835cd772668 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PassthroughObjectProperty.g.cs @@ -27,18 +27,144 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class PassthroughObjectPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnabled = System.Text.Json.JsonEncodedText.Encode("enabled"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PassthroughObjectProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnabled = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propPriority = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnabled.TryRead(ref reader, options, PropEnabled)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PassthroughObjectProperty + { + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Enabled = propEnabled.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Priority = propPriority.Value +, + Properties = propProperties.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PassthroughObjectProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnabled, value.Enabled); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PassthroughObjectPropertyConverter))] public sealed partial class PassthroughObjectProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enabled")] public bool? Enabled { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,18 +172,12 @@ public sealed partial class PassthroughObjectProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "passthrough"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs index b02111781c2..ce8f384617e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/PointProperty.g.cs @@ -27,22 +27,156 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class PointPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override PointProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PointProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, PointProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(PointPropertyConverter))] public sealed partial class PointProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -50,16 +184,11 @@ public sealed partial class PointProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "point"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs index b3b3c49457d..373dac809c6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/Properties.g.cs @@ -318,289 +318,238 @@ public PropertiesDescriptor() : base(new Properties()) public PropertiesDescriptor Wildcard(Expression> propertyName, Action> configure) => AssignVariant, WildcardProperty>(propertyName, configure); } -internal sealed partial class PropertyInterfaceConverter : JsonConverter +internal sealed partial class PropertyInterfaceConverter : System.Text.Json.Serialization.JsonConverter { - public override IProperty Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropDiscriminator = System.Text.Json.JsonEncodedText.Encode("type"); + + public override IProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - var copiedReader = reader; - string? type = null; - using var jsonDoc = JsonDocument.ParseValue(ref copiedReader); - if (jsonDoc is not null && jsonDoc.RootElement.TryGetProperty("type", out var readType) && readType.ValueKind == JsonValueKind.String) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var readerSnapshot = reader; + string? discriminator = "object"; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - type = readType.ToString(); + if (reader.TryReadProperty(options, PropDiscriminator, ref discriminator)) + { + break; + } + + reader.Skip(); } - switch (type) + reader = readerSnapshot; + return discriminator switch { - case "aggregate_metric_double": - return JsonSerializer.Deserialize(ref reader, options); - case "binary": - return JsonSerializer.Deserialize(ref reader, options); - case "boolean": - return JsonSerializer.Deserialize(ref reader, options); - case "byte": - return JsonSerializer.Deserialize(ref reader, options); - case "completion": - return JsonSerializer.Deserialize(ref reader, options); - case "constant_keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "date_nanos": - return JsonSerializer.Deserialize(ref reader, options); - case "date": - return JsonSerializer.Deserialize(ref reader, options); - case "date_range": - return JsonSerializer.Deserialize(ref reader, options); - case "dense_vector": - return JsonSerializer.Deserialize(ref reader, options); - case "double": - return JsonSerializer.Deserialize(ref reader, options); - case "double_range": - return JsonSerializer.Deserialize(ref reader, options); - case "{dynamic_type}": - return JsonSerializer.Deserialize(ref reader, options); - case "alias": - return JsonSerializer.Deserialize(ref reader, options); - case "flattened": - return JsonSerializer.Deserialize(ref reader, options); - case "float": - return JsonSerializer.Deserialize(ref reader, options); - case "float_range": - return JsonSerializer.Deserialize(ref reader, options); - case "geo_point": - return JsonSerializer.Deserialize(ref reader, options); - case "geo_shape": - return JsonSerializer.Deserialize(ref reader, options); - case "half_float": - return JsonSerializer.Deserialize(ref reader, options); - case "histogram": - return JsonSerializer.Deserialize(ref reader, options); - case "icu_collation_keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "integer": - return JsonSerializer.Deserialize(ref reader, options); - case "integer_range": - return JsonSerializer.Deserialize(ref reader, options); - case "ip": - return JsonSerializer.Deserialize(ref reader, options); - case "ip_range": - return JsonSerializer.Deserialize(ref reader, options); - case "join": - return JsonSerializer.Deserialize(ref reader, options); - case "keyword": - return JsonSerializer.Deserialize(ref reader, options); - case "long": - return JsonSerializer.Deserialize(ref reader, options); - case "long_range": - return JsonSerializer.Deserialize(ref reader, options); - case "match_only_text": - return JsonSerializer.Deserialize(ref reader, options); - case "murmur3": - return JsonSerializer.Deserialize(ref reader, options); - case "nested": - return JsonSerializer.Deserialize(ref reader, options); - case "object": - return JsonSerializer.Deserialize(ref reader, options); - case "passthrough": - return JsonSerializer.Deserialize(ref reader, options); - case "percolator": - return JsonSerializer.Deserialize(ref reader, options); - case "point": - return JsonSerializer.Deserialize(ref reader, options); - case "rank_feature": - return JsonSerializer.Deserialize(ref reader, options); - case "rank_features": - return JsonSerializer.Deserialize(ref reader, options); - case "scaled_float": - return JsonSerializer.Deserialize(ref reader, options); - case "search_as_you_type": - return JsonSerializer.Deserialize(ref reader, options); - case "semantic_text": - return JsonSerializer.Deserialize(ref reader, options); - case "shape": - return JsonSerializer.Deserialize(ref reader, options); - case "short": - return JsonSerializer.Deserialize(ref reader, options); - case "sparse_vector": - return JsonSerializer.Deserialize(ref reader, options); - case "text": - return JsonSerializer.Deserialize(ref reader, options); - case "token_count": - return JsonSerializer.Deserialize(ref reader, options); - case "unsigned_long": - return JsonSerializer.Deserialize(ref reader, options); - case "version": - return JsonSerializer.Deserialize(ref reader, options); - case "wildcard": - return JsonSerializer.Deserialize(ref reader, options); - default: - return JsonSerializer.Deserialize(ref reader, options); - } + "aggregate_metric_double" => reader.ReadValue(options), + "binary" => reader.ReadValue(options), + "boolean" => reader.ReadValue(options), + "byte" => reader.ReadValue(options), + "completion" => reader.ReadValue(options), + "constant_keyword" => reader.ReadValue(options), + "date_nanos" => reader.ReadValue(options), + "date" => reader.ReadValue(options), + "date_range" => reader.ReadValue(options), + "dense_vector" => reader.ReadValue(options), + "double" => reader.ReadValue(options), + "double_range" => reader.ReadValue(options), + "{dynamic_type}" => reader.ReadValue(options), + "alias" => reader.ReadValue(options), + "flattened" => reader.ReadValue(options), + "float" => reader.ReadValue(options), + "float_range" => reader.ReadValue(options), + "geo_point" => reader.ReadValue(options), + "geo_shape" => reader.ReadValue(options), + "half_float" => reader.ReadValue(options), + "histogram" => reader.ReadValue(options), + "icu_collation_keyword" => reader.ReadValue(options), + "integer" => reader.ReadValue(options), + "integer_range" => reader.ReadValue(options), + "ip" => reader.ReadValue(options), + "ip_range" => reader.ReadValue(options), + "join" => reader.ReadValue(options), + "keyword" => reader.ReadValue(options), + "long" => reader.ReadValue(options), + "long_range" => reader.ReadValue(options), + "match_only_text" => reader.ReadValue(options), + "murmur3" => reader.ReadValue(options), + "nested" => reader.ReadValue(options), + "object" => reader.ReadValue(options), + "passthrough" => reader.ReadValue(options), + "percolator" => reader.ReadValue(options), + "point" => reader.ReadValue(options), + "rank_feature" => reader.ReadValue(options), + "rank_features" => reader.ReadValue(options), + "scaled_float" => reader.ReadValue(options), + "search_as_you_type" => reader.ReadValue(options), + "semantic_text" => reader.ReadValue(options), + "shape" => reader.ReadValue(options), + "short" => reader.ReadValue(options), + "sparse_vector" => reader.ReadValue(options), + "text" => reader.ReadValue(options), + "token_count" => reader.ReadValue(options), + "unsigned_long" => reader.ReadValue(options), + "version" => reader.ReadValue(options), + "wildcard" => reader.ReadValue(options), + _ => throw new System.Text.Json.JsonException($"Variant '{discriminator}' is not supported for type '{nameof(IProperty)}'.") + }; } - public override void Write(Utf8JsonWriter writer, IProperty value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IProperty value, System.Text.Json.JsonSerializerOptions options) { - if (value is null) - { - writer.WriteNullValue(); - return; - } - switch (value.Type) { case "aggregate_metric_double": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.AggregateMetricDoubleProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.AggregateMetricDoubleProperty)value); + break; case "binary": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.BinaryProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.BinaryProperty)value); + break; case "boolean": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.BooleanProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.BooleanProperty)value); + break; case "byte": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ByteNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ByteNumberProperty)value); + break; case "completion": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.CompletionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.CompletionProperty)value); + break; case "constant_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ConstantKeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ConstantKeywordProperty)value); + break; case "date_nanos": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateNanosProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateNanosProperty)value); + break; case "date": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateProperty)value); + break; case "date_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DateRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DateRangeProperty)value); + break; case "dense_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DenseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DenseVectorProperty)value); + break; case "double": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DoubleNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DoubleNumberProperty)value); + break; case "double_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DoubleRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DoubleRangeProperty)value); + break; case "{dynamic_type}": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.DynamicProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.DynamicProperty)value); + break; case "alias": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FieldAliasProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FieldAliasProperty)value); + break; case "flattened": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FlattenedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FlattenedProperty)value); + break; case "float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FloatNumberProperty)value); + break; case "float_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.FloatRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.FloatRangeProperty)value); + break; case "geo_point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.GeoPointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.GeoPointProperty)value); + break; case "geo_shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.GeoShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.GeoShapeProperty)value); + break; case "half_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.HalfFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.HalfFloatNumberProperty)value); + break; case "histogram": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.HistogramProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.HistogramProperty)value); + break; case "icu_collation_keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IcuCollationProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IcuCollationProperty)value); + break; case "integer": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IntegerNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IntegerNumberProperty)value); + break; case "integer_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IntegerRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IntegerRangeProperty)value); + break; case "ip": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IpProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IpProperty)value); + break; case "ip_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.IpRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.IpRangeProperty)value); + break; case "join": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.JoinProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.JoinProperty)value); + break; case "keyword": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.KeywordProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.KeywordProperty)value); + break; case "long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.LongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.LongNumberProperty)value); + break; case "long_range": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.LongRangeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.LongRangeProperty)value); + break; case "match_only_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.MatchOnlyTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.MatchOnlyTextProperty)value); + break; case "murmur3": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.Murmur3HashProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.Murmur3HashProperty)value); + break; case "nested": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.NestedProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.NestedProperty)value); + break; case "object": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ObjectProperty)value); + break; case "passthrough": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PassthroughObjectProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PassthroughObjectProperty)value); + break; case "percolator": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PercolatorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PercolatorProperty)value); + break; case "point": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.PointProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.PointProperty)value); + break; case "rank_feature": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.RankFeatureProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.RankFeatureProperty)value); + break; case "rank_features": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.RankFeaturesProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.RankFeaturesProperty)value); + break; case "scaled_float": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ScaledFloatNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ScaledFloatNumberProperty)value); + break; case "search_as_you_type": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SearchAsYouTypeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SearchAsYouTypeProperty)value); + break; case "semantic_text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SemanticTextProperty)value); + break; case "shape": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ShapeProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ShapeProperty)value); + break; case "short": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.ShortNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.ShortNumberProperty)value); + break; case "sparse_vector": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.SparseVectorProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.SparseVectorProperty)value); + break; case "text": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.TextProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.TextProperty)value); + break; case "token_count": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.TokenCountProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.TokenCountProperty)value); + break; case "unsigned_long": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.UnsignedLongNumberProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.UnsignedLongNumberProperty)value); + break; case "version": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.VersionProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.VersionProperty)value); + break; case "wildcard": - JsonSerializer.Serialize(writer, value, typeof(Elastic.Clients.Elasticsearch.Mapping.WildcardProperty), options); - return; + writer.WriteValue(options, (Elastic.Clients.Elasticsearch.Mapping.WildcardProperty)value); + break; default: - var type = value.GetType(); - JsonSerializer.Serialize(writer, value, type, options); - return; + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IProperty)}'."); } } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs index e541c98952f..9edbc7161d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/RuntimeFieldFetchFields.g.cs @@ -27,11 +27,59 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class RuntimeFieldFetchFieldsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + + public override RuntimeFieldFetchFields Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new RuntimeFieldFetchFields { Field = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RuntimeFieldFetchFields + { + Field = propField.Value +, + Format = propFormat.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuntimeFieldFetchFields value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuntimeFieldFetchFieldsConverter))] public sealed partial class RuntimeFieldFetchFields { - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs index af85a307d39..c64ca9cacfd 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ScaledFloatNumberProperty.g.cs @@ -27,26 +27,228 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class ScaledFloatNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScalingFactor = System.Text.Json.JsonEncodedText.Encode("scaling_factor"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ScaledFloatNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScalingFactor = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScalingFactor.TryRead(ref reader, options, PropScalingFactor)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ScaledFloatNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + ScalingFactor = propScalingFactor.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ScaledFloatNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScalingFactor, value.ScalingFactor); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ScaledFloatNumberPropertyConverter))] public sealed partial class ScaledFloatNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,19 +256,12 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("scaling_factor")] public double? ScalingFactor { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -74,7 +269,6 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -82,10 +276,8 @@ public sealed partial class ScaledFloatNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "scaled_float"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs index 01869286d25..676990fe878 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/SearchAsYouTypeProperty.g.cs @@ -27,24 +27,207 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class SearchAsYouTypePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropMaxShingleSize = System.Text.Json.JsonEncodedText.Encode("max_shingle_size"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override SearchAsYouTypeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propMaxShingleSize = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propMaxShingleSize.TryRead(ref reader, options, PropMaxShingleSize)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SearchAsYouTypeProperty + { + Analyzer = propAnalyzer.Value +, + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + MaxShingleSize = propMaxShingleSize.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Similarity = propSimilarity.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SearchAsYouTypeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropMaxShingleSize, value.MaxShingleSize); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SearchAsYouTypePropertyConverter))] public sealed partial class SearchAsYouTypeProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("max_shingle_size")] public int? MaxShingleSize { get; set; } /// @@ -52,24 +235,15 @@ public sealed partial class SearchAsYouTypeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "search_as_you_type"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs index 746ae77f100..1b0f6615c6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShapeProperty.g.cs @@ -27,6 +27,157 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class ShapePropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreZValue = System.Text.Json.JsonEncodedText.Encode("ignore_z_value"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropOrientation = System.Text.Json.JsonEncodedText.Encode("orientation"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ShapeProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIgnoreZValue = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propOrientation = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIgnoreZValue.TryRead(ref reader, options, PropIgnoreZValue)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propOrientation.TryRead(ref reader, options, PropOrientation)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShapeProperty + { + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + IgnoreZValue = propIgnoreZValue.Value +, + Meta = propMeta.Value +, + Orientation = propOrientation.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIgnoreZValue, value.IgnoreZValue); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropOrientation, value.Orientation); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + /// /// /// The shape data type facilitates the indexing of and searching with arbitrary x, y cartesian shapes such as @@ -34,24 +185,16 @@ namespace Elastic.Clients.Elasticsearch.Mapping; /// /// Learn more about this API in the Elasticsearch documentation. /// +[JsonConverter(typeof(ShapePropertyConverter))] public sealed partial class ShapeProperty : IProperty { - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("ignore_z_value")] public bool? IgnoreZValue { get; set; } /// @@ -59,16 +202,11 @@ public sealed partial class ShapeProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("orientation")] public Elastic.Clients.Elasticsearch.Mapping.GeoOrientation? Orientation { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "shape"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs index 828c1519a6d..69f684b1ccc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/ShortNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class ShortNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override ShortNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShortNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShortNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(ShortNumberPropertyConverter))] public sealed partial class ShortNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class ShortNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public short? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class ShortNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class ShortNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "short"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs index 507e09126cc..25b7426e9d1 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TextProperty.g.cs @@ -27,34 +27,272 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class TextPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEagerGlobalOrdinals = System.Text.Json.JsonEncodedText.Encode("eager_global_ordinals"); + private static readonly System.Text.Json.JsonEncodedText PropFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata"); + private static readonly System.Text.Json.JsonEncodedText PropFielddataFrequencyFilter = System.Text.Json.JsonEncodedText.Encode("fielddata_frequency_filter"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropIndexOptions = System.Text.Json.JsonEncodedText.Encode("index_options"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPhrases = System.Text.Json.JsonEncodedText.Encode("index_phrases"); + private static readonly System.Text.Json.JsonEncodedText PropIndexPrefixes = System.Text.Json.JsonEncodedText.Encode("index_prefixes"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNorms = System.Text.Json.JsonEncodedText.Encode("norms"); + private static readonly System.Text.Json.JsonEncodedText PropPositionIncrementGap = System.Text.Json.JsonEncodedText.Encode("position_increment_gap"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropSearchAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSearchQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("search_quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropSimilarity = System.Text.Json.JsonEncodedText.Encode("similarity"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTermVector = System.Text.Json.JsonEncodedText.Encode("term_vector"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TextProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEagerGlobalOrdinals = default; + LocalJsonValue propFielddata = default; + LocalJsonValue propFielddataFrequencyFilter = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue propIndexOptions = default; + LocalJsonValue propIndexPhrases = default; + LocalJsonValue propIndexPrefixes = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNorms = default; + LocalJsonValue propPositionIncrementGap = default; + LocalJsonValue propProperties = default; + LocalJsonValue propSearchAnalyzer = default; + LocalJsonValue propSearchQuoteAnalyzer = default; + LocalJsonValue propSimilarity = default; + LocalJsonValue propStore = default; + LocalJsonValue propTermVector = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEagerGlobalOrdinals.TryRead(ref reader, options, PropEagerGlobalOrdinals)) + { + continue; + } + + if (propFielddata.TryRead(ref reader, options, PropFielddata)) + { + continue; + } + + if (propFielddataFrequencyFilter.TryRead(ref reader, options, PropFielddataFrequencyFilter)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propIndexOptions.TryRead(ref reader, options, PropIndexOptions)) + { + continue; + } + + if (propIndexPhrases.TryRead(ref reader, options, PropIndexPhrases)) + { + continue; + } + + if (propIndexPrefixes.TryRead(ref reader, options, PropIndexPrefixes)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNorms.TryRead(ref reader, options, PropNorms)) + { + continue; + } + + if (propPositionIncrementGap.TryRead(ref reader, options, PropPositionIncrementGap)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propSearchAnalyzer.TryRead(ref reader, options, PropSearchAnalyzer)) + { + continue; + } + + if (propSearchQuoteAnalyzer.TryRead(ref reader, options, PropSearchQuoteAnalyzer)) + { + continue; + } + + if (propSimilarity.TryRead(ref reader, options, PropSimilarity)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTermVector.TryRead(ref reader, options, PropTermVector)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TextProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + Dynamic = propDynamic.Value +, + EagerGlobalOrdinals = propEagerGlobalOrdinals.Value +, + Fielddata = propFielddata.Value +, + FielddataFrequencyFilter = propFielddataFrequencyFilter.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + IndexOptions = propIndexOptions.Value +, + IndexPhrases = propIndexPhrases.Value +, + IndexPrefixes = propIndexPrefixes.Value +, + Meta = propMeta.Value +, + Norms = propNorms.Value +, + PositionIncrementGap = propPositionIncrementGap.Value +, + Properties = propProperties.Value +, + SearchAnalyzer = propSearchAnalyzer.Value +, + SearchQuoteAnalyzer = propSearchQuoteAnalyzer.Value +, + Similarity = propSimilarity.Value +, + Store = propStore.Value +, + TermVector = propTermVector.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TextProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEagerGlobalOrdinals, value.EagerGlobalOrdinals); + writer.WriteProperty(options, PropFielddata, value.Fielddata); + writer.WriteProperty(options, PropFielddataFrequencyFilter, value.FielddataFrequencyFilter); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropIndexOptions, value.IndexOptions); + writer.WriteProperty(options, PropIndexPhrases, value.IndexPhrases); + writer.WriteProperty(options, PropIndexPrefixes, value.IndexPrefixes); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNorms, value.Norms); + writer.WriteProperty(options, PropPositionIncrementGap, value.PositionIncrementGap); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropSearchAnalyzer, value.SearchAnalyzer); + writer.WriteProperty(options, PropSearchQuoteAnalyzer, value.SearchQuoteAnalyzer); + writer.WriteProperty(options, PropSimilarity, value.Similarity); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTermVector, value.TermVector); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TextPropertyConverter))] public sealed partial class TextProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("eager_global_ordinals")] public bool? EagerGlobalOrdinals { get; set; } - [JsonInclude, JsonPropertyName("fielddata")] public bool? Fielddata { get; set; } - [JsonInclude, JsonPropertyName("fielddata_frequency_filter")] public Elastic.Clients.Elasticsearch.IndexManagement.FielddataFrequencyFilter? FielddataFrequencyFilter { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } - [JsonInclude, JsonPropertyName("index_options")] public Elastic.Clients.Elasticsearch.Mapping.IndexOptions? IndexOptions { get; set; } - [JsonInclude, JsonPropertyName("index_phrases")] public bool? IndexPhrases { get; set; } - [JsonInclude, JsonPropertyName("index_prefixes")] public Elastic.Clients.Elasticsearch.Mapping.TextIndexPrefixes? IndexPrefixes { get; set; } /// @@ -62,26 +300,16 @@ public sealed partial class TextProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("norms")] public bool? Norms { get; set; } - [JsonInclude, JsonPropertyName("position_increment_gap")] public int? PositionIncrementGap { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("search_analyzer")] public string? SearchAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("search_quote_analyzer")] public string? SearchQuoteAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("similarity")] public string? Similarity { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("term_vector")] public Elastic.Clients.Elasticsearch.Mapping.TermVectorOption? TermVector { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "text"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs index 6a9e2302b3e..11a509ae1a9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/TokenCountProperty.g.cs @@ -27,26 +27,178 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class TokenCountPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropEnablePositionIncrements = System.Text.Json.JsonEncodedText.Encode("enable_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override TokenCountProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propEnablePositionIncrements = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propEnablePositionIncrements.TryRead(ref reader, options, PropEnablePositionIncrements)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TokenCountProperty + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + EnablePositionIncrements = propEnablePositionIncrements.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TokenCountProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropEnablePositionIncrements, value.EnablePositionIncrements); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TokenCountPropertyConverter))] public sealed partial class TokenCountProperty : IProperty { - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("enable_position_increments")] public bool? EnablePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,16 +206,11 @@ public sealed partial class TokenCountProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public double? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "token_count"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs index 0d7d4bebd18..2ec3f4a8232 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/UnsignedLongNumberProperty.g.cs @@ -27,26 +27,218 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class UnsignedLongNumberPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCoerce = System.Text.Json.JsonEncodedText.Encode("coerce"); + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreMalformed = System.Text.Json.JsonEncodedText.Encode("ignore_malformed"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("index"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropOnScriptError = System.Text.Json.JsonEncodedText.Encode("on_script_error"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesDimension = System.Text.Json.JsonEncodedText.Encode("time_series_dimension"); + private static readonly System.Text.Json.JsonEncodedText PropTimeSeriesMetric = System.Text.Json.JsonEncodedText.Encode("time_series_metric"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override UnsignedLongNumberProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCoerce = default; + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue propIgnoreMalformed = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propOnScriptError = default; + LocalJsonValue propProperties = default; + LocalJsonValue propScript = default; + LocalJsonValue propStore = default; + LocalJsonValue propTimeSeriesDimension = default; + LocalJsonValue propTimeSeriesMetric = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCoerce.TryRead(ref reader, options, PropCoerce)) + { + continue; + } + + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propIgnoreMalformed.TryRead(ref reader, options, PropIgnoreMalformed)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propOnScriptError.TryRead(ref reader, options, PropOnScriptError)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (propTimeSeriesDimension.TryRead(ref reader, options, PropTimeSeriesDimension)) + { + continue; + } + + if (propTimeSeriesMetric.TryRead(ref reader, options, PropTimeSeriesMetric)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UnsignedLongNumberProperty + { + Boost = propBoost.Value +, + Coerce = propCoerce.Value +, + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + IgnoreMalformed = propIgnoreMalformed.Value +, + Index = propIndex.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + OnScriptError = propOnScriptError.Value +, + Properties = propProperties.Value +, + Script = propScript.Value +, + Store = propStore.Value +, + TimeSeriesDimension = propTimeSeriesDimension.Value +, + TimeSeriesMetric = propTimeSeriesMetric.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, UnsignedLongNumberProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCoerce, value.Coerce); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropIgnoreMalformed, value.IgnoreMalformed); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropOnScriptError, value.OnScriptError); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropTimeSeriesDimension, value.TimeSeriesDimension); + writer.WriteProperty(options, PropTimeSeriesMetric, value.TimeSeriesMetric); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(UnsignedLongNumberPropertyConverter))] public sealed partial class UnsignedLongNumberProperty : IProperty { - [JsonInclude, JsonPropertyName("boost")] public double? Boost { get; set; } - [JsonInclude, JsonPropertyName("coerce")] public bool? Coerce { get; set; } - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } - [JsonInclude, JsonPropertyName("ignore_malformed")] public bool? IgnoreMalformed { get; set; } - [JsonInclude, JsonPropertyName("index")] public bool? Index { get; set; } /// @@ -54,17 +246,11 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public long? NullValue { get; set; } - [JsonInclude, JsonPropertyName("on_script_error")] public Elastic.Clients.Elasticsearch.Mapping.OnScriptError? OnScriptError { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Script? Script { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } /// @@ -72,7 +258,6 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_dimension")] public bool? TimeSeriesDimension { get; set; } /// @@ -80,10 +265,8 @@ public sealed partial class UnsignedLongNumberProperty : IProperty /// For internal use by Elastic only. Marks the field as a time series dimension. Defaults to false. /// /// - [JsonInclude, JsonPropertyName("time_series_metric")] public Elastic.Clients.Elasticsearch.Mapping.TimeSeriesMetricType? TimeSeriesMetric { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "unsigned_long"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs index aeab1142b5e..3d2205a4895 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/VersionProperty.g.cs @@ -27,18 +27,124 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class VersionPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override VersionProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new VersionProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, VersionProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(VersionPropertyConverter))] public sealed partial class VersionProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,14 +152,10 @@ public sealed partial class VersionProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "version"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs index a35b3b65721..05e920239be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Mapping/WildcardProperty.g.cs @@ -27,18 +27,134 @@ namespace Elastic.Clients.Elasticsearch.Mapping; +internal sealed partial class WildcardPropertyConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropCopyTo = System.Text.Json.JsonEncodedText.Encode("copy_to"); + private static readonly System.Text.Json.JsonEncodedText PropDocValues = System.Text.Json.JsonEncodedText.Encode("doc_values"); + private static readonly System.Text.Json.JsonEncodedText PropDynamic = System.Text.Json.JsonEncodedText.Encode("dynamic"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreAbove = System.Text.Json.JsonEncodedText.Encode("ignore_above"); + private static readonly System.Text.Json.JsonEncodedText PropMeta = System.Text.Json.JsonEncodedText.Encode("meta"); + private static readonly System.Text.Json.JsonEncodedText PropNullValue = System.Text.Json.JsonEncodedText.Encode("null_value"); + private static readonly System.Text.Json.JsonEncodedText PropProperties = System.Text.Json.JsonEncodedText.Encode("properties"); + private static readonly System.Text.Json.JsonEncodedText PropStore = System.Text.Json.JsonEncodedText.Encode("store"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override WildcardProperty Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propCopyTo = default; + LocalJsonValue propDocValues = default; + LocalJsonValue propDynamic = default; + LocalJsonValue propFields = default; + LocalJsonValue propIgnoreAbove = default; + LocalJsonValue?> propMeta = default; + LocalJsonValue propNullValue = default; + LocalJsonValue propProperties = default; + LocalJsonValue propStore = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propCopyTo.TryRead(ref reader, options, PropCopyTo, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propDocValues.TryRead(ref reader, options, PropDocValues)) + { + continue; + } + + if (propDynamic.TryRead(ref reader, options, PropDynamic)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields)) + { + continue; + } + + if (propIgnoreAbove.TryRead(ref reader, options, PropIgnoreAbove)) + { + continue; + } + + if (propMeta.TryRead(ref reader, options, PropMeta)) + { + continue; + } + + if (propNullValue.TryRead(ref reader, options, PropNullValue)) + { + continue; + } + + if (propProperties.TryRead(ref reader, options, PropProperties)) + { + continue; + } + + if (propStore.TryRead(ref reader, options, PropStore)) + { + continue; + } + + if (reader.ValueTextEquals(PropType)) + { + reader.Skip(); + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new WildcardProperty + { + CopyTo = propCopyTo.Value +, + DocValues = propDocValues.Value +, + Dynamic = propDynamic.Value +, + Fields = propFields.Value +, + IgnoreAbove = propIgnoreAbove.Value +, + Meta = propMeta.Value +, + NullValue = propNullValue.Value +, + Properties = propProperties.Value +, + Store = propStore.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, WildcardProperty value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropCopyTo, value.CopyTo, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropDocValues, value.DocValues); + writer.WriteProperty(options, PropDynamic, value.Dynamic); + writer.WriteProperty(options, PropFields, value.Fields); + writer.WriteProperty(options, PropIgnoreAbove, value.IgnoreAbove); + writer.WriteProperty(options, PropMeta, value.Meta); + writer.WriteProperty(options, PropNullValue, value.NullValue); + writer.WriteProperty(options, PropProperties, value.Properties); + writer.WriteProperty(options, PropStore, value.Store); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(WildcardPropertyConverter))] public sealed partial class WildcardProperty : IProperty { - [JsonInclude, JsonPropertyName("copy_to")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? CopyTo { get; set; } - [JsonInclude, JsonPropertyName("doc_values")] public bool? DocValues { get; set; } - [JsonInclude, JsonPropertyName("dynamic")] public Elastic.Clients.Elasticsearch.Mapping.DynamicMapping? Dynamic { get; set; } - [JsonInclude, JsonPropertyName("fields")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Fields { get; set; } - [JsonInclude, JsonPropertyName("ignore_above")] public int? IgnoreAbove { get; set; } /// @@ -46,16 +162,11 @@ public sealed partial class WildcardProperty : IProperty /// Metadata about the field. /// /// - [JsonInclude, JsonPropertyName("meta")] public IDictionary? Meta { get; set; } - [JsonInclude, JsonPropertyName("null_value")] public string? NullValue { get; set; } - [JsonInclude, JsonPropertyName("properties")] public Elastic.Clients.Elasticsearch.Mapping.Properties? Properties { get; set; } - [JsonInclude, JsonPropertyName("store")] public bool? Store { get; set; } - [JsonInclude, JsonPropertyName("type")] public string Type => "wildcard"; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs index 82482a861f6..9a67d5ec95a 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoDiscover.g.cs @@ -27,51 +27,70 @@ namespace Elastic.Clients.Elasticsearch.Nodes; -internal sealed partial class NodeInfoDiscoverConverter : JsonConverter +internal sealed partial class NodeInfoDiscoverConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeInfoDiscover Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropSettings = System.Text.Json.JsonEncodedText.Encode("settings"); + private static readonly System.Text.Json.JsonEncodedText PropSeedHosts = System.Text.Json.JsonEncodedText.Encode("seed_hosts"); + private static readonly System.Text.Json.JsonEncodedText PropSeedProviders = System.Text.Json.JsonEncodedText.Encode("seed_providers"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override NodeInfoDiscover Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection? seedHosts = default; - IReadOnlyCollection? seedProviders = default; - string? type = default; - Dictionary additionalProperties = null; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + System.Collections.Generic.Dictionary propSettings = default; + LocalJsonValue?> propSeedHosts = default; + LocalJsonValue?> propSeedProviders = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propSeedHosts.TryRead(ref reader, options, PropSeedHosts)) { - var property = reader.GetString(); - if (property == "seed_hosts") - { - seedHosts = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } - - if (property == "seed_providers") - { - seedProviders = JsonSerializer.Deserialize?>(ref reader, options); - continue; - } + continue; + } - if (property == "type") - { - type = JsonSerializer.Deserialize(ref reader, options); - continue; - } + if (propSeedProviders.TryRead(ref reader, options, PropSeedProviders)) + { + continue; + } - additionalProperties ??= new Dictionary(); - var additionalValue = JsonSerializer.Deserialize(ref reader, options); - additionalProperties.Add(property, additionalValue); + if (propType.TryRead(ref reader, options, PropType)) + { + continue; } + + propSettings ??= new System.Collections.Generic.Dictionary(); + reader.ReadProperty(options, out string key, out object value); + propSettings[key] = value; } - return new NodeInfoDiscover { SeedHosts = seedHosts, SeedProviders = seedProviders, Settings = additionalProperties, Type = type }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoDiscover + { + Settings = propSettings +, + SeedHosts = propSeedHosts.Value +, + SeedProviders = propSeedProviders.Value +, + Type = propType.Value + }; } - public override void Write(Utf8JsonWriter writer, NodeInfoDiscover value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoDiscover value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NodeInfoDiscover' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropSeedHosts, value.SeedHosts); + writer.WriteProperty(options, PropSeedProviders, value.SeedProviders); + writer.WriteProperty(options, PropType, value.Type); + if (value.Settings is not null) + { + foreach (var item in value.Settings) + { + writer.WriteProperty(options, item.Key, item.Value); + } + } + + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs index d80db597c5b..9d9a491ec6e 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoPath.g.cs @@ -27,15 +27,74 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodeInfoPathConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropData = System.Text.Json.JsonEncodedText.Encode("data"); + private static readonly System.Text.Json.JsonEncodedText PropHome = System.Text.Json.JsonEncodedText.Encode("home"); + private static readonly System.Text.Json.JsonEncodedText PropLogs = System.Text.Json.JsonEncodedText.Encode("logs"); + private static readonly System.Text.Json.JsonEncodedText PropRepo = System.Text.Json.JsonEncodedText.Encode("repo"); + + public override NodeInfoPath Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propData = default; + LocalJsonValue propHome = default; + LocalJsonValue propLogs = default; + LocalJsonValue?> propRepo = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propData.TryRead(ref reader, options, PropData, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propHome.TryRead(ref reader, options, PropHome)) + { + continue; + } + + if (propLogs.TryRead(ref reader, options, PropLogs)) + { + continue; + } + + if (propRepo.TryRead(ref reader, options, PropRepo)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoPath + { + Data = propData.Value +, + Home = propHome.Value +, + Logs = propLogs.Value +, + Repo = propRepo.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoPath value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropData, value.Data, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropHome, value.Home); + writer.WriteProperty(options, PropLogs, value.Logs); + writer.WriteProperty(options, PropRepo, value.Repo); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoPathConverter))] public sealed partial class NodeInfoPath { - [JsonInclude, JsonPropertyName("data")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Data { get; init; } - [JsonInclude, JsonPropertyName("home")] public string? Home { get; init; } - [JsonInclude, JsonPropertyName("logs")] public string? Logs { get; init; } - [JsonInclude, JsonPropertyName("repo")] public IReadOnlyCollection? Repo { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs index 59254699ab8..bc19c63bdcc 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsHttpType.g.cs @@ -27,8 +27,47 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodeInfoSettingsHttpTypeConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override NodeInfoSettingsHttpType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new NodeInfoSettingsHttpType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryRead(ref reader, options, PropDefault)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsHttpType + { + Default = propDefault.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsHttpType value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefault, value.Default); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsHttpTypeConverter))] public sealed partial class NodeInfoSettingsHttpType { - [JsonInclude, JsonPropertyName("default")] public string Default { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs index 34db00f7452..0efb105a21c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsNetwork.g.cs @@ -27,9 +27,41 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodeInfoSettingsNetworkConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropHost = System.Text.Json.JsonEncodedText.Encode("host"); + + public override NodeInfoSettingsNetwork Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propHost = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propHost.TryRead(ref reader, options, PropHost, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsNetwork + { + Host = propHost.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsNetwork value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropHost, value.Host, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsNetworkConverter))] public sealed partial class NodeInfoSettingsNetwork { - [JsonInclude, JsonPropertyName("host")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Host { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs index 4ffc3899a83..a4622624e28 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeInfoSettingsTransportType.g.cs @@ -27,8 +27,47 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class NodeInfoSettingsTransportTypeConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDefault = System.Text.Json.JsonEncodedText.Encode("default"); + + public override NodeInfoSettingsTransportType Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new NodeInfoSettingsTransportType { Default = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDefault = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDefault.TryRead(ref reader, options, PropDefault)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeInfoSettingsTransportType + { + Default = propDefault.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeInfoSettingsTransportType value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDefault, value.Default); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(NodeInfoSettingsTransportTypeConverter))] public sealed partial class NodeInfoSettingsTransportType { - [JsonInclude, JsonPropertyName("default")] public string Default { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs index 47707519655..7f6aad77ef2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/NodeJvmInfo.g.cs @@ -27,109 +27,147 @@ namespace Elastic.Clients.Elasticsearch.Nodes; -internal sealed partial class NodeJvmInfoConverter : JsonConverter +internal sealed partial class NodeJvmInfoConverter : System.Text.Json.Serialization.JsonConverter { - public override NodeJvmInfo Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropGcCollectors = System.Text.Json.JsonEncodedText.Encode("gc_collectors"); + private static readonly System.Text.Json.JsonEncodedText PropInputArguments = System.Text.Json.JsonEncodedText.Encode("input_arguments"); + private static readonly System.Text.Json.JsonEncodedText PropMem = System.Text.Json.JsonEncodedText.Encode("mem"); + private static readonly System.Text.Json.JsonEncodedText PropMemoryPools = System.Text.Json.JsonEncodedText.Encode("memory_pools"); + private static readonly System.Text.Json.JsonEncodedText PropPid = System.Text.Json.JsonEncodedText.Encode("pid"); + private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis"); + private static readonly System.Text.Json.JsonEncodedText PropUsingBundledJdk = System.Text.Json.JsonEncodedText.Encode("using_bundled_jdk"); + private static readonly System.Text.Json.JsonEncodedText PropUsingBundledJdk1 = System.Text.Json.JsonEncodedText.Encode("bundled_jdk"); + private static readonly System.Text.Json.JsonEncodedText PropUsingCompressedOrdinaryObjectPointers = System.Text.Json.JsonEncodedText.Encode("using_compressed_ordinary_object_pointers"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVmName = System.Text.Json.JsonEncodedText.Encode("vm_name"); + private static readonly System.Text.Json.JsonEncodedText PropVmVendor = System.Text.Json.JsonEncodedText.Encode("vm_vendor"); + private static readonly System.Text.Json.JsonEncodedText PropVmVersion = System.Text.Json.JsonEncodedText.Encode("vm_version"); + + public override NodeJvmInfo Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - IReadOnlyCollection gcCollectors = default; - IReadOnlyCollection inputArguments = default; - Elastic.Clients.Elasticsearch.Nodes.NodeInfoJvmMemory mem = default; - IReadOnlyCollection memoryPools = default; - int pid = default; - long startTimeInMillis = default; - bool usingBundledJdk = default; - object? usingCompressedOrdinaryObjectPointers = default; - string version = default; - string vmName = default; - string vmVendor = default; - string vmVersion = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue> propGcCollectors = default; + LocalJsonValue> propInputArguments = default; + LocalJsonValue propMem = default; + LocalJsonValue> propMemoryPools = default; + LocalJsonValue propPid = default; + LocalJsonValue propStartTimeInMillis = default; + LocalJsonValue propUsingBundledJdk = default; + LocalJsonValue propUsingCompressedOrdinaryObjectPointers = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVmName = default; + LocalJsonValue propVmVendor = default; + LocalJsonValue propVmVersion = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propGcCollectors.TryRead(ref reader, options, PropGcCollectors)) { - var property = reader.GetString(); - if (property == "gc_collectors") - { - gcCollectors = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "input_arguments") - { - inputArguments = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "mem") - { - mem = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "memory_pools") - { - memoryPools = JsonSerializer.Deserialize>(ref reader, options); - continue; - } - - if (property == "pid") - { - pid = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "start_time_in_millis") - { - startTimeInMillis = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "using_bundled_jdk" || property == "bundled_jdk") - { - usingBundledJdk = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "using_compressed_ordinary_object_pointers") - { - usingCompressedOrdinaryObjectPointers = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "version") - { - version = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_name") - { - vmName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_vendor") - { - vmVendor = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "vm_version") - { - vmVersion = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } + + if (propInputArguments.TryRead(ref reader, options, PropInputArguments)) + { + continue; + } + + if (propMem.TryRead(ref reader, options, PropMem)) + { + continue; + } + + if (propMemoryPools.TryRead(ref reader, options, PropMemoryPools)) + { + continue; + } + + if (propPid.TryRead(ref reader, options, PropPid)) + { + continue; + } + + if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis)) + { + continue; + } + + if (propUsingBundledJdk.TryRead(ref reader, options, PropUsingBundledJdk) || propUsingBundledJdk.TryRead(ref reader, options, PropUsingBundledJdk1)) + { + continue; + } + + if (propUsingCompressedOrdinaryObjectPointers.TryRead(ref reader, options, PropUsingCompressedOrdinaryObjectPointers)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVmName.TryRead(ref reader, options, PropVmName)) + { + continue; + } + + if (propVmVendor.TryRead(ref reader, options, PropVmVendor)) + { + continue; + } + + if (propVmVersion.TryRead(ref reader, options, PropVmVersion)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - return new NodeJvmInfo { GcCollectors = gcCollectors, InputArguments = inputArguments, Mem = mem, MemoryPools = memoryPools, Pid = pid, StartTimeInMillis = startTimeInMillis, UsingBundledJdk = usingBundledJdk, UsingCompressedOrdinaryObjectPointers = usingCompressedOrdinaryObjectPointers, Version = version, VmName = vmName, VmVendor = vmVendor, VmVersion = vmVersion }; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NodeJvmInfo + { + GcCollectors = propGcCollectors.Value +, + InputArguments = propInputArguments.Value +, + Mem = propMem.Value +, + MemoryPools = propMemoryPools.Value +, + Pid = propPid.Value +, + StartTimeInMillis = propStartTimeInMillis.Value +, + UsingBundledJdk = propUsingBundledJdk.Value +, + UsingCompressedOrdinaryObjectPointers = propUsingCompressedOrdinaryObjectPointers.Value +, + Version = propVersion.Value +, + VmName = propVmName.Value +, + VmVendor = propVmVendor.Value +, + VmVersion = propVmVersion.Value + }; } - public override void Write(Utf8JsonWriter writer, NodeJvmInfo value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, NodeJvmInfo value, System.Text.Json.JsonSerializerOptions options) { - throw new NotImplementedException("'NodeJvmInfo' is a readonly type, used only on responses and does not support being written to JSON."); + writer.WriteStartObject(); + writer.WriteProperty(options, PropGcCollectors, value.GcCollectors); + writer.WriteProperty(options, PropInputArguments, value.InputArguments); + writer.WriteProperty(options, PropMem, value.Mem); + writer.WriteProperty(options, PropMemoryPools, value.MemoryPools); + writer.WriteProperty(options, PropPid, value.Pid); + writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis); + writer.WriteProperty(options, PropUsingBundledJdk, value.UsingBundledJdk); + writer.WriteProperty(options, PropUsingCompressedOrdinaryObjectPointers, value.UsingCompressedOrdinaryObjectPointers); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVmName, value.VmName); + writer.WriteProperty(options, PropVmVendor, value.VmVendor); + writer.WriteProperty(options, PropVmVersion, value.VmVersion); + writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs index 069731edd49..387a2cb2bff 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Nodes/Stats.g.cs @@ -27,6 +27,250 @@ namespace Elastic.Clients.Elasticsearch.Nodes; +internal sealed partial class StatsConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAdaptiveSelection = System.Text.Json.JsonEncodedText.Encode("adaptive_selection"); + private static readonly System.Text.Json.JsonEncodedText PropAttributes = System.Text.Json.JsonEncodedText.Encode("attributes"); + private static readonly System.Text.Json.JsonEncodedText PropBreakers = System.Text.Json.JsonEncodedText.Encode("breakers"); + private static readonly System.Text.Json.JsonEncodedText PropDiscovery = System.Text.Json.JsonEncodedText.Encode("discovery"); + private static readonly System.Text.Json.JsonEncodedText PropFs = System.Text.Json.JsonEncodedText.Encode("fs"); + private static readonly System.Text.Json.JsonEncodedText PropHost = System.Text.Json.JsonEncodedText.Encode("host"); + private static readonly System.Text.Json.JsonEncodedText PropHttp = System.Text.Json.JsonEncodedText.Encode("http"); + private static readonly System.Text.Json.JsonEncodedText PropIndexingPressure = System.Text.Json.JsonEncodedText.Encode("indexing_pressure"); + private static readonly System.Text.Json.JsonEncodedText PropIndices = System.Text.Json.JsonEncodedText.Encode("indices"); + private static readonly System.Text.Json.JsonEncodedText PropIngest = System.Text.Json.JsonEncodedText.Encode("ingest"); + private static readonly System.Text.Json.JsonEncodedText PropIp = System.Text.Json.JsonEncodedText.Encode("ip"); + private static readonly System.Text.Json.JsonEncodedText PropJvm = System.Text.Json.JsonEncodedText.Encode("jvm"); + private static readonly System.Text.Json.JsonEncodedText PropName = System.Text.Json.JsonEncodedText.Encode("name"); + private static readonly System.Text.Json.JsonEncodedText PropOs = System.Text.Json.JsonEncodedText.Encode("os"); + private static readonly System.Text.Json.JsonEncodedText PropProcess = System.Text.Json.JsonEncodedText.Encode("process"); + private static readonly System.Text.Json.JsonEncodedText PropRoles = System.Text.Json.JsonEncodedText.Encode("roles"); + private static readonly System.Text.Json.JsonEncodedText PropScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText PropScriptCache = System.Text.Json.JsonEncodedText.Encode("script_cache"); + private static readonly System.Text.Json.JsonEncodedText PropThreadPool = System.Text.Json.JsonEncodedText.Encode("thread_pool"); + private static readonly System.Text.Json.JsonEncodedText PropTimestamp = System.Text.Json.JsonEncodedText.Encode("timestamp"); + private static readonly System.Text.Json.JsonEncodedText PropTransport = System.Text.Json.JsonEncodedText.Encode("transport"); + private static readonly System.Text.Json.JsonEncodedText PropTransportAddress = System.Text.Json.JsonEncodedText.Encode("transport_address"); + + public override Stats Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propAdaptiveSelection = default; + LocalJsonValue?> propAttributes = default; + LocalJsonValue?> propBreakers = default; + LocalJsonValue propDiscovery = default; + LocalJsonValue propFs = default; + LocalJsonValue propHost = default; + LocalJsonValue propHttp = default; + LocalJsonValue propIndexingPressure = default; + LocalJsonValue propIndices = default; + LocalJsonValue propIngest = default; + LocalJsonValue?> propIp = default; + LocalJsonValue propJvm = default; + LocalJsonValue propName = default; + LocalJsonValue propOs = default; + LocalJsonValue propProcess = default; + LocalJsonValue?> propRoles = default; + LocalJsonValue propScript = default; + LocalJsonValue>>?> propScriptCache = default; + LocalJsonValue?> propThreadPool = default; + LocalJsonValue propTimestamp = default; + LocalJsonValue propTransport = default; + LocalJsonValue propTransportAddress = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAdaptiveSelection.TryRead(ref reader, options, PropAdaptiveSelection)) + { + continue; + } + + if (propAttributes.TryRead(ref reader, options, PropAttributes)) + { + continue; + } + + if (propBreakers.TryRead(ref reader, options, PropBreakers)) + { + continue; + } + + if (propDiscovery.TryRead(ref reader, options, PropDiscovery)) + { + continue; + } + + if (propFs.TryRead(ref reader, options, PropFs)) + { + continue; + } + + if (propHost.TryRead(ref reader, options, PropHost)) + { + continue; + } + + if (propHttp.TryRead(ref reader, options, PropHttp)) + { + continue; + } + + if (propIndexingPressure.TryRead(ref reader, options, PropIndexingPressure)) + { + continue; + } + + if (propIndices.TryRead(ref reader, options, PropIndices)) + { + continue; + } + + if (propIngest.TryRead(ref reader, options, PropIngest)) + { + continue; + } + + if (propIp.TryRead(ref reader, options, PropIp, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propJvm.TryRead(ref reader, options, PropJvm)) + { + continue; + } + + if (propName.TryRead(ref reader, options, PropName)) + { + continue; + } + + if (propOs.TryRead(ref reader, options, PropOs)) + { + continue; + } + + if (propProcess.TryRead(ref reader, options, PropProcess)) + { + continue; + } + + if (propRoles.TryRead(ref reader, options, PropRoles)) + { + continue; + } + + if (propScript.TryRead(ref reader, options, PropScript)) + { + continue; + } + + if (propScriptCache.TryRead(ref reader, options, PropScriptCache)) + { + continue; + } + + if (propThreadPool.TryRead(ref reader, options, PropThreadPool)) + { + continue; + } + + if (propTimestamp.TryRead(ref reader, options, PropTimestamp)) + { + continue; + } + + if (propTransport.TryRead(ref reader, options, PropTransport)) + { + continue; + } + + if (propTransportAddress.TryRead(ref reader, options, PropTransportAddress)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Stats + { + AdaptiveSelection = propAdaptiveSelection.Value +, + Attributes = propAttributes.Value +, + Breakers = propBreakers.Value +, + Discovery = propDiscovery.Value +, + Fs = propFs.Value +, + Host = propHost.Value +, + Http = propHttp.Value +, + IndexingPressure = propIndexingPressure.Value +, + Indices = propIndices.Value +, + Ingest = propIngest.Value +, + Ip = propIp.Value +, + Jvm = propJvm.Value +, + Name = propName.Value +, + Os = propOs.Value +, + Process = propProcess.Value +, + Roles = propRoles.Value +, + Script = propScript.Value +, + ScriptCache = propScriptCache.Value +, + ThreadPool = propThreadPool.Value +, + Timestamp = propTimestamp.Value +, + Transport = propTransport.Value +, + TransportAddress = propTransportAddress.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, Stats value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAdaptiveSelection, value.AdaptiveSelection); + writer.WriteProperty(options, PropAttributes, value.Attributes); + writer.WriteProperty(options, PropBreakers, value.Breakers); + writer.WriteProperty(options, PropDiscovery, value.Discovery); + writer.WriteProperty(options, PropFs, value.Fs); + writer.WriteProperty(options, PropHost, value.Host); + writer.WriteProperty(options, PropHttp, value.Http); + writer.WriteProperty(options, PropIndexingPressure, value.IndexingPressure); + writer.WriteProperty(options, PropIndices, value.Indices); + writer.WriteProperty(options, PropIngest, value.Ingest); + writer.WriteProperty(options, PropIp, value.Ip, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropJvm, value.Jvm); + writer.WriteProperty(options, PropName, value.Name); + writer.WriteProperty(options, PropOs, value.Os); + writer.WriteProperty(options, PropProcess, value.Process); + writer.WriteProperty(options, PropRoles, value.Roles); + writer.WriteProperty(options, PropScript, value.Script); + writer.WriteProperty(options, PropScriptCache, value.ScriptCache); + writer.WriteProperty(options, PropThreadPool, value.ThreadPool); + writer.WriteProperty(options, PropTimestamp, value.Timestamp); + writer.WriteProperty(options, PropTransport, value.Transport); + writer.WriteProperty(options, PropTransportAddress, value.TransportAddress); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(StatsConverter))] public sealed partial class Stats { /// @@ -34,7 +278,6 @@ public sealed partial class Stats /// Statistics about adaptive replica selection. /// /// - [JsonInclude, JsonPropertyName("adaptive_selection")] public IReadOnlyDictionary? AdaptiveSelection { get; init; } /// @@ -42,8 +285,6 @@ public sealed partial class Stats /// Contains a list of attributes for the node. /// /// - [JsonInclude, JsonPropertyName("attributes")] - [ReadOnlyFieldDictionaryConverter(typeof(string))] public IReadOnlyDictionary? Attributes { get; init; } /// @@ -51,7 +292,6 @@ public sealed partial class Stats /// Statistics about the field data circuit breaker. /// /// - [JsonInclude, JsonPropertyName("breakers")] public IReadOnlyDictionary? Breakers { get; init; } /// @@ -59,7 +299,6 @@ public sealed partial class Stats /// Contains node discovery statistics for the node. /// /// - [JsonInclude, JsonPropertyName("discovery")] public Elastic.Clients.Elasticsearch.Nodes.Discovery? Discovery { get; init; } /// @@ -67,7 +306,6 @@ public sealed partial class Stats /// File system information, data path, free disk space, read/write stats. /// /// - [JsonInclude, JsonPropertyName("fs")] public Elastic.Clients.Elasticsearch.Nodes.FileSystem? Fs { get; init; } /// @@ -75,7 +313,6 @@ public sealed partial class Stats /// Network host for the node, based on the network host setting. /// /// - [JsonInclude, JsonPropertyName("host")] public string? Host { get; init; } /// @@ -83,7 +320,6 @@ public sealed partial class Stats /// HTTP connection information. /// /// - [JsonInclude, JsonPropertyName("http")] public Elastic.Clients.Elasticsearch.Nodes.Http? Http { get; init; } /// @@ -91,7 +327,6 @@ public sealed partial class Stats /// Contains indexing pressure statistics for the node. /// /// - [JsonInclude, JsonPropertyName("indexing_pressure")] public Elastic.Clients.Elasticsearch.Nodes.IndexingPressure? IndexingPressure { get; init; } /// @@ -99,7 +334,6 @@ public sealed partial class Stats /// Indices stats about size, document count, indexing and deletion times, search times, field cache size, merges and flushes. /// /// - [JsonInclude, JsonPropertyName("indices")] public Elastic.Clients.Elasticsearch.IndexManagement.ShardStats? Indices { get; init; } /// @@ -107,7 +341,6 @@ public sealed partial class Stats /// Statistics about ingest preprocessing. /// /// - [JsonInclude, JsonPropertyName("ingest")] public Elastic.Clients.Elasticsearch.Nodes.Ingest? Ingest { get; init; } /// @@ -115,8 +348,6 @@ public sealed partial class Stats /// IP address and port for the node. /// /// - [JsonInclude, JsonPropertyName("ip")] - [SingleOrManyCollectionConverter(typeof(string))] public IReadOnlyCollection? Ip { get; init; } /// @@ -124,7 +355,6 @@ public sealed partial class Stats /// JVM stats, memory pool information, garbage collection, buffer pools, number of loaded/unloaded classes. /// /// - [JsonInclude, JsonPropertyName("jvm")] public Elastic.Clients.Elasticsearch.Nodes.Jvm? Jvm { get; init; } /// @@ -133,7 +363,6 @@ public sealed partial class Stats /// Based on the node name setting. /// /// - [JsonInclude, JsonPropertyName("name")] public string? Name { get; init; } /// @@ -141,7 +370,6 @@ public sealed partial class Stats /// Operating system stats, load average, mem, swap. /// /// - [JsonInclude, JsonPropertyName("os")] public Elastic.Clients.Elasticsearch.Nodes.OperatingSystem? Os { get; init; } /// @@ -149,7 +377,6 @@ public sealed partial class Stats /// Process statistics, memory consumption, cpu usage, open file descriptors. /// /// - [JsonInclude, JsonPropertyName("process")] public Elastic.Clients.Elasticsearch.Nodes.Process? Process { get; init; } /// @@ -157,7 +384,6 @@ public sealed partial class Stats /// Roles assigned to the node. /// /// - [JsonInclude, JsonPropertyName("roles")] public IReadOnlyCollection? Roles { get; init; } /// @@ -165,9 +391,7 @@ public sealed partial class Stats /// Contains script statistics for the node. /// /// - [JsonInclude, JsonPropertyName("script")] public Elastic.Clients.Elasticsearch.Nodes.Scripting? Script { get; init; } - [JsonInclude, JsonPropertyName("script_cache")] public IReadOnlyDictionary>>? ScriptCache { get; init; } /// @@ -175,9 +399,7 @@ public sealed partial class Stats /// Statistics about each thread pool, including current size, queue and rejected tasks. /// /// - [JsonInclude, JsonPropertyName("thread_pool")] public IReadOnlyDictionary? ThreadPool { get; init; } - [JsonInclude, JsonPropertyName("timestamp")] public long? Timestamp { get; init; } /// @@ -185,7 +407,6 @@ public sealed partial class Stats /// Transport statistics about sent and received bytes in cluster communication. /// /// - [JsonInclude, JsonPropertyName("transport")] public Elastic.Clients.Elasticsearch.Nodes.Transport? Transport { get; init; } /// @@ -193,6 +414,5 @@ public sealed partial class Stats /// Host and port for the transport layer, used for internal communication between nodes in a cluster. /// /// - [JsonInclude, JsonPropertyName("transport_address")] public string? TransportAddress { get; init; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs index bbf7f54b574..9abdbb85d99 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/BoolQuery.g.cs @@ -27,6 +27,100 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class BoolQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMust = System.Text.Json.JsonEncodedText.Encode("must"); + private static readonly System.Text.Json.JsonEncodedText PropMustNot = System.Text.Json.JsonEncodedText.Encode("must_not"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropShould = System.Text.Json.JsonEncodedText.Encode("should"); + + public override BoolQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue?> propFilter = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue?> propMust = default; + LocalJsonValue?> propMustNot = default; + LocalJsonValue propQueryName = default; + LocalJsonValue?> propShould = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propMust.TryRead(ref reader, options, PropMust, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propMustNot.TryRead(ref reader, options, PropMustNot, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propShould.TryRead(ref reader, options, PropShould, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new BoolQuery + { + Boost = propBoost.Value +, + Filter = propFilter.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Must = propMust.Value +, + MustNot = propMustNot.Value +, + QueryName = propQueryName.Value +, + Should = propShould.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, BoolQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMust, value.Must, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropMustNot, value.MustNot, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropShould, value.Should, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(BoolQueryConverter))] public sealed partial class BoolQuery { /// @@ -37,7 +131,6 @@ public sealed partial class BoolQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -46,8 +139,6 @@ public sealed partial class BoolQuery /// However, unlike must, the score of the query will be ignored. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -55,7 +146,6 @@ public sealed partial class BoolQuery /// Specifies the number or percentage of should clauses returned documents must match. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -63,8 +153,6 @@ public sealed partial class BoolQuery /// The clause (query) must appear in matching documents and will contribute to the score. /// /// - [JsonInclude, JsonPropertyName("must")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Must { get; set; } /// @@ -73,10 +161,7 @@ public sealed partial class BoolQuery /// Because scoring is ignored, a score of 0 is returned for all documents. /// /// - [JsonInclude, JsonPropertyName("must_not")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? MustNot { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -84,8 +169,6 @@ public sealed partial class BoolQuery /// The clause (query) should appear in the matching document. /// /// - [JsonInclude, JsonPropertyName("should")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Should { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(BoolQuery boolQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.Bool(boolQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs index 387ff96f3a0..14d3a4cf918 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/CombinedFieldsQuery.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class CombinedFieldsQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override CombinedFieldsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFields = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new CombinedFieldsQuery + { + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Fields = propFields.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, CombinedFieldsQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(CombinedFieldsQueryConverter))] public sealed partial class CombinedFieldsQuery { /// @@ -34,7 +138,6 @@ public sealed partial class CombinedFieldsQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -45,7 +148,6 @@ public sealed partial class CombinedFieldsQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -53,8 +155,6 @@ public sealed partial class CombinedFieldsQuery /// List of fields to search. Field wildcard patterns are allowed. Only text fields are supported, and they must all have the same search analyzer. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// @@ -62,7 +162,6 @@ public sealed partial class CombinedFieldsQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -70,7 +169,6 @@ public sealed partial class CombinedFieldsQuery /// Boolean logic used to interpret text in the query value. /// /// - [JsonInclude, JsonPropertyName("operator")] public Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsOperator? Operator { get; set; } /// @@ -79,9 +177,7 @@ public sealed partial class CombinedFieldsQuery /// The combined_fields query analyzes the provided text before performing a search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -89,7 +185,6 @@ public sealed partial class CombinedFieldsQuery /// Indicates whether no documents are returned if the analyzer removes all tokens, such as when using a stop filter. /// /// - [JsonInclude, JsonPropertyName("zero_terms_query")] public Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsZeroTerms? ZeroTermsQuery { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(CombinedFieldsQuery combinedFieldsQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.CombinedFields(combinedFieldsQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs index 2694b98502b..cf432b84093 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDecayFunction.g.cs @@ -27,60 +27,51 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class DateDecayFunctionConverter : JsonConverter +internal sealed partial class DateDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override DateDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new DateDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, DateDecayFunction value, JsonSerializerOptions options) + public override DateDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(DateDecayFunctionConverter))] -public sealed partial class DateDecayFunction +public sealed partial class DateDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +82,8 @@ public sealed partial class DateDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "datedecayfunction"; } public sealed partial class DateDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs index bfa49e3ec4b..1606b09c462 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class DateDistanceFeatureQuery +public sealed partial class DateDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class DateDistanceFeatureQuery public Elastic.Clients.Elasticsearch.Duration Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "datedistancefeaturequery"; } public sealed partial class DateDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs index 537b0a37d46..a9c46463d0b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DateRangeQuery.g.cs @@ -27,151 +27,134 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class DateRangeQueryConverter : JsonConverter +internal sealed partial class DateRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override DateRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override DateRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new DateRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_zone") - { - variant.TimeZone = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, DateRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize DateRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.TimeZone)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DateRangeQuery { - writer.WritePropertyName("time_zone"); - writer.WriteStringValue(value.TimeZone); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value +, + TimeZone = propTimeZone.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, DateRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(DateRangeQueryConverter))] -public sealed partial class DateRangeQuery +public sealed partial class DateRangeQuery : IRangeQuery { public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -180,6 +163,10 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal DateRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +227,8 @@ public DateRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "daterangequery"; } public sealed partial class DateRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs new file mode 100644 index 00000000000..5c2285deae3 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayFunction.g.cs @@ -0,0 +1,63 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.QueryDsl; + +[JsonConverter(typeof(DecayFunctionConverter))] +public partial interface IDecayFunction +{ + public string? Type { get; } +} + +internal sealed partial class DecayFunctionConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IDecayFunction)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs index cd6e15ce644..d838f75ce06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DecayPlacement.g.cs @@ -27,6 +27,87 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class DecayPlacementConverter : System.Text.Json.Serialization.JsonConverter> +{ + private static readonly System.Text.Json.JsonEncodedText PropDecay = System.Text.Json.JsonEncodedText.Encode("decay"); + private static readonly System.Text.Json.JsonEncodedText PropOffset = System.Text.Json.JsonEncodedText.Encode("offset"); + private static readonly System.Text.Json.JsonEncodedText PropOrigin = System.Text.Json.JsonEncodedText.Encode("origin"); + private static readonly System.Text.Json.JsonEncodedText PropScale = System.Text.Json.JsonEncodedText.Encode("scale"); + + public override DecayPlacement Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDecay = default; + LocalJsonValue propOffset = default; + LocalJsonValue propOrigin = default; + LocalJsonValue propScale = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDecay.TryRead(ref reader, options, PropDecay)) + { + continue; + } + + if (propOffset.TryRead(ref reader, options, PropOffset, typeof(SourceMarker))) + { + continue; + } + + if (propOrigin.TryRead(ref reader, options, PropOrigin, typeof(SourceMarker))) + { + continue; + } + + if (propScale.TryRead(ref reader, options, PropScale, typeof(SourceMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new DecayPlacement + { + Decay = propDecay.Value +, + Offset = propOffset.Value +, + Origin = propOrigin.Value +, + Scale = propScale.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, DecayPlacement value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDecay, value.Decay); + writer.WriteProperty(options, PropOffset, value.Offset, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropOrigin, value.Origin, null, typeof(SourceMarker)); + writer.WriteProperty(options, PropScale, value.Scale, null, typeof(SourceMarker)); + writer.WriteEndObject(); + } +} + +internal sealed partial class DecayPlacementConverterFactory : System.Text.Json.Serialization.JsonConverterFactory +{ + public override bool CanConvert(System.Type typeToConvert) + { + return typeToConvert.IsGenericType && typeToConvert.GetGenericTypeDefinition() == typeof(DecayPlacement<,>); + } + + public override System.Text.Json.Serialization.JsonConverter CreateConverter(System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + var args = typeToConvert.GetGenericArguments(); +#pragma warning disable IL3050 + var converter = (System.Text.Json.Serialization.JsonConverter)System.Activator.CreateInstance(typeof(DecayPlacementConverter<,>).MakeGenericType(args[0], args[1]), System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, binder: null, args: null, culture: null)!; +#pragma warning restore IL3050 + return converter; + } +} + +[JsonConverter(typeof(DecayPlacementConverterFactory))] public sealed partial class DecayPlacement { /// @@ -34,7 +115,6 @@ public sealed partial class DecayPlacement /// Defines how documents are scored at the distance given at scale. /// /// - [JsonInclude, JsonPropertyName("decay")] public double? Decay { get; set; } /// @@ -42,8 +122,6 @@ public sealed partial class DecayPlacement /// If defined, the decay function will only compute the decay function for documents with a distance greater than the defined offset. /// /// - [JsonInclude, JsonPropertyName("offset")] - [SourceConverter] public TScale? Offset { get; set; } /// @@ -51,8 +129,6 @@ public sealed partial class DecayPlacement /// The point of origin used for calculating distance. Must be given as a number for numeric field, date for date fields and geo point for geo fields. /// /// - [JsonInclude, JsonPropertyName("origin")] - [SourceConverter] public TOrigin? Origin { get; set; } /// @@ -60,7 +136,5 @@ public sealed partial class DecayPlacement /// Defines the distance from origin + offset at which the computed score will equal decay parameter. /// /// - [JsonInclude, JsonPropertyName("scale")] - [SourceConverter] public TScale? Scale { get; set; } } \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs new file mode 100644 index 00000000000..356cb780037 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/DistanceFeatureQuery.g.cs @@ -0,0 +1,60 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.QueryDsl; + +[JsonConverter(typeof(DistanceFeatureQueryConverter))] +public partial interface IDistanceFeatureQuery +{ + public string? Type { get; } +} + +internal sealed partial class DistanceFeatureQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IDistanceFeatureQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IDistanceFeatureQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IDistanceFeatureQuery)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs index 16db583ecbe..94be3fe0375 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FieldAndFormat.g.cs @@ -27,11 +27,71 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class FieldAndFormatConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropIncludeUnmapped = System.Text.Json.JsonEncodedText.Encode("include_unmapped"); + + public override FieldAndFormat Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + return new FieldAndFormat { Field = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propFormat = default; + LocalJsonValue propIncludeUnmapped = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propField.TryRead(ref reader, options, PropField)) + { + continue; + } + + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } + + if (propIncludeUnmapped.TryRead(ref reader, options, PropIncludeUnmapped)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FieldAndFormat + { + Field = propField.Value +, + Format = propFormat.Value +, + IncludeUnmapped = propIncludeUnmapped.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FieldAndFormat value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropIncludeUnmapped, value.IncludeUnmapped); + writer.WriteEndObject(); + } +} + /// /// /// A reference to a field with formatting instructions on how to return the value /// /// +[JsonConverter(typeof(FieldAndFormatConverter))] public sealed partial class FieldAndFormat { /// @@ -39,7 +99,6 @@ public sealed partial class FieldAndFormat /// Wildcard pattern. The request returns values for field names matching this pattern. /// /// - [JsonInclude, JsonPropertyName("field")] public Elastic.Clients.Elasticsearch.Field Field { get; set; } /// @@ -47,9 +106,7 @@ public sealed partial class FieldAndFormat /// Format in which the values are returned. /// /// - [JsonInclude, JsonPropertyName("format")] public string? Format { get; set; } - [JsonInclude, JsonPropertyName("include_unmapped")] public bool? IncludeUnmapped { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs index 15eea6a6ae2..01f853a82d8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScore.g.cs @@ -39,22 +39,29 @@ internal FunctionScore(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal FunctionScore() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } + public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("exp", decayFunction); public static FunctionScore FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => new FunctionScore("field_value_factor", fieldValueFactorScoreFunction); + public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); public static FunctionScore Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => new FunctionScore("gauss", decayFunction); + public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); public static FunctionScore Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => new FunctionScore("linear", decayFunction); @@ -80,137 +87,129 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class FunctionScoreConverter : JsonConverter +internal sealed partial class FunctionScoreConverter : System.Text.Json.Serialization.JsonConverter { - public override FunctionScore Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropWeight = System.Text.Json.JsonEncodedText.Encode("weight"); + private static readonly System.Text.Json.JsonEncodedText VariantExp = System.Text.Json.JsonEncodedText.Encode("exp"); + private static readonly System.Text.Json.JsonEncodedText VariantFieldValueFactor = System.Text.Json.JsonEncodedText.Encode("field_value_factor"); + private static readonly System.Text.Json.JsonEncodedText VariantGauss = System.Text.Json.JsonEncodedText.Encode("gauss"); + private static readonly System.Text.Json.JsonEncodedText VariantLinear = System.Text.Json.JsonEncodedText.Encode("linear"); + private static readonly System.Text.Json.JsonEncodedText VariantRandomScore = System.Text.Json.JsonEncodedText.Encode("random_score"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptScore = System.Text.Json.JsonEncodedText.Encode("script_score"); + + public override FunctionScore Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query? filterValue = default; - double? weightValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFilter = default; + LocalJsonValue propWeight = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "filter") + if (propFilter.TryRead(ref reader, options, PropFilter)) { - filterValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "weight") + if (propWeight.TryRead(ref reader, options, PropWeight)) { - weightValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "exp") + if (reader.ValueTextEquals(VariantExp)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExp.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "field_value_factor") + if (reader.ValueTextEquals(VariantFieldValueFactor)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFieldValueFactor.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "gauss") + if (reader.ValueTextEquals(VariantGauss)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGauss.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "linear") + if (reader.ValueTextEquals(VariantLinear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantLinear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "random_score") + if (reader.ValueTextEquals(VariantRandomScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRandomScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script_score") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'FunctionScore' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new FunctionScore(variantNameValue, variantValue); - result.Filter = filterValue; - result.Weight = weightValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FunctionScore + { + VariantType = variantType, + Variant = variant, + Filter = propFilter.Value +, + Weight = propWeight.Value + }; } - public override void Write(Utf8JsonWriter writer, FunctionScore value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScore value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Filter is not null) - { - writer.WritePropertyName("filter"); - JsonSerializer.Serialize(writer, value.Filter, options); - } - - if (value.Weight.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("weight"); - writer.WriteNumberValue(value.Weight.Value); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "exp": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "field_value_factor": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction)value.Variant, options); - break; - case "gauss": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "linear": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "random_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RandomScoreFunction)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreFunction)value.Variant, options); - break; - } + case "": + break; + case "exp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant); + break; + case "field_value_factor": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction?)value.Variant); + break; + case "gauss": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant); + break; + case "linear": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction)value.Variant); + break; + case "random_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RandomScoreFunction?)value.Variant); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreFunction?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(FunctionScore)}'."); } + writer.WriteProperty(options, PropFilter, value.Filter); + writer.WriteProperty(options, PropWeight, value.Weight); writer.WriteEndObject(); } } @@ -261,16 +260,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action> configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); @@ -358,16 +360,19 @@ public FunctionScoreDescriptor Weight(double? weight) return Self; } + public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor Exp(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "exp"); public FunctionScoreDescriptor FieldValueFactor(Elastic.Clients.Elasticsearch.QueryDsl.FieldValueFactorScoreFunction fieldValueFactorScoreFunction) => Set(fieldValueFactorScoreFunction, "field_value_factor"); public FunctionScoreDescriptor FieldValueFactor(Action configure) => Set(configure, "field_value_factor"); + public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "gauss"); public FunctionScoreDescriptor Gauss(Elastic.Clients.Elasticsearch.QueryDsl.GeoDecayFunction decayFunction) => Set(decayFunction, "gauss"); + public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.IDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.DateDecayFunction decayFunction) => Set(decayFunction, "linear"); public FunctionScoreDescriptor Linear(Elastic.Clients.Elasticsearch.QueryDsl.NumericDecayFunction decayFunction) => Set(decayFunction, "linear"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs index 0b27f35c415..479bbbc27d6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FunctionScoreQuery.g.cs @@ -27,6 +27,116 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class FunctionScoreQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropBoostMode = System.Text.Json.JsonEncodedText.Encode("boost_mode"); + private static readonly System.Text.Json.JsonEncodedText PropFunctions = System.Text.Json.JsonEncodedText.Encode("functions"); + private static readonly System.Text.Json.JsonEncodedText PropMaxBoost = System.Text.Json.JsonEncodedText.Encode("max_boost"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropScoreMode = System.Text.Json.JsonEncodedText.Encode("score_mode"); + + public override FunctionScoreQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue?>(options); + return new FunctionScoreQuery { Functions = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propBoostMode = default; + LocalJsonValue?> propFunctions = default; + LocalJsonValue propMaxBoost = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propScoreMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propBoostMode.TryRead(ref reader, options, PropBoostMode)) + { + continue; + } + + if (propFunctions.TryRead(ref reader, options, PropFunctions)) + { + continue; + } + + if (propMaxBoost.TryRead(ref reader, options, PropMaxBoost)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propScoreMode.TryRead(ref reader, options, PropScoreMode)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FunctionScoreQuery + { + Boost = propBoost.Value +, + BoostMode = propBoostMode.Value +, + Functions = propFunctions.Value +, + MaxBoost = propMaxBoost.Value +, + MinScore = propMinScore.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ScoreMode = propScoreMode.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, FunctionScoreQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropBoostMode, value.BoostMode); + writer.WriteProperty(options, PropFunctions, value.Functions); + writer.WriteProperty(options, PropMaxBoost, value.MaxBoost); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropScoreMode, value.ScoreMode); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(FunctionScoreQueryConverter))] public sealed partial class FunctionScoreQuery { /// @@ -37,7 +147,6 @@ public sealed partial class FunctionScoreQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -45,7 +154,6 @@ public sealed partial class FunctionScoreQuery /// Defines how he newly computed score is combined with the score of the query /// /// - [JsonInclude, JsonPropertyName("boost_mode")] public Elastic.Clients.Elasticsearch.QueryDsl.FunctionBoostMode? BoostMode { get; set; } /// @@ -53,7 +161,6 @@ public sealed partial class FunctionScoreQuery /// One or more functions that compute a new score for each document returned by the query. /// /// - [JsonInclude, JsonPropertyName("functions")] public ICollection? Functions { get; set; } /// @@ -61,7 +168,6 @@ public sealed partial class FunctionScoreQuery /// Restricts the new score to not exceed the provided limit. /// /// - [JsonInclude, JsonPropertyName("max_boost")] public double? MaxBoost { get; set; } /// @@ -69,7 +175,6 @@ public sealed partial class FunctionScoreQuery /// Excludes documents that do not meet the provided score threshold. /// /// - [JsonInclude, JsonPropertyName("min_score")] public double? MinScore { get; set; } /// @@ -77,9 +182,7 @@ public sealed partial class FunctionScoreQuery /// A query that determines the documents for which a new score is computed. /// /// - [JsonInclude, JsonPropertyName("query")] public Elastic.Clients.Elasticsearch.QueryDsl.Query? Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -87,7 +190,6 @@ public sealed partial class FunctionScoreQuery /// Specifies how the computed scores are combined /// /// - [JsonInclude, JsonPropertyName("score_mode")] public Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreMode? ScoreMode { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(FunctionScoreQuery functionScoreQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.FunctionScore(functionScoreQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs index 511e2e5009d..b53b1fd63b6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/FuzzyQuery.g.cs @@ -27,128 +27,124 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class FuzzyQueryConverter : JsonConverter +internal sealed partial class FuzzyQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override FuzzyQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropTranspositions = System.Text.Json.JsonEncodedText.Encode("transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override FuzzyQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new FuzzyQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new FuzzyQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propTranspositions = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "transpositions") - { - variant.Transpositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, FuzzyQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize FuzzyQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTranspositions.TryRead(ref reader, options, PropTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Transpositions.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new FuzzyQuery { - writer.WritePropertyName("transpositions"); - writer.WriteBooleanValue(value.Transpositions.Value); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + MaxExpansions = propMaxExpansions.Value +, + PrefixLength = propPrefixLength.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Transpositions = propTranspositions.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - JsonSerializer.Serialize(writer, value.Value, options); + public override void Write(System.Text.Json.Utf8JsonWriter writer, FuzzyQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropTranspositions, value.Transpositions); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -164,6 +160,10 @@ public FuzzyQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal FuzzyQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs index 8833c66c219..9dd16f9d00f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoBoundingBoxQuery.g.cs @@ -27,90 +27,75 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class GeoBoundingBoxQueryConverter : JsonConverter +internal sealed partial class GeoBoundingBoxQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoBoundingBoxQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoundingBox = System.Text.Json.JsonEncodedText.Encode("bounding_box"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValidationMethod = System.Text.Json.JsonEncodedText.Encode("validation_method"); + + public override GeoBoundingBoxQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoBoundingBoxQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoundingBox = default; + LocalJsonValue propField = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "validation_method") - { - variant.ValidationMethod = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.BoundingBox = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoBoundingBoxQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.BoundingBox is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.BoundingBox, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryRead(ref reader, options, PropValidationMethod)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + propField.Initialized = propBoundingBox.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propBoundingBox.Value); } - if (value.ValidationMethod is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoBoundingBoxQuery { - writer.WritePropertyName("validation_method"); - JsonSerializer.Serialize(writer, value.ValidationMethod, options); - } + BoundingBox = propBoundingBox.Value +, + Field = propField.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value +, + ValidationMethod = propValidationMethod.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoBoundingBoxQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod); + writer.WriteProperty(options, value.Field, value.BoundingBox); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs index 446768423be..70949197cd5 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDecayFunction.g.cs @@ -27,60 +27,51 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class GeoDecayFunctionConverter : JsonConverter +internal sealed partial class GeoDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, GeoDecayFunction value, JsonSerializerOptions options) + public override GeoDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(GeoDecayFunctionConverter))] -public sealed partial class GeoDecayFunction +public sealed partial class GeoDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +82,8 @@ public sealed partial class GeoDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "geodecayfunction"; } public sealed partial class GeoDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs index 5c04cad4816..e93b625fb09 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class GeoDistanceFeatureQuery +public sealed partial class GeoDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class GeoDistanceFeatureQuery public string Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "geodistancefeaturequery"; } public sealed partial class GeoDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs index 04dae04ae98..d99fc34e7a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoDistanceQuery.g.cs @@ -27,110 +27,95 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class GeoDistanceQueryConverter : JsonConverter +internal sealed partial class GeoDistanceQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoDistanceQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropLocation = System.Text.Json.JsonEncodedText.Encode("location"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDistance = System.Text.Json.JsonEncodedText.Encode("distance"); + private static readonly System.Text.Json.JsonEncodedText PropDistanceType = System.Text.Json.JsonEncodedText.Encode("distance_type"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValidationMethod = System.Text.Json.JsonEncodedText.Encode("validation_method"); + + public override GeoDistanceQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoDistanceQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propLocation = default; + LocalJsonValue propBoost = default; + LocalJsonValue propDistance = default; + LocalJsonValue propDistanceType = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValidationMethod = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "distance") - { - variant.Distance = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "distance_type") - { - variant.DistanceType = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "validation_method") - { - variant.ValidationMethod = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Location = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoDistanceQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Location is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propDistance.TryRead(ref reader, options, PropDistance)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Location, options); - } + if (propDistanceType.TryRead(ref reader, options, PropDistanceType)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) + { + continue; + } - writer.WritePropertyName("distance"); - writer.WriteStringValue(value.Distance); - if (value.DistanceType is not null) - { - writer.WritePropertyName("distance_type"); - JsonSerializer.Serialize(writer, value.DistanceType, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); - } + if (propValidationMethod.TryRead(ref reader, options, PropValidationMethod)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + propField.Initialized = propLocation.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propLocation.Value); } - if (value.ValidationMethod is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoDistanceQuery { - writer.WritePropertyName("validation_method"); - JsonSerializer.Serialize(writer, value.ValidationMethod, options); - } + Field = propField.Value +, + Location = propLocation.Value +, + Boost = propBoost.Value +, + Distance = propDistance.Value +, + DistanceType = propDistanceType.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value +, + ValidationMethod = propValidationMethod.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoDistanceQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDistance, value.Distance); + writer.WriteProperty(options, PropDistanceType, value.DistanceType); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValidationMethod, value.ValidationMethod); + writer.WriteProperty(options, value.Field, value.Location); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs index ec6e5429145..e7a9ebd6f87 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/GeoShapeQuery.g.cs @@ -27,78 +27,65 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class GeoShapeQueryConverter : JsonConverter +internal sealed partial class GeoShapeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override GeoShapeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override GeoShapeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new GeoShapeQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propShape = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Shape = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, GeoShapeQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Shape is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Shape, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); + propField.Initialized = propShape.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propShape.Value); } - if (!string.IsNullOrEmpty(value.QueryName)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new GeoShapeQuery { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Shape = propShape.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, GeoShapeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Shape); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs index dc8261d52d0..3cac1aec6d2 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Intervals.g.cs @@ -39,12 +39,16 @@ internal Intervals(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Intervals() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Intervals AllOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf intervalsAllOf) => new Intervals("all_of", intervalsAllOf); public static Intervals AnyOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new Intervals("any_of", intervalsAnyOf); @@ -66,107 +70,104 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsConverter : JsonConverter +internal sealed partial class IntervalsConverter : System.Text.Json.Serialization.JsonConverter { - public override Intervals Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAllOf = System.Text.Json.JsonEncodedText.Encode("all_of"); + private static readonly System.Text.Json.JsonEncodedText VariantAnyOf = System.Text.Json.JsonEncodedText.Encode("any_of"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override Intervals Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAllOf)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "all_of") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Intervals' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Intervals(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Intervals { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Intervals value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Intervals value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf?)value.Variant); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Intervals)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs index 09e338e1fe9..ec17b03720c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsFilter.g.cs @@ -39,12 +39,16 @@ internal IntervalsFilter(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IntervalsFilter() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IntervalsFilter After(Elastic.Clients.Elasticsearch.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("after", intervalsContainer); public static IntervalsFilter Before(Elastic.Clients.Elasticsearch.QueryDsl.Intervals intervalsContainer) => new IntervalsFilter("before", intervalsContainer); @@ -69,137 +73,140 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsFilterConverter : JsonConverter +internal sealed partial class IntervalsFilterConverter : System.Text.Json.Serialization.JsonConverter { - public override IntervalsFilter Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantAfter = System.Text.Json.JsonEncodedText.Encode("after"); + private static readonly System.Text.Json.JsonEncodedText VariantBefore = System.Text.Json.JsonEncodedText.Encode("before"); + private static readonly System.Text.Json.JsonEncodedText VariantContainedBy = System.Text.Json.JsonEncodedText.Encode("contained_by"); + private static readonly System.Text.Json.JsonEncodedText VariantContaining = System.Text.Json.JsonEncodedText.Encode("containing"); + private static readonly System.Text.Json.JsonEncodedText VariantNotContainedBy = System.Text.Json.JsonEncodedText.Encode("not_contained_by"); + private static readonly System.Text.Json.JsonEncodedText VariantNotContaining = System.Text.Json.JsonEncodedText.Encode("not_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantNotOverlapping = System.Text.Json.JsonEncodedText.Encode("not_overlapping"); + private static readonly System.Text.Json.JsonEncodedText VariantOverlapping = System.Text.Json.JsonEncodedText.Encode("overlapping"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + + public override IntervalsFilter Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantAfter)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "after") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAfter.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "before") + if (reader.ValueTextEquals(VariantBefore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBefore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "contained_by") + if (reader.ValueTextEquals(VariantContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "containing") + if (reader.ValueTextEquals(VariantContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_contained_by") + if (reader.ValueTextEquals(VariantNotContainedBy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContainedBy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_containing") + if (reader.ValueTextEquals(VariantNotContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "not_overlapping") + if (reader.ValueTextEquals(VariantNotOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNotOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "overlapping") + if (reader.ValueTextEquals(VariantOverlapping)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantOverlapping.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsFilter' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new IntervalsFilter(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntervalsFilter { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, IntervalsFilter value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntervalsFilter value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "after": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "before": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_contained_by": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "not_overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "overlapping": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Script)value.Variant, options); - break; - } + case "": + break; + case "after": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "before": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "not_contained_by": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "not_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "not_overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "overlapping": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.Intervals?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Script?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IntervalsFilter)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs index bf1ea817e74..e26165f14c3 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/IntervalsQuery.g.cs @@ -39,12 +39,16 @@ internal IntervalsQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal IntervalsQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static IntervalsQuery AllOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf intervalsAllOf) => new IntervalsQuery("all_of", intervalsAllOf); public static IntervalsQuery AnyOf(Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf intervalsAnyOf) => new IntervalsQuery("any_of", intervalsAnyOf); @@ -81,149 +85,139 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class IntervalsQueryConverter : JsonConverter +internal sealed partial class IntervalsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override IntervalsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantAllOf = System.Text.Json.JsonEncodedText.Encode("all_of"); + private static readonly System.Text.Json.JsonEncodedText VariantAnyOf = System.Text.Json.JsonEncodedText.Encode("any_of"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override IntervalsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - reader.Read(); - var fieldName = reader.GetString(); - reader.Read(); - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); + continue; } - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") + if (propField.TryRead(ref reader, options, PropField)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "all_of") + if (reader.ValueTextEquals(VariantAllOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAllOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "any_of") + if (reader.ValueTextEquals(VariantAnyOf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantAnyOf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'IntervalsQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - reader.Read(); - var result = new IntervalsQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Field = fieldName; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new IntervalsQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Field = propField.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, IntervalsQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, IntervalsQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize IntervalsQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); writer.WriteStartObject(); - if (value.Boost.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + case "": + break; + case "all_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf?)value.Variant); + break; + case "any_of": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(IntervalsQuery)}'."); } - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "all_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAllOf)value.Variant, options); - break; - case "any_of": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsAnyOf)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsFuzzy)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsMatch)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsPrefix)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsWildcard)value.Variant, options); - break; - } - } - - writer.WriteEndObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs index 181ce211247..9c4d09017d7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/LikeDocument.g.cs @@ -27,6 +27,110 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class LikeDocumentConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropDoc = System.Text.Json.JsonEncodedText.Encode("doc"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("_id"); + private static readonly System.Text.Json.JsonEncodedText PropIndex = System.Text.Json.JsonEncodedText.Encode("_index"); + private static readonly System.Text.Json.JsonEncodedText PropPerFieldAnalyzer = System.Text.Json.JsonEncodedText.Encode("per_field_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override LikeDocument Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propDoc = default; + LocalJsonValue propFields = default; + LocalJsonValue propId = default; + LocalJsonValue propIndex = default; + LocalJsonValue?> propPerFieldAnalyzer = default; + LocalJsonValue propRouting = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propDoc.TryRead(ref reader, options, PropDoc)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propId.TryRead(ref reader, options, PropId)) + { + continue; + } + + if (propIndex.TryRead(ref reader, options, PropIndex)) + { + continue; + } + + if (propPerFieldAnalyzer.TryRead(ref reader, options, PropPerFieldAnalyzer)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new LikeDocument + { + Doc = propDoc.Value +, + Fields = propFields.Value +, + Id = propId.Value +, + Index = propIndex.Value +, + PerFieldAnalyzer = propPerFieldAnalyzer.Value +, + Routing = propRouting.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, LikeDocument value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropDoc, value.Doc); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropId, value.Id); + writer.WriteProperty(options, PropIndex, value.Index); + writer.WriteProperty(options, PropPerFieldAnalyzer, value.PerFieldAnalyzer); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(LikeDocumentConverter))] public sealed partial class LikeDocument { /// @@ -34,10 +138,7 @@ public sealed partial class LikeDocument /// A document not present in the index. /// /// - [JsonInclude, JsonPropertyName("doc")] public object? Doc { get; set; } - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -45,7 +146,6 @@ public sealed partial class LikeDocument /// ID of a document. /// /// - [JsonInclude, JsonPropertyName("_id")] public Elastic.Clients.Elasticsearch.Id? Id { get; set; } /// @@ -53,7 +153,6 @@ public sealed partial class LikeDocument /// Index of a document. /// /// - [JsonInclude, JsonPropertyName("_index")] public Elastic.Clients.Elasticsearch.IndexName? Index { get; set; } /// @@ -61,13 +160,9 @@ public sealed partial class LikeDocument /// Overrides the default analyzer. /// /// - [JsonInclude, JsonPropertyName("per_field_analyzer")] public IDictionary? PerFieldAnalyzer { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs index 4d56cdd27b8..d57def64206 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchBoolPrefixQuery.g.cs @@ -27,164 +27,154 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class MatchBoolPrefixQueryConverter : JsonConverter +internal sealed partial class MatchBoolPrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchBoolPrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override MatchBoolPrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new MatchBoolPrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchBoolPrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_rewrite") - { - variant.FuzzyRewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_transpositions") - { - variant.FuzzyTranspositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "operator") - { - variant.Operator = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchBoolPrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchBoolPrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchBoolPrefixQuery + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchBoolPrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -200,6 +190,10 @@ public MatchBoolPrefixQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal MatchBoolPrefixQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs index 3a1f22002b6..e31cc3a25aa 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhrasePrefixQuery.g.cs @@ -27,116 +27,114 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class MatchPhrasePrefixQueryConverter : JsonConverter +internal sealed partial class MatchPhrasePrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchPhrasePrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchPhrasePrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new MatchPhrasePrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchPhrasePrefixQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slop") - { - variant.Slop = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchPhrasePrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchPhrasePrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ZeroTermsQuery is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchPhrasePrefixQuery { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); - } + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + MaxExpansions = propMaxExpansions.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchPhrasePrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +150,10 @@ public MatchPhrasePrefixQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal MatchPhrasePrefixQuery() + { + } + /// /// /// Analyzer used to convert text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs index ff6632c7399..0239621e15b 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchPhraseQuery.g.cs @@ -27,104 +27,104 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class MatchPhraseQueryConverter : JsonConverter +internal sealed partial class MatchPhraseQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchPhraseQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchPhraseQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new MatchPhraseQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new MatchPhraseQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "slop") - { - variant.Slop = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchPhraseQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchPhraseQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } - if (value.Slop.HasValue) - { - writer.WritePropertyName("slop"); - writer.WriteNumberValue(value.Slop.Value); + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.ZeroTermsQuery is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchPhraseQuery { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); - } + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchPhraseQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +140,10 @@ public MatchPhraseQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal MatchPhraseQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs index 21611f7384a..1d7e0999341 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MatchQuery.g.cs @@ -27,200 +27,184 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class MatchQueryConverter : JsonConverter +internal sealed partial class MatchQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override MatchQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MatchQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new MatchQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + reader.Read(); + return new MatchQuery { Query = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) { - var property = reader.GetString(); - if (property == "analyzer") - { - variant.Analyzer = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "auto_generate_synonyms_phrase_query") - { - variant.AutoGenerateSynonymsPhraseQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzziness") - { - variant.Fuzziness = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_rewrite") - { - variant.FuzzyRewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "fuzzy_transpositions") - { - variant.FuzzyTranspositions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lenient") - { - variant.Lenient = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_expansions") - { - variant.MaxExpansions = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "operator") - { - variant.Operator = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "prefix_length") - { - variant.PrefixLength = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "query") - { - variant.Query = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "zero_terms_query") - { - variant.ZeroTermsQuery = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, MatchQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize MatchQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (!string.IsNullOrEmpty(value.Analyzer)) - { - writer.WritePropertyName("analyzer"); - writer.WriteStringValue(value.Analyzer); - } + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } - if (value.AutoGenerateSynonymsPhraseQuery.HasValue) - { - writer.WritePropertyName("auto_generate_synonyms_phrase_query"); - writer.WriteBooleanValue(value.AutoGenerateSynonymsPhraseQuery.Value); - } + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } - if (value.Fuzziness is not null) - { - writer.WritePropertyName("fuzziness"); - JsonSerializer.Serialize(writer, value.Fuzziness, options); - } + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } - if (!string.IsNullOrEmpty(value.FuzzyRewrite)) - { - writer.WritePropertyName("fuzzy_rewrite"); - writer.WriteStringValue(value.FuzzyRewrite); - } + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } - if (value.FuzzyTranspositions.HasValue) - { - writer.WritePropertyName("fuzzy_transpositions"); - writer.WriteBooleanValue(value.FuzzyTranspositions.Value); - } + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } - if (value.Lenient.HasValue) - { - writer.WritePropertyName("lenient"); - writer.WriteBooleanValue(value.Lenient.Value); - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - if (value.MaxExpansions.HasValue) - { - writer.WritePropertyName("max_expansions"); - writer.WriteNumberValue(value.MaxExpansions.Value); - } + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } - if (value.Operator is not null) - { - writer.WritePropertyName("operator"); - JsonSerializer.Serialize(writer, value.Operator, options); - } + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } - if (value.PrefixLength.HasValue) - { - writer.WritePropertyName("prefix_length"); - writer.WriteNumberValue(value.PrefixLength.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - writer.WritePropertyName("query"); - JsonSerializer.Serialize(writer, value.Query, options); - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } - if (value.ZeroTermsQuery is not null) - { - writer.WritePropertyName("zero_terms_query"); - JsonSerializer.Serialize(writer, value.ZeroTermsQuery, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MatchQuery + { + Analyzer = propAnalyzer.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Field = propField.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MatchQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -236,6 +220,10 @@ public MatchQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal MatchQuery() + { + } + /// /// /// Analyzer used to convert the text in the query value into tokens. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs index 30e777edcfb..641ff6f2cb6 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MoreLikeThisQuery.g.cs @@ -27,6 +27,230 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class MoreLikeThisQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropBoostTerms = System.Text.Json.JsonEncodedText.Encode("boost_terms"); + private static readonly System.Text.Json.JsonEncodedText PropFailOnUnsupportedField = System.Text.Json.JsonEncodedText.Encode("fail_on_unsupported_field"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropInclude = System.Text.Json.JsonEncodedText.Encode("include"); + private static readonly System.Text.Json.JsonEncodedText PropLike = System.Text.Json.JsonEncodedText.Encode("like"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDocFreq = System.Text.Json.JsonEncodedText.Encode("max_doc_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMaxQueryTerms = System.Text.Json.JsonEncodedText.Encode("max_query_terms"); + private static readonly System.Text.Json.JsonEncodedText PropMaxWordLength = System.Text.Json.JsonEncodedText.Encode("max_word_length"); + private static readonly System.Text.Json.JsonEncodedText PropMinDocFreq = System.Text.Json.JsonEncodedText.Encode("min_doc_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMinTermFreq = System.Text.Json.JsonEncodedText.Encode("min_term_freq"); + private static readonly System.Text.Json.JsonEncodedText PropMinWordLength = System.Text.Json.JsonEncodedText.Encode("min_word_length"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRouting = System.Text.Json.JsonEncodedText.Encode("routing"); + private static readonly System.Text.Json.JsonEncodedText PropStopWords = System.Text.Json.JsonEncodedText.Encode("stop_words"); + private static readonly System.Text.Json.JsonEncodedText PropUnlike = System.Text.Json.JsonEncodedText.Encode("unlike"); + private static readonly System.Text.Json.JsonEncodedText PropVersion = System.Text.Json.JsonEncodedText.Encode("version"); + private static readonly System.Text.Json.JsonEncodedText PropVersionType = System.Text.Json.JsonEncodedText.Encode("version_type"); + + public override MoreLikeThisQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propBoost = default; + LocalJsonValue propBoostTerms = default; + LocalJsonValue propFailOnUnsupportedField = default; + LocalJsonValue propFields = default; + LocalJsonValue propInclude = default; + LocalJsonValue> propLike = default; + LocalJsonValue propMaxDocFreq = default; + LocalJsonValue propMaxQueryTerms = default; + LocalJsonValue propMaxWordLength = default; + LocalJsonValue propMinDocFreq = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propMinTermFreq = default; + LocalJsonValue propMinWordLength = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRouting = default; + LocalJsonValue?> propStopWords = default; + LocalJsonValue?> propUnlike = default; + LocalJsonValue propVersion = default; + LocalJsonValue propVersionType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propBoostTerms.TryRead(ref reader, options, PropBoostTerms)) + { + continue; + } + + if (propFailOnUnsupportedField.TryRead(ref reader, options, PropFailOnUnsupportedField)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propInclude.TryRead(ref reader, options, PropInclude)) + { + continue; + } + + if (propLike.TryRead(ref reader, options, PropLike, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryDsl.Like>))) + { + continue; + } + + if (propMaxDocFreq.TryRead(ref reader, options, PropMaxDocFreq)) + { + continue; + } + + if (propMaxQueryTerms.TryRead(ref reader, options, PropMaxQueryTerms)) + { + continue; + } + + if (propMaxWordLength.TryRead(ref reader, options, PropMaxWordLength)) + { + continue; + } + + if (propMinDocFreq.TryRead(ref reader, options, PropMinDocFreq)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propMinTermFreq.TryRead(ref reader, options, PropMinTermFreq)) + { + continue; + } + + if (propMinWordLength.TryRead(ref reader, options, PropMinWordLength)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propRouting.TryRead(ref reader, options, PropRouting)) + { + continue; + } + + if (propStopWords.TryRead(ref reader, options, PropStopWords, typeof(SingleOrManyMarker?, string>))) + { + continue; + } + + if (propUnlike.TryRead(ref reader, options, PropUnlike, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Like>))) + { + continue; + } + + if (propVersion.TryRead(ref reader, options, PropVersion)) + { + continue; + } + + if (propVersionType.TryRead(ref reader, options, PropVersionType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MoreLikeThisQuery + { + Analyzer = propAnalyzer.Value +, + Boost = propBoost.Value +, + BoostTerms = propBoostTerms.Value +, + FailOnUnsupportedField = propFailOnUnsupportedField.Value +, + Fields = propFields.Value +, + Include = propInclude.Value +, + Like = propLike.Value +, + MaxDocFreq = propMaxDocFreq.Value +, + MaxQueryTerms = propMaxQueryTerms.Value +, + MaxWordLength = propMaxWordLength.Value +, + MinDocFreq = propMinDocFreq.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + MinTermFreq = propMinTermFreq.Value +, + MinWordLength = propMinWordLength.Value +, + QueryName = propQueryName.Value +, + Routing = propRouting.Value +, + StopWords = propStopWords.Value +, + Unlike = propUnlike.Value +, + Version = propVersion.Value +, + VersionType = propVersionType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MoreLikeThisQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropBoostTerms, value.BoostTerms); + writer.WriteProperty(options, PropFailOnUnsupportedField, value.FailOnUnsupportedField); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropInclude, value.Include); + writer.WriteProperty(options, PropLike, value.Like, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryDsl.Like>)); + writer.WriteProperty(options, PropMaxDocFreq, value.MaxDocFreq); + writer.WriteProperty(options, PropMaxQueryTerms, value.MaxQueryTerms); + writer.WriteProperty(options, PropMaxWordLength, value.MaxWordLength); + writer.WriteProperty(options, PropMinDocFreq, value.MinDocFreq); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMinTermFreq, value.MinTermFreq); + writer.WriteProperty(options, PropMinWordLength, value.MinWordLength); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRouting, value.Routing); + writer.WriteProperty(options, PropStopWords, value.StopWords, null, typeof(SingleOrManyMarker?, string>)); + writer.WriteProperty(options, PropUnlike, value.Unlike, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Like>)); + writer.WriteProperty(options, PropVersion, value.Version); + writer.WriteProperty(options, PropVersionType, value.VersionType); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MoreLikeThisQueryConverter))] public sealed partial class MoreLikeThisQuery { /// @@ -35,7 +259,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to the analyzer associated with the first field in fields. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -46,7 +269,6 @@ public sealed partial class MoreLikeThisQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -56,7 +278,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to deactivated (0). /// /// - [JsonInclude, JsonPropertyName("boost_terms")] public double? BoostTerms { get; set; } /// @@ -64,7 +285,6 @@ public sealed partial class MoreLikeThisQuery /// Controls whether the query should fail (throw an exception) if any of the specified fields are not of the supported types (text or keyword). /// /// - [JsonInclude, JsonPropertyName("fail_on_unsupported_field")] public bool? FailOnUnsupportedField { get; set; } /// @@ -73,8 +293,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -82,7 +300,6 @@ public sealed partial class MoreLikeThisQuery /// Specifies whether the input documents should also be included in the search results returned. /// /// - [JsonInclude, JsonPropertyName("include")] public bool? Include { get; set; } /// @@ -90,8 +307,6 @@ public sealed partial class MoreLikeThisQuery /// Specifies free form text and/or a single or multiple documents for which you want to find similar documents. /// /// - [JsonInclude, JsonPropertyName("like")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Like))] public ICollection Like { get; set; } /// @@ -99,7 +314,6 @@ public sealed partial class MoreLikeThisQuery /// The maximum document frequency above which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("max_doc_freq")] public int? MaxDocFreq { get; set; } /// @@ -107,7 +321,6 @@ public sealed partial class MoreLikeThisQuery /// The maximum number of query terms that can be selected. /// /// - [JsonInclude, JsonPropertyName("max_query_terms")] public int? MaxQueryTerms { get; set; } /// @@ -116,7 +329,6 @@ public sealed partial class MoreLikeThisQuery /// Defaults to unbounded (0). /// /// - [JsonInclude, JsonPropertyName("max_word_length")] public int? MaxWordLength { get; set; } /// @@ -124,7 +336,6 @@ public sealed partial class MoreLikeThisQuery /// The minimum document frequency below which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("min_doc_freq")] public int? MinDocFreq { get; set; } /// @@ -132,7 +343,6 @@ public sealed partial class MoreLikeThisQuery /// After the disjunctive query has been formed, this parameter controls the number of terms that must match. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -140,7 +350,6 @@ public sealed partial class MoreLikeThisQuery /// The minimum term frequency below which the terms are ignored from the input document. /// /// - [JsonInclude, JsonPropertyName("min_term_freq")] public int? MinTermFreq { get; set; } /// @@ -148,11 +357,8 @@ public sealed partial class MoreLikeThisQuery /// The minimum word length below which the terms are ignored. /// /// - [JsonInclude, JsonPropertyName("min_word_length")] public int? MinWordLength { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } - [JsonInclude, JsonPropertyName("routing")] public Elastic.Clients.Elasticsearch.Routing? Routing { get; set; } /// @@ -161,8 +367,6 @@ public sealed partial class MoreLikeThisQuery /// Any word in this set is ignored. /// /// - [JsonInclude, JsonPropertyName("stop_words")] - [SingleOrManyCollectionConverter(typeof(string))] public ICollection? StopWords { get; set; } /// @@ -170,12 +374,8 @@ public sealed partial class MoreLikeThisQuery /// Used in combination with like to exclude documents that match a set of terms. /// /// - [JsonInclude, JsonPropertyName("unlike")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Like))] public ICollection? Unlike { get; set; } - [JsonInclude, JsonPropertyName("version")] public long? Version { get; set; } - [JsonInclude, JsonPropertyName("version_type")] public Elastic.Clients.Elasticsearch.VersionType? VersionType { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(MoreLikeThisQuery moreLikeThisQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.MoreLikeThis(moreLikeThisQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs index 8a01d0b1f4c..ab74bbd1459 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/MultiMatchQuery.g.cs @@ -27,6 +27,210 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class MultiMatchQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxExpansions = System.Text.Json.JsonEncodedText.Encode("max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropOperator = System.Text.Json.JsonEncodedText.Encode("operator"); + private static readonly System.Text.Json.JsonEncodedText PropPrefixLength = System.Text.Json.JsonEncodedText.Encode("prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropSlop = System.Text.Json.JsonEncodedText.Encode("slop"); + private static readonly System.Text.Json.JsonEncodedText PropTieBreaker = System.Text.Json.JsonEncodedText.Encode("tie_breaker"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + private static readonly System.Text.Json.JsonEncodedText PropZeroTermsQuery = System.Text.Json.JsonEncodedText.Encode("zero_terms_query"); + + public override MultiMatchQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propFields = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMaxExpansions = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propOperator = default; + LocalJsonValue propPrefixLength = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propSlop = default; + LocalJsonValue propTieBreaker = default; + LocalJsonValue propType = default; + LocalJsonValue propZeroTermsQuery = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } + + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMaxExpansions.TryRead(ref reader, options, PropMaxExpansions)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propOperator.TryRead(ref reader, options, PropOperator)) + { + continue; + } + + if (propPrefixLength.TryRead(ref reader, options, PropPrefixLength)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propSlop.TryRead(ref reader, options, PropSlop)) + { + continue; + } + + if (propTieBreaker.TryRead(ref reader, options, PropTieBreaker)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + if (propZeroTermsQuery.TryRead(ref reader, options, PropZeroTermsQuery)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new MultiMatchQuery + { + Analyzer = propAnalyzer.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + Fields = propFields.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxExpansions = propMaxExpansions.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Operator = propOperator.Value +, + PrefixLength = propPrefixLength.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + Slop = propSlop.Value +, + TieBreaker = propTieBreaker.Value +, + Type = propType.Value +, + ZeroTermsQuery = propZeroTermsQuery.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, MultiMatchQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxExpansions, value.MaxExpansions); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropOperator, value.Operator); + writer.WriteProperty(options, PropPrefixLength, value.PrefixLength); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropSlop, value.Slop); + writer.WriteProperty(options, PropTieBreaker, value.TieBreaker); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteProperty(options, PropZeroTermsQuery, value.ZeroTermsQuery); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(MultiMatchQueryConverter))] public sealed partial class MultiMatchQuery { /// @@ -34,7 +238,6 @@ public sealed partial class MultiMatchQuery /// Analyzer used to convert the text in the query value into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -42,7 +245,6 @@ public sealed partial class MultiMatchQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -53,7 +255,6 @@ public sealed partial class MultiMatchQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -62,8 +263,6 @@ public sealed partial class MultiMatchQuery /// Defaults to the index.query.default_field index settings, which in turn defaults to *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -71,7 +270,6 @@ public sealed partial class MultiMatchQuery /// Maximum edit distance allowed for matching. /// /// - [JsonInclude, JsonPropertyName("fuzziness")] public Elastic.Clients.Elasticsearch.Fuzziness? Fuzziness { get; set; } /// @@ -79,7 +277,6 @@ public sealed partial class MultiMatchQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("fuzzy_rewrite")] public string? FuzzyRewrite { get; set; } /// @@ -88,7 +285,6 @@ public sealed partial class MultiMatchQuery /// Can be applied to the term subqueries constructed for all terms but the final term. /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -96,7 +292,6 @@ public sealed partial class MultiMatchQuery /// If true, format-based errors, such as providing a text query value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -104,7 +299,6 @@ public sealed partial class MultiMatchQuery /// Maximum number of terms to which the query will expand. /// /// - [JsonInclude, JsonPropertyName("max_expansions")] public int? MaxExpansions { get; set; } /// @@ -112,7 +306,6 @@ public sealed partial class MultiMatchQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -120,7 +313,6 @@ public sealed partial class MultiMatchQuery /// Boolean logic used to interpret text in the query value. /// /// - [JsonInclude, JsonPropertyName("operator")] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? Operator { get; set; } /// @@ -128,7 +320,6 @@ public sealed partial class MultiMatchQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("prefix_length")] public int? PrefixLength { get; set; } /// @@ -136,9 +327,7 @@ public sealed partial class MultiMatchQuery /// Text, number, boolean value or date you wish to find in the provided field. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -146,7 +335,6 @@ public sealed partial class MultiMatchQuery /// Maximum number of positions allowed between matching tokens. /// /// - [JsonInclude, JsonPropertyName("slop")] public int? Slop { get; set; } /// @@ -154,7 +342,6 @@ public sealed partial class MultiMatchQuery /// Determines how scores for each per-term blended query and scores across groups are combined. /// /// - [JsonInclude, JsonPropertyName("tie_breaker")] public double? TieBreaker { get; set; } /// @@ -162,7 +349,6 @@ public sealed partial class MultiMatchQuery /// How the multi_match query is executed internally. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryDsl.TextQueryType? Type { get; set; } /// @@ -170,7 +356,6 @@ public sealed partial class MultiMatchQuery /// Indicates whether no documents are returned if the analyzer removes all tokens, such as when using a stop filter. /// /// - [JsonInclude, JsonPropertyName("zero_terms_query")] public Elastic.Clients.Elasticsearch.QueryDsl.ZeroTermsQuery? ZeroTermsQuery { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(MultiMatchQuery multiMatchQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.MultiMatch(multiMatchQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs index cfbc2a0079e..ad9ea2925d4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumberRangeQuery.g.cs @@ -27,127 +27,114 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class NumberRangeQueryConverter : JsonConverter +internal sealed partial class NumberRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override NumberRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + + public override NumberRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new NumberRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, NumberRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize NumberRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt.HasValue) - { - writer.WritePropertyName("gt"); - writer.WriteNumberValue(value.Gt.Value); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte.HasValue) - { - writer.WritePropertyName("gte"); - writer.WriteNumberValue(value.Gte.Value); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt.HasValue) - { - writer.WritePropertyName("lt"); - writer.WriteNumberValue(value.Lt.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte.HasValue) - { - writer.WritePropertyName("lte"); - writer.WriteNumberValue(value.Lte.Value); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Relation is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NumberRangeQuery { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumberRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(NumberRangeQueryConverter))] -public sealed partial class NumberRangeQuery +public sealed partial class NumberRangeQuery : IRangeQuery { public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -156,6 +143,10 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal NumberRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +193,8 @@ public NumberRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public Elastic.Clients.Elasticsearch.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "numberrangequery"; } public sealed partial class NumberRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs index 7b69411a236..645ebf56b11 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/NumericDecayFunction.g.cs @@ -27,60 +27,51 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class NumericDecayFunctionConverter : JsonConverter +internal sealed partial class NumericDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override NumericDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new NumericDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, NumericDecayFunction value, JsonSerializerOptions options) + public override NumericDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new NumericDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, NumericDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(NumericDecayFunctionConverter))] -public sealed partial class NumericDecayFunction +public sealed partial class NumericDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +82,8 @@ public sealed partial class NumericDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "numericdecayfunction"; } public sealed partial class NumericDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs index 26dd33fbbfb..d601cebfb77 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PinnedQuery.g.cs @@ -39,12 +39,16 @@ internal PinnedQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal PinnedQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static PinnedQuery Docs(IReadOnlyCollection pinnedDoc) => new PinnedQuery("docs", pinnedDoc); public static PinnedQuery Ids(IReadOnlyCollection id) => new PinnedQuery("ids", id); @@ -83,111 +87,91 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class PinnedQueryConverter : JsonConverter +internal sealed partial class PinnedQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override PinnedQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropOrganic = System.Text.Json.JsonEncodedText.Encode("organic"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantDocs = System.Text.Json.JsonEncodedText.Encode("docs"); + private static readonly System.Text.Json.JsonEncodedText VariantIds = System.Text.Json.JsonEncodedText.Encode("ids"); - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - Elastic.Clients.Elasticsearch.QueryDsl.Query organicValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override PinnedQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propOrganic = default; + LocalJsonValue propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") - { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "organic") + if (propOrganic.TryRead(ref reader, options, PropOrganic)) { - organicValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "docs") + if (reader.ValueTextEquals(VariantDocs)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDocs.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - if (propertyName == "ids") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'PinnedQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new PinnedQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Organic = organicValue; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PinnedQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Organic = propOrganic.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, PinnedQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, PinnedQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Boost.HasValue) + switch (value.VariantType) { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.Organic is not null) - { - writer.WritePropertyName("organic"); - JsonSerializer.Serialize(writer, value.Organic, options); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "docs": - JsonSerializer.Serialize>(writer, (IReadOnlyCollection)value.Variant, options); - break; - case "ids": - JsonSerializer.Serialize>(writer, (IReadOnlyCollection)value.Variant, options); - break; - } + case "": + break; + case "docs": + writer.WriteProperty(options, value.VariantType, (ICollection?)value.Variant); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (ICollection?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(PinnedQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropOrganic, value.Organic); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs index bf5373da149..5070917a57f 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/PrefixQuery.g.cs @@ -27,92 +27,94 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class PrefixQueryConverter : JsonConverter +internal sealed partial class PrefixQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override PrefixQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override PrefixQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new PrefixQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new PrefixQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, PrefixQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize PrefixQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Rewrite)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new PrefixQuery { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + public override void Write(System.Text.Json.Utf8JsonWriter writer, PrefixQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -128,6 +130,10 @@ public PrefixQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal PrefixQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs index 35c8ba75904..4370ab67f4c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/Query.g.cs @@ -39,18 +39,23 @@ internal Query(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Query() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Query Bool(Elastic.Clients.Elasticsearch.QueryDsl.BoolQuery boolQuery) => new Query("bool", boolQuery); public static Query Boosting(Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery boostingQuery) => new Query("boosting", boostingQuery); public static Query CombinedFields(Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery combinedFieldsQuery) => new Query("combined_fields", combinedFieldsQuery); public static Query ConstantScore(Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery constantScoreQuery) => new Query("constant_score", constantScoreQuery); public static Query DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => new Query("dis_max", disMaxQuery); + public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); public static Query DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => new Query("distance_feature", distanceFeatureQuery); @@ -79,6 +84,7 @@ internal Query(string variantName, object variant) public static Query Pinned(Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery pinnedQuery) => new Query("pinned", pinnedQuery); public static Query Prefix(Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery prefixQuery) => new Query("prefix", prefixQuery); public static Query QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => new Query("query_string", queryStringQuery); + public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => new Query("range", rangeQuery); public static Query Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => new Query("range", rangeQuery); @@ -121,607 +127,704 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class QueryConverter : JsonConverter +internal sealed partial class QueryConverter : System.Text.Json.Serialization.JsonConverter { - public override Query Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantBool = System.Text.Json.JsonEncodedText.Encode("bool"); + private static readonly System.Text.Json.JsonEncodedText VariantBoosting = System.Text.Json.JsonEncodedText.Encode("boosting"); + private static readonly System.Text.Json.JsonEncodedText VariantCombinedFields = System.Text.Json.JsonEncodedText.Encode("combined_fields"); + private static readonly System.Text.Json.JsonEncodedText VariantConstantScore = System.Text.Json.JsonEncodedText.Encode("constant_score"); + private static readonly System.Text.Json.JsonEncodedText VariantDisMax = System.Text.Json.JsonEncodedText.Encode("dis_max"); + private static readonly System.Text.Json.JsonEncodedText VariantDistanceFeature = System.Text.Json.JsonEncodedText.Encode("distance_feature"); + private static readonly System.Text.Json.JsonEncodedText VariantExists = System.Text.Json.JsonEncodedText.Encode("exists"); + private static readonly System.Text.Json.JsonEncodedText VariantFunctionScore = System.Text.Json.JsonEncodedText.Encode("function_score"); + private static readonly System.Text.Json.JsonEncodedText VariantFuzzy = System.Text.Json.JsonEncodedText.Encode("fuzzy"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoBoundingBox = System.Text.Json.JsonEncodedText.Encode("geo_bounding_box"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoDistance = System.Text.Json.JsonEncodedText.Encode("geo_distance"); + private static readonly System.Text.Json.JsonEncodedText VariantGeoShape = System.Text.Json.JsonEncodedText.Encode("geo_shape"); + private static readonly System.Text.Json.JsonEncodedText VariantHasChild = System.Text.Json.JsonEncodedText.Encode("has_child"); + private static readonly System.Text.Json.JsonEncodedText VariantHasParent = System.Text.Json.JsonEncodedText.Encode("has_parent"); + private static readonly System.Text.Json.JsonEncodedText VariantIds = System.Text.Json.JsonEncodedText.Encode("ids"); + private static readonly System.Text.Json.JsonEncodedText VariantIntervals = System.Text.Json.JsonEncodedText.Encode("intervals"); + private static readonly System.Text.Json.JsonEncodedText VariantKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText VariantMatch = System.Text.Json.JsonEncodedText.Encode("match"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchAll = System.Text.Json.JsonEncodedText.Encode("match_all"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchBoolPrefix = System.Text.Json.JsonEncodedText.Encode("match_bool_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchNone = System.Text.Json.JsonEncodedText.Encode("match_none"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchPhrase = System.Text.Json.JsonEncodedText.Encode("match_phrase"); + private static readonly System.Text.Json.JsonEncodedText VariantMatchPhrasePrefix = System.Text.Json.JsonEncodedText.Encode("match_phrase_prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantMoreLikeThis = System.Text.Json.JsonEncodedText.Encode("more_like_this"); + private static readonly System.Text.Json.JsonEncodedText VariantMultiMatch = System.Text.Json.JsonEncodedText.Encode("multi_match"); + private static readonly System.Text.Json.JsonEncodedText VariantNested = System.Text.Json.JsonEncodedText.Encode("nested"); + private static readonly System.Text.Json.JsonEncodedText VariantParentId = System.Text.Json.JsonEncodedText.Encode("parent_id"); + private static readonly System.Text.Json.JsonEncodedText VariantPercolate = System.Text.Json.JsonEncodedText.Encode("percolate"); + private static readonly System.Text.Json.JsonEncodedText VariantPinned = System.Text.Json.JsonEncodedText.Encode("pinned"); + private static readonly System.Text.Json.JsonEncodedText VariantPrefix = System.Text.Json.JsonEncodedText.Encode("prefix"); + private static readonly System.Text.Json.JsonEncodedText VariantQueryString = System.Text.Json.JsonEncodedText.Encode("query_string"); + private static readonly System.Text.Json.JsonEncodedText VariantRange = System.Text.Json.JsonEncodedText.Encode("range"); + private static readonly System.Text.Json.JsonEncodedText VariantRankFeature = System.Text.Json.JsonEncodedText.Encode("rank_feature"); + private static readonly System.Text.Json.JsonEncodedText VariantRawJson = System.Text.Json.JsonEncodedText.Encode("raw_json"); + private static readonly System.Text.Json.JsonEncodedText VariantRegexp = System.Text.Json.JsonEncodedText.Encode("regexp"); + private static readonly System.Text.Json.JsonEncodedText VariantRule = System.Text.Json.JsonEncodedText.Encode("rule"); + private static readonly System.Text.Json.JsonEncodedText VariantScript = System.Text.Json.JsonEncodedText.Encode("script"); + private static readonly System.Text.Json.JsonEncodedText VariantScriptScore = System.Text.Json.JsonEncodedText.Encode("script_score"); + private static readonly System.Text.Json.JsonEncodedText VariantSemantic = System.Text.Json.JsonEncodedText.Encode("semantic"); + private static readonly System.Text.Json.JsonEncodedText VariantShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText VariantSimpleQueryString = System.Text.Json.JsonEncodedText.Encode("simple_query_string"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanContaining = System.Text.Json.JsonEncodedText.Encode("span_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFieldMasking = System.Text.Json.JsonEncodedText.Encode("span_field_masking"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFirst = System.Text.Json.JsonEncodedText.Encode("span_first"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanMulti = System.Text.Json.JsonEncodedText.Encode("span_multi"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNear = System.Text.Json.JsonEncodedText.Encode("span_near"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNot = System.Text.Json.JsonEncodedText.Encode("span_not"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanOr = System.Text.Json.JsonEncodedText.Encode("span_or"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanTerm = System.Text.Json.JsonEncodedText.Encode("span_term"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanWithin = System.Text.Json.JsonEncodedText.Encode("span_within"); + private static readonly System.Text.Json.JsonEncodedText VariantSparseVector = System.Text.Json.JsonEncodedText.Encode("sparse_vector"); + private static readonly System.Text.Json.JsonEncodedText VariantTerm = System.Text.Json.JsonEncodedText.Encode("term"); + private static readonly System.Text.Json.JsonEncodedText VariantTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText VariantTermsSet = System.Text.Json.JsonEncodedText.Encode("terms_set"); + private static readonly System.Text.Json.JsonEncodedText VariantWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + private static readonly System.Text.Json.JsonEncodedText VariantWrapper = System.Text.Json.JsonEncodedText.Encode("wrapper"); + + public override Query Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantBool)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "bool") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBool.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "boosting") + if (reader.ValueTextEquals(VariantBoosting)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantBoosting.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "combined_fields") + if (reader.ValueTextEquals(VariantCombinedFields)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantCombinedFields.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "constant_score") + if (reader.ValueTextEquals(VariantConstantScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantConstantScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "dis_max") + if (reader.ValueTextEquals(VariantDisMax)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDisMax.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "distance_feature") + if (reader.ValueTextEquals(VariantDistanceFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantDistanceFeature.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "exists") + if (reader.ValueTextEquals(VariantExists)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantExists.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "function_score") + if (reader.ValueTextEquals(VariantFunctionScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFunctionScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "fuzzy") + if (reader.ValueTextEquals(VariantFuzzy)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantFuzzy.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_bounding_box") + if (reader.ValueTextEquals(VariantGeoBoundingBox)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoBoundingBox.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_distance") + if (reader.ValueTextEquals(VariantGeoDistance)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoDistance.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "geo_shape") + if (reader.ValueTextEquals(VariantGeoShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantGeoShape.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "has_child") + if (reader.ValueTextEquals(VariantHasChild)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasChild.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "has_parent") + if (reader.ValueTextEquals(VariantHasParent)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantHasParent.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "ids") + if (reader.ValueTextEquals(VariantIds)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIds.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "intervals") + if (reader.ValueTextEquals(VariantIntervals)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantIntervals.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "knn") + if (reader.ValueTextEquals(VariantKnn)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match") + if (reader.ValueTextEquals(VariantMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_all") + if (reader.ValueTextEquals(VariantMatchAll)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchAll.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_bool_prefix") + if (reader.ValueTextEquals(VariantMatchBoolPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchBoolPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_none") + if (reader.ValueTextEquals(VariantMatchNone)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchNone.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_phrase") + if (reader.ValueTextEquals(VariantMatchPhrase)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrase.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "match_phrase_prefix") + if (reader.ValueTextEquals(VariantMatchPhrasePrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMatchPhrasePrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "more_like_this") + if (reader.ValueTextEquals(VariantMoreLikeThis)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMoreLikeThis.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "multi_match") + if (reader.ValueTextEquals(VariantMultiMatch)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantMultiMatch.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "nested") + if (reader.ValueTextEquals(VariantNested)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantNested.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "parent_id") + if (reader.ValueTextEquals(VariantParentId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantParentId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "percolate") + if (reader.ValueTextEquals(VariantPercolate)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPercolate.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "pinned") + if (reader.ValueTextEquals(VariantPinned)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPinned.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "prefix") + if (reader.ValueTextEquals(VariantPrefix)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantPrefix.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "query_string") + if (reader.ValueTextEquals(VariantQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "range") + if (reader.ValueTextEquals(VariantRange)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRange.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rank_feature") + if (reader.ValueTextEquals(VariantRankFeature)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRankFeature.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "raw_json") + if (reader.ValueTextEquals(VariantRawJson)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRawJson.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "regexp") + if (reader.ValueTextEquals(VariantRegexp)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRegexp.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script") + if (reader.ValueTextEquals(VariantScript)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScript.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "script_score") + if (reader.ValueTextEquals(VariantScriptScore)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantScriptScore.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "semantic") + if (reader.ValueTextEquals(VariantSemantic)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSemantic.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "shape") + if (reader.ValueTextEquals(VariantShape)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantShape.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "simple_query_string") + if (reader.ValueTextEquals(VariantSimpleQueryString)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSimpleQueryString.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_containing") + if (reader.ValueTextEquals(VariantSpanContaining)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_within") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "sparse_vector") + if (reader.ValueTextEquals(VariantSparseVector)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSparseVector.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "term") + if (reader.ValueTextEquals(VariantTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms") + if (reader.ValueTextEquals(VariantTerms)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTerms.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "terms_set") + if (reader.ValueTextEquals(VariantTermsSet)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTermsSet.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wildcard") + if (reader.ValueTextEquals(VariantWildcard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWildcard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "wrapper") + if (reader.ValueTextEquals(VariantWrapper)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantWrapper.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Query' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Query(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Query { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Query value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Query value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "bool": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.BoolQuery)value.Variant, options); - break; - case "boosting": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery)value.Variant, options); - break; - case "combined_fields": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery)value.Variant, options); - break; - case "constant_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery)value.Variant, options); - break; - case "dis_max": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery)value.Variant, options); - break; - case "distance_feature": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "exists": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ExistsQuery)value.Variant, options); - break; - case "function_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreQuery)value.Variant, options); - break; - case "fuzzy": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.FuzzyQuery)value.Variant, options); - break; - case "geo_bounding_box": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoBoundingBoxQuery)value.Variant, options); - break; - case "geo_distance": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceQuery)value.Variant, options); - break; - case "geo_shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.GeoShapeQuery)value.Variant, options); - break; - case "has_child": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.HasChildQuery)value.Variant, options); - break; - case "has_parent": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.HasParentQuery)value.Variant, options); - break; - case "ids": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IdsQuery)value.Variant, options); - break; - case "intervals": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery)value.Variant, options); - break; - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.KnnQuery)value.Variant, options); - break; - case "match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery)value.Variant, options); - break; - case "match_all": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchAllQuery)value.Variant, options); - break; - case "match_bool_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchBoolPrefixQuery)value.Variant, options); - break; - case "match_none": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchNoneQuery)value.Variant, options); - break; - case "match_phrase": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhraseQuery)value.Variant, options); - break; - case "match_phrase_prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhrasePrefixQuery)value.Variant, options); - break; - case "more_like_this": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MoreLikeThisQuery)value.Variant, options); - break; - case "multi_match": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.MultiMatchQuery)value.Variant, options); - break; - case "nested": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.NestedQuery)value.Variant, options); - break; - case "parent_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ParentIdQuery)value.Variant, options); - break; - case "percolate": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PercolateQuery)value.Variant, options); - break; - case "pinned": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery)value.Variant, options); - break; - case "prefix": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery)value.Variant, options); - break; - case "query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery)value.Variant, options); - break; - case "range": - JsonSerializer.Serialize(writer, value.Variant, value.Variant.GetType(), options); - break; - case "rank_feature": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RankFeatureQuery)value.Variant, options); - break; - case "raw_json": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RawJsonQuery)value.Variant, options); - break; - case "regexp": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RegexpQuery)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.RuleQuery)value.Variant, options); - break; - case "script": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery)value.Variant, options); - break; - case "script_score": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery)value.Variant, options); - break; - case "semantic": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SemanticQuery)value.Variant, options); - break; - case "shape": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery)value.Variant, options); - break; - case "simple_query_string": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery)value.Variant, options); - break; - case "span_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery)value.Variant, options); - break; - case "span_multi": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - case "sparse_vector": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SparseVectorQuery)value.Variant, options); - break; - case "term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermQuery)value.Variant, options); - break; - case "terms": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermsQuery)value.Variant, options); - break; - case "terms_set": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.TermsSetQuery)value.Variant, options); - break; - case "wildcard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.WildcardQuery)value.Variant, options); - break; - case "wrapper": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.WrapperQuery)value.Variant, options); - break; - } + case "": + break; + case "bool": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.BoolQuery?)value.Variant); + break; + case "boosting": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.BoostingQuery?)value.Variant); + break; + case "combined_fields": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.CombinedFieldsQuery?)value.Variant); + break; + case "constant_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ConstantScoreQuery?)value.Variant); + break; + case "dis_max": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery?)value.Variant); + break; + case "distance_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery)value.Variant); + break; + case "exists": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ExistsQuery?)value.Variant); + break; + case "function_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FunctionScoreQuery?)value.Variant); + break; + case "fuzzy": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.FuzzyQuery?)value.Variant); + break; + case "geo_bounding_box": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoBoundingBoxQuery?)value.Variant); + break; + case "geo_distance": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceQuery?)value.Variant); + break; + case "geo_shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.GeoShapeQuery?)value.Variant); + break; + case "has_child": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.HasChildQuery?)value.Variant); + break; + case "has_parent": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.HasParentQuery?)value.Variant); + break; + case "ids": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IdsQuery?)value.Variant); + break; + case "intervals": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IntervalsQuery?)value.Variant); + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.KnnQuery?)value.Variant); + break; + case "match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchQuery?)value.Variant); + break; + case "match_all": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchAllQuery?)value.Variant); + break; + case "match_bool_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchBoolPrefixQuery?)value.Variant); + break; + case "match_none": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchNoneQuery?)value.Variant); + break; + case "match_phrase": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhraseQuery?)value.Variant); + break; + case "match_phrase_prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MatchPhrasePrefixQuery?)value.Variant); + break; + case "more_like_this": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MoreLikeThisQuery?)value.Variant); + break; + case "multi_match": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.MultiMatchQuery?)value.Variant); + break; + case "nested": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.NestedQuery?)value.Variant); + break; + case "parent_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ParentIdQuery?)value.Variant); + break; + case "percolate": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PercolateQuery?)value.Variant); + break; + case "pinned": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PinnedQuery?)value.Variant); + break; + case "prefix": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.PrefixQuery?)value.Variant); + break; + case "query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery?)value.Variant); + break; + case "range": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery)value.Variant); + break; + case "rank_feature": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RankFeatureQuery?)value.Variant); + break; + case "raw_json": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RawJsonQuery?)value.Variant); + break; + case "regexp": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RegexpQuery?)value.Variant); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.RuleQuery?)value.Variant); + break; + case "script": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptQuery?)value.Variant); + break; + case "script_score": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ScriptScoreQuery?)value.Variant); + break; + case "semantic": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SemanticQuery?)value.Variant); + break; + case "shape": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.ShapeQuery?)value.Variant); + break; + case "simple_query_string": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringQuery?)value.Variant); + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery?)value.Variant); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery?)value.Variant); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery?)value.Variant); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery?)value.Variant); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery?)value.Variant); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery?)value.Variant); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery?)value.Variant); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery?)value.Variant); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery?)value.Variant); + break; + case "sparse_vector": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SparseVectorQuery?)value.Variant); + break; + case "term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermQuery?)value.Variant); + break; + case "terms": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermsQuery?)value.Variant); + break; + case "terms_set": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.TermsSetQuery?)value.Variant); + break; + case "wildcard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.WildcardQuery?)value.Variant); + break; + case "wrapper": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.WrapperQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Query)}'."); } writer.WriteEndObject(); @@ -769,6 +872,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action> configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action> configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -822,6 +926,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action> configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action> configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); @@ -935,6 +1040,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor ConstantScore(Action configure) => Set(configure, "constant_score"); public QueryDescriptor DisMax(Elastic.Clients.Elasticsearch.QueryDsl.DisMaxQuery disMaxQuery) => Set(disMaxQuery, "dis_max"); public QueryDescriptor DisMax(Action configure) => Set(configure, "dis_max"); + public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.IDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.UntypedDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.GeoDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); public QueryDescriptor DistanceFeature(Elastic.Clients.Elasticsearch.QueryDsl.DateDistanceFeatureQuery distanceFeatureQuery) => Set(distanceFeatureQuery, "distance_feature"); @@ -988,6 +1094,7 @@ private QueryDescriptor Set(object variant, string variantName) public QueryDescriptor Prefix(Action configure) => Set(configure, "prefix"); public QueryDescriptor QueryString(Elastic.Clients.Elasticsearch.QueryDsl.QueryStringQuery queryStringQuery) => Set(queryStringQuery, "query_string"); public QueryDescriptor QueryString(Action configure) => Set(configure, "query_string"); + public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.IRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery rangeQuery) => Set(rangeQuery, "range"); public QueryDescriptor Range(Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery rangeQuery) => Set(rangeQuery, "range"); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs index c805604bc93..694d16e8b72 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/QueryStringQuery.g.cs @@ -27,6 +27,300 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class QueryStringQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAllowLeadingWildcard = System.Text.Json.JsonEncodedText.Encode("allow_leading_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzeWildcard = System.Text.Json.JsonEncodedText.Encode("analyze_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultField = System.Text.Json.JsonEncodedText.Encode("default_field"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultOperator = System.Text.Json.JsonEncodedText.Encode("default_operator"); + private static readonly System.Text.Json.JsonEncodedText PropEnablePositionIncrements = System.Text.Json.JsonEncodedText.Encode("enable_position_increments"); + private static readonly System.Text.Json.JsonEncodedText PropEscape = System.Text.Json.JsonEncodedText.Encode("escape"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFuzziness = System.Text.Json.JsonEncodedText.Encode("fuzziness"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyMaxExpansions = System.Text.Json.JsonEncodedText.Encode("fuzzy_max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyPrefixLength = System.Text.Json.JsonEncodedText.Encode("fuzzy_prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyRewrite = System.Text.Json.JsonEncodedText.Encode("fuzzy_rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDeterminizedStates = System.Text.Json.JsonEncodedText.Encode("max_determinized_states"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropPhraseSlop = System.Text.Json.JsonEncodedText.Encode("phrase_slop"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteAnalyzer = System.Text.Json.JsonEncodedText.Encode("quote_analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteFieldSuffix = System.Text.Json.JsonEncodedText.Encode("quote_field_suffix"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropTieBreaker = System.Text.Json.JsonEncodedText.Encode("tie_breaker"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override QueryStringQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAllowLeadingWildcard = default; + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAnalyzeWildcard = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propDefaultField = default; + LocalJsonValue propDefaultOperator = default; + LocalJsonValue propEnablePositionIncrements = default; + LocalJsonValue propEscape = default; + LocalJsonValue propFields = default; + LocalJsonValue propFuzziness = default; + LocalJsonValue propFuzzyMaxExpansions = default; + LocalJsonValue propFuzzyPrefixLength = default; + LocalJsonValue propFuzzyRewrite = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMaxDeterminizedStates = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propPhraseSlop = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propQuoteAnalyzer = default; + LocalJsonValue propQuoteFieldSuffix = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propTieBreaker = default; + LocalJsonValue propTimeZone = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAllowLeadingWildcard.TryRead(ref reader, options, PropAllowLeadingWildcard)) + { + continue; + } + + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAnalyzeWildcard.TryRead(ref reader, options, PropAnalyzeWildcard)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propDefaultField.TryRead(ref reader, options, PropDefaultField)) + { + continue; + } + + if (propDefaultOperator.TryRead(ref reader, options, PropDefaultOperator)) + { + continue; + } + + if (propEnablePositionIncrements.TryRead(ref reader, options, PropEnablePositionIncrements)) + { + continue; + } + + if (propEscape.TryRead(ref reader, options, PropEscape)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propFuzziness.TryRead(ref reader, options, PropFuzziness)) + { + continue; + } + + if (propFuzzyMaxExpansions.TryRead(ref reader, options, PropFuzzyMaxExpansions)) + { + continue; + } + + if (propFuzzyPrefixLength.TryRead(ref reader, options, PropFuzzyPrefixLength)) + { + continue; + } + + if (propFuzzyRewrite.TryRead(ref reader, options, PropFuzzyRewrite)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMaxDeterminizedStates.TryRead(ref reader, options, PropMaxDeterminizedStates)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propPhraseSlop.TryRead(ref reader, options, PropPhraseSlop)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQuoteAnalyzer.TryRead(ref reader, options, PropQuoteAnalyzer)) + { + continue; + } + + if (propQuoteFieldSuffix.TryRead(ref reader, options, PropQuoteFieldSuffix)) + { + continue; + } + + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } + + if (propTieBreaker.TryRead(ref reader, options, PropTieBreaker)) + { + continue; + } + + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryStringQuery + { + AllowLeadingWildcard = propAllowLeadingWildcard.Value +, + Analyzer = propAnalyzer.Value +, + AnalyzeWildcard = propAnalyzeWildcard.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + DefaultField = propDefaultField.Value +, + DefaultOperator = propDefaultOperator.Value +, + EnablePositionIncrements = propEnablePositionIncrements.Value +, + Escape = propEscape.Value +, + Fields = propFields.Value +, + Fuzziness = propFuzziness.Value +, + FuzzyMaxExpansions = propFuzzyMaxExpansions.Value +, + FuzzyPrefixLength = propFuzzyPrefixLength.Value +, + FuzzyRewrite = propFuzzyRewrite.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MaxDeterminizedStates = propMaxDeterminizedStates.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + PhraseSlop = propPhraseSlop.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + QuoteAnalyzer = propQuoteAnalyzer.Value +, + QuoteFieldSuffix = propQuoteFieldSuffix.Value +, + Rewrite = propRewrite.Value +, + TieBreaker = propTieBreaker.Value +, + TimeZone = propTimeZone.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryStringQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAllowLeadingWildcard, value.AllowLeadingWildcard); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAnalyzeWildcard, value.AnalyzeWildcard); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDefaultField, value.DefaultField); + writer.WriteProperty(options, PropDefaultOperator, value.DefaultOperator); + writer.WriteProperty(options, PropEnablePositionIncrements, value.EnablePositionIncrements); + writer.WriteProperty(options, PropEscape, value.Escape); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropFuzziness, value.Fuzziness); + writer.WriteProperty(options, PropFuzzyMaxExpansions, value.FuzzyMaxExpansions); + writer.WriteProperty(options, PropFuzzyPrefixLength, value.FuzzyPrefixLength); + writer.WriteProperty(options, PropFuzzyRewrite, value.FuzzyRewrite); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMaxDeterminizedStates, value.MaxDeterminizedStates); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropPhraseSlop, value.PhraseSlop); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQuoteAnalyzer, value.QuoteAnalyzer); + writer.WriteProperty(options, PropQuoteFieldSuffix, value.QuoteFieldSuffix); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropTieBreaker, value.TieBreaker); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryStringQueryConverter))] public sealed partial class QueryStringQuery { /// @@ -34,7 +328,6 @@ public sealed partial class QueryStringQuery /// If true, the wildcard characters * and ? are allowed as the first character of the query string. /// /// - [JsonInclude, JsonPropertyName("allow_leading_wildcard")] public bool? AllowLeadingWildcard { get; set; } /// @@ -42,7 +335,6 @@ public sealed partial class QueryStringQuery /// Analyzer used to convert text in the query string into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -50,7 +342,6 @@ public sealed partial class QueryStringQuery /// If true, the query attempts to analyze wildcard terms in the query string. /// /// - [JsonInclude, JsonPropertyName("analyze_wildcard")] public bool? AnalyzeWildcard { get; set; } /// @@ -58,7 +349,6 @@ public sealed partial class QueryStringQuery /// If true, match phrase queries are automatically created for multi-term synonyms. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -69,7 +359,6 @@ public sealed partial class QueryStringQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -79,7 +368,6 @@ public sealed partial class QueryStringQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("default_field")] public Elastic.Clients.Elasticsearch.Field? DefaultField { get; set; } /// @@ -87,7 +375,6 @@ public sealed partial class QueryStringQuery /// Default boolean logic used to interpret text in the query string if no operators are specified. /// /// - [JsonInclude, JsonPropertyName("default_operator")] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get; set; } /// @@ -95,9 +382,7 @@ public sealed partial class QueryStringQuery /// If true, enable position increments in queries constructed from a query_string search. /// /// - [JsonInclude, JsonPropertyName("enable_position_increments")] public bool? EnablePositionIncrements { get; set; } - [JsonInclude, JsonPropertyName("escape")] public bool? Escape { get; set; } /// @@ -105,8 +390,6 @@ public sealed partial class QueryStringQuery /// Array of fields to search. Supports wildcards (*). /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -114,7 +397,6 @@ public sealed partial class QueryStringQuery /// Maximum edit distance allowed for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzziness")] public Elastic.Clients.Elasticsearch.Fuzziness? Fuzziness { get; set; } /// @@ -122,7 +404,6 @@ public sealed partial class QueryStringQuery /// Maximum number of terms to which the query expands for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_max_expansions")] public int? FuzzyMaxExpansions { get; set; } /// @@ -130,7 +411,6 @@ public sealed partial class QueryStringQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_prefix_length")] public int? FuzzyPrefixLength { get; set; } /// @@ -138,7 +418,6 @@ public sealed partial class QueryStringQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("fuzzy_rewrite")] public string? FuzzyRewrite { get; set; } /// @@ -146,7 +425,6 @@ public sealed partial class QueryStringQuery /// If true, edits for fuzzy matching include transpositions of two adjacent characters (for example, ab to ba). /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -154,7 +432,6 @@ public sealed partial class QueryStringQuery /// If true, format-based errors, such as providing a text value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -162,7 +439,6 @@ public sealed partial class QueryStringQuery /// Maximum number of automaton states required for the query. /// /// - [JsonInclude, JsonPropertyName("max_determinized_states")] public int? MaxDeterminizedStates { get; set; } /// @@ -170,7 +446,6 @@ public sealed partial class QueryStringQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -178,7 +453,6 @@ public sealed partial class QueryStringQuery /// Maximum number of positions allowed between matching tokens for phrases. /// /// - [JsonInclude, JsonPropertyName("phrase_slop")] public double? PhraseSlop { get; set; } /// @@ -186,9 +460,7 @@ public sealed partial class QueryStringQuery /// Query string you wish to parse and use for search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -197,7 +469,6 @@ public sealed partial class QueryStringQuery /// For quoted text, this parameter overrides the analyzer specified in the analyzer parameter. /// /// - [JsonInclude, JsonPropertyName("quote_analyzer")] public string? QuoteAnalyzer { get; set; } /// @@ -206,7 +477,6 @@ public sealed partial class QueryStringQuery /// You can use this suffix to use a different analysis method for exact matches. /// /// - [JsonInclude, JsonPropertyName("quote_field_suffix")] public string? QuoteFieldSuffix { get; set; } /// @@ -214,7 +484,6 @@ public sealed partial class QueryStringQuery /// Method used to rewrite the query. /// /// - [JsonInclude, JsonPropertyName("rewrite")] public string? Rewrite { get; set; } /// @@ -222,7 +491,6 @@ public sealed partial class QueryStringQuery /// How to combine the queries generated from the individual search terms in the resulting dis_max query. /// /// - [JsonInclude, JsonPropertyName("tie_breaker")] public double? TieBreaker { get; set; } /// @@ -230,7 +498,6 @@ public sealed partial class QueryStringQuery /// Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query string to UTC. /// /// - [JsonInclude, JsonPropertyName("time_zone")] public string? TimeZone { get; set; } /// @@ -238,7 +505,6 @@ public sealed partial class QueryStringQuery /// Determines how the query matches and scores documents. /// /// - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryDsl.TextQueryType? Type { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(QueryStringQuery queryStringQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.QueryString(queryStringQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs new file mode 100644 index 00000000000..ad155c69c88 --- /dev/null +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RangeQuery.g.cs @@ -0,0 +1,63 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information. +// +// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗ +// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝ +// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗ +// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝ +// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗ +// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝ +// ------------------------------------------------ +// +// This file is automatically generated. +// Please do not edit these files manually. +// +// ------------------------------------------------ + +#nullable restore + +using Elastic.Clients.Elasticsearch.Fluent; +using Elastic.Clients.Elasticsearch.Serialization; +using System; +using System.Collections.Generic; +using System.Linq.Expressions; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Elastic.Clients.Elasticsearch.QueryDsl; + +[JsonConverter(typeof(RangeQueryConverter))] +public partial interface IRangeQuery +{ + public string? Type { get; } +} + +internal sealed partial class RangeQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + public override IRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + return reader.ReadValue(options); + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, IRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + switch (value) + { + case Elastic.Clients.Elasticsearch.QueryDsl.DateRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.NumberRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.TermRangeQuery v: + writer.WriteValue(options, v); + break; + case Elastic.Clients.Elasticsearch.QueryDsl.UntypedRangeQuery v: + writer.WriteValue(options, v); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.Type}' is not supported for type '{nameof(IRangeQuery)}'."); + } + } +} \ No newline at end of file diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs index 4d47a0cbec5..19a18d39259 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/RegexpQuery.g.cs @@ -27,116 +27,114 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class RegexpQueryConverter : JsonConverter +internal sealed partial class RegexpQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override RegexpQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropMaxDeterminizedStates = System.Text.Json.JsonEncodedText.Encode("max_determinized_states"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override RegexpQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new RegexpQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new RegexpQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propFlags = default; + LocalJsonValue propMaxDeterminizedStates = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "flags") - { - variant.Flags = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "max_determinized_states") - { - variant.MaxDeterminizedStates = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, RegexpQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize RegexpQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propMaxDeterminizedStates.TryRead(ref reader, options, PropMaxDeterminizedStates)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Flags)) - { - writer.WritePropertyName("flags"); - writer.WriteStringValue(value.Flags); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.MaxDeterminizedStates.HasValue) - { - writer.WritePropertyName("max_determinized_states"); - writer.WriteNumberValue(value.MaxDeterminizedStates.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Rewrite)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RegexpQuery { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + Flags = propFlags.Value +, + MaxDeterminizedStates = propMaxDeterminizedStates.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value + }; + } - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + public override void Write(System.Text.Json.Utf8JsonWriter writer, RegexpQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropMaxDeterminizedStates, value.MaxDeterminizedStates); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -152,6 +150,10 @@ public RegexpQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal RegexpQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs index 9b313e9a20a..1156b9f170c 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/ShapeQuery.g.cs @@ -27,78 +27,65 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class ShapeQueryConverter : JsonConverter +internal sealed partial class ShapeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override ShapeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropShape = System.Text.Json.JsonEncodedText.Encode("shape"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropIgnoreUnmapped = System.Text.Json.JsonEncodedText.Encode("ignore_unmapped"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override ShapeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new ShapeQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propShape = default; + LocalJsonValue propBoost = default; + LocalJsonValue propIgnoreUnmapped = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "ignore_unmapped") - { - variant.IgnoreUnmapped = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Shape = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - - return variant; - } - public override void Write(Utf8JsonWriter writer, ShapeQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Shape is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propIgnoreUnmapped.TryRead(ref reader, options, PropIgnoreUnmapped)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Shape, options); - } - - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.IgnoreUnmapped.HasValue) - { - writer.WritePropertyName("ignore_unmapped"); - writer.WriteBooleanValue(value.IgnoreUnmapped.Value); + propField.Initialized = propShape.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propShape.Value); } - if (!string.IsNullOrEmpty(value.QueryName)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new ShapeQuery { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Shape = propShape.Value +, + Boost = propBoost.Value +, + IgnoreUnmapped = propIgnoreUnmapped.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, ShapeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropIgnoreUnmapped, value.IgnoreUnmapped); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Shape); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs index 14e77720775..32d85f636ac 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SimpleQueryStringQuery.g.cs @@ -27,6 +27,180 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; +internal sealed partial class SimpleQueryStringQueryConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropAnalyzer = System.Text.Json.JsonEncodedText.Encode("analyzer"); + private static readonly System.Text.Json.JsonEncodedText PropAnalyzeWildcard = System.Text.Json.JsonEncodedText.Encode("analyze_wildcard"); + private static readonly System.Text.Json.JsonEncodedText PropAutoGenerateSynonymsPhraseQuery = System.Text.Json.JsonEncodedText.Encode("auto_generate_synonyms_phrase_query"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropDefaultOperator = System.Text.Json.JsonEncodedText.Encode("default_operator"); + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropFlags = System.Text.Json.JsonEncodedText.Encode("flags"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyMaxExpansions = System.Text.Json.JsonEncodedText.Encode("fuzzy_max_expansions"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyPrefixLength = System.Text.Json.JsonEncodedText.Encode("fuzzy_prefix_length"); + private static readonly System.Text.Json.JsonEncodedText PropFuzzyTranspositions = System.Text.Json.JsonEncodedText.Encode("fuzzy_transpositions"); + private static readonly System.Text.Json.JsonEncodedText PropLenient = System.Text.Json.JsonEncodedText.Encode("lenient"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropQuoteFieldSuffix = System.Text.Json.JsonEncodedText.Encode("quote_field_suffix"); + + public override SimpleQueryStringQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propAnalyzer = default; + LocalJsonValue propAnalyzeWildcard = default; + LocalJsonValue propAutoGenerateSynonymsPhraseQuery = default; + LocalJsonValue propBoost = default; + LocalJsonValue propDefaultOperator = default; + LocalJsonValue propFields = default; + LocalJsonValue propFlags = default; + LocalJsonValue propFuzzyMaxExpansions = default; + LocalJsonValue propFuzzyPrefixLength = default; + LocalJsonValue propFuzzyTranspositions = default; + LocalJsonValue propLenient = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propQuoteFieldSuffix = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propAnalyzer.TryRead(ref reader, options, PropAnalyzer)) + { + continue; + } + + if (propAnalyzeWildcard.TryRead(ref reader, options, PropAnalyzeWildcard)) + { + continue; + } + + if (propAutoGenerateSynonymsPhraseQuery.TryRead(ref reader, options, PropAutoGenerateSynonymsPhraseQuery)) + { + continue; + } + + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propDefaultOperator.TryRead(ref reader, options, PropDefaultOperator)) + { + continue; + } + + if (propFields.TryRead(ref reader, options, PropFields, typeof(FieldsMarker))) + { + continue; + } + + if (propFlags.TryRead(ref reader, options, PropFlags)) + { + continue; + } + + if (propFuzzyMaxExpansions.TryRead(ref reader, options, PropFuzzyMaxExpansions)) + { + continue; + } + + if (propFuzzyPrefixLength.TryRead(ref reader, options, PropFuzzyPrefixLength)) + { + continue; + } + + if (propFuzzyTranspositions.TryRead(ref reader, options, PropFuzzyTranspositions)) + { + continue; + } + + if (propLenient.TryRead(ref reader, options, PropLenient)) + { + continue; + } + + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } + + if (propQuery.TryRead(ref reader, options, PropQuery)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propQuoteFieldSuffix.TryRead(ref reader, options, PropQuoteFieldSuffix)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SimpleQueryStringQuery + { + Analyzer = propAnalyzer.Value +, + AnalyzeWildcard = propAnalyzeWildcard.Value +, + AutoGenerateSynonymsPhraseQuery = propAutoGenerateSynonymsPhraseQuery.Value +, + Boost = propBoost.Value +, + DefaultOperator = propDefaultOperator.Value +, + Fields = propFields.Value +, + Flags = propFlags.Value +, + FuzzyMaxExpansions = propFuzzyMaxExpansions.Value +, + FuzzyPrefixLength = propFuzzyPrefixLength.Value +, + FuzzyTranspositions = propFuzzyTranspositions.Value +, + Lenient = propLenient.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + Query = propQuery.Value +, + QueryName = propQueryName.Value +, + QuoteFieldSuffix = propQuoteFieldSuffix.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, SimpleQueryStringQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropAnalyzer, value.Analyzer); + writer.WriteProperty(options, PropAnalyzeWildcard, value.AnalyzeWildcard); + writer.WriteProperty(options, PropAutoGenerateSynonymsPhraseQuery, value.AutoGenerateSynonymsPhraseQuery); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropDefaultOperator, value.DefaultOperator); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(FieldsMarker)); + writer.WriteProperty(options, PropFlags, value.Flags); + writer.WriteProperty(options, PropFuzzyMaxExpansions, value.FuzzyMaxExpansions); + writer.WriteProperty(options, PropFuzzyPrefixLength, value.FuzzyPrefixLength); + writer.WriteProperty(options, PropFuzzyTranspositions, value.FuzzyTranspositions); + writer.WriteProperty(options, PropLenient, value.Lenient); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropQuoteFieldSuffix, value.QuoteFieldSuffix); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(SimpleQueryStringQueryConverter))] public sealed partial class SimpleQueryStringQuery { /// @@ -34,7 +208,6 @@ public sealed partial class SimpleQueryStringQuery /// Analyzer used to convert text in the query string into tokens. /// /// - [JsonInclude, JsonPropertyName("analyzer")] public string? Analyzer { get; set; } /// @@ -42,7 +215,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, the query attempts to analyze wildcard terms in the query string. /// /// - [JsonInclude, JsonPropertyName("analyze_wildcard")] public bool? AnalyzeWildcard { get; set; } /// @@ -50,7 +222,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, the parser creates a match_phrase query for each multi-position token. /// /// - [JsonInclude, JsonPropertyName("auto_generate_synonyms_phrase_query")] public bool? AutoGenerateSynonymsPhraseQuery { get; set; } /// @@ -61,7 +232,6 @@ public sealed partial class SimpleQueryStringQuery /// A value greater than 1.0 increases the relevance score. /// /// - [JsonInclude, JsonPropertyName("boost")] public float? Boost { get; set; } /// @@ -69,7 +239,6 @@ public sealed partial class SimpleQueryStringQuery /// Default boolean logic used to interpret text in the query string if no operators are specified. /// /// - [JsonInclude, JsonPropertyName("default_operator")] public Elastic.Clients.Elasticsearch.QueryDsl.Operator? DefaultOperator { get; set; } /// @@ -80,8 +249,6 @@ public sealed partial class SimpleQueryStringQuery /// Defaults to the index.query.default_field index setting, which has a default value of *. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(FieldsConverter))] public Elastic.Clients.Elasticsearch.Fields? Fields { get; set; } /// @@ -89,7 +256,6 @@ public sealed partial class SimpleQueryStringQuery /// List of enabled operators for the simple query string syntax. /// /// - [JsonInclude, JsonPropertyName("flags")] public Elastic.Clients.Elasticsearch.QueryDsl.SimpleQueryStringFlag? Flags { get; set; } /// @@ -97,7 +263,6 @@ public sealed partial class SimpleQueryStringQuery /// Maximum number of terms to which the query expands for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_max_expansions")] public int? FuzzyMaxExpansions { get; set; } /// @@ -105,7 +270,6 @@ public sealed partial class SimpleQueryStringQuery /// Number of beginning characters left unchanged for fuzzy matching. /// /// - [JsonInclude, JsonPropertyName("fuzzy_prefix_length")] public int? FuzzyPrefixLength { get; set; } /// @@ -113,7 +277,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, edits for fuzzy matching include transpositions of two adjacent characters (for example, ab to ba). /// /// - [JsonInclude, JsonPropertyName("fuzzy_transpositions")] public bool? FuzzyTranspositions { get; set; } /// @@ -121,7 +284,6 @@ public sealed partial class SimpleQueryStringQuery /// If true, format-based errors, such as providing a text value for a numeric field, are ignored. /// /// - [JsonInclude, JsonPropertyName("lenient")] public bool? Lenient { get; set; } /// @@ -129,7 +291,6 @@ public sealed partial class SimpleQueryStringQuery /// Minimum number of clauses that must match for a document to be returned. /// /// - [JsonInclude, JsonPropertyName("minimum_should_match")] public Elastic.Clients.Elasticsearch.MinimumShouldMatch? MinimumShouldMatch { get; set; } /// @@ -137,9 +298,7 @@ public sealed partial class SimpleQueryStringQuery /// Query string in the simple query string syntax you wish to parse and use for search. /// /// - [JsonInclude, JsonPropertyName("query")] public string Query { get; set; } - [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } /// @@ -147,7 +306,6 @@ public sealed partial class SimpleQueryStringQuery /// Suffix appended to quoted text in the query string. /// /// - [JsonInclude, JsonPropertyName("quote_field_suffix")] public string? QuoteFieldSuffix { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.QueryDsl.Query(SimpleQueryStringQuery simpleQueryStringQuery) => Elastic.Clients.Elasticsearch.QueryDsl.Query.SimpleQueryString(simpleQueryStringQuery); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs index 68096795d8c..fa593150065 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanQuery.g.cs @@ -39,12 +39,16 @@ internal SpanQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SpanQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SpanQuery SpanContaining(Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery spanContainingQuery) => new SpanQuery("span_containing", spanContainingQuery); public static SpanQuery SpanFieldMasking(Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery spanFieldMaskingQuery) => new SpanQuery("span_field_masking", spanFieldMaskingQuery); @@ -70,147 +74,152 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SpanQueryConverter : JsonConverter +internal sealed partial class SpanQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SpanQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText VariantSpanContaining = System.Text.Json.JsonEncodedText.Encode("span_containing"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFieldMasking = System.Text.Json.JsonEncodedText.Encode("span_field_masking"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanFirst = System.Text.Json.JsonEncodedText.Encode("span_first"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanGap = System.Text.Json.JsonEncodedText.Encode("span_gap"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanMulti = System.Text.Json.JsonEncodedText.Encode("span_multi"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNear = System.Text.Json.JsonEncodedText.Encode("span_near"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanNot = System.Text.Json.JsonEncodedText.Encode("span_not"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanOr = System.Text.Json.JsonEncodedText.Encode("span_or"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanTerm = System.Text.Json.JsonEncodedText.Encode("span_term"); + private static readonly System.Text.Json.JsonEncodedText VariantSpanWithin = System.Text.Json.JsonEncodedText.Encode("span_within"); + + public override SpanQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantSpanContaining)) { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "span_containing") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanContaining.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_field_masking") + if (reader.ValueTextEquals(VariantSpanFieldMasking)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFieldMasking.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_first") + if (reader.ValueTextEquals(VariantSpanFirst)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanFirst.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_gap") + if (reader.ValueTextEquals(VariantSpanGap)) { - variantValue = JsonSerializer.Deserialize?>(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanGap.Value; + reader.Read(); + variant = reader.ReadValue?>(options); continue; } - if (propertyName == "span_multi") + if (reader.ValueTextEquals(VariantSpanMulti)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanMulti.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_near") + if (reader.ValueTextEquals(VariantSpanNear)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNear.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_not") + if (reader.ValueTextEquals(VariantSpanNot)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanNot.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_or") + if (reader.ValueTextEquals(VariantSpanOr)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanOr.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_term") + if (reader.ValueTextEquals(VariantSpanTerm)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanTerm.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "span_within") + if (reader.ValueTextEquals(VariantSpanWithin)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantSpanWithin.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SpanQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SpanQuery(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanQuery { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, SpanQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "span_containing": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery)value.Variant, options); - break; - case "span_field_masking": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery)value.Variant, options); - break; - case "span_first": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery)value.Variant, options); - break; - case "span_gap": - JsonSerializer.Serialize>(writer, (KeyValuePair)value.Variant, options); - break; - case "span_multi": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery)value.Variant, options); - break; - case "span_near": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery)value.Variant, options); - break; - case "span_not": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery)value.Variant, options); - break; - case "span_or": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery)value.Variant, options); - break; - case "span_term": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery)value.Variant, options); - break; - case "span_within": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery)value.Variant, options); - break; - } + case "": + break; + case "span_containing": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanContainingQuery?)value.Variant); + break; + case "span_field_masking": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFieldMaskingQuery?)value.Variant); + break; + case "span_first": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanFirstQuery?)value.Variant); + break; + case "span_gap": + writer.WriteProperty(options, value.VariantType, (KeyValuePair?)value.Variant); + break; + case "span_multi": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanMultiTermQuery?)value.Variant); + break; + case "span_near": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNearQuery?)value.Variant); + break; + case "span_not": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanNotQuery?)value.Variant); + break; + case "span_or": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanOrQuery?)value.Variant); + break; + case "span_term": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanTermQuery?)value.Variant); + break; + case "span_within": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.QueryDsl.SpanWithinQuery?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SpanQuery)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs index 80695af511c..4f83cfe0bad 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SpanTermQuery.g.cs @@ -27,68 +27,74 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class SpanTermQueryConverter : JsonConverter +internal sealed partial class SpanTermQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SpanTermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override SpanTermQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new SpanTermQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) + { + var value = reader.ReadValue(options); + reader.Read(); + return new SpanTermQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); reader.Read(); - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SpanTermQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Value = propValue.Value + }; } - public override void Write(Utf8JsonWriter writer, SpanTermQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SpanTermQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize SpanTermQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); + writer.WritePropertyName(options, value.Field); writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -104,6 +110,10 @@ public SpanTermQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal SpanTermQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs index cb6c959ad3d..a6424b559d4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/SparseVectorQuery.g.cs @@ -39,12 +39,16 @@ internal SparseVectorQuery(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal SparseVectorQuery() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static SparseVectorQuery InferenceId(Elastic.Clients.Elasticsearch.Id id) => new SparseVectorQuery("inference_id", id); @@ -113,143 +117,109 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class SparseVectorQueryConverter : JsonConverter +internal sealed partial class SparseVectorQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override SparseVectorQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPrune = System.Text.Json.JsonEncodedText.Encode("prune"); + private static readonly System.Text.Json.JsonEncodedText PropPruningConfig = System.Text.Json.JsonEncodedText.Encode("pruning_config"); + private static readonly System.Text.Json.JsonEncodedText PropQuery = System.Text.Json.JsonEncodedText.Encode("query"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText VariantInferenceId = System.Text.Json.JsonEncodedText.Encode("inference_id"); + + public override SparseVectorQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } - - object? variantValue = default; - string? variantNameValue = default; - float? boostValue = default; - Elastic.Clients.Elasticsearch.Field fieldValue = default; - bool? pruneValue = default; - Elastic.Clients.Elasticsearch.QueryDsl.TokenPruningConfig? pruningConfigValue = default; - string? queryValue = default; - string? queryNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propField = default; + LocalJsonValue propPrune = default; + LocalJsonValue propPruningConfig = default; + LocalJsonValue propQuery = default; + LocalJsonValue propQueryName = default; + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "boost") + if (propBoost.TryRead(ref reader, options, PropBoost)) { - boostValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "field") + if (propField.TryRead(ref reader, options, PropField)) { - fieldValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "prune") + if (propPrune.TryRead(ref reader, options, PropPrune)) { - pruneValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "pruning_config") + if (propPruningConfig.TryRead(ref reader, options, PropPruningConfig)) { - pruningConfigValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "query") + if (propQuery.TryRead(ref reader, options, PropQuery)) { - queryValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "_name") + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - queryNameValue = JsonSerializer.Deserialize(ref reader, options); continue; } - if (propertyName == "inference_id") + if (reader.ValueTextEquals(VariantInferenceId)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantInferenceId.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'SparseVectorQuery' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new SparseVectorQuery(variantNameValue, variantValue); - result.Boost = boostValue; - result.Field = fieldValue; - result.Prune = pruneValue; - result.PruningConfig = pruningConfigValue; - result.Query = queryValue; - result.QueryName = queryNameValue; - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new SparseVectorQuery + { + VariantType = variantType, + Variant = variant, + Boost = propBoost.Value + , + Field = propField.Value + , + Prune = propPrune.Value + , + PruningConfig = propPruningConfig.Value + , + Query = propQuery.Value + , + QueryName = propQueryName.Value + }; } - public override void Write(Utf8JsonWriter writer, SparseVectorQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, SparseVectorQuery value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.Field is not null) + switch (value.VariantType) { - writer.WritePropertyName("field"); - JsonSerializer.Serialize(writer, value.Field, options); - } - - if (value.Prune.HasValue) - { - writer.WritePropertyName("prune"); - writer.WriteBooleanValue(value.Prune.Value); - } - - if (value.PruningConfig is not null) - { - writer.WritePropertyName("pruning_config"); - JsonSerializer.Serialize(writer, value.PruningConfig, options); - } - - if (!string.IsNullOrEmpty(value.Query)) - { - writer.WritePropertyName("query"); - writer.WriteStringValue(value.Query); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - if (value.VariantName is not null && value.Variant is not null) - { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "inference_id": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.Id)value.Variant, options); - break; - } + case "": + break; + case "inference_id": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.Id?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(SparseVectorQuery)}'."); } + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropField, value.Field); + writer.WriteProperty(options, PropPrune, value.Prune); + writer.WriteProperty(options, PropPruningConfig, value.PruningConfig); + writer.WriteProperty(options, PropQuery, value.Query); + writer.WriteProperty(options, PropQueryName, value.QueryName); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs index 3a3e17909a0..963cd73ac06 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermQuery.g.cs @@ -27,80 +27,87 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class TermQueryConverter : JsonConverter +internal sealed partial class TermQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + + public override TermQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new TermQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + var readerSnapshot = reader; + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propValue = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) + { + continue; + } + + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } + + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } + + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } + + try + { + reader = readerSnapshot; + var result = reader.ReadValue(options); + return new TermQuery { Field = propField.Value, Value = result }; + } + catch (System.Text.Json.JsonException) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } + throw; } } + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); reader.Read(); - return variant; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermQuery + { + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Value = propValue.Value + }; } - public override void Write(Utf8JsonWriter writer, TermQuery value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermQuery value, System.Text.Json.JsonSerializerOptions options) { - if (value.Field is null) - throw new JsonException("Unable to serialize TermQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); + writer.WritePropertyName(options, value.Field); writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } - - writer.WritePropertyName("value"); - JsonSerializer.Serialize(writer, value.Value, options); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropValue, value.Value); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -116,6 +123,10 @@ public TermQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal TermQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs index 5e175e78f1b..d028b422fa7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermRangeQuery.g.cs @@ -27,127 +27,114 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class TermRangeQueryConverter : JsonConverter +internal sealed partial class TermRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + + public override TermRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new TermRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, TermRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize TermRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gt)) - { - writer.WritePropertyName("gt"); - writer.WriteStringValue(value.Gt); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Gte)) - { - writer.WritePropertyName("gte"); - writer.WriteStringValue(value.Gte); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lt)) - { - writer.WritePropertyName("lt"); - writer.WriteStringValue(value.Lt); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Lte)) - { - writer.WritePropertyName("lte"); - writer.WriteStringValue(value.Lte); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (value.Relation is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermRangeQuery { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(TermRangeQueryConverter))] -public sealed partial class TermRangeQuery +public sealed partial class TermRangeQuery : IRangeQuery { public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -156,6 +143,10 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal TermRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -202,6 +193,8 @@ public TermRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public Elastic.Clients.Elasticsearch.QueryDsl.RangeRelation? Relation { get; set; } + + public string Type => "termrangequery"; } public sealed partial class TermRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs index a56cf458603..e0d0fe29f12 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsQuery.g.cs @@ -27,66 +27,55 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class TermsQueryConverter : JsonConverter +internal sealed partial class TermsQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + + public override TermsQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new TermsQuery(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue propTerms = default; + LocalJsonValue propBoost = default; + LocalJsonValue propQueryName = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Terms = JsonSerializer.Deserialize(ref reader, options); + continue; } - } - return variant; - } - - public override void Write(Utf8JsonWriter writer, TermsQuery value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - if (value.Field is not null && value.Terms is not null) - { - if (!options.TryGetClientSettings(out var settings)) + if (propQueryName.TryRead(ref reader, options, PropQueryName)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Terms, options); + propField.Initialized = propTerms.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propTerms.Value); } - if (value.Boost.HasValue) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsQuery { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } - - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + Field = propField.Value +, + Terms = propTerms.Value +, + Boost = propBoost.Value +, + QueryName = propQueryName.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, value.Field, value.Terms); writer.WriteEndObject(); } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs index 47cb8cf5415..8af23ce1464 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/TermsSetQuery.g.cs @@ -27,104 +27,97 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class TermsSetQueryConverter : JsonConverter +internal sealed partial class TermsSetQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override TermsSetQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatch = System.Text.Json.JsonEncodedText.Encode("minimum_should_match"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatchField = System.Text.Json.JsonEncodedText.Encode("minimum_should_match_field"); + private static readonly System.Text.Json.JsonEncodedText PropMinimumShouldMatchScript = System.Text.Json.JsonEncodedText.Encode("minimum_should_match_script"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropTerms = System.Text.Json.JsonEncodedText.Encode("terms"); + + public override TermsSetQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new TermsSetQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propMinimumShouldMatch = default; + LocalJsonValue propMinimumShouldMatchField = default; + LocalJsonValue propMinimumShouldMatchScript = default; + LocalJsonValue propQueryName = default; + LocalJsonValue> propTerms = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match") - { - variant.MinimumShouldMatch = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match_field") - { - variant.MinimumShouldMatchField = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "minimum_should_match_script") - { - variant.MinimumShouldMatchScript = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "terms") - { - variant.Terms = JsonSerializer.Deserialize>(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propMinimumShouldMatch.TryRead(ref reader, options, PropMinimumShouldMatch)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, TermsSetQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize TermsSetQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propMinimumShouldMatchField.TryRead(ref reader, options, PropMinimumShouldMatchField)) + { + continue; + } - if (value.MinimumShouldMatch is not null) - { - writer.WritePropertyName("minimum_should_match"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatch, options); - } + if (propMinimumShouldMatchScript.TryRead(ref reader, options, PropMinimumShouldMatchScript)) + { + continue; + } - if (value.MinimumShouldMatchField is not null) - { - writer.WritePropertyName("minimum_should_match_field"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchField, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.MinimumShouldMatchScript is not null) - { - writer.WritePropertyName("minimum_should_match_script"); - JsonSerializer.Serialize(writer, value.MinimumShouldMatchScript, options); - } + if (propTerms.TryRead(ref reader, options, PropTerms)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - writer.WritePropertyName("terms"); - JsonSerializer.Serialize(writer, value.Terms, options); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsSetQuery + { + Boost = propBoost.Value +, + Field = propField.Value +, + MinimumShouldMatch = propMinimumShouldMatch.Value +, + MinimumShouldMatchField = propMinimumShouldMatchField.Value +, + MinimumShouldMatchScript = propMinimumShouldMatchScript.Value +, + QueryName = propQueryName.Value +, + Terms = propTerms.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsSetQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropMinimumShouldMatch, value.MinimumShouldMatch); + writer.WriteProperty(options, PropMinimumShouldMatchField, value.MinimumShouldMatchField); + writer.WriteProperty(options, PropMinimumShouldMatchScript, value.MinimumShouldMatchScript); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropTerms, value.Terms); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -140,6 +133,10 @@ public TermsSetQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal TermsSetQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs index 0972c6b4a4a..fa05e081175 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDecayFunction.g.cs @@ -27,60 +27,51 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class UntypedDecayFunctionConverter : JsonConverter +internal sealed partial class UntypedDecayFunctionConverter : System.Text.Json.Serialization.JsonConverter { - public override UntypedDecayFunction Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); - var variant = new UntypedDecayFunction(); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) - { - if (reader.TokenType == JsonTokenType.PropertyName) - { - var property = reader.GetString(); - if (property == "multi_value_mode") - { - variant.MultiValueMode = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - variant.Field = property; - reader.Read(); - variant.Placement = JsonSerializer.Deserialize>(ref reader, options); - } - } - - return variant; - } + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropPlacement = System.Text.Json.JsonEncodedText.Encode("placement"); + private static readonly System.Text.Json.JsonEncodedText PropMultiValueMode = System.Text.Json.JsonEncodedText.Encode("multi_value_mode"); - public override void Write(Utf8JsonWriter writer, UntypedDecayFunction value, JsonSerializerOptions options) + public override UntypedDecayFunction Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - writer.WriteStartObject(); - if (value.Field is not null && value.Placement is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; + LocalJsonValue> propPlacement = default; + LocalJsonValue propMultiValueMode = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (!options.TryGetClientSettings(out var settings)) + if (propMultiValueMode.TryRead(ref reader, options, PropMultiValueMode)) { - ThrowHelper.ThrowJsonExceptionForMissingSettings(); + continue; } - var propertyName = settings.Inferrer.Field(value.Field); - writer.WritePropertyName(propertyName); - JsonSerializer.Serialize(writer, value.Placement, options); + propField.Initialized = propPlacement.Initialized = true; + reader.ReadProperty(options, out propField.Value, out propPlacement.Value); } - if (value.MultiValueMode is not null) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UntypedDecayFunction { - writer.WritePropertyName("multi_value_mode"); - JsonSerializer.Serialize(writer, value.MultiValueMode, options); - } + Field = propField.Value +, + Placement = propPlacement.Value +, + MultiValueMode = propMultiValueMode.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UntypedDecayFunction value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropMultiValueMode, value.MultiValueMode); + writer.WriteProperty(options, value.Field, value.Placement); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedDecayFunctionConverter))] -public sealed partial class UntypedDecayFunction +public sealed partial class UntypedDecayFunction : IDecayFunction { public Elastic.Clients.Elasticsearch.Field Field { get; set; } @@ -91,6 +82,8 @@ public sealed partial class UntypedDecayFunction /// public Elastic.Clients.Elasticsearch.QueryDsl.MultiValueMode? MultiValueMode { get; set; } public Elastic.Clients.Elasticsearch.QueryDsl.DecayPlacement Placement { get; set; } + + public string Type => "untypeddecayfunction"; } public sealed partial class UntypedDecayFunctionDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs index 728ae35facf..9df04c7c815 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedDistanceFeatureQuery.g.cs @@ -27,7 +27,7 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -public sealed partial class UntypedDistanceFeatureQuery +public sealed partial class UntypedDistanceFeatureQuery : IDistanceFeatureQuery { /// /// @@ -72,6 +72,9 @@ public sealed partial class UntypedDistanceFeatureQuery public object Pivot { get; set; } [JsonInclude, JsonPropertyName("_name")] public string? QueryName { get; set; } + + [JsonInclude, JsonPropertyName("")] + public string Type => "untypeddistancefeaturequery"; } public sealed partial class UntypedDistanceFeatureQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs index 582463372a6..771fb4beac7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/UntypedRangeQuery.g.cs @@ -27,151 +27,134 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class UntypedRangeQueryConverter : JsonConverter +internal sealed partial class UntypedRangeQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override UntypedRangeQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropFormat = System.Text.Json.JsonEncodedText.Encode("format"); + private static readonly System.Text.Json.JsonEncodedText PropGt = System.Text.Json.JsonEncodedText.Encode("gt"); + private static readonly System.Text.Json.JsonEncodedText PropGte = System.Text.Json.JsonEncodedText.Encode("gte"); + private static readonly System.Text.Json.JsonEncodedText PropLt = System.Text.Json.JsonEncodedText.Encode("lt"); + private static readonly System.Text.Json.JsonEncodedText PropLte = System.Text.Json.JsonEncodedText.Encode("lte"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRelation = System.Text.Json.JsonEncodedText.Encode("relation"); + private static readonly System.Text.Json.JsonEncodedText PropTimeZone = System.Text.Json.JsonEncodedText.Encode("time_zone"); + + public override UntypedRangeQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new UntypedRangeQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propFormat = default; + LocalJsonValue propGt = default; + LocalJsonValue propGte = default; + LocalJsonValue propLt = default; + LocalJsonValue propLte = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRelation = default; + LocalJsonValue propTimeZone = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType == JsonTokenType.PropertyName) + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "format") - { - variant.Format = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gt") - { - variant.Gt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "gte") - { - variant.Gte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lt") - { - variant.Lt = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "lte") - { - variant.Lte = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "relation") - { - variant.Relation = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "time_zone") - { - variant.TimeZone = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propFormat.TryRead(ref reader, options, PropFormat)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, UntypedRangeQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize UntypedRangeQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propGt.TryRead(ref reader, options, PropGt)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Format)) - { - writer.WritePropertyName("format"); - writer.WriteStringValue(value.Format); - } + if (propGte.TryRead(ref reader, options, PropGte)) + { + continue; + } - if (value.Gt is not null) - { - writer.WritePropertyName("gt"); - JsonSerializer.Serialize(writer, value.Gt, options); - } + if (propLt.TryRead(ref reader, options, PropLt)) + { + continue; + } - if (value.Gte is not null) - { - writer.WritePropertyName("gte"); - JsonSerializer.Serialize(writer, value.Gte, options); - } + if (propLte.TryRead(ref reader, options, PropLte)) + { + continue; + } - if (value.Lt is not null) - { - writer.WritePropertyName("lt"); - JsonSerializer.Serialize(writer, value.Lt, options); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.Lte is not null) - { - writer.WritePropertyName("lte"); - JsonSerializer.Serialize(writer, value.Lte, options); - } + if (propRelation.TryRead(ref reader, options, PropRelation)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propTimeZone.TryRead(ref reader, options, PropTimeZone)) + { + continue; + } - if (value.Relation is not null) - { - writer.WritePropertyName("relation"); - JsonSerializer.Serialize(writer, value.Relation, options); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.TimeZone)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new UntypedRangeQuery { - writer.WritePropertyName("time_zone"); - writer.WriteStringValue(value.TimeZone); - } + Boost = propBoost.Value +, + Field = propField.Value +, + Format = propFormat.Value +, + Gt = propGt.Value +, + Gte = propGte.Value +, + Lt = propLt.Value +, + Lte = propLte.Value +, + QueryName = propQueryName.Value +, + Relation = propRelation.Value +, + TimeZone = propTimeZone.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, UntypedRangeQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropFormat, value.Format); + writer.WriteProperty(options, PropGt, value.Gt); + writer.WriteProperty(options, PropGte, value.Gte); + writer.WriteProperty(options, PropLt, value.Lt); + writer.WriteProperty(options, PropLte, value.Lte); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRelation, value.Relation); + writer.WriteProperty(options, PropTimeZone, value.TimeZone); writer.WriteEndObject(); writer.WriteEndObject(); } } [JsonConverter(typeof(UntypedRangeQueryConverter))] -public sealed partial class UntypedRangeQuery +public sealed partial class UntypedRangeQuery : IRangeQuery { public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) { @@ -180,6 +163,10 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal UntypedRangeQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. @@ -240,6 +227,8 @@ public UntypedRangeQuery(Elastic.Clients.Elasticsearch.Field field) /// /// public string? TimeZone { get; set; } + + public string Type => "untypedrangequery"; } public sealed partial class UntypedRangeQueryDescriptor : SerializableDescriptor> diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs index 5b449de8d98..fdb63e0dde7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryDsl/WildcardQuery.g.cs @@ -27,108 +27,104 @@ namespace Elastic.Clients.Elasticsearch.QueryDsl; -internal sealed partial class WildcardQueryConverter : JsonConverter +internal sealed partial class WildcardQueryConverter : System.Text.Json.Serialization.JsonConverter { - public override WildcardQuery Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + private static readonly System.Text.Json.JsonEncodedText PropBoost = System.Text.Json.JsonEncodedText.Encode("boost"); + private static readonly System.Text.Json.JsonEncodedText PropCaseInsensitive = System.Text.Json.JsonEncodedText.Encode("case_insensitive"); + private static readonly System.Text.Json.JsonEncodedText PropField = System.Text.Json.JsonEncodedText.Encode("field"); + private static readonly System.Text.Json.JsonEncodedText PropQueryName = System.Text.Json.JsonEncodedText.Encode("_name"); + private static readonly System.Text.Json.JsonEncodedText PropRewrite = System.Text.Json.JsonEncodedText.Encode("rewrite"); + private static readonly System.Text.Json.JsonEncodedText PropValue = System.Text.Json.JsonEncodedText.Encode("value"); + private static readonly System.Text.Json.JsonEncodedText PropWildcard = System.Text.Json.JsonEncodedText.Encode("wildcard"); + + public override WildcardQuery Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { - if (reader.TokenType != JsonTokenType.StartObject) - throw new JsonException("Unexpected JSON detected."); + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propField = default; reader.Read(); - var fieldName = reader.GetString(); + propField.ReadPropertyName(ref reader, options); reader.Read(); - var variant = new WildcardQuery(fieldName); - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + if (reader.TokenType is not System.Text.Json.JsonTokenType.StartObject) { - if (reader.TokenType == JsonTokenType.PropertyName) + var value = reader.ReadValue(options); + reader.Read(); + return new WildcardQuery { Value = value }; + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propBoost = default; + LocalJsonValue propCaseInsensitive = default; + LocalJsonValue propQueryName = default; + LocalJsonValue propRewrite = default; + LocalJsonValue propValue = default; + LocalJsonValue propWildcard = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propBoost.TryRead(ref reader, options, PropBoost)) { - var property = reader.GetString(); - if (property == "boost") - { - variant.Boost = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "case_insensitive") - { - variant.CaseInsensitive = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "_name") - { - variant.QueryName = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "rewrite") - { - variant.Rewrite = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "value") - { - variant.Value = JsonSerializer.Deserialize(ref reader, options); - continue; - } - - if (property == "wildcard") - { - variant.Wildcard = JsonSerializer.Deserialize(ref reader, options); - continue; - } + continue; } - } - reader.Read(); - return variant; - } + if (propCaseInsensitive.TryRead(ref reader, options, PropCaseInsensitive)) + { + continue; + } - public override void Write(Utf8JsonWriter writer, WildcardQuery value, JsonSerializerOptions options) - { - if (value.Field is null) - throw new JsonException("Unable to serialize WildcardQuery because the `Field` property is not set. Field name queries must include a valid field name."); - if (!options.TryGetClientSettings(out var settings)) - throw new JsonException("Unable to retrieve client settings required to infer field."); - writer.WriteStartObject(); - writer.WritePropertyName(settings.Inferrer.Field(value.Field)); - writer.WriteStartObject(); - if (value.Boost.HasValue) - { - writer.WritePropertyName("boost"); - writer.WriteNumberValue(value.Boost.Value); - } + if (propQueryName.TryRead(ref reader, options, PropQueryName)) + { + continue; + } - if (value.CaseInsensitive.HasValue) - { - writer.WritePropertyName("case_insensitive"); - writer.WriteBooleanValue(value.CaseInsensitive.Value); - } + if (propRewrite.TryRead(ref reader, options, PropRewrite)) + { + continue; + } - if (!string.IsNullOrEmpty(value.QueryName)) - { - writer.WritePropertyName("_name"); - writer.WriteStringValue(value.QueryName); - } + if (propValue.TryRead(ref reader, options, PropValue)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Rewrite)) - { - writer.WritePropertyName("rewrite"); - writer.WriteStringValue(value.Rewrite); - } + if (propWildcard.TryRead(ref reader, options, PropWildcard)) + { + continue; + } - if (!string.IsNullOrEmpty(value.Value)) - { - writer.WritePropertyName("value"); - writer.WriteStringValue(value.Value); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - if (!string.IsNullOrEmpty(value.Wildcard)) + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + reader.Read(); + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new WildcardQuery { - writer.WritePropertyName("wildcard"); - writer.WriteStringValue(value.Wildcard); - } + Boost = propBoost.Value +, + CaseInsensitive = propCaseInsensitive.Value +, + Field = propField.Value +, + QueryName = propQueryName.Value +, + Rewrite = propRewrite.Value +, + Value = propValue.Value +, + Wildcard = propWildcard.Value + }; + } + public override void Write(System.Text.Json.Utf8JsonWriter writer, WildcardQuery value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WritePropertyName(options, value.Field); + writer.WriteStartObject(); + writer.WriteProperty(options, PropBoost, value.Boost); + writer.WriteProperty(options, PropCaseInsensitive, value.CaseInsensitive); + writer.WriteProperty(options, PropQueryName, value.QueryName); + writer.WriteProperty(options, PropRewrite, value.Rewrite); + writer.WriteProperty(options, PropValue, value.Value); + writer.WriteProperty(options, PropWildcard, value.Wildcard); writer.WriteEndObject(); writer.WriteEndObject(); } @@ -144,6 +140,10 @@ public WildcardQuery(Elastic.Clients.Elasticsearch.Field field) Field = field; } + internal WildcardQuery() + { + } + /// /// /// Floating point number used to decrease or increase the relevance scores of the query. diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs index fc8f7a84ead..6273a7a7ea4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryRules/QueryRule.g.cs @@ -27,18 +27,86 @@ namespace Elastic.Clients.Elasticsearch.QueryRules; +internal sealed partial class QueryRuleConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropActions = System.Text.Json.JsonEncodedText.Encode("actions"); + private static readonly System.Text.Json.JsonEncodedText PropCriteria = System.Text.Json.JsonEncodedText.Encode("criteria"); + private static readonly System.Text.Json.JsonEncodedText PropPriority = System.Text.Json.JsonEncodedText.Encode("priority"); + private static readonly System.Text.Json.JsonEncodedText PropRuleId = System.Text.Json.JsonEncodedText.Encode("rule_id"); + private static readonly System.Text.Json.JsonEncodedText PropType = System.Text.Json.JsonEncodedText.Encode("type"); + + public override QueryRule Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propActions = default; + LocalJsonValue> propCriteria = default; + LocalJsonValue propPriority = default; + LocalJsonValue propRuleId = default; + LocalJsonValue propType = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propActions.TryRead(ref reader, options, PropActions)) + { + continue; + } + + if (propCriteria.TryRead(ref reader, options, PropCriteria, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>))) + { + continue; + } + + if (propPriority.TryRead(ref reader, options, PropPriority)) + { + continue; + } + + if (propRuleId.TryRead(ref reader, options, PropRuleId)) + { + continue; + } + + if (propType.TryRead(ref reader, options, PropType)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryRule + { + Actions = propActions.Value +, + Criteria = propCriteria.Value +, + Priority = propPriority.Value +, + RuleId = propRuleId.Value +, + Type = propType.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryRule value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropActions, value.Actions); + writer.WriteProperty(options, PropCriteria, value.Criteria, null, typeof(SingleOrManyMarker, Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria>)); + writer.WriteProperty(options, PropPriority, value.Priority); + writer.WriteProperty(options, PropRuleId, value.RuleId); + writer.WriteProperty(options, PropType, value.Type); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(QueryRuleConverter))] public sealed partial class QueryRule { - [JsonInclude, JsonPropertyName("actions")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleActions Actions { get; set; } - [JsonInclude, JsonPropertyName("criteria")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryRules.QueryRuleCriteria))] public ICollection Criteria { get; set; } - [JsonInclude, JsonPropertyName("priority")] public int? Priority { get; set; } - [JsonInclude, JsonPropertyName("rule_id")] public Elastic.Clients.Elasticsearch.Id RuleId { get; set; } - [JsonInclude, JsonPropertyName("type")] public Elastic.Clients.Elasticsearch.QueryRules.QueryRuleType Type { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs index 77354d637e6..51253fc9979 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/QueryVectorBuilder.g.cs @@ -39,12 +39,16 @@ internal QueryVectorBuilder(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal QueryVectorBuilder() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static QueryVectorBuilder TextEmbedding(Elastic.Clients.Elasticsearch.TextEmbedding textEmbedding) => new QueryVectorBuilder("text_embedding", textEmbedding); @@ -61,57 +65,44 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class QueryVectorBuilderConverter : JsonConverter +internal sealed partial class QueryVectorBuilderConverter : System.Text.Json.Serialization.JsonConverter { - public override QueryVectorBuilder Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantTextEmbedding = System.Text.Json.JsonEncodedText.Encode("text_embedding"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override QueryVectorBuilder Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantTextEmbedding)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "text_embedding") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextEmbedding.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'QueryVectorBuilder' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new QueryVectorBuilder(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new QueryVectorBuilder { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, QueryVectorBuilder value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, QueryVectorBuilder value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "text_embedding": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.TextEmbedding)value.Variant, options); - break; - } + case "": + break; + case "text_embedding": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.TextEmbedding?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(QueryVectorBuilder)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs index 62c90d43295..890e30cfa73 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RRFRetriever.g.cs @@ -27,6 +27,80 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class RRFRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropRankConstant = System.Text.Json.JsonEncodedText.Encode("rank_constant"); + private static readonly System.Text.Json.JsonEncodedText PropRankWindowSize = System.Text.Json.JsonEncodedText.Encode("rank_window_size"); + private static readonly System.Text.Json.JsonEncodedText PropRetrievers = System.Text.Json.JsonEncodedText.Encode("retrievers"); + + public override RRFRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propFilter = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propRankConstant = default; + LocalJsonValue propRankWindowSize = default; + LocalJsonValue> propRetrievers = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propRankConstant.TryRead(ref reader, options, PropRankConstant)) + { + continue; + } + + if (propRankWindowSize.TryRead(ref reader, options, PropRankWindowSize)) + { + continue; + } + + if (propRetrievers.TryRead(ref reader, options, PropRetrievers)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RRFRetriever + { + Filter = propFilter.Value +, + MinScore = propMinScore.Value +, + RankConstant = propRankConstant.Value +, + RankWindowSize = propRankWindowSize.Value +, + Retrievers = propRetrievers.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RRFRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropRankConstant, value.RankConstant); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize); + writer.WriteProperty(options, PropRetrievers, value.Retrievers); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RRFRetrieverConverter))] public sealed partial class RRFRetriever { /// @@ -34,8 +108,6 @@ public sealed partial class RRFRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +115,6 @@ public sealed partial class RRFRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -51,7 +122,6 @@ public sealed partial class RRFRetriever /// This value determines how much influence documents in individual result sets per query have over the final ranked result set. /// /// - [JsonInclude, JsonPropertyName("rank_constant")] public int? RankConstant { get; set; } /// @@ -59,7 +129,6 @@ public sealed partial class RRFRetriever /// This value determines the size of the individual result sets per query. /// /// - [JsonInclude, JsonPropertyName("rank_window_size")] public int? RankWindowSize { get; set; } /// @@ -67,7 +136,6 @@ public sealed partial class RRFRetriever /// A list of child retrievers to specify which sets of returned top documents will have the RRF formula applied to them. /// /// - [JsonInclude, JsonPropertyName("retrievers")] public ICollection Retrievers { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Retriever(RRFRetriever rRFRetriever) => Elastic.Clients.Elasticsearch.Retriever.Rrf(rRFRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs index 272931dfaa7..cf8d72695a4 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rank.g.cs @@ -39,12 +39,16 @@ internal Rank(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Rank() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Rank Rrf(Elastic.Clients.Elasticsearch.RrfRank rrfRank) => new Rank("rrf", rrfRank); @@ -61,57 +65,44 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RankConverter : JsonConverter +internal sealed partial class RankConverter : System.Text.Json.Serialization.JsonConverter { - public override Rank Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantRrf = System.Text.Json.JsonEncodedText.Encode("rrf"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Rank Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantRrf)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "rrf") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRrf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Rank' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Rank(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Rank { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Rank value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Rank value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "rrf": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RrfRank)value.Variant, options); - break; - } + case "": + break; + case "rrf": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RrfRank?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Rank)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs index 5a79a236a6a..4ee3f9012be 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Retriever.g.cs @@ -39,12 +39,16 @@ internal Retriever(string variantName, object variant) throw new ArgumentNullException(nameof(variant)); if (string.IsNullOrWhiteSpace(variantName)) throw new ArgumentException("Variant name must not be empty or whitespace."); - VariantName = variantName; + VariantType = variantName; Variant = variant; } - internal object Variant { get; } - internal string VariantName { get; } + internal Retriever() + { + } + + public object Variant { get; internal set; } + public string VariantType { get; internal set; } public static Retriever Knn(Elastic.Clients.Elasticsearch.KnnRetriever knnRetriever) => new Retriever("knn", knnRetriever); public static Retriever Rrf(Elastic.Clients.Elasticsearch.RRFRetriever rRFRetriever) => new Retriever("rrf", rRFRetriever); @@ -65,97 +69,92 @@ public bool TryGet([NotNullWhen(true)] out T? result) where T : class } } -internal sealed partial class RetrieverConverter : JsonConverter +internal sealed partial class RetrieverConverter : System.Text.Json.Serialization.JsonConverter { - public override Retriever Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType != JsonTokenType.StartObject) - { - throw new JsonException("Expected start token."); - } + private static readonly System.Text.Json.JsonEncodedText VariantKnn = System.Text.Json.JsonEncodedText.Encode("knn"); + private static readonly System.Text.Json.JsonEncodedText VariantRrf = System.Text.Json.JsonEncodedText.Encode("rrf"); + private static readonly System.Text.Json.JsonEncodedText VariantRule = System.Text.Json.JsonEncodedText.Encode("rule"); + private static readonly System.Text.Json.JsonEncodedText VariantStandard = System.Text.Json.JsonEncodedText.Encode("standard"); + private static readonly System.Text.Json.JsonEncodedText VariantTextSimilarityReranker = System.Text.Json.JsonEncodedText.Encode("text_similarity_reranker"); - object? variantValue = default; - string? variantNameValue = default; - while (reader.Read() && reader.TokenType != JsonTokenType.EndObject) + public override Retriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + var variantType = string.Empty; + object? variant = null; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) { - if (reader.TokenType != JsonTokenType.PropertyName) + if (reader.ValueTextEquals(VariantKnn)) { - throw new JsonException("Expected a property name token."); - } - - if (reader.TokenType != JsonTokenType.PropertyName) - { - throw new JsonException("Expected a property name token representing the name of an Elasticsearch field."); - } - - var propertyName = reader.GetString(); - reader.Read(); - if (propertyName == "knn") - { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantKnn.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rrf") + if (reader.ValueTextEquals(VariantRrf)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRrf.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "rule") + if (reader.ValueTextEquals(VariantRule)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantRule.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "standard") + if (reader.ValueTextEquals(VariantStandard)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantStandard.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - if (propertyName == "text_similarity_reranker") + if (reader.ValueTextEquals(VariantTextSimilarityReranker)) { - variantValue = JsonSerializer.Deserialize(ref reader, options); - variantNameValue = propertyName; + variantType = VariantTextSimilarityReranker.Value; + reader.Read(); + variant = reader.ReadValue(options); continue; } - throw new JsonException($"Unknown property name '{propertyName}' received while deserializing the 'Retriever' from the response."); + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); } - var result = new Retriever(variantNameValue, variantValue); - return result; + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new Retriever { VariantType = variantType, Variant = variant }; } - public override void Write(Utf8JsonWriter writer, Retriever value, JsonSerializerOptions options) + public override void Write(System.Text.Json.Utf8JsonWriter writer, Retriever value, System.Text.Json.JsonSerializerOptions options) { writer.WriteStartObject(); - if (value.VariantName is not null && value.Variant is not null) + switch (value.VariantType) { - writer.WritePropertyName(value.VariantName); - switch (value.VariantName) - { - case "knn": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.KnnRetriever)value.Variant, options); - break; - case "rrf": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RRFRetriever)value.Variant, options); - break; - case "rule": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.RuleRetriever)value.Variant, options); - break; - case "standard": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.StandardRetriever)value.Variant, options); - break; - case "text_similarity_reranker": - JsonSerializer.Serialize(writer, (Elastic.Clients.Elasticsearch.TextSimilarityReranker)value.Variant, options); - break; - } + case "": + break; + case "knn": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.KnnRetriever?)value.Variant); + break; + case "rrf": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RRFRetriever?)value.Variant); + break; + case "rule": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.RuleRetriever?)value.Variant); + break; + case "standard": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.StandardRetriever?)value.Variant); + break; + case "text_similarity_reranker": + writer.WriteProperty(options, value.VariantType, (Elastic.Clients.Elasticsearch.TextSimilarityReranker?)value.Variant); + break; + default: + throw new System.Text.Json.JsonException($"Variant '{value.VariantType}' is not supported for type '{nameof(Retriever)}'."); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs index 01f81c216af..2ac0b1404de 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/HistogramGrouping.g.cs @@ -27,6 +27,50 @@ namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class HistogramGroupingConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + private static readonly System.Text.Json.JsonEncodedText PropInterval = System.Text.Json.JsonEncodedText.Encode("interval"); + + public override HistogramGrouping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + LocalJsonValue propInterval = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + if (propInterval.TryRead(ref reader, options, PropInterval)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new HistogramGrouping + { + Fields = propFields.Value +, + Interval = propInterval.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, HistogramGrouping value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteProperty(options, PropInterval, value.Interval); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(HistogramGroupingConverter))] public sealed partial class HistogramGrouping { /// @@ -36,8 +80,6 @@ public sealed partial class HistogramGrouping /// Order does not matter. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } /// @@ -47,7 +89,6 @@ public sealed partial class HistogramGrouping /// Note that only one interval can be specified in the histogram group, meaning that all fields being grouped via the histogram must share the same interval. /// /// - [JsonInclude, JsonPropertyName("interval")] public long Interval { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs index 45fffa5a070..f55d20afab7 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupCapabilitySummary.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Rollup; public sealed partial class RollupCapabilitySummary { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary> Fields { get; init; } [JsonInclude, JsonPropertyName("index_pattern")] public string IndexPattern { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs index a015ca60a97..26a49395779 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/RollupJobSummary.g.cs @@ -30,7 +30,6 @@ namespace Elastic.Clients.Elasticsearch.Rollup; public sealed partial class RollupJobSummary { [JsonInclude, JsonPropertyName("fields")] - [ReadOnlyFieldDictionaryConverter(typeof(IReadOnlyCollection))] public IReadOnlyDictionary> Fields { get; init; } [JsonInclude, JsonPropertyName("index_pattern")] public string IndexPattern { get; init; } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs index 5a0659a009a..f827cd96474 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Rollup/TermsGrouping.g.cs @@ -27,6 +27,40 @@ namespace Elastic.Clients.Elasticsearch.Rollup; +internal sealed partial class TermsGroupingConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFields = System.Text.Json.JsonEncodedText.Encode("fields"); + + public override TermsGrouping Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue propFields = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFields.TryRead(ref reader, options, PropFields, typeof(SingleOrManyFieldsMarker))) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new TermsGrouping + { + Fields = propFields.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, TermsGrouping value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFields, value.Fields, null, typeof(SingleOrManyFieldsMarker)); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(TermsGroupingConverter))] public sealed partial class TermsGrouping { /// @@ -36,8 +70,6 @@ public sealed partial class TermsGrouping /// Order does not matter. /// /// - [JsonInclude, JsonPropertyName("fields")] - [JsonConverter(typeof(SingleOrManyFieldsConverter))] public Elastic.Clients.Elasticsearch.Fields Fields { get; set; } } diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs index 34346cfb0ce..e2ffabf0af9 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/RuleRetriever.g.cs @@ -27,6 +27,90 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class RuleRetrieverConverter : System.Text.Json.Serialization.JsonConverter +{ + private static readonly System.Text.Json.JsonEncodedText PropFilter = System.Text.Json.JsonEncodedText.Encode("filter"); + private static readonly System.Text.Json.JsonEncodedText PropMatchCriteria = System.Text.Json.JsonEncodedText.Encode("match_criteria"); + private static readonly System.Text.Json.JsonEncodedText PropMinScore = System.Text.Json.JsonEncodedText.Encode("min_score"); + private static readonly System.Text.Json.JsonEncodedText PropRankWindowSize = System.Text.Json.JsonEncodedText.Encode("rank_window_size"); + private static readonly System.Text.Json.JsonEncodedText PropRetriever = System.Text.Json.JsonEncodedText.Encode("retriever"); + private static readonly System.Text.Json.JsonEncodedText PropRulesetIds = System.Text.Json.JsonEncodedText.Encode("ruleset_ids"); + + public override RuleRetriever Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) + { + reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject); + LocalJsonValue?> propFilter = default; + LocalJsonValue propMatchCriteria = default; + LocalJsonValue propMinScore = default; + LocalJsonValue propRankWindowSize = default; + LocalJsonValue propRetriever = default; + LocalJsonValue> propRulesetIds = default; + while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName) + { + if (propFilter.TryRead(ref reader, options, PropFilter, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>))) + { + continue; + } + + if (propMatchCriteria.TryRead(ref reader, options, PropMatchCriteria)) + { + continue; + } + + if (propMinScore.TryRead(ref reader, options, PropMinScore)) + { + continue; + } + + if (propRankWindowSize.TryRead(ref reader, options, PropRankWindowSize)) + { + continue; + } + + if (propRetriever.TryRead(ref reader, options, PropRetriever)) + { + continue; + } + + if (propRulesetIds.TryRead(ref reader, options, PropRulesetIds)) + { + continue; + } + + throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'."); + } + + reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject); + return new RuleRetriever + { + Filter = propFilter.Value +, + MatchCriteria = propMatchCriteria.Value +, + MinScore = propMinScore.Value +, + RankWindowSize = propRankWindowSize.Value +, + Retriever = propRetriever.Value +, + RulesetIds = propRulesetIds.Value + }; + } + + public override void Write(System.Text.Json.Utf8JsonWriter writer, RuleRetriever value, System.Text.Json.JsonSerializerOptions options) + { + writer.WriteStartObject(); + writer.WriteProperty(options, PropFilter, value.Filter, null, typeof(SingleOrManyMarker?, Elastic.Clients.Elasticsearch.QueryDsl.Query>)); + writer.WriteProperty(options, PropMatchCriteria, value.MatchCriteria); + writer.WriteProperty(options, PropMinScore, value.MinScore); + writer.WriteProperty(options, PropRankWindowSize, value.RankWindowSize); + writer.WriteProperty(options, PropRetriever, value.Retriever); + writer.WriteProperty(options, PropRulesetIds, value.RulesetIds); + writer.WriteEndObject(); + } +} + +[JsonConverter(typeof(RuleRetrieverConverter))] public sealed partial class RuleRetriever { /// @@ -34,8 +118,6 @@ public sealed partial class RuleRetriever /// Query to filter the documents that can match. /// /// - [JsonInclude, JsonPropertyName("filter")] - [SingleOrManyCollectionConverter(typeof(Elastic.Clients.Elasticsearch.QueryDsl.Query))] public ICollection? Filter { get; set; } /// @@ -43,7 +125,6 @@ public sealed partial class RuleRetriever /// The match criteria that will determine if a rule in the provided rulesets should be applied. /// /// - [JsonInclude, JsonPropertyName("match_criteria")] public object MatchCriteria { get; set; } /// @@ -51,7 +132,6 @@ public sealed partial class RuleRetriever /// Minimum _score for matching documents. Documents with a lower _score are not included in the top documents. /// /// - [JsonInclude, JsonPropertyName("min_score")] public float? MinScore { get; set; } /// @@ -59,7 +139,6 @@ public sealed partial class RuleRetriever /// This value determines the size of the individual result set. /// /// - [JsonInclude, JsonPropertyName("rank_window_size")] public int? RankWindowSize { get; set; } /// @@ -67,7 +146,6 @@ public sealed partial class RuleRetriever /// The retriever whose results rules should be applied to. /// /// - [JsonInclude, JsonPropertyName("retriever")] public Elastic.Clients.Elasticsearch.Retriever Retriever { get; set; } /// @@ -75,7 +153,6 @@ public sealed partial class RuleRetriever /// The ruleset IDs containing the rules this retriever is evaluating against. /// /// - [JsonInclude, JsonPropertyName("ruleset_ids")] public ICollection RulesetIds { get; set; } public static implicit operator Elastic.Clients.Elasticsearch.Retriever(RuleRetriever ruleRetriever) => Elastic.Clients.Elasticsearch.Retriever.Rule(ruleRetriever); diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs index bb90104b52e..397ae2a41a8 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Script.g.cs @@ -27,6 +27,86 @@ namespace Elastic.Clients.Elasticsearch; +internal sealed partial class ScriptConverter : System.Text.Json.Serialization.JsonConverter