From ec57e474ddf4b99be277ea4bf98ddbe2a0d56c35 Mon Sep 17 00:00:00 2001 From: Lisa Cawley Date: Tue, 28 Jan 2025 15:54:33 -0800 Subject: [PATCH] Add x-codeSamples to check document API (#3594) (cherry picked from commit fcd7150771746274c0c83ff48da3c5e1e18a5ead) --- docs/overlays/elasticsearch-shared-overlays.yaml | 10 ++++++++++ .../xCodeSamples/DocumentExistsConsoleExample1.yaml | 4 ++++ .../xCodeSamples/DocumentExistsCurlExample1.yaml | 4 ++++ .../xCodeSamples/DocumentExistsJavaScriptExample1.yaml | 8 ++++++++ .../xCodeSamples/DocumentExistsPythonExample1.yaml | 8 ++++++++ .../xCodeSamples/DocumentExistsRubyExample1.yaml | 8 ++++++++ 6 files changed, 42 insertions(+) create mode 100644 specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml create mode 100644 specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml create mode 100644 specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml create mode 100644 specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml create mode 100644 specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml diff --git a/docs/overlays/elasticsearch-shared-overlays.yaml b/docs/overlays/elasticsearch-shared-overlays.yaml index 463b7422fe..36e042c71b 100644 --- a/docs/overlays/elasticsearch-shared-overlays.yaml +++ b/docs/overlays/elasticsearch-shared-overlays.yaml @@ -2381,3 +2381,13 @@ actions: examples: updateTransformResponseExample1: $ref: "../../specification/transform/update_transform/examples/response/UpdateTransformResponseExample1.yaml" +## xCodeSamples + - target: "$.paths['/{index}/_doc/{id}']['head']" + description: "Add xCodeSamples for check document operation" + update: + x-codeSamples: + - $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml" + - $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml" + - $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml" + - $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml" + - $ref: "../../specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml" diff --git a/specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml b/specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml new file mode 100644 index 0000000000..86d515fe09 --- /dev/null +++ b/specification/_global/exists/examples/xCodeSamples/DocumentExistsConsoleExample1.yaml @@ -0,0 +1,4 @@ +lang: Console +# label: +source: | + HEAD my-index-000001/_doc/0 diff --git a/specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml b/specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml new file mode 100644 index 0000000000..0f711687ce --- /dev/null +++ b/specification/_global/exists/examples/xCodeSamples/DocumentExistsCurlExample1.yaml @@ -0,0 +1,4 @@ +lang: Curl +# label: +source: | + curl -I "localhost:9200/my-index-000001/_doc/0?pretty" diff --git a/specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml b/specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml new file mode 100644 index 0000000000..c1dd8b311f --- /dev/null +++ b/specification/_global/exists/examples/xCodeSamples/DocumentExistsJavaScriptExample1.yaml @@ -0,0 +1,8 @@ +lang: JavaScript +# label: +source: | + const response = await client.exists({ + index: "my-index-000001", + id: 0, + }); + console.log(response); diff --git a/specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml b/specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml new file mode 100644 index 0000000000..e8447fe2a3 --- /dev/null +++ b/specification/_global/exists/examples/xCodeSamples/DocumentExistsPythonExample1.yaml @@ -0,0 +1,8 @@ +lang: Python +# label: +source: | + resp = client.exists( + index="my-index-000001", + id="0", + ) + print(resp) diff --git a/specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml b/specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml new file mode 100644 index 0000000000..d6a9adc51e --- /dev/null +++ b/specification/_global/exists/examples/xCodeSamples/DocumentExistsRubyExample1.yaml @@ -0,0 +1,8 @@ +lang: Ruby +# label: +source: | + response = client.exists( + index: 'my-index-000001', + id: 0 + ) + puts response