Skip to content

Commit 22c76c8

Browse files
move language examples to a separate file (#4910) (#4924)
(cherry picked from commit 1ba72cb) # Conflicts: # output/schema/schema.json # specification/_global/delete/examples/request/DeleteRequestExample1.yaml # specification/_global/delete_by_query_rethrottle/examples/request/DeleteByQueryRethrottleRequestExample1.yaml # specification/_global/delete_script/examples/request/DeleteScriptRequestExample1.yaml # specification/_global/exists/examples/request/DocumentExistsRequestExample1.yaml # specification/_global/exists_source/examples/request/ExistsSourceRequestExample1.yaml # specification/_global/get_script/examples/request/GetScriptRequestExample1.yaml # specification/_global/get_source/examples/request/GetSourceRequestExample1.yaml # specification/_global/health_report/examples/request/HealthReportRequestExample1.yaml # specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml # specification/_global/reindex/examples/request/ReindexRequestExample1.yaml # specification/_global/reindex/examples/request/ReindexRequestExample10.yaml # specification/_global/reindex/examples/request/ReindexRequestExample11.yaml # specification/_global/reindex/examples/request/ReindexRequestExample12.yaml # specification/_global/reindex/examples/request/ReindexRequestExample13.yaml # specification/_global/reindex/examples/request/ReindexRequestExample2.yaml # specification/_global/reindex/examples/request/ReindexRequestExample3.yaml # specification/_global/reindex/examples/request/ReindexRequestExample4.yaml # specification/_global/reindex/examples/request/ReindexRequestExample5.yaml # specification/_global/reindex/examples/request/ReindexRequestExample6.yaml # specification/_global/reindex/examples/request/ReindexRequestExample7.yaml # specification/_global/reindex/examples/request/ReindexRequestExample8.yaml # specification/_global/reindex/examples/request/ReindexRequestExample9.yaml # specification/_global/reindex_rethrottle/examples/request/ReindexRethrottleRequestExample1.yaml # specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml # specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml # specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml # specification/_global/search_shards/examples/request/SearchShardsRequestExample1.yaml # specification/_global/update/examples/request/UpdateRequestExample1.yaml # specification/_global/update/examples/request/UpdateRequestExample10.yaml # specification/_global/update/examples/request/UpdateRequestExample2.yaml # specification/_global/update/examples/request/UpdateRequestExample3.yaml # specification/_global/update/examples/request/UpdateRequestExample4.yaml # specification/_global/update/examples/request/UpdateRequestExample5.yaml # specification/_global/update/examples/request/UpdateRequestExample6.yaml # specification/_global/update/examples/request/UpdateRequestExample7.yaml # specification/_global/update/examples/request/UpdateRequestExample9.yaml # specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml # specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml # specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml # specification/_global/update_by_query_rethrottle/examples/request/UpdateByQueryRethrottleRequestExample1.yaml # specification/async_search/delete/examples/request/AsyncSearchDeleteExample1.yaml # specification/async_search/get/examples/request/AsyncSearchGetRequestExample1.yaml # specification/async_search/status/examples/request/AsyncSearchStatusRequestExample1.yaml # specification/autoscaling/delete_autoscaling_policy/examples/request/DeleteAutoscalingPolicyRequestExample1.yaml # specification/autoscaling/get_autoscaling_capacity/examples/request/GetAutoscalingCapacityRequestExample1.yaml # specification/autoscaling/get_autoscaling_policy/examples/request/GetAutoscalingPolicyRequestExample1.yaml # specification/ccr/delete_auto_follow_pattern/examples/request/DeleteAutoFollowPatternRequestExample1.yaml # specification/ccr/follow_info/examples/request/FollowInfoRequestExample1.yaml # specification/ccr/follow_stats/examples/request/FollowIndexStatsRequestExample1.yaml # specification/ccr/get_auto_follow_pattern/examples/request/GetAutoFollowPatternRequestExample1.yaml # specification/ccr/pause_auto_follow_pattern/examples/request/PauseAutoFollowPatternRequestExample1.yaml # specification/ccr/pause_follow/examples/request/PauseFollowIndexRequestExample1.yaml # specification/ccr/resume_auto_follow_pattern/examples/request/ResumeAutoFollowPatternRequestExample1.yaml # specification/ccr/stats/examples/request/CcrStatsRequestExample1.yaml # specification/ccr/unfollow/examples/request/UnfollowIndexRequestExample1.yaml # specification/cluster/delete_component_template/examples/request/ClusterDeleteComponentTemplateExample1.yaml # specification/cluster/get_component_template/examples/request/ClusterGetComponentTemplateExample1.yaml # specification/cluster/health/examples/request/ClusterHealthRequestExample1.yaml # specification/cluster/info/examples/request/ClusterInfoExample1.yaml # specification/cluster/pending_tasks/examples/request/ClusterPendingTasksExample1.yaml # specification/connector/check_in/examples/request/ConnectorCheckInExample1.yaml # specification/connector/delete/examples/request/ConnectorDeleteExample1.yaml # specification/connector/get/examples/request/ConnectorGetExample1.yaml # specification/connector/list/examples/request/ConnectorListExample1.yaml # specification/connector/sync_job_cancel/examples/request/ConnectorSyncJobCancelExample1.yaml # specification/connector/sync_job_check_in/examples/request/ConnectorSyncJobCheckInExample1.yaml # specification/connector/sync_job_delete/examples/request/ConnectorSyncJobDeleteExample1.yaml # specification/connector/sync_job_get/examples/request/ConnectorSyncJobGetExample1.yaml # specification/connector/sync_job_list/examples/request/ConnectorSyncJobListExample1.yaml # specification/dangling_indices/delete_dangling_index/examples/request/DanglingIndicesDeleteDanglingIndexExample1.yaml # specification/dangling_indices/import_dangling_index/examples/request/ImportDanglingIndexRequestExample1.yaml # specification/enrich/delete_policy/examples/request/EnrichDeletePolicyExample1.yaml # specification/enrich/execute_policy/examples/request/EnrichExecutePolicyExample1.yaml # specification/enrich/get_policy/examples/request/EnrichGetPolicyExample1.yaml # specification/enrich/stats/examples/request/EnrichStatsExample1.yaml # specification/eql/delete/examples/request/EqlDeleteExample1.yaml # specification/eql/get/examples/request/EqlGetExample1.yaml # specification/eql/get_status/examples/request/EqlGetStatusExample1.yaml # specification/eql/search/examples/request/EqlSearchRequestExample2.yaml # specification/esql/query/examples/request/QueryRequestExample1.yaml # specification/features/get_features/examples/request/FeaturesGetFeaturesExample1.yaml # specification/features/reset_features/examples/request/FeaturesResetFeaturesExample1.yaml # specification/graph/explore/examples/request/GraphExploreRequestExample1.yaml # specification/ilm/delete_lifecycle/examples/request/IlmDeleteLifecycleExample1.yaml # specification/ilm/explain_lifecycle/examples/request/IlmExplainLifecycleExample1.yaml # specification/ilm/get_lifecycle/examples/request/IlmGetLifecycleExample1.yaml # specification/ilm/remove_policy/examples/request/IlmRemovePolicyExample1.yaml # specification/ilm/retry/examples/request/IlmRetryExample1.yaml # specification/ilm/start/examples/request/IlmStartExample1.yaml # specification/ilm/stop/examples/request/IlmStopExample1.yaml # specification/indices/add_block/examples/request/IndicesAddBlockRequestExample1.yaml # specification/indices/cancel_migrate_reindex/examples/request/IndicesCancelMigrateReindexExample1.yaml # specification/indices/clear_cache/examples/request/IndicesClearCacheExample1.yaml # specification/indices/close/examples/request/CloseIndexRequestExample1.yaml # specification/indices/create_data_stream/examples/request/IndicesCreateDataStreamExample1.yaml # specification/indices/data_streams_stats/examples/request/indicesDataStreamStatsExampleRequest1.yaml # specification/indices/delete/examples/request/IndicesDeleteExample1.yaml # specification/indices/delete_alias/examples/request/IndicesDeleteAliasExample1.yaml # specification/indices/delete_data_lifecycle/examples/request/IndicesDeleteDataLifecycleExample1.yaml # specification/indices/delete_data_stream/examples/request/IndicesDeleteDataStreamExample1.yaml # specification/indices/delete_index_template/examples/request/IndicesDeleteIndexTemplateExample1.yaml # specification/indices/delete_template/examples/request/IndicesDeleteTemplateExample1.yaml # specification/indices/disk_usage/examples/request/IndicesDiskUsageExample1.yaml # specification/indices/exists/examples/request/IndicesExistsExample1.yaml # specification/indices/exists_alias/examples/request/IndicesExistsAliasExample1.yaml # specification/indices/exists_template/examples/request/IndicesExistsTemplateExample1.yaml # specification/indices/explain_data_lifecycle/examples/request/IndicesExplainDataLifecycleRequestExample1.yaml # specification/indices/field_usage_stats/examples/request/indicesFieldUsageStatsRequestExample1.yaml # specification/indices/flush/examples/request/IndicesFlushExample1.yaml # specification/indices/forcemerge/examples/request/IndicesForcemergeExample1.yaml # specification/indices/get/examples/request/IndicesGetExample1.yaml # specification/indices/get_alias/examples/request/IndicesGetAliasExample1.yaml # specification/indices/get_data_stream/examples/request/IndicesGetDataStreamExample1.yaml # specification/indices/get_data_stream_settings/examples/request/IndicesGetDataStreamSettingsRequestExample1.yaml # specification/indices/get_field_mapping/examples/request/indicesGetFieldMappingRequestExample1.yaml # specification/indices/get_mapping/examples/request/IndicesGetMappingExample1.yaml # specification/indices/get_migrate_reindex_status/examples/request/IndicesGetMigrateReindexStatusExample1.yaml # specification/indices/get_template/examples/request/IndicesGetTemplateExample1.yaml # specification/indices/migrate_to_data_stream/examples/request/IndicesMigrateToDataStreamExample1.yaml # specification/indices/open/examples/request/IndicesOpenExample1.yaml # specification/indices/promote_data_stream/examples/request/IndicesPromoteDataStreamExample1.yaml # specification/indices/put_data_stream_settings/examples/request/IndicesPutDataStreamSettingsRequestExample1.yaml # specification/indices/refresh/examples/request/IndicesRefreshExample1.yaml # specification/indices/remove_block/examples/request/IndicesRemoveBlockRequestExample1.yaml # specification/indices/resolve_cluster/examples/request/ResolveClusterRequestExample2.yaml # specification/indices/segments/examples/request/IndicesSegmentsExample1.yaml # specification/indices/simulate_index_template/examples/request/indicesSimulateIndexTemplateRequestExample1.yaml # specification/inference/delete/examples/request/InferenceDeleteExample1.yaml # specification/inference/get/examples/request/InferenceGetExample1.yaml # specification/inference/rerank/examples/request/RerankRequestExample2.yaml # specification/ingest/delete_ip_location_database/examples/request/IngestDeleteIpLocationDatabaseExample1.yaml # specification/ingest/delete_pipeline/examples/request/IngestDeletePipelineExample1.yaml # specification/ingest/get_ip_location_database/examples/request/IngestGetIpLocationDatabaseExample1.yaml # specification/ingest/get_pipeline/examples/request/IngestGetPipelineExample1.yaml # specification/license/delete/examples/request/LicenseDeleteExample1.yaml # specification/license/get/examples/request/GetLicenseRequestExample1.yaml # specification/license/post_start_basic/examples/request/StartBasicLicenseRequestExample1.yaml # specification/license/post_start_trial/examples/request/StartTrialLicenseRequestExample1.yaml # specification/logstash/delete_pipeline/examples/request/LogstashDeletePipelineExample1.yaml # specification/logstash/get_pipeline/examples/request/LogstashGetPipelineRequestExample1.yaml # specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml # specification/migration/deprecations/examples/request/DeprecationInfoRequestExample1.yaml # specification/ml/clear_trained_model_deployment_cache/examples/request/MlClearTrainedModelDeploymentCacheExample1.yaml # specification/ml/delete_calendar/examples/request/MlDeleteCalendarExample1.yaml # specification/ml/delete_calendar_event/examples/request/MlDeleteCalendarEventExample1.yaml # specification/ml/delete_calendar_job/examples/request/MlDeleteCalendarJobExample1.yaml # specification/ml/delete_data_frame_analytics/examples/request/MlDeleteDataFrameAnalyticsExample1.yaml # specification/ml/delete_datafeed/examples/request/MlDeleteDatafeedExample1.yaml # specification/ml/delete_filter/examples/request/MlDeleteFilterExample1.yaml # specification/ml/delete_forecast/examples/request/MlDeleteForecastExample1.yaml # specification/ml/delete_job/examples/request/MlDeleteJobExample1.yaml # specification/ml/delete_model_snapshot/examples/request/MlDeleteModelSnapshotExample1.yaml # specification/ml/delete_trained_model/examples/request/MlDeleteTrainedModelExample1.yaml # specification/ml/delete_trained_model_alias/examples/request/MlDeleteTrainedModelAliasExample1.yaml # specification/ml/get_calendar_events/examples/request/MlGetCalendarEventsExample1.yaml # specification/ml/get_data_frame_analytics/examples/request/MlGetDataFrameAnalyticsExample1.yaml # specification/ml/get_data_frame_analytics_stats/examples/request/MlGetDataFrameAnalyticsStatsExample1.yaml # specification/ml/get_datafeed_stats/examples/request/MlGetDatafeedStatsExample1.yaml # specification/ml/get_datafeeds/examples/request/MlGetDatafeedsExample1.yaml # specification/ml/get_filters/examples/request/MlGetFiltersExample1.yaml # specification/ml/get_job_stats/examples/request/MlGetJobStatsExample1.yaml # specification/ml/get_jobs/examples/request/MlGetJobsExample1.yaml # specification/ml/get_model_snapshot_upgrade_stats/examples/request/MlGetModelSnapshotUpgradeStatsExample1.yaml # specification/ml/get_trained_models/examples/request/MlGetTrainedModelsExample1.yaml # specification/ml/get_trained_models_stats/examples/request/MlGetTrainedModelsStatsExample1.yaml # specification/ml/put_calendar_job/examples/request/MlPutCalendarJobExample1.yaml # specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml # specification/ml/put_trained_model_alias/examples/request/MlPutTrainedModelAliasExample1.yaml # specification/ml/reset_job/examples/request/MlResetJobExample1.yaml # specification/ml/set_upgrade_mode/examples/request/MlSetUpgradeModeExample1.yaml # specification/ml/start_data_frame_analytics/examples/request/MlStartDataFrameAnalyticsExample1.yaml # specification/ml/stop_data_frame_analytics/examples/request/MlStopDataFrameAnalyticsExample1.yaml # specification/ml/stop_trained_model_deployment/examples/request/MlStopTrainedModelDeploymentExample1.yaml # specification/ml/upgrade_job_snapshot/examples/request/MlUpgradeJobSnapshotExample1.yaml # specification/nodes/hot_threads/examples/request/NodesHotThreadsExample1.yaml # specification/nodes/info/examples/request/NodesInfoExample1.yaml # specification/nodes/usage/examples/request/NodesUsageExample1.yaml # specification/query_rules/delete_rule/examples/request/QueryRulesDeleteRuleExample1.yaml # specification/query_rules/delete_ruleset/examples/request/QueryRulesDeleteRulesetExample1.yaml # specification/query_rules/get_rule/examples/request/QueryRuleGetRequestExample1.yaml # specification/query_rules/get_ruleset/examples/request/QueryRulesetGetRequestExample1.yaml # specification/query_rules/list_rulesets/examples/request/QueryRulesetListRequestExample1.yaml # specification/rollup/delete_job/examples/request/DeleteRollupJobRequestExample1.yaml # specification/rollup/get_jobs/examples/request/GetRollupJobRequestExample1.yaml # specification/rollup/get_rollup_caps/examples/request/GetRollupCapabilitiesRequestExample1.yaml # specification/rollup/get_rollup_index_caps/examples/request/GetRollupIndexCapabilitiesRequestExample1.yaml # specification/rollup/start_job/examples/request/StartRollupJobRequestExample1.yaml # specification/rollup/stop_job/examples/request/RollupStopJobExample1.yaml # specification/search_application/delete/examples/request/SearchApplicationDeleteExample1.yaml # specification/search_application/delete_behavioral_analytics/examples/request/SearchApplicationDeleteBehavioralAnalyticsExample1.yaml # specification/search_application/get/examples/request/SearchApplicationGetRequestExample1.yaml # specification/search_application/get_behavioral_analytics/examples/request/BehavioralAnalyticsGetRequestExample1.yaml # specification/search_application/list/examples/request/SearchApplicationsListRequestExample1.yaml # specification/search_application/put/examples/request/SearchApplicationPutRequestExample1.yaml # specification/search_application/put_behavioral_analytics/examples/request/SearchApplicationPutBehavioralAnalyticsExample1.yaml # specification/searchable_snapshots/cache_stats/examples/request/CacheStatsRequestExample1.yaml # specification/searchable_snapshots/clear_cache/examples/request/SearchableSnapshotsClearCacheExample1.yaml # specification/searchable_snapshots/stats/examples/request/SearchableSnapshotsStatsExample1.yaml # specification/security/clear_api_key_cache/examples/request/SecurityClearApiKeyCacheExample1.yaml # specification/security/clear_cached_privileges/examples/request/SecurityClearCachedPrivilegesExample1.yaml # specification/security/clear_cached_realms/examples/request/SecurityClearCachedRealmsExample1.yaml # specification/security/clear_cached_roles/examples/request/SecurityClearCachedRolesExample1.yaml # specification/security/clear_cached_service_tokens/examples/request/SecurityClearCachedServiceTokensExample1.yaml # specification/security/create_service_token/examples/request/CreateServiceTokenRequestExample1.yaml # specification/security/delete_privileges/examples/request/SecurityDeletePrivilegesRequestExample1.yaml # specification/security/delete_role/examples/request/SecurityDeleteRoleRequestExample1.yaml # specification/security/delete_role_mapping/examples/request/SecurityDeleteRoleMappingRequestExample1.yaml # specification/security/delete_service_token/examples/request/DeleteServiceTokenRequestExample1.yaml # specification/security/delete_user/examples/request/SecurityDeleteUserRequestExample1.yaml # specification/security/disable_user/examples/request/SecurityDisableUserExample1.yaml # specification/security/disable_user_profile/examples/request/SecurityDisableUserProfileExample1.yaml # specification/security/enable_user/examples/request/SecurityEnableUserExample1.yaml # specification/security/enable_user_profile/examples/request/SecurityEnableUserProfileExample1.yaml # specification/security/get_api_key/examples/request/SecurityGetApiKeyRequestExample2.yaml # specification/security/get_privileges/examples/request/SecurityGetPrivilegesRequestExample1.yaml # specification/security/get_role/examples/request/SecurityGetRoleRequestExample1.yaml # specification/security/get_role_mapping/examples/request/SecurityGetRoleMappingRequestExample1.yaml # specification/security/get_service_accounts/examples/request/GetServiceAccountsRequestExample1.yaml # specification/security/get_service_credentials/examples/request/GetServiceCredentialsRequestExample1.yaml # specification/security/get_settings/examples/request/SecurityGetSettingsExample1.yaml # specification/security/get_user/examples/request/SecurityGetUserRequestExample1.yaml # specification/security/get_user_privileges/examples/request/SecurityGetUserPrivilegesRequestExample1.yaml # specification/security/get_user_profile/examples/request/GetUserProfileRequestExample1.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml # specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml # specification/shutdown/delete_node/examples/request/ShutdownDeleteNodeRequestExample1.yaml # specification/shutdown/get_node/examples/request/ShutdownGetNodeRequestExample1.yaml # specification/slm/delete_lifecycle/examples/request/SlmDeleteLifecycleExample1.yaml # specification/slm/execute_lifecycle/examples/request/ExecuteSnapshotLifecycleRequestExample1.yaml # specification/slm/execute_retention/examples/request/SlmExecuteRetentionExample1.yaml # specification/slm/get_stats/examples/request/GetSnapshotLifecycleManagementStatsRequestExample1.yaml # specification/slm/get_status/examples/request/GetSnapshotLifecycleManagementStatusRequestExample1.yaml # specification/slm/start/examples/request/StartSnapshotLifecycleManagementRequestExample1.yaml # specification/snapshot/cleanup_repository/examples/request/SnapshotCleanupRepositoryRequestExample1.yaml # specification/snapshot/delete/examples/request/SnapshotDeleteRequestExample1.yaml # specification/snapshot/delete_repository/examples/request/SnapshotDeleteRepositoryExample1.yaml # specification/snapshot/get/examples/request/SnapshotGetRequestExample1.yaml # specification/snapshot/get_repository/examples/request/SnapshotGetRepositoryRequestExample1.yaml # specification/snapshot/repository_analyze/examples/request/SnapshotRepositoryAnalyzeRequestExample1.yaml # specification/snapshot/repository_verify_integrity/examples/request/SnapshotRepositoryVerifyIntegrityExample1.yaml # specification/snapshot/status/examples/request/SnapshotStatusRequestExample1.yaml # specification/snapshot/verify_repository/examples/request/SnapshotVerifyRepositoryExample1.yaml # specification/sql/delete_async/examples/request/SqlDeleteAsyncExample1.yaml # specification/sql/get_async/examples/request/SqlGetAsyncExample1.yaml # specification/sql/get_async_status/examples/request/SqlGetAsyncStatusExample1.yaml # specification/synonyms/delete_synonym/examples/request/SynonymsDeleteSynonymExample1.yaml # specification/synonyms/delete_synonym_rule/examples/request/SynonymRuleDeleteRequestExample1.yaml # specification/synonyms/get_synonym/examples/request/SynonymsGetRequestExample1.yaml # specification/synonyms/get_synonym_rule/examples/request/SynonymRuleGetRequestExample1.yaml # specification/synonyms/get_synonyms_sets/examples/request/SynonymsSetsGetRequestExample1.yaml # specification/tasks/cancel/examples/request/TasksCancelExample1.yaml # specification/text_structure/find_field_structure/examples/request/FindFieldStructureRequestExample1.yaml # specification/transform/delete_transform/examples/request/TransformDeleteTransformExample1.yaml # specification/transform/get_transform/examples/request/TransformGetTransformExample1.yaml # specification/transform/get_transform_stats/examples/request/TransformGetTransformStatsExample1.yaml # specification/transform/reset_transform/examples/request/TransformResetTransformExample1.yaml # specification/transform/schedule_now_transform/examples/request/TransformScheduleNowTransformExample1.yaml # specification/transform/start_transform/examples/request/TransformStartTransformExample1.yaml # specification/transform/stop_transform/examples/request/TransformStopTransformExample1.yaml # specification/transform/upgrade_transforms/examples/request/TransformUpgradeTransformsExample1.yaml # specification/watcher/ack_watch/examples/request/WatcherAckWatchRequestExample1.yaml # specification/watcher/activate_watch/examples/request/WatcherActivateWatchExample1.yaml # specification/watcher/deactivate_watch/examples/request/WatcherDeactivateWatchExample1.yaml # specification/watcher/delete_watch/examples/request/DeleteWatchRequestExample1.yaml # specification/watcher/get_settings/examples/request/WatcherGetSettingsExample1.yaml # specification/watcher/get_watch/examples/request/GetWatchRequestExample1.yaml # specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml # specification/watcher/start/examples/request/WatcherStartRequestExample1.yaml # specification/watcher/stats/examples/request/WatcherStatsRequestExample1.yaml # specification/watcher/stop/examples/request/WatcherStopRequestExample1.yaml # specification/xpack/info/examples/request/XPackInfoRequestExample1.yaml # specification/xpack/usage/examples/request/XPackUsageRequestExample1.yaml Co-authored-by: Miguel Grinberg <[email protected]>
1 parent ecebe9d commit 22c76c8

File tree

656 files changed

+17842
-36828
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

656 files changed

+17842
-36828
lines changed

compiler/src/steps/add-examples.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ export default class ExamplesProcessor {
5454
class BaseExamplesProcessor {
5555
model: model.Model
5656
specsFolder: string
57+
static languageExamples: Record<string, model.ExampleAlternative[]> = {}
5758

5859
constructor (model: model.Model, specsFolder: string) {
5960
this.model = model
6061
this.specsFolder = specsFolder
62+
if (Object.keys(BaseExamplesProcessor.languageExamples).length === 0) {
63+
// load the language examples
64+
const examplesJson = this.specsFolder + '/../docs/examples/languageExamples.json'
65+
if (fs.existsSync(examplesJson)) {
66+
BaseExamplesProcessor.languageExamples = JSON.parse(fs.readFileSync(examplesJson, 'utf8'))
67+
}
68+
}
6169
}
6270

6371
// Log a 'warning' message.
@@ -139,6 +147,11 @@ class BaseExamplesProcessor {
139147
const exampleFileContent = fs.readFileSync(filePath, 'utf8')
140148
const exampleName = path.basename(fileName, path.extname(fileName))
141149
const example: model.Example = yaml.load(exampleFileContent)
150+
// find the language alternative examples and add them
151+
const alternativeKey = 'specification/' + filePath.split('/specification/')[1]
152+
if (BaseExamplesProcessor.languageExamples[alternativeKey] !== undefined) {
153+
example.alternatives = BaseExamplesProcessor.languageExamples[alternativeKey]
154+
}
142155
// Some of the example files set their 'value' as a JSON string,
143156
// and some files set their 'value' as an object. For consistency,
144157
// if the value is not a JSON string, convert it to a JSON string.

docs/examples/generate-language-examples.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const {parseRequest} = require("@elastic/request-converter/dist/parse");
2525
const {JavaCaller} = require("java-caller");
2626

2727
const LANGUAGES = ['Python', 'JavaScript', 'Ruby', 'PHP', 'curl'];
28+
const EXAMPLES_JSON = 'docs/examples/languageExamples.json';
29+
let languageExamples = {};
2830

2931
async function generateLanguages(example) {
3032
const doc = yamlParseDocument(await fs.promises.readFile(example, 'utf8'));
@@ -38,14 +40,18 @@ async function generateLanguages(example) {
3840
request += '\n' + JSON.stringify(data.value);
3941
}
4042
}
41-
const alternatives = [];
43+
if (data.alternatives) {
44+
languageExamples[example] = data.alternatives;
45+
delete data.alternatives;
46+
}
47+
let alternatives = [];
4248
for (const lang of LANGUAGES) {
4349
alternatives.push({
4450
language: lang,
4551
code: (await convertRequests(request, lang, {})).trim(),
4652
});
4753
}
48-
data.alternatives = alternatives.concat((data.alternatives ?? []).filter(pair => !LANGUAGES.includes(pair.language)));
54+
alternatives = alternatives.concat((languageExamples[example] ?? []).filter(pair => !LANGUAGES.includes(pair.language)));
4955

5056
// specific java example generator
5157
if (process.argv[2] === "java") {
@@ -85,13 +91,13 @@ async function generateLanguages(example) {
8591
code: stdout,
8692
});
8793
// replace old java examples
88-
data.alternatives = data.alternatives.filter(pair => pair.language !== "Java");
89-
data.alternatives = data.alternatives.concat(alternative_java);
94+
alternatives = alternatives.filter(pair => pair.language !== "Java");
95+
alternatives = alternatives.concat(alternative_java);
9096
}
9197
}
9298

9399
doc.delete('alternatives');
94-
doc.add(doc.createPair('alternatives', data.alternatives));
100+
languageExamples[example] = alternatives;
95101
await fs.promises.writeFile(example, doc.toString({lineWidth: 132}));
96102
}
97103

@@ -128,6 +134,9 @@ async function main() {
128134
let count = 0;
129135
let errors = 0;
130136
await loadSchema('output/schema/schema.json');
137+
if (fs.existsSync(EXAMPLES_JSON)) {
138+
languageExamples = JSON.parse(await fs.promises.readFile(EXAMPLES_JSON, 'utf8'));
139+
}
131140
for await (const example of walkExamples('./specification/')) {
132141
try {
133142
await generateLanguages(example);
@@ -138,6 +147,7 @@ async function main() {
138147
}
139148
count += 1;
140149
}
150+
await fs.promises.writeFile(EXAMPLES_JSON, JSON.stringify(languageExamples, null, 2));
141151
console.log(`${count} examples processed, ${errors} errors.`);
142152
}
143153

0 commit comments

Comments
 (0)