diff --git a/Makefile b/Makefile index 5d22334433..6eb10a0f53 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,10 @@ generate-language-examples: @node docs/examples/generate-language-examples.js @npm run format:fix-examples --prefix compiler +generate-language-examples-with-java: + @node docs/examples/generate-language-examples.js java + @npm run format:fix-examples --prefix compiler + lint-docs: ## Lint the OpenAPI documents after overlays @npx @redocly/cli lint "output/openapi/elasticsearch-*.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500 diff --git a/docs/examples/generate-language-examples.js b/docs/examples/generate-language-examples.js index ada853caba..5378c739d9 100644 --- a/docs/examples/generate-language-examples.js +++ b/docs/examples/generate-language-examples.js @@ -21,6 +21,8 @@ const fs = require('fs'); const path = require('path'); const { parseDocument: yamlParseDocument } = require('yaml'); const { convertRequests, loadSchema } = require('@elastic/request-converter'); +const {parseRequest} = require("@elastic/request-converter/dist/parse"); +const {JavaCaller} = require("java-caller"); const LANGUAGES = ['Python', 'JavaScript', 'Ruby', 'PHP', 'curl']; @@ -44,6 +46,50 @@ async function generateLanguages(example) { }); } data.alternatives = alternatives.concat((data.alternatives ?? []).filter(pair => !LANGUAGES.includes(pair.language))); + + // specific java example generator + if (process.argv[2] === "java") { + const partialRequest = await parseRequest(request); + const java = new JavaCaller({ + minimumJavaVersion: 21, + jar: "path/to/converter/jar/java-es-request-converter-1.0-SNAPSHOT.jar", + }); + + let correctParams = getCodeGenParamNames(partialRequest.params, partialRequest.request); + let body = partialRequest.body; + if (!body) { + body = {} + } + + let javaReqs = []; + const javaParsedRequest = { + api: partialRequest.api, + params: correctParams, + query: partialRequest.query, + body: body, + }; + javaReqs.push(javaParsedRequest) + + let args = []; + args.push(JSON.stringify(javaReqs)); + + const {status, stdout, stderr} = await java.run(args); + if (status) { + console.log(stderr); + console.log(JSON.stringify(javaReqs)); + } + else { + const alternative_java = []; + alternative_java.push({ + language: "Java", + code: stdout, + }); + // replace old java examples + data.alternatives = data.alternatives.filter(pair => pair.language !== "Java"); + data.alternatives = data.alternatives.concat(alternative_java); + } + } + doc.delete('alternatives'); doc.add(doc.createPair('alternatives', data.alternatives)); await fs.promises.writeFile(example, doc.toString({lineWidth: 132})); @@ -61,6 +107,23 @@ async function* walkExamples(dir) { } } +function getCodeGenParamNames( + params, + request, +){ + for (const [key, value] of Object.entries(params)) { + if (request?.path) { + for (const prop of request.path) { + if (prop.name === key && prop.codegenName !== undefined) { + delete params[key]; + params[prop.codegenName] = value; + } + } + } + } + return params; +} + async function main() { let count = 0; let errors = 0; diff --git a/docs/examples/package.json b/docs/examples/package.json index 32c28c5450..0475768d2d 100644 --- a/docs/examples/package.json +++ b/docs/examples/package.json @@ -6,6 +6,7 @@ "@elastic/request-converter": "^9.1.1", "@redocly/cli": "^1.34.3", "@stoplight/spectral-cli": "^6.14.2", - "yaml": "^2.8.0" + "yaml": "^2.8.0", + "java-caller": "^4.1.1" } } diff --git a/specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml b/specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml index 3a0185aaab..eb61339204 100644 --- a/specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml +++ b/specification/_global/clear_scroll/examples/request/ClearScrollRequestExample1.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"scroll_id":"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="}'' "$ELASTICSEARCH_URL/_search/scroll"' + - language: Java + code: | + client.clearScroll(c -> c + .scrollId("DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==") + ); diff --git a/specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml b/specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml index 069fb85b2d..cc0a4eb39c 100644 --- a/specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml +++ b/specification/_global/close_point_in_time/examples/request/ClosePointInTimeRequestExample1.yaml @@ -36,3 +36,8 @@ alternatives: "curl -X DELETE -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAA\ AAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==\"}' \"$ELASTICSEARCH_URL/_pit\"" + - language: Java + code: > + client.closePointInTime(c -> c + .id("46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==") + ); diff --git a/specification/_global/count/examples/request/CountRequestExample1.yaml b/specification/_global/count/examples/request/CountRequestExample1.yaml index c8465931be..857e40f5b4 100644 --- a/specification/_global/count/examples/request/CountRequestExample1.yaml +++ b/specification/_global/count/examples/request/CountRequestExample1.yaml @@ -59,3 +59,14 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"user.id":"kimchy"}}}'' "$ELASTICSEARCH_URL/my-index-000001/_count"' + - language: Java + code: | + client.count(c -> c + .index("my-index-000001") + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + ); diff --git a/specification/_global/create/examples/request/CreateRequestExample1.yaml b/specification/_global/create/examples/request/CreateRequestExample1.yaml index 12df45ce7c..dfde37d20a 100644 --- a/specification/_global/create/examples/request/CreateRequestExample1.yaml +++ b/specification/_global/create/examples/request/CreateRequestExample1.yaml @@ -69,3 +69,10 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"@timestamp":"2099-11-15T13:12:00","message":"GET /search HTTP/1.1 200 1070000","user":{"id":"kimchy"}}'' "$ELASTICSEARCH_URL/my-index-000001/_create/1"' + - language: Java + code: > + client.create(c -> c + .id("1") + .index("my-index-000001") + .document(JsonData.fromJson("{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}")) + ); diff --git a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml index 150a70f8fa..c250ea4e0f 100644 --- a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml +++ b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample1.yaml @@ -49,3 +49,11 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"match_all":{}}}'' "$ELASTICSEARCH_URL/my-index-000001,my-index-000002/_delete_by_query"' + - language: Java + code: | + client.deleteByQuery(d -> d + .index(List.of("my-index-000001","my-index-000002")) + .query(q -> q + .matchAll(m -> m) + ) + ); diff --git a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml index 3b619c8d51..fd9b0117ca 100644 --- a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml +++ b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample2.yaml @@ -64,3 +64,15 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"user.id":"kimchy"}},"max_docs":1}'' "$ELASTICSEARCH_URL/my-index-000001/_delete_by_query"' + - language: Java + code: | + client.deleteByQuery(d -> d + .index("my-index-000001") + .maxDocs(1L) + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + ); diff --git a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml index 462153d038..14d9a2e78c 100644 --- a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml +++ b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample3.yaml @@ -91,3 +91,20 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"slice":{"id":0,"max":2},"query":{"range":{"http.response.bytes":{"lt":2000000}}}}'' "$ELASTICSEARCH_URL/my-index-000001/_delete_by_query"' + - language: Java + code: | + client.deleteByQuery(d -> d + .index("my-index-000001") + .query(q -> q + .range(r -> r + .untyped(u -> u + .field("http.response.bytes") + .lt(JsonData.fromJson("2000000")) + ) + ) + ) + .slice(s -> s + .id("0") + .max(2) + ) + ); diff --git a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml index 81d72cad60..3515eee83d 100644 --- a/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml +++ b/specification/_global/delete_by_query/examples/request/DeleteByQueryRequestExample4.yaml @@ -80,3 +80,20 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"range":{"http.response.bytes":{"lt":2000000}}}}'' "$ELASTICSEARCH_URL/my-index-000001/_delete_by_query?refresh&slices=5"' + - language: Java + code: | + client.deleteByQuery(d -> d + .index("my-index-000001") + .query(q -> q + .range(r -> r + .untyped(u -> u + .field("http.response.bytes") + .lt(JsonData.fromJson("2000000")) + ) + ) + ) + .refresh(true) + .slices(s -> s + .value(5) + ) + ); diff --git a/specification/_global/explain/examples/request/ExplainRequestExample1.yaml b/specification/_global/explain/examples/request/ExplainRequestExample1.yaml index f96f1ff26b..5ffef69b50 100644 --- a/specification/_global/explain/examples/request/ExplainRequestExample1.yaml +++ b/specification/_global/explain/examples/request/ExplainRequestExample1.yaml @@ -63,3 +63,15 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"match":{"message":"elasticsearch"}}}'' "$ELASTICSEARCH_URL/my-index-000001/_explain/0"' + - language: Java + code: | + client.explain(e -> e + .id("0") + .index("my-index-000001") + .query(q -> q + .match(m -> m + .field("message") + .query(FieldValue.of("elasticsearch")) + ) + ) + ); diff --git a/specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml b/specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml index 0fd94dcf49..e141bee6a7 100644 --- a/specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml +++ b/specification/_global/get_script_context/examples/request/GetScriptContextRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->getScriptContext(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_script_context"' + - language: Java + code: | + client.getScriptContext(); diff --git a/specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml b/specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml index 11d9f091e1..a8193bbfb3 100644 --- a/specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml +++ b/specification/_global/get_script_languages/examples/request/GetScriptLanguagesRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->getScriptLanguages(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_script_language"' + - language: Java + code: | + client.getScriptLanguages(); diff --git a/specification/_global/index/examples/request/IndexRequestExample1.yaml b/specification/_global/index/examples/request/IndexRequestExample1.yaml index 2ccf8a72aa..75c40c0d48 100644 --- a/specification/_global/index/examples/request/IndexRequestExample1.yaml +++ b/specification/_global/index/examples/request/IndexRequestExample1.yaml @@ -66,3 +66,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"@timestamp":"2099-11-15T13:12:00","message":"GET /search HTTP/1.1 200 1070000","user":{"id":"kimchy"}}'' "$ELASTICSEARCH_URL/my-index-000001/_doc/"' + - language: Java + code: > + client.index(i -> i + .index("my-index-000001") + .document(JsonData.fromJson("{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}")) + ); diff --git a/specification/_global/index/examples/request/IndexRequestExample2.yaml b/specification/_global/index/examples/request/IndexRequestExample2.yaml index 9a3635e0fe..dacad5caad 100644 --- a/specification/_global/index/examples/request/IndexRequestExample2.yaml +++ b/specification/_global/index/examples/request/IndexRequestExample2.yaml @@ -69,3 +69,10 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"@timestamp":"2099-11-15T13:12:00","message":"GET /search HTTP/1.1 200 1070000","user":{"id":"kimchy"}}'' "$ELASTICSEARCH_URL/my-index-000001/_doc/1"' + - language: Java + code: > + client.index(i -> i + .id("1") + .index("my-index-000001") + .document(JsonData.fromJson("{\"@timestamp\":\"2099-11-15T13:12:00\",\"message\":\"GET /search HTTP/1.1 200 1070000\",\"user\":{\"id\":\"kimchy\"}}")) + ); diff --git a/specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml b/specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml index 6082d4d7cc..daeaea8b37 100644 --- a/specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml +++ b/specification/_global/info/examples/request/RootNodeInfoRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->info(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/"' + - language: Java + code: | + client.info(); diff --git a/specification/_global/mget/examples/request/MultiGetRequestExample1.yaml b/specification/_global/mget/examples/request/MultiGetRequestExample1.yaml index 4c607cc96f..d69aebb34f 100644 --- a/specification/_global/mget/examples/request/MultiGetRequestExample1.yaml +++ b/specification/_global/mget/examples/request/MultiGetRequestExample1.yaml @@ -76,3 +76,11 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"docs":[{"_id":"1"},{"_id":"2"}]}'' "$ELASTICSEARCH_URL/my-index-000001/_mget"' + - language: Java + code: | + client.mget(m -> m + .docs(List.of(MultiGetOperation.of(mu -> mu + .id("1")),MultiGetOperation.of(mu -> mu + .id("2")))) + .index("my-index-000001") + ); diff --git a/specification/_global/mget/examples/request/MultiGetRequestExample3.yaml b/specification/_global/mget/examples/request/MultiGetRequestExample3.yaml index 9a9a7535ec..142f19c386 100644 --- a/specification/_global/mget/examples/request/MultiGetRequestExample3.yaml +++ b/specification/_global/mget/examples/request/MultiGetRequestExample3.yaml @@ -110,3 +110,14 @@ alternatives: "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_index\":\"test\",\"_id\":\"1\",\"stored_fields\":[\"field1\",\"field2\"]},{\"_index\":\"test\",\"_id\":\"2\",\ \"stored_fields\":[\"field3\",\"field4\"]}]}' \"$ELASTICSEARCH_URL/_mget\"" + - language: Java + code: | + client.mget(m -> m + .docs(List.of(MultiGetOperation.of(mu -> mu + .id("1") + .index("test") + .storedFields(List.of("field1","field2"))),MultiGetOperation.of(mu -> mu + .id("2") + .index("test") + .storedFields(List.of("field3","field4"))))) + ); diff --git a/specification/_global/mget/examples/request/MultiGetRequestExample4.yaml b/specification/_global/mget/examples/request/MultiGetRequestExample4.yaml index 291aa37342..44e02b0357 100644 --- a/specification/_global/mget/examples/request/MultiGetRequestExample4.yaml +++ b/specification/_global/mget/examples/request/MultiGetRequestExample4.yaml @@ -93,3 +93,14 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"docs":[{"_index":"test","_id":"1","routing":"key2"},{"_index":"test","_id":"2"}]}'' "$ELASTICSEARCH_URL/_mget?routing=key1"' + - language: Java + code: | + client.mget(m -> m + .docs(List.of(MultiGetOperation.of(mu -> mu + .id("1") + .index("test") + .routing("key2")),MultiGetOperation.of(mu -> mu + .id("2") + .index("test")))) + .routing("key1") + ); diff --git a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml index 2486307f7a..6f4b325a4f 100644 --- a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml +++ b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample1.yaml @@ -95,3 +95,13 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"docs":[{"_id":"2","fields":["message"],"term_statistics":true},{"_id":"1"}]}'' "$ELASTICSEARCH_URL/my-index-000001/_mtermvectors"' + - language: Java + code: | + client.mtermvectors(m -> m + .docs(List.of(MultiTermVectorsOperation.of(mu -> mu + .id("2") + .fields("message") + .termStatistics(true)),MultiTermVectorsOperation.of(mu -> mu + .id("1")))) + .index("my-index-000001") + ); diff --git a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml index 853ed225f4..64eb906f4c 100644 --- a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml +++ b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample2.yaml @@ -69,3 +69,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"ids":["1","2"],"fields":["message"],"term_statistics":true}'' "$ELASTICSEARCH_URL/my-index-000001/_mtermvectors"' + - language: Java + code: | + client.mtermvectors(m -> m + .ids(List.of("1","2")) + .index("my-index-000001") + ); diff --git a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml index 33a46d9ed1..4e3612f7c2 100644 --- a/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml +++ b/specification/_global/mtermvectors/examples/request/MultiTermVectorsRequestExample3.yaml @@ -103,3 +103,12 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"docs":[{"_index":"my-index-000001","doc":{"message":"test test test"}},{"_index":"my-index-000001","doc":{"message":"Another test ..."}}]}'' "$ELASTICSEARCH_URL/_mtermvectors"' + - language: Java + code: | + client.mtermvectors(m -> m + .docs(List.of(MultiTermVectorsOperation.of(mu -> mu + .index("my-index-000001") + .doc(JsonData.fromJson("{\"message\":\"test test test\"}"))),MultiTermVectorsOperation.of(mu -> mu + .index("my-index-000001") + .doc(JsonData.fromJson("{\"message\":\"Another test ...\"}"))))) + ); diff --git a/specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml b/specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml index c3802c1f77..f000fffea0 100644 --- a/specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml +++ b/specification/_global/open_point_in_time/examples/request/OpenPointInTimeRequestExample1.yaml @@ -31,3 +31,12 @@ alternatives: - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/my-index-000001/_pit?keep_alive=1m&allow_partial_search_results=true"' + - language: Java + code: | + client.openPointInTime(o -> o + .allowPartialSearchResults(true) + .index("my-index-000001") + .keepAlive(k -> k + .offset(1) + ) + ); diff --git a/specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml b/specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml index f22efacfc1..88a4c2c690 100644 --- a/specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml +++ b/specification/_global/put_script/examples/request/PutScriptRequestExample2.yaml @@ -56,3 +56,12 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"lang":"painless","source":"Math.log(_score * 2) + params[''"''"''my_modifier''"''"'']"}}'' "$ELASTICSEARCH_URL/_scripts/my-stored-script"' + - language: Java + code: | + client.putScript(p -> p + .id("my-stored-script") + .script(s -> s + .lang("painless") + .source("Math.log(_score * 2) + params['my_modifier']") + ) + ); diff --git a/specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml b/specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml index b369152906..8878cb87dc 100644 --- a/specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml +++ b/specification/_global/rank_eval/examples/request/RankEvalRequestExample1.yaml @@ -120,3 +120,23 @@ alternatives: '{\"requests\":[{\"id\":\"JFK query\",\"request\":{\"query\":{\"match_all\":{}}},\"ratings\":[]}],\"metric\":{\"precision\":{\"k\":20,\"relevant_rating_thr\ eshold\":1,\"ignore_unlabeled\":false}}}' \"$ELASTICSEARCH_URL/my-index-000001/_rank_eval\"" + - language: Java + code: | + client.rankEval(r -> r + .index("my-index-000001") + .metric(m -> m + .precision(p -> p + .ignoreUnlabeled(false) + .relevantRatingThreshold(1) + .k(20) + ) + ) + .requests(re -> re + .id("JFK query") + .request(req -> req + .query(q -> q + .matchAll(m -> m) + ) + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample1.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample1.yaml index 3786fc34d6..b3dd5054fe 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample1.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample1.yaml @@ -72,3 +72,13 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":["my-index-000001","my-index-000002"]},"dest":{"index":"my-new-index-000002"}}'' "$ELASTICSEARCH_URL/_reindex"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000002") + ) + .source(s -> s + .index(List.of("my-index-000001","my-index-000002")) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample10.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample10.yaml index dbeaea2d47..4119857759 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample10.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample10.yaml @@ -96,3 +96,17 @@ alternatives: '{\"source\":{\"index\":\"metricbeat-*\"},\"dest\":{\"index\":\"metricbeat\"},\"script\":{\"lang\":\"painless\",\"source\":\"\ ctx._index = '\"'\"'metricbeat-'\"'\"' + (ctx._index.substring('\"'\"'metricbeat-'\"'\"'.length(), ctx._index.length())) + '\"'\"'-1'\"'\"'\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("metricbeat") + ) + .script(s -> s + .source("ctx._index = 'metricbeat-' + (ctx._index.substring('metricbeat-'.length(), ctx._index.length())) + '-1'") + .lang("painless") + ) + .source(s -> s + .index("metricbeat-*") + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample11.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample11.yaml index d0f57bd8e8..03b9db8117 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample11.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample11.yaml @@ -111,3 +111,19 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"max_docs\":10,\"source\":{\"index\":\"my-index-000001\",\"query\":{\"function_score\":{\"random_score\":{},\"min_score\":\ 0.9}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .maxDocs(10L) + .source(s -> s + .index("my-index-000001") + .query(q -> q + .functionScore(f -> f + .minScore(0.9D) + ) + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample12.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample12.yaml index 66e980472b..e6b6d43ce1 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample12.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample12.yaml @@ -100,3 +100,18 @@ alternatives: '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\",\"version_type\":\"external\"},\"scr\ ipt\":{\"source\":\"if (ctx._source.foo == '\"'\"'bar'\"'\"') {ctx._version++; ctx._source.remove('\"'\"'foo'\"'\"')}\",\"lang\":\"painless\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + .versionType(VersionType.External) + ) + .script(s -> s + .source("if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}") + .lang("painless") + ) + .source(s -> s + .index("my-index-000001") + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample13.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample13.yaml index d0bd227d8d..5c39577405 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample13.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample13.yaml @@ -129,3 +129,24 @@ alternatives: '{\"source\":{\"remote\":{\"host\":\"http://otherhost:9200\",\"username\":\"user\",\"password\":\"pass\"},\"index\":\"my-inde\ x-000001\",\"query\":{\"match\":{\"test\":\"data\"}}},\"dest\":{\"index\":\"my-new-index-000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .source(s -> s + .index("my-index-000001") + .query(q -> q + .match(m -> m + .field("test") + .query(FieldValue.of("data")) + ) + ) + .remote(re -> re + .host("http://otherhost:9200") + .username("user") + .password("pass") + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample2.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample2.yaml index 4287b24477..8150dfe08c 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample2.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample2.yaml @@ -82,3 +82,17 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"my-index-000001","slice":{"id":0,"max":2}},"dest":{"index":"my-new-index-000001"}}'' "$ELASTICSEARCH_URL/_reindex"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .source(s -> s + .index("my-index-000001") + .slice(sl -> sl + .id("0") + .max(2) + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample3.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample3.yaml index 9d7d697f53..1c13564881 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample3.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample3.yaml @@ -77,3 +77,17 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"my-index-000001"},"dest":{"index":"my-new-index-000001"}}'' "$ELASTICSEARCH_URL/_reindex?slices=5&refresh"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .refresh(true) + .slices(s -> s + .value(5) + ) + .source(so -> so + .index("my-index-000001") + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample4.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample4.yaml index cf9ac7468e..ca37b171e0 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample4.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample4.yaml @@ -106,3 +106,20 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"source\",\"query\":{\"match\":{\"company\":\"cat\"}}},\"dest\":{\"index\":\"dest\",\"routing\":\"=c\ at\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("dest") + .routing("=cat") + ) + .source(s -> s + .index("source") + .query(q -> q + .match(m -> m + .field("company") + .query(FieldValue.of("cat")) + ) + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample5.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample5.yaml index 4bf87ee51f..3f161a60b4 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample5.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample5.yaml @@ -73,3 +73,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"source"},"dest":{"index":"dest","pipeline":"some_ingest_pipeline"}}'' "$ELASTICSEARCH_URL/_reindex"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("dest") + .pipeline("some_ingest_pipeline") + ) + .source(s -> s + .index("source") + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample6.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample6.yaml index bffcabbf6b..e4613d858b 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample6.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample6.yaml @@ -99,3 +99,19 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\",\"query\":{\"term\":{\"user.id\":\"kimchy\"}}},\"dest\":{\"index\":\"my-new-index\ -000001\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .source(s -> s + .index("my-index-000001") + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample7.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample7.yaml index bf5afbe09d..716e4b9bce 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample7.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample7.yaml @@ -75,3 +75,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"max_docs":1,"source":{"index":"my-index-000001"},"dest":{"index":"my-new-index-000001"}}'' "$ELASTICSEARCH_URL/_reindex"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .maxDocs(1L) + .source(s -> s + .index("my-index-000001") + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample8.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample8.yaml index 549eb679e0..fc0a3b1586 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample8.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample8.yaml @@ -84,3 +84,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"my-index-000001","_source":["user.id","_doc"]},"dest":{"index":"my-new-index-000001"}}'' "$ELASTICSEARCH_URL/_reindex"' + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .source(s -> s + .index("my-index-000001") + .sourceFields(List.of("user.id","_doc")) + ) + ); diff --git a/specification/_global/reindex/examples/request/ReindexRequestExample9.yaml b/specification/_global/reindex/examples/request/ReindexRequestExample9.yaml index a45b9f8dfc..c9b6b8cf3d 100644 --- a/specification/_global/reindex/examples/request/ReindexRequestExample9.yaml +++ b/specification/_global/reindex/examples/request/ReindexRequestExample9.yaml @@ -87,3 +87,16 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"source\":{\"index\":\"my-index-000001\"},\"dest\":{\"index\":\"my-new-index-000001\"},\"script\":{\"source\":\"ctx._sourc\ e.tag = ctx._source.remove(\\\"flag\\\")\"}}' \"$ELASTICSEARCH_URL/_reindex\"" + - language: Java + code: | + client.reindex(r -> r + .dest(d -> d + .index("my-new-index-000001") + ) + .script(s -> s + .source("ctx._source.tag = ctx._source.remove("flag")") + ) + .source(s -> s + .index("my-index-000001") + ) + ); diff --git a/specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml b/specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml index 523d01b91a..2bc4fc4563 100644 --- a/specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml +++ b/specification/_global/render_search_template/examples/request/RenderSearchTemplateRequestExample1.yaml @@ -61,3 +61,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"id":"my-search-template","params":{"query_string":"hello world","from":20,"size":10}}'' "$ELASTICSEARCH_URL/_render/template"' + - language: Java + code: > + client.renderSearchTemplate(r -> r + .id("my-search-template") + .params(Map.of("size", JsonData.fromJson("10"),"from", JsonData.fromJson("20"),"query_string", JsonData.fromJson("\"hello world\""))) + ); diff --git a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml index 357732595a..591fa5cde7 100644 --- a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml +++ b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample1.yaml @@ -69,3 +69,11 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"params.count / params.total","params":{"count":100,"total":1000}}}'' "$ELASTICSEARCH_URL/_scripts/painless/_execute"' + - language: Java + code: | + client.scriptsPainlessExecute(s -> s + .script(sc -> sc + .source("params.count / params.total") + .params(Map.of("total", JsonData.fromJson("1000"),"count", JsonData.fromJson("100"))) + ) + ); diff --git a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml index 6f273adc63..d0ec2f5a52 100644 --- a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml +++ b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample2.yaml @@ -100,3 +100,16 @@ alternatives: '{\"script\":{\"source\":\"doc['\"'\"'field'\"'\"'].value.length() <= params.max_length\",\"params\":{\"max_length\":4}},\"context\":\"filter\",\"context_setup\":{\"index\":\"my-index-000001\",\"\ document\":{\"field\":\"four\"}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" + - language: Java + code: | + client.scriptsPainlessExecute(s -> s + .context(PainlessContext.Filter) + .contextSetup(c -> c + .document(JsonData.fromJson("{\"field\":\"four\"}")) + .index("my-index-000001") + ) + .script(sc -> sc + .source("doc['field'].value.length() <= params.max_length") + .params("max_length", JsonData.fromJson("4")) + ) + ); diff --git a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml index 3f4f823904..88a06ae007 100644 --- a/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml +++ b/specification/_global/scripts_painless_execute/examples/request/ExecutePainlessScriptRequestExample3.yaml @@ -99,3 +99,16 @@ alternatives: '{\"script\":{\"source\":\"doc['\"'\"'rank'\"'\"'].value / params.max_rank\",\"params\":{\"max_rank\":5}},\"context\":\"score\",\"context_setup\":{\"index\":\"my-index-000001\",\"docum\ ent\":{\"rank\":4}}}' \"$ELASTICSEARCH_URL/_scripts/painless/_execute\"" + - language: Java + code: | + client.scriptsPainlessExecute(s -> s + .context(PainlessContext.Score) + .contextSetup(c -> c + .document(JsonData.fromJson("{\"rank\":4}")) + .index("my-index-000001") + ) + .script(sc -> sc + .source("doc['rank'].value / params.max_rank") + .params("max_rank", JsonData.fromJson("5")) + ) + ); diff --git a/specification/_global/scroll/examples/request/ScrollRequestExample1.yaml b/specification/_global/scroll/examples/request/ScrollRequestExample1.yaml index 4c19167c6b..81f2a228bc 100644 --- a/specification/_global/scroll/examples/request/ScrollRequestExample1.yaml +++ b/specification/_global/scroll/examples/request/ScrollRequestExample1.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"scroll_id":"DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="}'' "$ELASTICSEARCH_URL/_search/scroll"' + - language: Java + code: | + client.scroll(s -> s + .scrollId("DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==") + ); diff --git a/specification/_global/search/examples/request/SearchRequestExample1.yaml b/specification/_global/search/examples/request/SearchRequestExample1.yaml index eb56c23097..5558342c91 100644 --- a/specification/_global/search/examples/request/SearchRequestExample1.yaml +++ b/specification/_global/search/examples/request/SearchRequestExample1.yaml @@ -68,3 +68,16 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"user.id":"kimchy"}}}'' "$ELASTICSEARCH_URL/my-index-000001/_search?from=40&size=20"' + - language: Java + code: | + client.search(s -> s + .from(40) + .index("my-index-000001") + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + .size(20) + ,Void.class); diff --git a/specification/_global/search/examples/request/SearchRequestExample2.yaml b/specification/_global/search/examples/request/SearchRequestExample2.yaml index 9e81e593bc..908f395ec4 100644 --- a/specification/_global/search/examples/request/SearchRequestExample2.yaml +++ b/specification/_global/search/examples/request/SearchRequestExample2.yaml @@ -85,3 +85,20 @@ alternatives: '{\"size\":100,\"query\":{\"match\":{\"title\":\"elasticsearch\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAA\ ACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_g\ AAAAA==\",\"keep_alive\":\"1m\"}}' \"$ELASTICSEARCH_URL/_search\"" + - language: Java + code: > + client.search(s -> s + .pit(p -> p + .id("46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==") + .keepAlive(k -> k + .time("1m") + ) + ) + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("elasticsearch")) + ) + ) + .size(100) + ,Void.class); diff --git a/specification/_global/search/examples/request/SearchRequestExample3.yaml b/specification/_global/search/examples/request/SearchRequestExample3.yaml index 1fda26daa2..ea1ad63dff 100644 --- a/specification/_global/search/examples/request/SearchRequestExample3.yaml +++ b/specification/_global/search/examples/request/SearchRequestExample3.yaml @@ -96,3 +96,20 @@ alternatives: '{\"slice\":{\"id\":0,\"max\":2},\"query\":{\"match\":{\"message\":\"foo\"}},\"pit\":{\"id\":\"46ToAwMDaWR5BXV1aWQyKwZub2RlXz\ MAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXR\ jaF9hbGw_gAAAAA==\"}}' \"$ELASTICSEARCH_URL/_search\"" + - language: Java + code: > + client.search(s -> s + .pit(p -> p + .id("46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADaWR5BXV1aWQyKgZub2RlXzIAAAAAAAAAAAwBYgACBXV1aWQyAAAFdXVpZDEAAQltYXRjaF9hbGw_gAAAAA==") + ) + .query(q -> q + .match(m -> m + .field("message") + .query(FieldValue.of("foo")) + ) + ) + .slice(sl -> sl + .id("0") + .max(2) + ) + ,Void.class); diff --git a/specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml b/specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml index a1b4cf18b9..74894235f6 100644 --- a/specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml +++ b/specification/_global/search_template/examples/request/SearchTemplateRequestExample1.yaml @@ -66,3 +66,10 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"id":"my-search-template","params":{"query_string":"hello world","from":0,"size":10}}'' "$ELASTICSEARCH_URL/my-index/_search/template"' + - language: Java + code: > + client.searchTemplate(s -> s + .id("my-search-template") + .index("my-index") + .params(Map.of("size", JsonData.fromJson("10"),"from", JsonData.fromJson("0"),"query_string", JsonData.fromJson("\"hello world\""))) + ); diff --git a/specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml b/specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml index 73ec007784..8172e843c4 100644 --- a/specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml +++ b/specification/_global/terms_enum/examples/request/TermsEnumRequestExample1.yaml @@ -44,3 +44,10 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"field":"tags","string":"kiba"}'' "$ELASTICSEARCH_URL/stackoverflow/_terms_enum"' + - language: Java + code: | + client.termsEnum(t -> t + .field("tags") + .index("stackoverflow") + .string("kiba") + ); diff --git a/specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml b/specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml index 84c0660195..c785494fd4 100644 --- a/specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml +++ b/specification/_global/termvectors/examples/request/TermVectorsRequestExample1.yaml @@ -76,3 +76,15 @@ alternatives: "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\"],\"offsets\":true,\"payloads\":true,\"positions\":true,\"term_statistics\":true,\"field_statistics\":t\ rue}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" + - language: Java + code: | + client.termvectors(t -> t + .fieldStatistics(true) + .fields("text") + .id("1") + .index("my-index-000001") + .offsets(true) + .payloads(true) + .positions(true) + .termStatistics(true) + ); diff --git a/specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml b/specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml index 460f8f9c29..8476a9163e 100644 --- a/specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml +++ b/specification/_global/termvectors/examples/request/TermVectorsRequestExample2.yaml @@ -84,3 +84,11 @@ alternatives: ''{"doc":{"fullname":"John Doe","text":"test test test"},"fields":["fullname"],"per_field_analyzer":{"fullname":"keyword"}}'' "$ELASTICSEARCH_URL/my-index-000001/_termvectors"' + - language: Java + code: | + client.termvectors(t -> t + .doc(JsonData.fromJson("{\"fullname\":\"John Doe\",\"text\":\"test test test\"}")) + .fields("fullname") + .index("my-index-000001") + .perFieldAnalyzer("fullname", "keyword") + ); diff --git a/specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml b/specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml index cb1a96d3e3..8361494d4c 100644 --- a/specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml +++ b/specification/_global/termvectors/examples/request/TermVectorsRequestExample3.yaml @@ -100,3 +100,18 @@ alternatives: to use its technology to fight against evil.\"},\"term_statistics\":true,\"field_statistics\":true,\"positions\":false,\"offsets\":false,\"filter\":{\"max_num_terms\ \":3,\"min_term_freq\":1,\"min_doc_freq\":1}}' \"$ELASTICSEARCH_URL/imdb/_termvectors\"" + - language: Java + code: > + client.termvectors(t -> t + .doc(JsonData.fromJson("{\"plot\":\"When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil.\"}")) + .fieldStatistics(true) + .filter(f -> f + .maxNumTerms(3) + .minDocFreq(1) + .minTermFreq(1) + ) + .index("imdb") + .offsets(false) + .positions(false) + .termStatistics(true) + ); diff --git a/specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml b/specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml index c0a46533e2..dfb1044ffd 100644 --- a/specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml +++ b/specification/_global/termvectors/examples/request/TermVectorsRequestExample4.yaml @@ -76,3 +76,14 @@ alternatives: "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"fields\":[\"text\",\"some_field_without_term_vectors\"],\"offsets\":true,\"positions\":true,\"term_statistics\":true,\"fi\ eld_statistics\":true}' \"$ELASTICSEARCH_URL/my-index-000001/_termvectors/1\"" + - language: Java + code: | + client.termvectors(t -> t + .fieldStatistics(true) + .fields(List.of("text","some_field_without_term_vectors")) + .id("1") + .index("my-index-000001") + .offsets(true) + .positions(true) + .termStatistics(true) + ); diff --git a/specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml b/specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml index 4af72f71ae..6d23fc8c0e 100644 --- a/specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml +++ b/specification/_global/termvectors/examples/request/TermVectorsRequestExample5.yaml @@ -57,3 +57,9 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"doc":{"fullname":"John Doe","text":"test test test"}}'' "$ELASTICSEARCH_URL/my-index-000001/_termvectors"' + - language: Java + code: | + client.termvectors(t -> t + .doc(JsonData.fromJson("{\"fullname\":\"John Doe\",\"text\":\"test test test\"}")) + .index("my-index-000001") + ); diff --git a/specification/_global/update/examples/request/UpdateRequestExample1.yaml b/specification/_global/update/examples/request/UpdateRequestExample1.yaml index 1064fea9e4..ba61a23a92 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample1.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample1.yaml @@ -81,3 +81,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"ctx._source.counter += params.count","lang":"painless","params":{"count":4}}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source.counter += params.count") + .params("count", JsonData.fromJson("4")) + .lang("painless") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample10.yaml b/specification/_global/update/examples/request/UpdateRequestExample10.yaml index baedb16d8f..1fae642648 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample10.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample10.yaml @@ -103,3 +103,21 @@ alternatives: '{\"scripted_upsert\":true,\"script\":{\"source\":\"\\n if ( ctx.op == '\"'\"'create'\"'\"' ) {\\n ctx._source.counter = params.count\\n } else {\\n ctx._source.counter += params.count\\n }\\n \",\"params\":{\"count\":4}},\"upsert\":{}}' \"$ELASTICSEARCH_URL/test/_update/1\"" + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source(" + if ( ctx.op == 'create' ) { + ctx._source.counter = params.count + } else { + ctx._source.counter += params.count + } + ") + .params("count", JsonData.fromJson("4")) + ) + .scriptedUpsert(true) + .upsert(JsonData.fromJson("{}")) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample11.yaml b/specification/_global/update/examples/request/UpdateRequestExample11.yaml index 8610e081d8..d901d30edb 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample11.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample11.yaml @@ -64,3 +64,11 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"doc":{"name":"new_name"},"doc_as_upsert":true}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .doc(JsonData.fromJson("{\"name\":\"new_name\"}")) + .docAsUpsert(true) + .id("1") + .index("test") + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample2.yaml b/specification/_global/update/examples/request/UpdateRequestExample2.yaml index 3b7019a878..f42aef742e 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample2.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample2.yaml @@ -83,3 +83,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"ctx._source.tags.add(params.tag)","lang":"painless","params":{"tag":"blue"}}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source.tags.add(params.tag)") + .params("tag", JsonData.fromJson("\"blue\"")) + .lang("painless") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample3.yaml b/specification/_global/update/examples/request/UpdateRequestExample3.yaml index 4eea8078f0..edec40011a 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample3.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample3.yaml @@ -86,3 +86,14 @@ alternatives: ''{"script":{"source":"if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }","lang":"painless","params":{"tag":"blue"}}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: > + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }") + .params("tag", JsonData.fromJson("\"blue\"")) + .lang("painless") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample4.yaml b/specification/_global/update/examples/request/UpdateRequestExample4.yaml index 8d59cf69ac..a210f7d7cb 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample4.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample4.yaml @@ -45,3 +45,12 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":"ctx._source.new_field = ''"''"''value_of_new_field''"''"''"}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source.new_field = 'value_of_new_field'") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample5.yaml b/specification/_global/update/examples/request/UpdateRequestExample5.yaml index 5bec9b1c66..43e74f0f1f 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample5.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample5.yaml @@ -45,3 +45,12 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":"ctx._source.remove(''"''"''new_field''"''"'')"}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source.remove('new_field')") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample6.yaml b/specification/_global/update/examples/request/UpdateRequestExample6.yaml index ac90332e44..4d9472d504 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample6.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample6.yaml @@ -46,3 +46,12 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":"ctx._source[''"''"''my-object''"''"''].remove(''"''"''my-subfield''"''"'')"}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source['my-object'].remove('my-subfield')") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample7.yaml b/specification/_global/update/examples/request/UpdateRequestExample7.yaml index 4d66ae5ff8..160264eb5f 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample7.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample7.yaml @@ -84,3 +84,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"if (ctx._source.tags.contains(params.tag)) { ctx.op = ''"''"''delete''"''"'' } else { ctx.op = ''"''"''noop''"''"'' }","lang":"painless","params":{"tag":"green"}}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("if (ctx._source.tags.contains(params.tag)) { ctx.op = 'delete' } else { ctx.op = 'noop' }") + .params("tag", JsonData.fromJson("\"green\"")) + .lang("painless") + ) + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample8.yaml b/specification/_global/update/examples/request/UpdateRequestExample8.yaml index 7258b8c23d..f73a3b61d5 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample8.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample8.yaml @@ -57,3 +57,10 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"doc":{"name":"new_name"}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .doc(JsonData.fromJson("{\"name\":\"new_name\"}")) + .id("1") + .index("test") + ,Void.class); diff --git a/specification/_global/update/examples/request/UpdateRequestExample9.yaml b/specification/_global/update/examples/request/UpdateRequestExample9.yaml index 872171dbed..55362d0209 100644 --- a/specification/_global/update/examples/request/UpdateRequestExample9.yaml +++ b/specification/_global/update/examples/request/UpdateRequestExample9.yaml @@ -102,3 +102,15 @@ alternatives: ''{"script":{"source":"ctx._source.counter += params.count","lang":"painless","params":{"count":4}},"upsert":{"counter":1}}'' "$ELASTICSEARCH_URL/test/_update/1"' + - language: Java + code: | + client.update(u -> u + .id("1") + .index("test") + .script(s -> s + .source("ctx._source.counter += params.count") + .params("count", JsonData.fromJson("4")) + .lang("painless") + ) + .upsert(JsonData.fromJson("{\"counter\":1}")) + ,Void.class); diff --git a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml index 8095e6f18b..1bf4b580a8 100644 --- a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml +++ b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample1.yaml @@ -64,3 +64,15 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"user.id":"kimchy"}}}'' "$ELASTICSEARCH_URL/my-index-000001/_update_by_query?conflicts=proceed"' + - language: Java + code: | + client.updateByQuery(u -> u + .conflicts(Conflicts.Proceed) + .index("my-index-000001") + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + ); diff --git a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml index 005409f1f6..1975986c26 100644 --- a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml +++ b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample2.yaml @@ -82,3 +82,18 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"ctx._source.count++","lang":"painless"},"query":{"term":{"user.id":"kimchy"}}}'' "$ELASTICSEARCH_URL/my-index-000001/_update_by_query"' + - language: Java + code: | + client.updateByQuery(u -> u + .index("my-index-000001") + .query(q -> q + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + .script(s -> s + .source("ctx._source.count++") + .lang("painless") + ) + ); diff --git a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml index 976e4af383..4f7086fbc5 100644 --- a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml +++ b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample3.yaml @@ -72,3 +72,15 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"slice":{"id":0,"max":2},"script":{"source":"ctx._source[''"''"''extra''"''"''] = ''"''"''test''"''"''"}}'' "$ELASTICSEARCH_URL/my-index-000001/_update_by_query"' + - language: Java + code: | + client.updateByQuery(u -> u + .index("my-index-000001") + .script(s -> s + .source("ctx._source['extra'] = 'test'") + ) + .slice(s -> s + .id("0") + .max(2) + ) + ); diff --git a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml index f34b5a4b8e..dc310219e5 100644 --- a/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml +++ b/specification/_global/update_by_query/examples/request/UpdateByQueryRequestExample4.yaml @@ -60,3 +60,15 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"script":{"source":"ctx._source[''"''"''extra''"''"''] = ''"''"''test''"''"''"}}'' "$ELASTICSEARCH_URL/my-index-000001/_update_by_query?refresh&slices=5"' + - language: Java + code: | + client.updateByQuery(u -> u + .index("my-index-000001") + .refresh(true) + .script(s -> s + .source("ctx._source['extra'] = 'test'") + ) + .slices(s -> s + .value(5) + ) + ); diff --git a/specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml b/specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml index c4b9c643d3..1555e90d1c 100644 --- a/specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml +++ b/specification/async_search/submit/examples/request/AsyncSearchSubmitRequestExample1.yaml @@ -123,3 +123,21 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"sort\":[{\"date\":{\"order\":\"asc\"}}],\"aggs\":{\"sale_date\":{\"date_histogram\":{\"field\":\"date\",\"calendar_interv\ al\":\"1d\"}}}}' \"$ELASTICSEARCH_URL/sales*/_async_search?size=0\"" + - language: Java + code: | + client.asyncSearch().submit(s -> s + .aggregations("sale_date", a -> a + .dateHistogram(d -> d + .calendarInterval(CalendarInterval.Day) + .field("date") + ) + ) + .index("sales*") + .size(0) + .sort(so -> so + .field(f -> f + .field("date") + .order(SortOrder.Asc) + ) + ) + ,Void.class); diff --git a/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml b/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml index fab9cefae2..cdf73773cf 100644 --- a/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml +++ b/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample1.yaml @@ -65,3 +65,11 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"roles":[],"deciders":{"fixed":{}}}'' "$ELASTICSEARCH_URL/_autoscaling/policy/"' + - language: Java + code: | + client.autoscaling().putAutoscalingPolicy(p -> p + .name("") + .policy(po -> po + .deciders("fixed", JsonData.fromJson("{}")) + ) + ); diff --git a/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml b/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml index 56aff02cde..307246008a 100644 --- a/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml +++ b/specification/autoscaling/put_autoscaling_policy/examples/request/PutAutoscalingPolicyRequestExample2.yaml @@ -72,3 +72,12 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"roles":["data_hot"],"deciders":{"fixed":{}}}'' "$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy"' + - language: Java + code: | + client.autoscaling().putAutoscalingPolicy(p -> p + .name("my_autoscaling_policy") + .policy(po -> po + .roles("data_hot") + .deciders("fixed", JsonData.fromJson("{}")) + ) + ); diff --git a/specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml b/specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml index 04b09291c5..c2644b3287 100644 --- a/specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml +++ b/specification/cat/aliases/examples/request/CatAliasesRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/aliases?format=json&v=true"' + - language: Java + code: | + client.cat().aliases(); diff --git a/specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml b/specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml index cd2d8c8dfb..efa0210977 100644 --- a/specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml +++ b/specification/cat/allocation/examples/request/CatAllocationRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/allocation?v=true&format=json"' + - language: Java + code: | + client.cat().allocation(); diff --git a/specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml b/specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml index ea2a1441fe..5c915001b0 100644 --- a/specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml +++ b/specification/cat/component_templates/examples/request/CatComponentTemplatesRequestExample1.yaml @@ -35,3 +35,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/component_templates/my-template-*?v=true&s=name&format=json"' + - language: Java + code: | + client.cat().componentTemplates(); diff --git a/specification/cat/count/examples/request/CatCountRequestExample1.yaml b/specification/cat/count/examples/request/CatCountRequestExample1.yaml index 4954463002..4b9417aefd 100644 --- a/specification/cat/count/examples/request/CatCountRequestExample1.yaml +++ b/specification/cat/count/examples/request/CatCountRequestExample1.yaml @@ -30,3 +30,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/count/my-index-000001?v=true&format=json"' + - language: Java + code: | + client.cat().count(); diff --git a/specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml b/specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml index 03358be484..81ae892ce5 100644 --- a/specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml +++ b/specification/cat/fielddata/examples/request/CatFielddataRequestExample1.yaml @@ -30,3 +30,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/fielddata?v=true&fields=body&format=json"' + - language: Java + code: | + client.cat().fielddata(); diff --git a/specification/cat/health/examples/request/CatHealthRequestExample1.yaml b/specification/cat/health/examples/request/CatHealthRequestExample1.yaml index 8609d149fc..3f54cd484f 100644 --- a/specification/cat/health/examples/request/CatHealthRequestExample1.yaml +++ b/specification/cat/health/examples/request/CatHealthRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/health?v=true&format=json"' + - language: Java + code: | + client.cat().health(); diff --git a/specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml b/specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml index 2d6cc4456a..5934f98f58 100644 --- a/specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml +++ b/specification/cat/indices/examples/request/CatIndicesRequestExample1.yaml @@ -35,3 +35,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/indices/my-index-*?v=true&s=index&format=json"' + - language: Java + code: | + client.cat().indices(); diff --git a/specification/cat/master/examples/request/CatMasterRequestExample1.yaml b/specification/cat/master/examples/request/CatMasterRequestExample1.yaml index 612fb342a3..8b2bba5afe 100644 --- a/specification/cat/master/examples/request/CatMasterRequestExample1.yaml +++ b/specification/cat/master/examples/request/CatMasterRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/master?v=true&format=json"' + - language: Java + code: | + client.cat().master(); diff --git a/specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml b/specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml index 459d616794..b1a41228f4 100644 --- a/specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml +++ b/specification/cat/ml_data_frame_analytics/examples/request/CatDataframeanalyticsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/ml/data_frame/analytics?v=true&format=json"' + - language: Java + code: | + client.cat().mlDataFrameAnalytics(); diff --git a/specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml b/specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml index 8697017409..3196d11788 100644 --- a/specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml +++ b/specification/cat/ml_datafeeds/examples/request/CatDatafeedsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/ml/datafeeds?v=true&format=json"' + - language: Java + code: | + client.cat().mlDatafeeds(); diff --git a/specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml b/specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml index 9e1b5d63e8..2ccf72d1c5 100644 --- a/specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml +++ b/specification/cat/ml_jobs/examples/request/CatJobsRequestExample1.yaml @@ -31,3 +31,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/ml/anomaly_detectors?h=id,s,dpr,mb&v=true&format=json"' + - language: Java + code: | + client.cat().mlJobs(); diff --git a/specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml b/specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml index f0089c9498..092023b08e 100644 --- a/specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml +++ b/specification/cat/ml_trained_models/examples/request/CatTrainedModelsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/ml/trained_models?v=true&format=json"' + - language: Java + code: | + client.cat().mlTrainedModels(); diff --git a/specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml b/specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml index 00e1df538a..2ce5d90458 100644 --- a/specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml +++ b/specification/cat/nodeattrs/examples/request/CatNodeAttributesRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/nodeattrs?v=true&format=json"' + - language: Java + code: | + client.cat().nodeattrs(); diff --git a/specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml b/specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml index d77df0042d..5c436967da 100644 --- a/specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml +++ b/specification/cat/nodes/examples/request/CatNodesRequestExample2.yaml @@ -30,3 +30,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/nodes?v=true&h=id,ip,port,v,m&format=json"' + - language: Java + code: | + client.cat().nodes(); diff --git a/specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml b/specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml index 6bfbf53644..609fc1fd30 100644 --- a/specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml +++ b/specification/cat/pending_tasks/examples/request/CatPendingTasksRequestExample1.yaml @@ -27,3 +27,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/pending_tasks?v=trueh=insertOrder,timeInQueue,priority,source&format=json"' + - language: Java + code: | + client.cat().pendingTasks(); diff --git a/specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml b/specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml index 58b74c25e2..d9ea551db5 100644 --- a/specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml +++ b/specification/cat/plugins/examples/request/CatPluginsRequestExample1.yaml @@ -35,3 +35,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/plugins?v=true&s=component&h=name,component,version,description&format=json"' + - language: Java + code: | + client.cat().plugins(); diff --git a/specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml b/specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml index dfd76ae6cd..5e0826bffb 100644 --- a/specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml +++ b/specification/cat/recovery/examples/request/CatRecoveryRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/recovery?v=true&format=json"' + - language: Java + code: | + client.cat().recovery(); diff --git a/specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml b/specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml index babf73dff8..72ea6d7560 100644 --- a/specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml +++ b/specification/cat/repositories/examples/request/CatRepositoriesRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/repositories?v=true&format=json"' + - language: Java + code: | + client.cat().repositories(); diff --git a/specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml b/specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml index e1fdd8817f..ad082cb170 100644 --- a/specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml +++ b/specification/cat/segments/examples/request/CatSegmentsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/segments?v=true&format=json"' + - language: Java + code: | + client.cat().segments(); diff --git a/specification/cat/shards/examples/request/CatShardsRequestExample1.yaml b/specification/cat/shards/examples/request/CatShardsRequestExample1.yaml index c33a466695..8f2e6d0b31 100644 --- a/specification/cat/shards/examples/request/CatShardsRequestExample1.yaml +++ b/specification/cat/shards/examples/request/CatShardsRequestExample1.yaml @@ -22,3 +22,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/shards?format=json"' + - language: Java + code: | + client.cat().shards(); diff --git a/specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml b/specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml index d6c034d480..dae40f5b60 100644 --- a/specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml +++ b/specification/cat/snapshots/examples/request/CatSnapshotsRequestExample1.yaml @@ -34,3 +34,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/snapshots/repo1?v=true&s=id&format=json"' + - language: Java + code: | + client.cat().snapshots(); diff --git a/specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml b/specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml index 2325878f10..793bc61b23 100644 --- a/specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml +++ b/specification/cat/tasks/examples/request/CatTasksRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/tasks?v=true&format=json"' + - language: Java + code: | + client.cat().tasks(); diff --git a/specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml b/specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml index 868bd34967..98986a03be 100644 --- a/specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml +++ b/specification/cat/templates/examples/request/CatTemplatesRequestExample1.yaml @@ -35,3 +35,6 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/templates/my-template-*?v=true&s=name&format=json"' + - language: Java + code: | + client.cat().templates(); diff --git a/specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml b/specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml index 6332cc079f..6dd9fb57cd 100644 --- a/specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml +++ b/specification/cat/thread_pool/examples/request/CatThreadPoolRequestExample1.yaml @@ -22,3 +22,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/thread_pool?format=json"' + - language: Java + code: | + client.cat().threadPool(); diff --git a/specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml b/specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml index bc408d2c37..c5cb85163d 100644 --- a/specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml +++ b/specification/cat/transforms/examples/request/CatTransformsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cat/transforms?v=true&format=json"' + - language: Java + code: | + client.cat().transforms(); diff --git a/specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml b/specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml index 9e4401db29..3b29670ab6 100644 --- a/specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml +++ b/specification/ccr/follow/examples/request/CreateFollowIndexRequestExample1.yaml @@ -117,3 +117,30 @@ alternatives: uest_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\ \":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/follow?wait_for_active_shards=1\"" + - language: Java + code: | + client.ccr().follow(f -> f + .index("follower_index") + .leaderIndex("leader_index") + .maxOutstandingReadRequests(16L) + .maxOutstandingWriteRequests(8) + .maxReadRequestOperationCount(1024) + .maxReadRequestSize("1024k") + .maxRetryDelay(m -> m + .time("10s") + ) + .maxWriteBufferCount(512) + .maxWriteBufferSize("512k") + .maxWriteRequestOperationCount(32768) + .maxWriteRequestSize("16k") + .readPollTimeout(r -> r + .time("30s") + ) + .remoteCluster("remote_cluster") + .settings(s -> s + .otherSettings("index.number_of_replicas", JsonData.fromJson("0")) + ) + .waitForActiveShards(w -> w + .count(1) + ) + ); diff --git a/specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml b/specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml index dc5558b8d0..7d61cd79e5 100644 --- a/specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml +++ b/specification/ccr/forget_follower/examples/request/ForgetFollowerIndexRequestExample1.yaml @@ -59,3 +59,12 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"follower_cluster\":\"\",\"follower_index\":\"\",\"follower_index_uuid\":\"\",\"leader_remote_cluster\":\"\"}' \"$ELASTICSEARCH_URL//_ccr/forget_follower\"" + - language: Java + code: | + client.ccr().forgetFollower(f -> f + .followerCluster("") + .followerIndex("") + .followerIndexUuid("") + .index("") + .leaderRemoteCluster("") + ); diff --git a/specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml b/specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml index 168203ff2d..f36dc32b60 100644 --- a/specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml +++ b/specification/ccr/put_auto_follow_pattern/examples/request/PutAutoFollowPatternRequestExample1.yaml @@ -147,3 +147,26 @@ alternatives: d_requests\":16,\"max_read_request_size\":\"1024k\",\"max_write_request_operation_count\":32768,\"max_write_request_size\":\"\ 16k\",\"max_outstanding_write_requests\":8,\"max_write_buffer_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\ \":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/_ccr/auto_follow/my_auto_follow_pattern\"" + - language: Java + code: | + client.ccr().putAutoFollowPattern(p -> p + .followIndexPattern("{{leader_index}}-follower") + .leaderIndexPatterns("leader_index*") + .maxOutstandingReadRequests(16) + .maxOutstandingWriteRequests(8) + .maxReadRequestOperationCount(1024) + .maxReadRequestSize("1024k") + .maxRetryDelay(m -> m + .time("10s") + ) + .maxWriteBufferCount(512) + .maxWriteBufferSize("512k") + .maxWriteRequestOperationCount(32768) + .maxWriteRequestSize("16k") + .name("my_auto_follow_pattern") + .readPollTimeout(r -> r + .time("30s") + ) + .remoteCluster("remote_cluster") + .settings("index.number_of_replicas", JsonData.fromJson("0")) + ); diff --git a/specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml b/specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml index 820f6d0543..e936715283 100644 --- a/specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml +++ b/specification/ccr/resume_follow/examples/request/ResumeFollowIndexRequestExample1.yaml @@ -87,3 +87,22 @@ alternatives: ite_request_operation_count\":32768,\"max_write_request_size\":\"16k\",\"max_outstanding_write_requests\":8,\"max_write_buffe\ r_count\":512,\"max_write_buffer_size\":\"512k\",\"max_retry_delay\":\"10s\",\"read_poll_timeout\":\"30s\"}' \"$ELASTICSEARCH_URL/follower_index/_ccr/resume_follow\"" + - language: Java + code: | + client.ccr().resumeFollow(r -> r + .index("follower_index") + .maxOutstandingReadRequests(16L) + .maxOutstandingWriteRequests(8L) + .maxReadRequestOperationCount(1024L) + .maxReadRequestSize("1024k") + .maxRetryDelay(m -> m + .time("10s") + ) + .maxWriteBufferCount(512L) + .maxWriteBufferSize("512k") + .maxWriteRequestOperationCount(32768L) + .maxWriteRequestSize("16k") + .readPollTimeout(re -> re + .time("30s") + ) + ); diff --git a/specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml b/specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml index 9efb788997..ef53821360 100644 --- a/specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml +++ b/specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml @@ -51,3 +51,11 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index":"my-index-000001","shard":0,"primary":false,"current_node":"my-node"}'' "$ELASTICSEARCH_URL/_cluster/allocation/explain"' + - language: Java + code: | + client.cluster().allocationExplain(a -> a + .currentNode("my-node") + .index("my-index-000001") + .primary(false) + .shard(0) + ); diff --git a/specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml b/specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml index 1ca9210db2..1eb833d002 100644 --- a/specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml +++ b/specification/cluster/get_settings/examples/request/ClusterGetSettingsExample1.yaml @@ -23,3 +23,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cluster/settings?filter_path=persistent.cluster.remote"' + - language: Java + code: "\n" diff --git a/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml b/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml index 146a7ca5ce..f8e67f57e5 100644 --- a/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml +++ b/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample1.yaml @@ -45,3 +45,8 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"persistent":{"indices.recovery.max_bytes_per_sec":"50mb"}}'' "$ELASTICSEARCH_URL/_cluster/settings"' + - language: Java + code: | + client.cluster().putSettings(p -> p + .persistent("indices.recovery.max_bytes_per_sec", JsonData.fromJson("\"50mb\"")) + ); diff --git a/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml b/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml index 9ceaa8c89a..425860b2fb 100644 --- a/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml +++ b/specification/cluster/put_settings/examples/request/ClusterPutSettingsRequestExample2.yaml @@ -51,3 +51,8 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"persistent":{"action.auto_create_index":"my-index-000001,index10,-index1*,+ind*"}}'' "$ELASTICSEARCH_URL/_cluster/settings"' + - language: Java + code: | + client.cluster().putSettings(p -> p + .persistent("action.auto_create_index", JsonData.fromJson("\"my-index-000001,index10,-index1*,+ind*\"")) + ); diff --git a/specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml b/specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml index 905c30e9ef..8512892d65 100644 --- a/specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml +++ b/specification/cluster/remote_info/examples/request/ClusterRemoteInfoExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->cluster()->remoteInfo(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_remote/info"' + - language: Java + code: | + client.cluster().remoteInfo(); diff --git a/specification/cluster/state/examples/request/ClusterStateExample1.yaml b/specification/cluster/state/examples/request/ClusterStateExample1.yaml index 62c322836f..07e1a52727 100644 --- a/specification/cluster/state/examples/request/ClusterStateExample1.yaml +++ b/specification/cluster/state/examples/request/ClusterStateExample1.yaml @@ -23,3 +23,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cluster/state?filter_path=metadata.cluster_coordination.last_committed_config"' + - language: Java + code: "\n" diff --git a/specification/cluster/stats/examples/request/ClusterStatsExample1.yaml b/specification/cluster/stats/examples/request/ClusterStatsExample1.yaml index 67630b86b0..ecac7caa71 100644 --- a/specification/cluster/stats/examples/request/ClusterStatsExample1.yaml +++ b/specification/cluster/stats/examples/request/ClusterStatsExample1.yaml @@ -27,3 +27,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_cluster/stats?human&filter_path=indices.mappings.total_deduplicated_mapping_size*"' + - language: Java + code: "\n" diff --git a/specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml b/specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml index 02f32ca775..79b38e6aee 100644 --- a/specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml +++ b/specification/connector/put/examples/request/ConnectorPutRequestExample1.yaml @@ -53,3 +53,11 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index_name":"search-google-drive","name":"My Connector","service_type":"google_drive"}'' "$ELASTICSEARCH_URL/_connector/my-connector"' + - language: Java + code: | + client.connector().put(p -> p + .connectorId("my-connector") + .indexName("search-google-drive") + .name("My Connector") + .serviceType("google_drive") + ); diff --git a/specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml b/specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml index c6ab53ffa1..fa4d100138 100644 --- a/specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml +++ b/specification/connector/put/examples/request/ConnectorPutRequestExample2.yaml @@ -66,3 +66,13 @@ alternatives: ''{"index_name":"search-google-drive","name":"My Connector","description":"My Connector to sync data to Elastic index from Google Drive","service_type":"google_drive","language":"english"}'' "$ELASTICSEARCH_URL/_connector/my-connector"' + - language: Java + code: | + client.connector().put(p -> p + .connectorId("my-connector") + .description("My Connector to sync data to Elastic index from Google Drive") + .indexName("search-google-drive") + .language("english") + .name("My Connector") + .serviceType("google_drive") + ); diff --git a/specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml b/specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml index 616117ece3..531af2b4c5 100644 --- a/specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml +++ b/specification/connector/sync_job_claim/examples/request/ConnectorSyncJobClaimExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"worker_hostname":"some-machine"}'' "$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job-id/_claim"' + - language: Java + code: | + client.connector().syncJobClaim(s -> s + .connectorSyncJobId("my-connector-sync-job-id") + .workerHostname("some-machine") + ); diff --git a/specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml b/specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml index a379929e32..65530cbcdd 100644 --- a/specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml +++ b/specification/connector/sync_job_error/examples/request/SyncJobErrorRequestExample1.yaml @@ -36,3 +36,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"error":"some-error"}'' "$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_error"' + - language: Java + code: | + client.connector().syncJobError(s -> s + .connectorSyncJobId("my-connector-sync-job") + .error("some-error") + ); diff --git a/specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml b/specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml index f326c44e98..3a0b1e24f2 100644 --- a/specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml +++ b/specification/connector/sync_job_post/examples/request/SyncJobPostRequestExample1.yaml @@ -49,3 +49,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"id":"connector-id","job_type":"full","trigger_method":"on_demand"}'' "$ELASTICSEARCH_URL/_connector/_sync_job"' + - language: Java + code: | + client.connector().syncJobPost(s -> s + .id("connector-id") + .jobType(SyncJobType.Full) + .triggerMethod(SyncJobTriggerMethod.OnDemand) + ); diff --git a/specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml b/specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml index 1efd4b5bba..1aeb2cc7cf 100644 --- a/specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml +++ b/specification/connector/sync_job_update_stats/examples/request/ConnectorSyncJobUpdateStatsExample1.yaml @@ -58,3 +58,15 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"deleted_document_count\":10,\"indexed_document_count\":20,\"indexed_document_volume\":1000,\"total_document_count\":2000,\ \"last_seen\":\"2023-01-02T10:00:00Z\"}' \"$ELASTICSEARCH_URL/_connector/_sync_job/my-connector-sync-job/_stats\"" + - language: Java + code: | + client.connector().syncJobUpdateStats(s -> s + .connectorSyncJobId("my-connector-sync-job") + .deletedDocumentCount(10L) + .indexedDocumentCount(20L) + .indexedDocumentVolume(1000L) + .lastSeen(l -> l + .time("2023-01-02T10:00:00Z") + ) + .totalDocumentCount(2000) + ); diff --git a/specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml b/specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml index ab34678fb0..cf7e344ccd 100644 --- a/specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml +++ b/specification/connector/update_api_key_id/examples/request/ConnectorUpdateApiKeyIDRequestExample1.yaml @@ -47,3 +47,10 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"api_key_id":"my-api-key-id","api_key_secret_id":"my-connector-secret-id"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_api_key_id"' + - language: Java + code: | + client.connector().updateApiKeyId(u -> u + .apiKeyId("my-api-key-id") + .apiKeySecretId("my-connector-secret-id") + .connectorId("my-connector") + ); diff --git a/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml b/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml index af5e77a775..e1007a7bc3 100644 --- a/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml +++ b/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample1.yaml @@ -77,3 +77,9 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"values\":{\"tenant_id\":\"my-tenant-id\",\"tenant_name\":\"my-sharepoint-site\",\"client_id\":\"foo\",\"secret_value\":\"\ bar\",\"site_collections\":\"*\"}}' \"$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration\"" + - language: Java + code: > + client.connector().updateConfiguration(u -> u + .connectorId("my-spo-connector") + .values(Map.of("tenant_id", JsonData.fromJson("\"my-tenant-id\""),"tenant_name", JsonData.fromJson("\"my-sharepoint-site\""),"secret_value", JsonData.fromJson("\"bar\""),"client_id", JsonData.fromJson("\"foo\""),"site_collections", JsonData.fromJson("\"*\""))) + ); diff --git a/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml b/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml index 4dcd0fb697..9adf886424 100644 --- a/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml +++ b/specification/connector/update_configuration/examples/request/ConnectorUpdateConfigurationRequestExample2.yaml @@ -52,3 +52,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"values":{"secret_value":"foo-bar"}}'' "$ELASTICSEARCH_URL/_connector/my-spo-connector/_configuration"' + - language: Java + code: | + client.connector().updateConfiguration(u -> u + .connectorId("my-spo-connector") + .values("secret_value", JsonData.fromJson("\"foo-bar\"")) + ); diff --git a/specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml b/specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml index dadee189b6..19e5e83857 100644 --- a/specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml +++ b/specification/connector/update_error/examples/request/ConnectorUpdateErrorRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"error":"Houston, we have a problem!"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_error"' + - language: Java + code: | + client.connector().updateError(u -> u + .connectorId("my-connector") + .error("Houston, we have a problem!") + ); diff --git a/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml b/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml index 481ce69646..fafb30cb3c 100644 --- a/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml +++ b/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample1.yaml @@ -131,3 +131,24 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"features\":{\"document_level_security\":{\"enabled\":true},\"incremental_sync\":{\"enabled\":true},\"sync_rules\":{\"adva\ nced\":{\"enabled\":false},\"basic\":{\"enabled\":true}}}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_features\"" + - language: Java + code: | + client.connector().updateFeatures(u -> u + .connectorId("my-connector") + .features(f -> f + .documentLevelSecurity(d -> d + .enabled(true) + ) + .incrementalSync(i -> i + .enabled(true) + ) + .syncRules(s -> s + .advanced(a -> a + .enabled(false) + ) + .basic(b -> b + .enabled(true) + ) + ) + ) + ); diff --git a/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml b/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml index c9d28d333b..66f2e9c3a7 100644 --- a/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml +++ b/specification/connector/update_features/examples/request/ConnectorUpdateFeaturesRequestExample2.yaml @@ -64,3 +64,13 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"features":{"document_level_security":{"enabled":true}}}'' "$ELASTICSEARCH_URL/_connector/my-connector/_features"' + - language: Java + code: | + client.connector().updateFeatures(u -> u + .connectorId("my-connector") + .features(f -> f + .documentLevelSecurity(d -> d + .enabled(true) + ) + ) + ); diff --git a/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml b/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml index 66bd8e2a29..1bb11f2ef6 100644 --- a/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml +++ b/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample1.yaml @@ -144,3 +144,21 @@ alternatives: '{\"rules\":[{\"field\":\"file_extension\",\"id\":\"exclude-txt-files\",\"order\":0,\"policy\":\"exclude\",\"rule\":\"equals\ \",\"value\":\"txt\"},{\"field\":\"_\",\"id\":\"DEFAULT\",\"order\":1,\"policy\":\"include\",\"rule\":\"regex\",\"value\":\".*\ \"}]}' \"$ELASTICSEARCH_URL/_connector/my-g-drive-connector/_filtering\"" + - language: Java + code: | + client.connector().updateFiltering(u -> u + .connectorId("my-g-drive-connector") + .rules(List.of(FilteringRule.of(f -> f + .field("file_extension") + .id("exclude-txt-files") + .order(0) + .policy(FilteringPolicy.Exclude) + .rule(FilteringRuleRule.Equals) + .value("txt")),FilteringRule.of(f -> f + .field("_") + .id("DEFAULT") + .order(1) + .policy(FilteringPolicy.Include) + .rule(FilteringRuleRule.Regex) + .value(".*")))) + ); diff --git a/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml b/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml index f8ed9d2b2b..b2bd1f3e60 100644 --- a/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml +++ b/specification/connector/update_filtering/examples/request/ConnectorUpdateFilteringRequestExample2.yaml @@ -96,3 +96,11 @@ alternatives: ''{"advanced_snippet":{"value":[{"tables":["users","orders"],"query":"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id"}]}}'' "$ELASTICSEARCH_URL/_connector/my-sql-connector/_filtering"' + - language: Java + code: > + client.connector().updateFiltering(u -> u + .advancedSnippet(a -> a + .value(JsonData.fromJson("[{\"tables\":[\"users\",\"orders\"],\"query\":\"SELECT users.id AS id, orders.order_id AS order_id FROM users JOIN orders ON users.id = orders.user_id\"}]")) + ) + .connectorId("my-sql-connector") + ); diff --git a/specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml b/specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml index 34a289ea08..fc72b4dbc4 100644 --- a/specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml +++ b/specification/connector/update_index_name/examples/request/ConnectorUpdateIndexNameRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index_name":"data-from-my-google-drive"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_index_name"' + - language: Java + code: | + client.connector().updateIndexName(u -> u + .connectorId("my-connector") + .indexName("data-from-my-google-drive") + ); diff --git a/specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml b/specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml index ac95f6896e..eeca2c6fe7 100644 --- a/specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml +++ b/specification/connector/update_name/examples/request/ConnectorUpdateNameRequestExample1.yaml @@ -46,3 +46,10 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"name":"Custom connector","description":"This is my customized connector"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_name"' + - language: Java + code: | + client.connector().updateName(u -> u + .connectorId("my-connector") + .description("This is my customized connector") + .name("Custom connector") + ); diff --git a/specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml b/specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml index d89f52e879..75c4242316 100644 --- a/specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml +++ b/specification/connector/update_pipeline/examples/request/ConnectorUpdatePipelineRequestExample1.yaml @@ -71,3 +71,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"pipeline\":{\"extract_binary_content\":true,\"name\":\"my-connector-pipeline\",\"reduce_whitespace\":true,\"run_ml_infere\ nce\":true}}' \"$ELASTICSEARCH_URL/_connector/my-connector/_pipeline\"" + - language: Java + code: | + client.connector().updatePipeline(u -> u + .connectorId("my-connector") + .pipeline(p -> p + .extractBinaryContent(true) + .name("my-connector-pipeline") + .reduceWhitespace(true) + .runMlInference(true) + ) + ); diff --git a/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml b/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml index 6351c8f321..952fc05f55 100644 --- a/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml +++ b/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample1.yaml @@ -120,3 +120,22 @@ alternatives: ''{"scheduling":{"access_control":{"enabled":true,"interval":"0 10 0 * * ?"},"full":{"enabled":true,"interval":"0 20 0 * * ?"},"incremental":{"enabled":false,"interval":"0 30 0 * * ?"}}}'' "$ELASTICSEARCH_URL/_connector/my-connector/_scheduling"' + - language: Java + code: | + client.connector().updateScheduling(u -> u + .connectorId("my-connector") + .scheduling(s -> s + .accessControl(a -> a + .enabled(true) + .interval("0 10 0 * * ?") + ) + .full(f -> f + .enabled(true) + .interval("0 20 0 * * ?") + ) + .incremental(i -> i + .enabled(false) + .interval("0 30 0 * * ?") + ) + ) + ); diff --git a/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml b/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml index 52860696e6..5a50723d02 100644 --- a/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml +++ b/specification/connector/update_scheduling/examples/request/ConnectorUpdateSchedulingRequestExample2.yaml @@ -71,3 +71,14 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"scheduling":{"full":{"enabled":true,"interval":"0 10 0 * * ?"}}}'' "$ELASTICSEARCH_URL/_connector/my-connector/_scheduling"' + - language: Java + code: | + client.connector().updateScheduling(u -> u + .connectorId("my-connector") + .scheduling(s -> s + .full(f -> f + .enabled(true) + .interval("0 10 0 * * ?") + ) + ) + ); diff --git a/specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml b/specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml index 40978ebf3e..d741fb57a2 100644 --- a/specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml +++ b/specification/connector/update_service_type/examples/request/ConnectorUpdateServiceTypeRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service_type":"sharepoint_online"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_service_type"' + - language: Java + code: | + client.connector().updateServiceType(u -> u + .connectorId("my-connector") + .serviceType("sharepoint_online") + ); diff --git a/specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml b/specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml index b0f9f169fe..cffd08e00e 100644 --- a/specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml +++ b/specification/connector/update_status/examples/request/ConnectorUpdateStatusRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"status":"needs_configuration"}'' "$ELASTICSEARCH_URL/_connector/my-connector/_status"' + - language: Java + code: | + client.connector().updateStatus(u -> u + .connectorId("my-connector") + .status(ConnectorStatus.NeedsConfiguration) + ); diff --git a/specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml b/specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml index 2a6013b642..58e266cc48 100644 --- a/specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml +++ b/specification/dangling_indices/list_dangling_indices/examples/request/DanglingIndicesListDanglingIndicesExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->danglingIndices()->listDanglingIndices(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_dangling"' + - language: Java + code: | + client.danglingIndices().listDanglingIndices(); diff --git a/specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml b/specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml index 2cc6b4c080..ff7e6174e3 100644 --- a/specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml +++ b/specification/enrich/put_policy/examples/request/EnrichPutPolicyExample1.yaml @@ -67,3 +67,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"geo_match":{"indices":"postal_codes","match_field":"location","enrich_fields":["location","postal_code"]}}'' "$ELASTICSEARCH_URL/_enrich/policy/postal_policy"' + - language: Java + code: | + client.enrich().putPolicy(p -> p + .geoMatch(g -> g + .enrichFields(List.of("location","postal_code")) + .indices("postal_codes") + .matchField("location") + ) + .name("postal_policy") + ); diff --git a/specification/eql/search/examples/request/EqlSearchRequestExample1.yaml b/specification/eql/search/examples/request/EqlSearchRequestExample1.yaml index ac94c9ecaa..88b92c515e 100644 --- a/specification/eql/search/examples/request/EqlSearchRequestExample1.yaml +++ b/specification/eql/search/examples/request/EqlSearchRequestExample1.yaml @@ -45,3 +45,9 @@ alternatives: "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n process where (process.name == \\\"cmd.exe\\\" and process.pid != 2013)\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" + - language: Java + code: | + client.eql().search(s -> s + .index("my-data-stream") + .query(" process where (process.name == \"cmd.exe\" and process.pid != 2013) ") + ); diff --git a/specification/eql/search/examples/request/EqlSearchRequestExample2.yaml b/specification/eql/search/examples/request/EqlSearchRequestExample2.yaml index b8c8d9886d..22279323a7 100644 --- a/specification/eql/search/examples/request/EqlSearchRequestExample2.yaml +++ b/specification/eql/search/examples/request/EqlSearchRequestExample2.yaml @@ -50,3 +50,10 @@ alternatives: '{\"query\":\"\\n sequence by process.pid\\n [ file where file.name == \\\"cmd.exe\\\" and process.pid != 2013 ]\\n [ process where stringContains(process.executable, \\\"regsvr32\\\") ]\\n \"}' \"$ELASTICSEARCH_URL/my-data-stream/_eql/search\"" + - language: Java + code: | + client.eql().search(s -> s + .index("my-data-stream") + .query(" sequence by process.pid [ file where file.name == \"cmd.exe\" and process.pid != 2013 ][ process where stringContains(process.executable, \"regsvr32\") ] ") + ") + ); diff --git a/specification/esql/query/examples/request/QueryRequestExample1.yaml b/specification/esql/query/examples/request/QueryRequestExample1.yaml index 9408ea0d50..c7706a3e0d 100644 --- a/specification/esql/query/examples/request/QueryRequestExample1.yaml +++ b/specification/esql/query/examples/request/QueryRequestExample1.yaml @@ -48,3 +48,10 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"query\":\"\\n FROM library,remote-*:library\\n | EVAL year = DATE_TRUNC(1 YEARS, release_date)\\n | STATS MAX(page_count) BY year\\n | SORT year\\n | LIMIT 5\\n \",\"include_ccs_metadata\":true}' \"$ELASTICSEARCH_URL/_query\"" + - language: Java + code: | + client.esql().query(q -> q + .includeCcsMetadata(true) + .query(" FROM library,remote-*:library | EVAL year = DATE_TRUNC(1 YEARS, release_date) | STATS MAX(page_count) BY year | SORT year | LIMIT 5 ") + ") + ); diff --git a/specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml b/specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml index bf754beaed..1ac252a399 100644 --- a/specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml +++ b/specification/ilm/get_status/examples/request/IlmGetStatusExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->ilm()->getStatus(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ilm/status"' + - language: Java + code: | + client.ilm().getStatus(); diff --git a/specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml b/specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml index b57edd30e1..ae0c5ca0af 100644 --- a/specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml +++ b/specification/ilm/migrate_to_data_tiers/examples/request/MigrateToDataTiersRequestExample1.yaml @@ -44,3 +44,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"legacy_template_to_delete":"global-template","node_attribute":"custom_attribute_name"}'' "$ELASTICSEARCH_URL/_ilm/migrate_to_data_tiers"' + - language: Java + code: | + client.ilm().migrateToDataTiers(m -> m + .legacyTemplateToDelete("global-template") + .nodeAttribute("custom_attribute_name") + ); diff --git a/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml b/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml index 9cf7edb98c..c6e2d4a9dc 100644 --- a/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml +++ b/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample1.yaml @@ -86,3 +86,18 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"current_step\":{\"phase\":\"new\",\"action\":\"complete\",\"name\":\"complete\"},\"next_step\":{\"phase\":\"warm\",\"acti\ on\":\"forcemerge\",\"name\":\"forcemerge\"}}' \"$ELASTICSEARCH_URL/_ilm/move/my-index-000001\"" + - language: Java + code: | + client.ilm().moveToStep(m -> m + .currentStep(c -> c + .action("complete") + .name("complete") + .phase("new") + ) + .index("my-index-000001") + .nextStep(n -> n + .action("forcemerge") + .name("forcemerge") + .phase("warm") + ) + ); diff --git a/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml b/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml index 84c3eb1579..faee76fbf0 100644 --- a/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml +++ b/specification/ilm/move_to_step/examples/request/MoveToStepRequestExample2.yaml @@ -76,3 +76,16 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"current_step":{"phase":"hot","action":"complete","name":"complete"},"next_step":{"phase":"warm"}}'' "$ELASTICSEARCH_URL/_ilm/move/my-index-000001"' + - language: Java + code: | + client.ilm().moveToStep(m -> m + .currentStep(c -> c + .action("complete") + .name("complete") + .phase("hot") + ) + .index("my-index-000001") + .nextStep(n -> n + .phase("warm") + ) + ); diff --git a/specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml b/specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml index d8ede106f0..644db6fda3 100644 --- a/specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml +++ b/specification/ilm/put_lifecycle/examples/request/PutLifecycleRequestExample1.yaml @@ -163,3 +163,31 @@ alternatives: log\",\"project\":{\"name\":\"myProject\",\"department\":\"myDepartment\"}},\"phases\":{\"warm\":{\"min_age\":\"10d\",\"actio\ ns\":{\"forcemerge\":{\"max_num_segments\":1}}},\"delete\":{\"min_age\":\"30d\",\"actions\":{\"delete\":{}}}}}}' \"$ELASTICSEARCH_URL/_ilm/policy/my_policy\"" + - language: Java + code: > + client.ilm().putLifecycle(p -> p + .name("my_policy") + .policy(po -> po + .phases(ph -> ph + .delete(d -> d + .actions(a -> a + .delete(de -> de) + ) + .minAge(m -> m + .time("30d") + ) + ) + .warm(w -> w + .actions(a -> a + .forcemerge(f -> f + .maxNumSegments(1) + ) + ) + .minAge(m -> m + .time("10d") + ) + ) + ) + .meta(Map.of("description", JsonData.fromJson("\"used for nginx log\""),"project", JsonData.fromJson("{\"name\":\"myProject\",\"department\":\"myDepartment\"}"))) + ) + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml index 05e856ddd4..bce311aa10 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample1.yaml @@ -38,3 +38,9 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"analyzer":"standard","text":"this is a test"}'' "$ELASTICSEARCH_URL/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .analyzer("standard") + .text("this is a test") + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml index 5887878533..ba3a163205 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample2.yaml @@ -49,3 +49,9 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"analyzer":"standard","text":["this is a test","the second text"]}'' "$ELASTICSEARCH_URL/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .analyzer("standard") + .text(List.of("this is a test","the second text")) + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml index b3adae0e32..f354394e81 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample3.yaml @@ -65,3 +65,17 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"tokenizer":"keyword","filter":["lowercase"],"char_filter":["html_strip"],"text":"this is a test"}'' "$ELASTICSEARCH_URL/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .charFilter(c -> c + .name("html_strip") + ) + .filter(f -> f + .name("lowercase") + ) + .text("this is a test") + .tokenizer(t -> t + .name("keyword") + ) + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml index 541f41c14e..12f0104485 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample4.yaml @@ -86,3 +86,19 @@ alternatives: "curl -X GET -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"tokenizer\":\"whitespace\",\"filter\":[\"lowercase\",{\"type\":\"stop\",\"stopwords\":[\"a\",\"is\",\"this\"]}],\"text\":\ \"this is a test\"}' \"$ELASTICSEARCH_URL/_analyze\"" + - language: Java + code: | + client.indices().analyze(a -> a + .filter(List.of(TokenFilter.of(t -> t + .name("lowercase" + )),TokenFilter.of(to -> to + .definition(d -> d + .stop(s -> s + .stopwords(List.of("a","is","this")) + ) + )))) + .text("this is a test") + .tokenizer(tok -> tok + .name("whitespace") + ) + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml index a13db789ff..d07ecda06b 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample5.yaml @@ -44,3 +44,10 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"field":"obj1.field1","text":"this is a test"}'' "$ELASTICSEARCH_URL/analyze_sample/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .field("obj1.field1") + .index("analyze_sample") + .text("this is a test") + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml index ab6b43d19e..97b79a4021 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample6.yaml @@ -44,3 +44,10 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"normalizer":"my_normalizer","text":"BaR"}'' "$ELASTICSEARCH_URL/analyze_sample/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .index("analyze_sample") + .normalizer("my_normalizer") + .text("BaR") + ); diff --git a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml index 9fbb43aca9..e84e9134f2 100644 --- a/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml +++ b/specification/indices/analyze/examples/request/indicesAnalyzeRequestExample7.yaml @@ -71,3 +71,16 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"tokenizer":"standard","filter":["snowball"],"text":"detailed output","explain":true,"attributes":["keyword"]}'' "$ELASTICSEARCH_URL/_analyze"' + - language: Java + code: | + client.indices().analyze(a -> a + .attributes("keyword") + .explain(true) + .filter(f -> f + .name("snowball") + ) + .text("detailed output") + .tokenizer(t -> t + .name("standard") + ) + ); diff --git a/specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml b/specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml index 4281c464bc..dbc22b29cf 100644 --- a/specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml +++ b/specification/indices/clone/examples/request/indicesCloneRequestExample1.yaml @@ -77,3 +77,11 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"settings":{"index.number_of_shards":5},"aliases":{"my_search_indices":{}}}'' "$ELASTICSEARCH_URL/my_source_index/_clone/my_target_index"' + - language: Java + code: | + client.indices().clone(c -> c + .aliases("my_search_indices", a -> a) + .index("my_source_index") + .settings("index.number_of_shards", JsonData.fromJson("5")) + .target("my_target_index") + ); diff --git a/specification/indices/create/examples/request/indicesCreateRequestExample1.yaml b/specification/indices/create/examples/request/indicesCreateRequestExample1.yaml index f86012fc85..daea57ccd7 100644 --- a/specification/indices/create/examples/request/indicesCreateRequestExample1.yaml +++ b/specification/indices/create/examples/request/indicesCreateRequestExample1.yaml @@ -58,3 +58,12 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"settings":{"number_of_shards":3,"number_of_replicas":2}}'' "$ELASTICSEARCH_URL/my-index-000001"' + - language: Java + code: | + client.indices().create(c -> c + .index("my-index-000001") + .settings(s -> s + .numberOfShards("3") + .numberOfReplicas("2") + ) + ); diff --git a/specification/indices/create/examples/request/indicesCreateRequestExample2.yaml b/specification/indices/create/examples/request/indicesCreateRequestExample2.yaml index 38cdf60024..685dafdca4 100644 --- a/specification/indices/create/examples/request/indicesCreateRequestExample2.yaml +++ b/specification/indices/create/examples/request/indicesCreateRequestExample2.yaml @@ -91,3 +91,16 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"settings":{"number_of_shards":1},"mappings":{"properties":{"field1":{"type":"text"}}}}'' "$ELASTICSEARCH_URL/test"' + - language: Java + code: | + client.indices().create(c -> c + .index("test") + .mappings(m -> m + .properties("field1", p -> p + .text(t -> t) + ) + ) + .settings(s -> s + .numberOfShards("1") + ) + ); diff --git a/specification/indices/create/examples/request/indicesCreateRequestExample3.yaml b/specification/indices/create/examples/request/indicesCreateRequestExample3.yaml index ed98b5c0ea..a94e8e9f7d 100644 --- a/specification/indices/create/examples/request/indicesCreateRequestExample3.yaml +++ b/specification/indices/create/examples/request/indicesCreateRequestExample3.yaml @@ -85,3 +85,16 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"aliases":{"alias_1":{},"alias_2":{"filter":{"term":{"user.id":"kimchy"}},"routing":"shard-1"}}}'' "$ELASTICSEARCH_URL/test"' + - language: Java + code: | + client.indices().create(c -> c + .aliases(Map.of("alias_2", Alias.of(a -> a + .filter(f -> f + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + .routing("shard-1")),"alias_1", Alias.of(al -> al))) + .index("test") + ); diff --git a/specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml b/specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml index 88f0ce964d..9c5b8594fd 100644 --- a/specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml +++ b/specification/indices/create_from/examples/request/IndicesCreateFromExample1.yaml @@ -29,3 +29,10 @@ alternatives: $resp = $client->sendRequest($request); - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_create_from/my-index/my-new-index"' + - language: Java + code: | + client.indices().createFrom(c -> c + .dest("my-new-index") + .source("my-index") + .createFrom(cr -> cr) + ); diff --git a/specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml b/specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml index b5731c40fe..68faedbe78 100644 --- a/specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml +++ b/specification/indices/downsample/examples/request/DownsampleRequestExample1.yaml @@ -45,3 +45,14 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"fixed_interval":"1d"}'' "$ELASTICSEARCH_URL/my-time-series-index/_downsample/my-downsampled-time-series-index"' + - language: Java + code: | + client.indices().downsample(d -> d + .index("my-time-series-index") + .targetIndex("my-downsampled-time-series-index") + .config(c -> c + .fixedInterval(f -> f + .time("1d") + ) + ) + ); diff --git a/specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml b/specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml index a98c1dda9d..14e2e03e9b 100644 --- a/specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml +++ b/specification/indices/get_data_lifecycle/examples/request/IndicesGetDataLifecycleRequestExample1.yaml @@ -30,3 +30,5 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_data_stream/%7Bname%7D/_lifecycle?human&pretty"' + - language: Java + code: "\n" diff --git a/specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml b/specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml index 07d4ee3860..afda1ba46b 100644 --- a/specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml +++ b/specification/indices/get_data_lifecycle_stats/examples/request/IndicesGetDataLifecycleStatsRequestExample1.yaml @@ -26,3 +26,6 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_lifecycle/stats?human&pretty"' + - language: Java + code: | + client.indices().getDataLifecycleStats(); diff --git a/specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml b/specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml index ce06a3cf76..efa291e026 100644 --- a/specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml +++ b/specification/indices/get_index_template/examples/request/IndicesGetIndexTemplateExample1.yaml @@ -29,3 +29,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_index_template/*?filter_path=index_templates.name,index_templates.index_template.index_patterns,index_templates.index_template.data_stream"' + - language: Java + code: "\n" diff --git a/specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml b/specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml index 3c1cc5b31f..7de2544472 100644 --- a/specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml +++ b/specification/indices/migrate_reindex/examples/request/IndicesMigrateReindexExample1.yaml @@ -69,3 +69,13 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"my-data-stream"},"mode":"upgrade"}'' "$ELASTICSEARCH_URL/_migration/reindex"' + - language: Java + code: | + client.indices().migrateReindex(m -> m + .reindex(r -> r + .mode(ModeEnum.Upgrade) + .source(s -> s + .index("my-data-stream") + ) + ) + ); diff --git a/specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml b/specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml index 2566738368..85ff71c813 100644 --- a/specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml +++ b/specification/indices/modify_data_stream/examples/request/IndicesModifyDataStreamExample1.yaml @@ -100,3 +100,16 @@ alternatives: '{\"actions\":[{\"remove_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001\ \"}},{\"add_backing_index\":{\"data_stream\":\"my-data-stream\",\"index\":\".ds-my-data-stream-2023.07.26-000001-downsample\"\ }}]}' \"$ELASTICSEARCH_URL/_data_stream/_modify\"" + - language: Java + code: | + client.indices().modifyDataStream(m -> m + .actions(List.of(Action.of(a -> a + .removeBackingIndex(r -> r + .dataStream("my-data-stream") + .index(".ds-my-data-stream-2023.07.26-000001") + )),Action.of(ac -> ac + .addBackingIndex(ad -> ad + .dataStream("my-data-stream") + .index(".ds-my-data-stream-2023.07.26-000001-downsample") + )))) + ); diff --git a/specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml b/specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml index a6d98e3587..3f56492043 100644 --- a/specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml +++ b/specification/indices/put_alias/examples/request/indicesPutAliasRequestExample1.yaml @@ -78,3 +78,13 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"actions":[{"add":{"index":"my-data-stream","alias":"my-alias"}}]}'' "$ELASTICSEARCH_URL/_aliases"' + - language: Java + code: | + client.indices().updateAliases(u -> u + .actions(a -> a + .add(ad -> ad + .alias("my-alias") + .index("my-data-stream") + ) + ) + ); diff --git a/specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml b/specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml index 896e3f58bf..bafd45e7bf 100644 --- a/specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml +++ b/specification/indices/put_data_lifecycle/examples/request/IndicesPutDataLifecycleRequestExample1.yaml @@ -36,3 +36,11 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"data_retention":"7d"}'' "$ELASTICSEARCH_URL/_data_stream/my-data-stream/_lifecycle"' + - language: Java + code: | + client.indices().putDataLifecycle(p -> p + .dataRetention(d -> d + .time("7d") + ) + .name("my-data-stream") + ); diff --git a/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml b/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml index a76b5039f3..8984b78c2d 100644 --- a/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml +++ b/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample1.yaml @@ -83,3 +83,15 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index_patterns":["template*"],"priority":1,"template":{"settings":{"number_of_shards":2}}}'' "$ELASTICSEARCH_URL/_index_template/template_1"' + - language: Java + code: | + client.indices().putIndexTemplate(p -> p + .indexPatterns("template*") + .name("template_1") + .priority(1L) + .template(t -> t + .settings(s -> s + .numberOfShards("2") + ) + ) + ); diff --git a/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml b/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml index 6f747f2034..c23468d3b8 100644 --- a/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml +++ b/specification/indices/put_index_template/examples/request/IndicesPutIndexTemplateRequestExample2.yaml @@ -127,3 +127,22 @@ alternatives: '{\"index_patterns\":[\"template*\"],\"template\":{\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\ \":{\"filter\":{\"term\":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}}' \"$ELASTICSEARCH_URL/_index_template/template_1\"" + - language: Java + code: | + client.indices().putIndexTemplate(p -> p + .indexPatterns("template*") + .name("template_1") + .template(t -> t + .aliases(Map.of("alias1", Alias.of(a -> a),"{index}-alias", Alias.of(a -> a),"alias2", Alias.of(a -> a + .filter(f -> f + .term(te -> te + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + .routing("shard-1")))) + .settings(s -> s + .numberOfShards("1") + ) + ) + ); diff --git a/specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml b/specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml index dc969bbce8..1b239296ca 100644 --- a/specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml +++ b/specification/indices/put_mapping/examples/request/indicesPutMappingRequestExample1.yaml @@ -77,3 +77,15 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"properties":{"user":{"properties":{"name":{"type":"keyword"}}}}}'' "$ELASTICSEARCH_URL/my-index-000001/_mapping"' + - language: Java + code: | + client.indices().putMapping(p -> p + .index("my-index-000001") + .properties("user", pr -> pr + .object(o -> o + .properties("name", pro -> pro + .keyword(k -> k) + ) + ) + ) + ); diff --git a/specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml b/specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml index 2c8a451c4d..082ca28c1e 100644 --- a/specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml +++ b/specification/indices/put_settings/examples/request/IndicesPutSettingsRequestExample1.yaml @@ -56,3 +56,13 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index":{"number_of_replicas":2}}'' "$ELASTICSEARCH_URL/my-index-000001/_settings"' + - language: Java + code: | + client.indices().putSettings(p -> p + .index("my-index-000001") + .settings(s -> s + .index(i -> i + .numberOfReplicas("2") + ) + ) + ); diff --git a/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml b/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml index 524a442d4b..1f62c97126 100644 --- a/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml +++ b/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample1.yaml @@ -129,3 +129,17 @@ alternatives: '{\"index_patterns\":[\"te*\",\"bar*\"],\"settings\":{\"number_of_shards\":1},\"mappings\":{\"_source\":{\"enabled\":false}},\ \"properties\":{\"host_name\":{\"type\":\"keyword\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z yyyy\"}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" + - language: Java + code: | + client.indices().putTemplate(p -> p + .indexPatterns(List.of("te*","bar*")) + .mappings(m -> m + .source(s -> s + .enabled(false) + ) + ) + .name("template_1") + .settings(s -> s + .numberOfShards("1") + ) + ); diff --git a/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml b/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml index 839a583f47..d94b4e4df4 100644 --- a/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml +++ b/specification/indices/put_template/examples/request/indicesPutTemplateRequestExample2.yaml @@ -117,3 +117,20 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"te*\"],\"settings\":{\"number_of_shards\":1},\"aliases\":{\"alias1\":{},\"alias2\":{\"filter\":{\"term\ \":{\"user.id\":\"kimchy\"}},\"routing\":\"shard-1\"},\"{index}-alias\":{}}}' \"$ELASTICSEARCH_URL/_template/template_1\"" + - language: Java + code: | + client.indices().putTemplate(p -> p + .aliases(Map.of("alias1", Alias.of(a -> a),"{index}-alias", Alias.of(a -> a),"alias2", Alias.of(a -> a + .filter(f -> f + .term(t -> t + .field("user.id") + .value(FieldValue.of("kimchy")) + ) + ) + .routing("shard-1")))) + .indexPatterns("te*") + .name("template_1") + .settings(s -> s + .numberOfShards("1") + ) + ); diff --git a/specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml b/specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml index 8cbd19f794..65a02b3976 100644 --- a/specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml +++ b/specification/indices/recovery/examples/request/indicesRecoveryRequestExample1.yaml @@ -22,3 +22,5 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_recovery?human"' + - language: Java + code: "\n" diff --git a/specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml b/specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml index be12a63e38..33cdf9e178 100644 --- a/specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml +++ b/specification/indices/rollover/examples/request/indicesRolloverRequestExample1.yaml @@ -71,3 +71,16 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"conditions\":{\"max_age\":\"7d\",\"max_docs\":1000,\"max_primary_shard_size\":\"50gb\",\"max_primary_shard_docs\":\"2000\ \"}}' \"$ELASTICSEARCH_URL/my-data-stream/_rollover\"" + - language: Java + code: | + client.indices().rollover(r -> r + .alias("my-data-stream") + .conditions(c -> c + .maxAge(m -> m + .time("7d") + ) + .maxDocs(1000L) + .maxPrimaryShardSize("50gb") + .maxPrimaryShardDocs(2000L) + ) + ); diff --git a/specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml b/specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml index a40491d77c..dfe39fe6c3 100644 --- a/specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml +++ b/specification/indices/shrink/examples/request/indicesShrinkRequestExample1.yaml @@ -63,3 +63,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"settings":{"index.routing.allocation.require._name":null,"index.blocks.write":null}}'' "$ELASTICSEARCH_URL/my_source_index/_shrink/my_target_index"' + - language: Java + code: > + client.indices().shrink(s -> s + .index("my_source_index") + .settings(Map.of("index.blocks.write", JsonData.fromJson("null"),"index.routing.allocation.require._name", JsonData.fromJson("null"))) + .target("my_target_index") + ); diff --git a/specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml b/specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml index bd7716942d..ac154b1942 100644 --- a/specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml +++ b/specification/indices/simulate_template/examples/request/indicesSimulateTemplateRequestExample1.yaml @@ -93,3 +93,15 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"ct2\"],\"priority\":10,\"template\":{\"settings\":{\"index.number_of\ _replicas\":1}}}' \"$ELASTICSEARCH_URL/_index_template/_simulate\"" + - language: Java + code: | + client.indices().simulateTemplate(s -> s + .composedOf("ct2") + .indexPatterns("my-index-*") + .priority(10L) + .template(t -> t + .settings(se -> se + .otherSettings("index.number_of_replicas", JsonData.fromJson("1")) + ) + ) + ); diff --git a/specification/indices/split/examples/request/indicesSplitRequestExample1.yaml b/specification/indices/split/examples/request/indicesSplitRequestExample1.yaml index 23d91da8e1..61d97c6294 100644 --- a/specification/indices/split/examples/request/indicesSplitRequestExample1.yaml +++ b/specification/indices/split/examples/request/indicesSplitRequestExample1.yaml @@ -56,3 +56,10 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"settings":{"index.number_of_shards":2}}'' "$ELASTICSEARCH_URL/my-index-000001/_split/split-my-index-000001"' + - language: Java + code: | + client.indices().split(s -> s + .index("my-index-000001") + .settings("index.number_of_shards", JsonData.fromJson("2")) + .target("split-my-index-000001") + ); diff --git a/specification/indices/stats/examples/request/IndicesStatsExample1.yaml b/specification/indices/stats/examples/request/IndicesStatsExample1.yaml index d9fc8ca331..f76ab1df78 100644 --- a/specification/indices/stats/examples/request/IndicesStatsExample1.yaml +++ b/specification/indices/stats/examples/request/IndicesStatsExample1.yaml @@ -31,3 +31,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_stats/fielddata?human&fields=my_join_field#question"' + - language: Java + code: "\n" diff --git a/specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml b/specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml index b136c335ce..c559e5c57b 100644 --- a/specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml +++ b/specification/indices/update_aliases/examples/request/IndicesUpdateAliasesExample1.yaml @@ -68,3 +68,13 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"actions":[{"add":{"index":"logs-nginx.access-prod","alias":"logs"}}]}'' "$ELASTICSEARCH_URL/_aliases"' + - language: Java + code: | + client.indices().updateAliases(u -> u + .actions(a -> a + .add(ad -> ad + .alias("logs") + .index("logs-nginx.access-prod") + ) + ) + ); diff --git a/specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml b/specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml index dc3ee3b8ce..5a543b84ea 100644 --- a/specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml +++ b/specification/indices/validate_query/examples/request/IndicesValidateQueryExample1.yaml @@ -26,3 +26,9 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/my-index-000001/_validate/query?q=user.id:kimchy"' + - language: Java + code: | + client.indices().validateQuery(v -> v + .index("my-index-000001") + .q("user.id:kimchy") + ); diff --git a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml index 58629daa88..a123173746 100644 --- a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml +++ b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample1.yaml @@ -76,3 +76,17 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"model":"gpt-4o","messages":[{"role":"user","content":"What is Elastic?"}]}'' "$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream"' + - language: Java + code: | + client.inference().chatCompletionUnified(c -> c + .inferenceId("openai-completion") + .chatCompletionRequest(ch -> ch + .messages(m -> m + .content(co -> co + .string("What is Elastic?") + ) + .role("user") + ) + .model("gpt-4o") + ) + ); diff --git a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml index 2e73f07fb3..2f2fe48817 100644 --- a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml +++ b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample2.yaml @@ -149,3 +149,28 @@ alternatives: ther\",\"arguments\":\"{\\\"location\\\":\\\"Boston, MA\\\"}\"}}]},{\"role\":\"tool\",\"content\":\"The weather is cold\",\"tool_call_id\":\"call_KcAjWtAww20AihPHphUh46Gd\"}]}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" + - language: Java + code: | + client.inference().chatCompletionUnified(c -> c + .inferenceId("openai-completion") + .chatCompletionRequest(ch -> ch + .messages(List.of(Message.of(m -> m + .content(co -> co + .string("Let's find out what the weather is") + ) + .role("assistant") + .toolCalls(t -> t + .id("call_KcAjWtAww20AihPHphUh46Gd") + .function(f -> f + .arguments("{\"location\":\"Boston, MA\"}") + .name("get_current_weather") + ) + .type("function") + )),Message.of(me -> me + .content(co -> co + .string("The weather is cold") + ) + .role("tool") + .toolCallId("call_KcAjWtAww20AihPHphUh46Gd")))) + ) + ); diff --git a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml index 633caa2138..67aa38cd50 100644 --- a/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml +++ b/specification/inference/chat_completion_unified/examples/request/PostChatCompletionRequestExample3.yaml @@ -215,3 +215,32 @@ alternatives: item\",\"parameters\":{\"type\":\"object\",\"properties\":{\"item\":{\"id\":\"123\"}}}}}],\"tool_choice\":{\"type\":\"function\ \",\"function\":{\"name\":\"get_current_price\"}}}' \"$ELASTICSEARCH_URL/_inference/chat_completion/openai-completion/_stream\"" + - language: Java + code: | + client.inference().chatCompletionUnified(c -> c + .inferenceId("openai-completion") + .chatCompletionRequest(ch -> ch + .messages(m -> m + .content(co -> co + .string("What's the price of a scarf?") + ) + .role("user") + ) + .toolChoice(t -> t + .object(o -> o + .type("function") + .function(f -> f + .name("get_current_price") + ) + ) + ) + .tools(to -> to + .type("function") + .function(f -> f + .description("Get the current price of a item") + .name("get_current_price") + .parameters(JsonData.fromJson("{\"type\":\"object\",\"properties\":{\"item\":{\"id\":\"123\"}}}")) + ) + ) + ) + ); diff --git a/specification/inference/completion/examples/request/CompletionRequestExample1.yaml b/specification/inference/completion/examples/request/CompletionRequestExample1.yaml index 4304febca6..2b001f3cb3 100644 --- a/specification/inference/completion/examples/request/CompletionRequestExample1.yaml +++ b/specification/inference/completion/examples/request/CompletionRequestExample1.yaml @@ -39,3 +39,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":"What is Elastic?"}'' "$ELASTICSEARCH_URL/_inference/completion/openai_chat_completions"' + - language: Java + code: | + client.inference().completion(c -> c + .inferenceId("openai_chat_completions") + .input("What is Elastic?") + ); diff --git a/specification/inference/put/examples/request/InferencePutExample1.yaml b/specification/inference/put/examples/request/InferencePutExample1.yaml index 5b818e6517..5b6236368e 100644 --- a/specification/inference/put/examples/request/InferencePutExample1.yaml +++ b/specification/inference/put/examples/request/InferencePutExample1.yaml @@ -66,3 +66,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"cohere","service_settings":{"model_id":"rerank-english-v3.0","api_key":"{{COHERE_API_KEY}}"}}'' "$ELASTICSEARCH_URL/_inference/rerank/my-rerank-model"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("my-rerank-model") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("cohere") + .serviceSettings(JsonData.fromJson("{\"model_id\":\"rerank-english-v3.0\",\"api_key\":\"{{COHERE_API_KEY}}\"}")) + ) + ); diff --git a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml index 93ce05ce0a..5685eae079 100644 --- a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml +++ b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample1.yaml @@ -79,3 +79,13 @@ alternatives: '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyunc\ s.com\",\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-qwen-turbo\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/completion/alibabacloud_ai_search_completion\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("alibabacloud_ai_search_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("alibabacloud-ai-search") + .serviceSettings(JsonData.fromJson("{\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-qwen-turbo\",\"workspace\":\"default\"}")) + ) + ); diff --git a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml index 63ed71cbf8..583471ff3c 100644 --- a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml +++ b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample2.yaml @@ -79,3 +79,13 @@ alternatives: '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-bge-\ reranker-larger\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/alibabacloud_ai_search_rerank\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("alibabacloud_ai_search_rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("alibabacloud-ai-search") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-bge-reranker-larger\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}")) + ) + ); diff --git a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml index 7e439d067f..8a1d027bb5 100644 --- a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml +++ b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample3.yaml @@ -81,3 +81,13 @@ alternatives: '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text\ -sparse-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/alibabacloud_ai_search_sparse\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("alibabacloud_ai_search_sparse") + .taskType(TaskType.SparseEmbedding) + .inferenceConfig(i -> i + .service("alibabacloud-ai-search") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-sparse-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}")) + ) + ); diff --git a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml index 07fa5493e7..c0ee46957e 100644 --- a/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml +++ b/specification/inference/put_alibabacloud/examples/request/PutAlibabaCloudRequestExample4.yaml @@ -81,3 +81,13 @@ alternatives: '{\"service\":\"alibabacloud-ai-search\",\"service_settings\":{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text\ -embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/alibabacloud_ai_search_embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("alibabacloud_ai_search_embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("alibabacloud-ai-search") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"AlibabaCloud-API-Key\",\"service_id\":\"ops-text-embedding-001\",\"host\":\"default-j01.platform-cn-shanghai.opensearch.aliyuncs.com\",\"workspace\":\"default\"}")) + ) + ); diff --git a/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml b/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml index f18d206d4a..6a335421df 100644 --- a/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml +++ b/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample1.yaml @@ -84,3 +84,13 @@ alternatives: '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"r\ egion\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-embed-text-v2:0\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/amazon_bedrock_embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("amazon_bedrock_embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("amazonbedrock") + .serviceSettings(JsonData.fromJson("{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-embed-text-v2:0\"}")) + ) + ); diff --git a/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml b/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml index 99cdfbcb3d..75cc653d9d 100644 --- a/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml +++ b/specification/inference/put_amazonbedrock/examples/request/PutAmazonBedrockRequestExample2.yaml @@ -68,3 +68,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"openai","service_settings":{"api_key":"OpenAI-API-Key","model_id":"gpt-3.5-turbo"}}'' "$ELASTICSEARCH_URL/_inference/completion/openai-completion"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("openai-completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("openai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"gpt-3.5-turbo\"}")) + ) + ); diff --git a/specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml b/specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml index 53346f1711..c043af4ba3 100644 --- a/specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml +++ b/specification/inference/put_anthropic/examples/request/PutAnthropicRequestExample1.yaml @@ -83,3 +83,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"anthropic\",\"service_settings\":{\"api_key\":\"Anthropic-Api-Key\",\"model_id\":\"Model-ID\"},\"task_settings\ \":{\"max_tokens\":1024}}' \"$ELASTICSEARCH_URL/_inference/completion/anthropic_completion\"" + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("anthropic_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("anthropic") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Anthropic-Api-Key\",\"model_id\":\"Model-ID\"}")) + .taskSettings(JsonData.fromJson("{\"max_tokens\":1024}")) + ) + ); diff --git a/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml b/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml index be721776bb..699cee5878 100644 --- a/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml +++ b/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample1.yaml @@ -80,3 +80,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-Uri\",\"pro\ vider\":\"openai\",\"endpoint_type\":\"token\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_ai_studio_embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("azure_ai_studio_embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("azureaistudio") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-Uri\",\"provider\":\"openai\",\"endpoint_type\":\"token\"}")) + ) + ); diff --git a/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml b/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml index 4594b35f0c..73720b0f3c 100644 --- a/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml +++ b/specification/inference/put_azureaistudio/examples/request/PutAzureAiStudioRequestExample2.yaml @@ -79,3 +79,13 @@ alternatives: '{\"service\":\"azureaistudio\",\"service_settings\":{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"pro\ vider\":\"databricks\",\"endpoint_type\":\"realtime\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_ai_studio_completion\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("azure_ai_studio_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("azureaistudio") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Azure-AI-Studio-API-key\",\"target\":\"Target-URI\",\"provider\":\"databricks\",\"endpoint_type\":\"realtime\"}")) + ) + ); diff --git a/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml b/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml index b4b5c39234..6392cc20cf 100644 --- a/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml +++ b/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample1.yaml @@ -81,3 +81,13 @@ alternatives: '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_\ id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/azure_openai_embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("azure_openai_embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("azureopenai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}")) + ) + ); diff --git a/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml b/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml index e3fa91cf1e..48e09cff9c 100644 --- a/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml +++ b/specification/inference/put_azureopenai/examples/request/PutAzureOpenAiRequestExample2.yaml @@ -78,3 +78,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"azureopenai\",\"service_settings\":{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_\ id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}}' \"$ELASTICSEARCH_URL/_inference/completion/azure_openai_completion\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("azure_openai_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("azureopenai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Api-Key\",\"resource_name\":\"Resource-name\",\"deployment_id\":\"Deployment-id\",\"api_version\":\"2024-02-01\"}")) + ) + ); diff --git a/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml b/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml index 2990b43a93..7a63fdf6e0 100644 --- a/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml +++ b/specification/inference/put_cohere/examples/request/PutCohereRequestExample1.yaml @@ -73,3 +73,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-Api-key\",\"model_id\":\"embed-english-light-v3.0\",\"emb\ edding_type\":\"byte\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/cohere-embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("cohere-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("cohere") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Cohere-Api-key\",\"model_id\":\"embed-english-light-v3.0\",\"embedding_type\":\"byte\"}")) + ) + ); diff --git a/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml b/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml index 3035c3b40a..0c7368cb88 100644 --- a/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml +++ b/specification/inference/put_cohere/examples/request/PutCohereRequestExample2.yaml @@ -88,3 +88,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"cohere\",\"service_settings\":{\"api_key\":\"Cohere-API-key\",\"model_id\":\"rerank-english-v3.0\"},\"task_se\ ttings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/cohere-rerank\"" + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("cohere-rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("cohere") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Cohere-API-key\",\"model_id\":\"rerank-english-v3.0\"}")) + .taskSettings(JsonData.fromJson("{\"top_n\":10,\"return_documents\":true}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml index 105fd418be..27f182e68b 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample1.yaml @@ -97,3 +97,13 @@ alternatives: '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\ \":1,\"max_number_of_allocations\":4},\"num_threads\":1,\"model_id\":\".elser_model_2\"}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-elser-model") + .taskType(TaskType.SparseEmbedding) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4},\"num_threads\":1,\"model_id\":\".elser_model_2\"}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml index eec3d07a89..ecf4f0933e 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample2.yaml @@ -98,3 +98,13 @@ alternatives: '{\"service\":\"elasticsearch\",\"service_settings\":{\"model_id\":\".rerank-v1\",\"num_threads\":1,\"adaptive_allocations\":{\ \"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4}}}' \"$ELASTICSEARCH_URL/_inference/rerank/my-elastic-rerank\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-elastic-rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"model_id\":\".rerank-v1\",\"num_threads\":1,\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":1,\"max_number_of_allocations\":4}}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml index 593d3cc393..ebd2646814 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample3.yaml @@ -76,3 +76,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\".multilingual-e5\ -small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-e5-model") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml index d2213417ca..1a8b93bcff 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample4.yaml @@ -75,3 +75,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elasticsearch\",\"service_settings\":{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\"msmarco-MiniLM-L\ 12-cos-v5\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-msmarco-minilm-model\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-msmarco-minilm-model") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"num_allocations\":1,\"num_threads\":1,\"model_id\":\"msmarco-MiniLM-L12-cos-v5\"}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml index 8fbfba7152..d1cae4c160 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample5.yaml @@ -97,3 +97,13 @@ alternatives: '{\"service\":\"elasticsearch\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\ \":3,\"max_number_of_allocations\":10},\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/my-e5-model\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-e5-model") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1,\"model_id\":\".multilingual-e5-small\"}")) + ) + ); diff --git a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml index 398627a34d..6b0f9e515d 100644 --- a/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml +++ b/specification/inference/put_elasticsearch/examples/request/PutElasticsearchRequestExample6.yaml @@ -65,3 +65,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"elasticsearch","service_settings":{"deployment_id":".elser_model_2"}}'' "$ELASTICSEARCH_URL/_inference/sparse_embedding/use_existing_deployment"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("use_existing_deployment") + .taskType(TaskType.SparseEmbedding) + .inferenceConfig(i -> i + .service("elasticsearch") + .serviceSettings(JsonData.fromJson("{\"deployment_id\":\".elser_model_2\"}")) + ) + ); diff --git a/specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml b/specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml index c8242a8ab8..8f3cc47569 100644 --- a/specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml +++ b/specification/inference/put_elser/examples/request/PutElserRequestExample1.yaml @@ -70,3 +70,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"elser","service_settings":{"num_allocations":1,"num_threads":1}}'' "$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("my-elser-model") + .taskType(TaskType.SparseEmbedding) + .inferenceConfig(i -> i + .service("elser") + .serviceSettings(JsonData.fromJson("{\"num_allocations\":1,\"num_threads\":1}")) + ) + ); diff --git a/specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml b/specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml index f5063dd420..20975ba3ad 100644 --- a/specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml +++ b/specification/inference/put_elser/examples/request/PutElserRequestExample2.yaml @@ -91,3 +91,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"elser\",\"service_settings\":{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"ma\ x_number_of_allocations\":10},\"num_threads\":1}}' \"$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("my-elser-model") + .taskType(TaskType.SparseEmbedding) + .inferenceConfig(i -> i + .service("elser") + .serviceSettings(JsonData.fromJson("{\"adaptive_allocations\":{\"enabled\":true,\"min_number_of_allocations\":3,\"max_number_of_allocations\":10},\"num_threads\":1}")) + ) + ); diff --git a/specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml b/specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml index e31af536cf..32f130ab9b 100644 --- a/specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml +++ b/specification/inference/put_googleaistudio/examples/request/PutGoogleAiStudioRequestExample1.yaml @@ -68,3 +68,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"googleaistudio","service_settings":{"api_key":"api-key","model_id":"model-id"}}'' "$ELASTICSEARCH_URL/_inference/completion/google_ai_studio_completion"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("google_ai_studio_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("googleaistudio") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"api-key\",\"model_id\":\"model-id\"}")) + ) + ); diff --git a/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml b/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml index 2a782d4de4..b6eba7c454 100644 --- a/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml +++ b/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample1.yaml @@ -81,3 +81,13 @@ alternatives: '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"model_id\":\"model\ -id\",\"location\":\"location\",\"project_id\":\"project-id\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/google_vertex_ai_embeddingss\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("google_vertex_ai_embeddingss") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("googlevertexai") + .serviceSettings(JsonData.fromJson("{\"service_account_json\":\"service-account-json\",\"model_id\":\"model-id\",\"location\":\"location\",\"project_id\":\"project-id\"}")) + ) + ); diff --git a/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml b/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml index 1211e7bbd2..d1e18f9b1e 100644 --- a/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml +++ b/specification/inference/put_googlevertexai/examples/request/PutGoogleVertexAiRequestExample2.yaml @@ -68,3 +68,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"googlevertexai\",\"service_settings\":{\"service_account_json\":\"service-account-json\",\"project_id\":\"pro\ ject-id\"}}' \"$ELASTICSEARCH_URL/_inference/rerank/google_vertex_ai_rerank\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("google_vertex_ai_rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("googlevertexai") + .serviceSettings(JsonData.fromJson("{\"service_account_json\":\"service-account-json\",\"project_id\":\"project-id\"}")) + ) + ); diff --git a/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml b/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml index 02529ad83a..2d4d81269d 100644 --- a/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml +++ b/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample1.yaml @@ -70,3 +70,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"hugging_face","service_settings":{"api_key":"hugging-face-access-token","url":"url-endpoint"}}'' "$ELASTICSEARCH_URL/_inference/text_embedding/hugging-face-embeddings"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("hugging-face-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("hugging_face") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"}")) + ) + ); diff --git a/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml b/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml index 1a04c7c7c3..e6f830d821 100644 --- a/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml +++ b/specification/inference/put_hugging_face/examples/request/PutHuggingFaceRequestExample2.yaml @@ -88,3 +88,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"hugging_face\",\"service_settings\":{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"},\"ta\ sk_settings\":{\"return_documents\":true,\"top_n\":3}}' \"$ELASTICSEARCH_URL/_inference/rerank/hugging-face-rerank\"" + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("hugging-face-rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("hugging_face") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"hugging-face-access-token\",\"url\":\"url-endpoint\"}")) + .taskSettings(JsonData.fromJson("{\"return_documents\":true,\"top_n\":3}")) + ) + ); diff --git a/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml b/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml index 82f6291b1a..01a6f1221e 100644 --- a/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml +++ b/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample1.yaml @@ -70,3 +70,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"jinaai","service_settings":{"model_id":"jina-embeddings-v3","api_key":"JinaAi-Api-key"}}'' "$ELASTICSEARCH_URL/_inference/text_embedding/jinaai-embeddings"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("jinaai-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("jinaai") + .serviceSettings(JsonData.fromJson("{\"model_id\":\"jina-embeddings-v3\",\"api_key\":\"JinaAi-Api-key\"}")) + ) + ); diff --git a/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml b/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml index f68cd18cb0..a638f53a0d 100644 --- a/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml +++ b/specification/inference/put_jinaai/examples/request/PutJinaAiRequestExample2.yaml @@ -88,3 +88,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"jinaai\",\"service_settings\":{\"api_key\":\"JinaAI-Api-key\",\"model_id\":\"jina-reranker-v2-base-multilingu\ al\"},\"task_settings\":{\"top_n\":10,\"return_documents\":true}}' \"$ELASTICSEARCH_URL/_inference/rerank/jinaai-rerank\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("jinaai-rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("jinaai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"JinaAI-Api-key\",\"model_id\":\"jina-reranker-v2-base-multilingual\"}")) + .taskSettings(JsonData.fromJson("{\"top_n\":10,\"return_documents\":true}")) + ) + ); diff --git a/specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml b/specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml index 24752de5e7..29e006a4f3 100644 --- a/specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml +++ b/specification/inference/put_mistral/examples/request/PutMistralRequestExample1.yaml @@ -70,3 +70,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"mistral","service_settings":{"api_key":"Mistral-API-Key","model":"mistral-embed"}}'' "$ELASTICSEARCH_URL/_inference/text_embedding/mistral-embeddings-test"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("mistral-embeddings-test") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("mistral") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Mistral-API-Key\",\"model\":\"mistral-embed\"}")) + ) + ); diff --git a/specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml b/specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml index 3ab1bbd26e..c57ae807fa 100644 --- a/specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml +++ b/specification/inference/put_openai/examples/request/PutOpenAiRequestExample1.yaml @@ -75,3 +75,13 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"service\":\"openai\",\"service_settings\":{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"text-embedding-3-small\",\"dimen\ sions\":128}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("openai-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("openai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"OpenAI-API-Key\",\"model_id\":\"text-embedding-3-small\",\"dimensions\":128}")) + ) + ); diff --git a/specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml b/specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml index 33984233a1..c40aaeb571 100644 --- a/specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml +++ b/specification/inference/put_openai/examples/request/PutOpenAiRequestExample2.yaml @@ -84,3 +84,13 @@ alternatives: '{\"service\":\"amazonbedrock\",\"service_settings\":{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"r\ egion\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-text-premier-v1:0\"}}' \"$ELASTICSEARCH_URL/_inference/completion/amazon_bedrock_completion\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("amazon_bedrock_completion") + .taskType(TaskType.Completion) + .inferenceConfig(i -> i + .service("amazonbedrock") + .serviceSettings(JsonData.fromJson("{\"access_key\":\"AWS-access-key\",\"secret_key\":\"AWS-secret-key\",\"region\":\"us-east-1\",\"provider\":\"amazontitan\",\"model\":\"amazon.titan-text-premier-v1:0\"}")) + ) + ); diff --git a/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml b/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml index acd9cd96ba..fe2ccf9b0b 100644 --- a/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml +++ b/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample1.yaml @@ -70,3 +70,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"voyageai","service_settings":{"model_id":"voyage-3-large","dimensions":512}}'' "$ELASTICSEARCH_URL/_inference/text_embedding/openai-embeddings"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("openai-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("voyageai") + .serviceSettings(JsonData.fromJson("{\"model_id\":\"voyage-3-large\",\"dimensions\":512}")) + ) + ); diff --git a/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml b/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml index 563d80a35e..66f6dcc496 100644 --- a/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml +++ b/specification/inference/put_voyageai/examples/request/PutVoyageAIRequestExample2.yaml @@ -63,3 +63,13 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"service":"voyageai","service_settings":{"model_id":"rerank-2"}}'' "$ELASTICSEARCH_URL/_inference/rerank/voyageai-rerank"' + - language: Java + code: | + client.inference().put(p -> p + .inferenceId("voyageai-rerank") + .taskType(TaskType.Rerank) + .inferenceConfig(i -> i + .service("voyageai") + .serviceSettings(JsonData.fromJson("{\"model_id\":\"rerank-2\"}")) + ) + ); diff --git a/specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml b/specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml index a9048b28c6..ff714c44f5 100644 --- a/specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml +++ b/specification/inference/put_watsonx/examples/request/PutWatsonxRequestExample1.yaml @@ -84,3 +84,13 @@ alternatives: '{\"service\":\"watsonxai\",\"service_settings\":{\"api_key\":\"Watsonx-API-Key\",\"url\":\"Wastonx-URL\",\"model_id\":\"ibm/\ slate-30m-english-rtrvr\",\"project_id\":\"IBM-Cloud-ID\",\"api_version\":\"2024-03-14\"}}' \"$ELASTICSEARCH_URL/_inference/text_embedding/watsonx-embeddings\"" + - language: Java + code: > + client.inference().put(p -> p + .inferenceId("watsonx-embeddings") + .taskType(TaskType.TextEmbedding) + .inferenceConfig(i -> i + .service("watsonxai") + .serviceSettings(JsonData.fromJson("{\"api_key\":\"Watsonx-API-Key\",\"url\":\"Wastonx-URL\",\"model_id\":\"ibm/slate-30m-english-rtrvr\",\"project_id\":\"IBM-Cloud-ID\",\"api_version\":\"2024-03-14\"}")) + ) + ); diff --git a/specification/inference/rerank/examples/request/RerankRequestExample1.yaml b/specification/inference/rerank/examples/request/RerankRequestExample1.yaml index 0451903482..1440c6f642 100644 --- a/specification/inference/rerank/examples/request/RerankRequestExample1.yaml +++ b/specification/inference/rerank/examples/request/RerankRequestExample1.yaml @@ -69,3 +69,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":["luke","like","leia","chewy","r2d2","star","wars"],"query":"star wars main character"}'' "$ELASTICSEARCH_URL/_inference/rerank/cohere_rerank"' + - language: Java + code: | + client.inference().rerank(r -> r + .inferenceId("cohere_rerank") + .input(List.of("luke","like","leia","chewy","r2d2","star","wars")) + .query("star wars main character") + ); diff --git a/specification/inference/rerank/examples/request/RerankRequestExample3.yaml b/specification/inference/rerank/examples/request/RerankRequestExample3.yaml index ed30c86ac1..3e351a9863 100644 --- a/specification/inference/rerank/examples/request/RerankRequestExample3.yaml +++ b/specification/inference/rerank/examples/request/RerankRequestExample3.yaml @@ -79,3 +79,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":["luke","like","leia","chewy","r2d2","star","wars"],"query":"star wars main character","return_documents":true,"top_n":3}'' "$ELASTICSEARCH_URL/_inference/rerank/bge-reranker-base-mkn"' + - language: Java + code: | + client.inference().rerank(r -> r + .inferenceId("bge-reranker-base-mkn") + .input(List.of("luke","like","leia","chewy","r2d2","star","wars")) + .query("star wars main character") + ); diff --git a/specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml b/specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml index 9680c2c529..9c8d16876b 100644 --- a/specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml +++ b/specification/inference/sparse_embedding/examples/request/SparseEmbeddingRequestExample1.yaml @@ -41,3 +41,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":"The sky above the port was the color of television tuned to a dead channel."}'' "$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model"' + - language: Java + code: | + client.inference().sparseEmbedding(s -> s + .inferenceId("my-elser-model") + .input("The sky above the port was the color of television tuned to a dead channel.") + ); diff --git a/specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml b/specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml index 7e4d81acfd..3a63b05227 100644 --- a/specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml +++ b/specification/inference/stream_completion/examples/request/StreamInferenceRequestExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":"What is Elastic?"}'' "$ELASTICSEARCH_URL/_inference/completion/openai-completion/_stream"' + - language: Java + code: | + client.inference().streamCompletion(s -> s + .inferenceId("openai-completion") + .input("What is Elastic?") + ); diff --git a/specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml b/specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml index 4275802128..94df7931ef 100644 --- a/specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml +++ b/specification/inference/text_embedding/examples/request/TextEmbeddingRequestExample1.yaml @@ -58,3 +58,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"input":"The sky above the port was the color of television tuned to a dead channel.","task_settings":{"input_type":"ingest"}}'' "$ELASTICSEARCH_URL/_inference/text_embedding/my-cohere-endpoint"' + - language: Java + code: | + client.inference().textEmbedding(t -> t + .inferenceId("my-cohere-endpoint") + .input("The sky above the port was the color of television tuned to a dead channel.") + .taskSettings(JsonData.fromJson("{\"input_type\":\"ingest\"}")) + ); diff --git a/specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml b/specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml index e81e4e27f5..86786c7345 100644 --- a/specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml +++ b/specification/ingest/geo_ip_stats/examples/request/IngestGeoIpStatsExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->ingest()->geoIpStats(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ingest/geoip/stats"' + - language: Java + code: | + client.ingest().geoIpStats(); diff --git a/specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml b/specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml index e5c8f5689a..10bd4e6426 100644 --- a/specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml +++ b/specification/ingest/processor_grok/examples/request/IngestProcessorGrokExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->ingest()->processorGrok(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ingest/processor/grok"' + - language: Java + code: | + client.ingest().processorGrok(); diff --git a/specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml b/specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml index 07ae27e7da..d18ae2ff8e 100644 --- a/specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml +++ b/specification/ingest/put_ip_location_database/examples/request/IngestPutIpLocationDatabaseExample1.yaml @@ -57,3 +57,14 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"name":"GeoIP2-Domain","maxmind":{"account_id":"1234567"}}'' "$ELASTICSEARCH_URL/_ingest/ip_location/database/my-database-1"' + - language: Java + code: | + client.ingest().putIpLocationDatabase(p -> p + .id("my-database-1") + .configuration(c -> c + .maxmind(m -> m + .accountId("1234567") + ) + .name("GeoIP2-Domain") + ) + ); diff --git a/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml b/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml index d70b9b1123..644076d96a 100644 --- a/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml +++ b/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample1.yaml @@ -95,3 +95,16 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"description":"My optional pipeline description","processors":[{"set":{"description":"My optional processor description","field":"my-keyword-field","value":"foo"}}]}'' "$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id"' + - language: Java + code: | + client.ingest().putPipeline(p -> p + .description("My optional pipeline description") + .id("my-pipeline-id") + .processors(pr -> pr + .set(s -> s + .field("my-keyword-field") + .value(JsonData.fromJson("\"foo\"")) + .description("My optional processor description") + ) + ) + ); diff --git a/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml b/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml index 5539ea104e..a8d421929f 100644 --- a/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml +++ b/specification/ingest/put_pipeline/examples/request/PutPipelineRequestExample2.yaml @@ -138,3 +138,17 @@ alternatives: optional pipeline description","processors":[{"set":{"description":"My optional processor description","field":"my-keyword-field","value":"foo"}}],"_meta":{"reason":"set my-keyword-field to foo","serialization":{"class":"MyPipeline","id":10}}}'' "$ELASTICSEARCH_URL/_ingest/pipeline/my-pipeline-id"' + - language: Java + code: > + client.ingest().putPipeline(p -> p + .meta(Map.of("serialization", JsonData.fromJson("{\"class\":\"MyPipeline\",\"id\":10}"),"reason", JsonData.fromJson("\"set my-keyword-field to foo\""))) + .description("My optional pipeline description") + .id("my-pipeline-id") + .processors(pr -> pr + .set(s -> s + .field("my-keyword-field") + .value(JsonData.fromJson("\"foo\"")) + .description("My optional processor description") + ) + ) + ); diff --git a/specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml b/specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml index 992ddf78d4..2bd4e4feb7 100644 --- a/specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml +++ b/specification/ingest/simulate/examples/request/SimulatePipelineRequestExample1.yaml @@ -196,3 +196,23 @@ alternatives: '{\"pipeline\":{\"description\":\"_description\",\"processors\":[{\"set\":{\"field\":\"field2\",\"value\":\"_value\"}}]},\"do\ cs\":[{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"index\",\"_id\":\"id\",\"_source\":{\ \"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/pipeline/_simulate\"" + - language: Java + code: | + client.ingest().simulate(s -> s + .docs(List.of(Document.of(d -> d + .id("id") + .index("index") + .source(JsonData.fromJson("{\"foo\":\"bar\"}"))),Document.of(d -> d + .id("id") + .index("index") + .source(JsonData.fromJson("{\"foo\":\"rab\"}"))))) + .pipeline(p -> p + .description("_description") + .processors(pr -> pr + .set(se -> se + .field("field2") + .value(JsonData.fromJson("\"_value\"")) + ) + ) + ) + ); diff --git a/specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml b/specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml index b9bb57bff2..0b808c7452 100644 --- a/specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml +++ b/specification/license/get_basic_status/examples/request/GetBasicLicenseStatusRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->license()->getBasicStatus(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_license/basic_status"' + - language: Java + code: | + client.license().getBasicStatus(); diff --git a/specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml b/specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml index 352f690ecf..f21cbefa7f 100644 --- a/specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml +++ b/specification/license/get_trial_status/examples/request/GetTrialLicenseStatusRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->license()->getTrialStatus(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_license/trial_status"' + - language: Java + code: | + client.license().getTrialStatus(); diff --git a/specification/license/post/examples/request/PostLicenseRequestExample1.yaml b/specification/license/post/examples/request/PostLicenseRequestExample1.yaml index c024e31ac6..df722c316b 100644 --- a/specification/license/post/examples/request/PostLicenseRequestExample1.yaml +++ b/specification/license/post/examples/request/PostLicenseRequestExample1.yaml @@ -106,3 +106,17 @@ alternatives: '{\"licenses\":[{\"uid\":\"893361dc-9749-4997-93cb-802e3d7fa4xx\",\"type\":\"basic\",\"issue_date_in_millis\":1411948800000,\ \"expiry_date_in_millis\":1914278399999,\"max_nodes\":1,\"issued_to\":\"issuedTo\",\"issuer\":\"issuer\",\"signature\":\"xx\"\ }]}' \"$ELASTICSEARCH_URL/_license\"" + - language: Java + code: | + client.license().post(p -> p + .licenses(l -> l + .expiryDateInMillis(1914278399999L) + .issueDateInMillis(1411948800000L) + .issuedTo("issuedTo") + .issuer("issuer") + .maxNodes(1L) + .signature("xx") + .type(LicenseType.Basic) + .uid("893361dc-9749-4997-93cb-802e3d7fa4xx") + ) + ); diff --git a/specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml b/specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml index 5a75f75e97..8ddf57fdd6 100644 --- a/specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml +++ b/specification/logstash/put_pipeline/examples/request/LogstashPutPipelineRequestExample1.yaml @@ -118,3 +118,26 @@ alternatives: },\"username\":\"elastic\",\"pipeline\":\"input {}\\\\n filter { grok {} }\\\\n output {}\",\"pipeline_settings\":{\"pipeline.workers\":1,\"pipeline.batch.size\":125,\"pipeline.batch.delay\":50,\"queue.type\":\"m\ emory\",\"queue.max_bytes\":\"1gb\",\"queue.checkpoint.writes\":1024}}' \"$ELASTICSEARCH_URL/_logstash/pipeline/my_pipeline\"" + - language: Java + code: | + client.logstash().putPipeline(p -> p + .id("my_pipeline") + .pipeline(pi -> pi + .description("Sample pipeline for illustration purposes") + .lastModified(DateTime.of("2021-01-02T02:50:51.250Z")) + .pipeline("input {}\n filter { grok {} }\n output {}") + .pipelineMetadata(pip -> pip + .type("logstash_pipeline") + .version("1") + ) + .pipelineSettings(pip -> pip + .pipelineWorkers(1) + .pipelineBatchSize(125) + .pipelineBatchDelay(50) + .queueType("memory") + .queueMaxBytes("1gb") + .queueCheckpointWrites(1024) + ) + .username("elastic") + ) + ); diff --git a/specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml b/specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml index c9732bf09c..062461451d 100644 --- a/specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml +++ b/specification/migration/get_feature_upgrade_status/examples/request/GetFeatureUpgradeStatusRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->migration()->getFeatureUpgradeStatus(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_migration/system_features"' + - language: Java + code: | + client.migration().getFeatureUpgradeStatus(); diff --git a/specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml b/specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml index 86419a6f54..1e875c2860 100644 --- a/specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml +++ b/specification/migration/post_feature_upgrade/examples/request/PostFeatureUpgradeRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->migration()->postFeatureUpgrade(); - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_migration/system_features"' + - language: Java + code: | + client.migration().postFeatureUpgrade(); diff --git a/specification/ml/close_job/examples/request/MlCloseJobExample1.yaml b/specification/ml/close_job/examples/request/MlCloseJobExample1.yaml index 17ae703b18..5635df9f63 100644 --- a/specification/ml/close_job/examples/request/MlCloseJobExample1.yaml +++ b/specification/ml/close_job/examples/request/MlCloseJobExample1.yaml @@ -22,3 +22,8 @@ alternatives: ]); - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_close"' + - language: Java + code: | + client.ml().closeJob(c -> c + .jobId("low_request_rate") + ); diff --git a/specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml b/specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml index 2764cc8caa..9fc52963d8 100644 --- a/specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml +++ b/specification/ml/delete_expired_data/examples/request/MlDeleteExpiredDataExample1.yaml @@ -22,3 +22,10 @@ alternatives: ]); - language: curl code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/_delete_expired_data?timeout=1h"' + - language: Java + code: | + client.ml().deleteExpiredData(d -> d + .timeout(t -> t + .offset(1) + ) + ); diff --git a/specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml b/specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml index 1a1386986c..f081dad394 100644 --- a/specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml +++ b/specification/ml/estimate_model_memory/examples/request/MlEstimateModelMemoryRequestExample1.yaml @@ -138,3 +138,21 @@ alternatives: \"status\",\"partition_field_name\":\"app\"}],\"influencers\":[\"source_ip\",\"dest_ip\"]},\"overall_cardinality\":{\"status\ \":10,\"app\":50},\"max_bucket_cardinality\":{\"source_ip\":300,\"dest_ip\":30}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/_estimate_model_memory\"" + - language: Java + code: | + client.ml().estimateModelMemory(e -> e + .analysisConfig(a -> a + .bucketSpan(b -> b + .time("5m") + ) + .detectors(d -> d + .byFieldName("status") + .fieldName("bytes") + .function("sum") + .partitionFieldName("app") + ) + .influencers(List.of("source_ip","dest_ip")) + ) + .maxBucketCardinality(Map.of("dest_ip", 30L,"source_ip", 300L)) + .overallCardinality(Map.of("app", 50L,"status", 10L)) + ); diff --git a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml index 5bd6fa6464..9e3a7d62c8 100644 --- a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml +++ b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample1.yaml @@ -79,3 +79,15 @@ alternatives: '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"predicted_field\ \":\"ml.animal_class_prediction\",\"metrics\":{\"multiclass_confusion_matrix\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + - language: Java + code: | + client.ml().evaluateDataFrame(e -> e + .evaluation(ev -> ev + .classification(c -> c + .actualField("animal_class") + .predictedField("ml.animal_class_prediction") + .metrics(m -> m) + ) + ) + .index("animal_classification") + ); diff --git a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml index 7fa591558e..e72b5a8216 100644 --- a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml +++ b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample2.yaml @@ -84,3 +84,18 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"animal_classification\",\"evaluation\":{\"classification\":{\"actual_field\":\"animal_class\",\"metrics\":{\"au\ c_roc\":{\"class_name\":\"dog\"}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + - language: Java + code: | + client.ml().evaluateDataFrame(e -> e + .evaluation(ev -> ev + .classification(c -> c + .actualField("animal_class") + .metrics(m -> m + .aucRoc(a -> a + .className("dog") + ) + ) + ) + ) + .index("animal_classification") + ); diff --git a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml index 96b6d605cd..cc6dbd8ef3 100644 --- a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml +++ b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample3.yaml @@ -63,3 +63,14 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_analytics_dest_index\",\"evaluation\":{\"outlier_detection\":{\"actual_field\":\"is_outlier\",\"predicted_pr\ obability_field\":\"ml.outlier_score\"}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + - language: Java + code: | + client.ml().evaluateDataFrame(e -> e + .evaluation(ev -> ev + .outlierDetection(o -> o + .actualField("is_outlier") + .predictedProbabilityField("ml.outlier_score") + ) + ) + .index("my_analytics_dest_index") + ); diff --git a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml index 81818b4533..622823476d 100644 --- a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml +++ b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample4.yaml @@ -162,3 +162,32 @@ alternatives: '{\"index\":\"house_price_predictions\",\"query\":{\"bool\":{\"filter\":[{\"term\":{\"ml.is_training\":false}}]}},\"evaluation\ \":{\"regression\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\ \":{},\"msle\":{\"offset\":10},\"huber\":{\"delta\":1.5}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + - language: Java + code: | + client.ml().evaluateDataFrame(e -> e + .evaluation(ev -> ev + .regression(r -> r + .actualField("price") + .predictedField("ml.price_prediction") + .metrics(m -> m + .msle(ms -> ms + .offset(10.0D) + ) + .huber(h -> h + .delta(1.5D) + ) + ) + ) + ) + .index("house_price_predictions") + .query(q -> q + .bool(b -> b + .filter(f -> f + .term(t -> t + .field("ml.is_training") + .value(FieldValue.of(false)) + ) + ) + ) + ) + ); diff --git a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml index 186af53933..41e76dd6fc 100644 --- a/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml +++ b/specification/ml/evaluate_data_frame/examples/request/MlEvaluateDataFrameRequestExample5.yaml @@ -127,3 +127,24 @@ alternatives: '{\"index\":\"house_price_predictions\",\"query\":{\"term\":{\"ml.is_training\":{\"value\":true}}},\"evaluation\":{\"regressi\ on\":{\"actual_field\":\"price\",\"predicted_field\":\"ml.price_prediction\",\"metrics\":{\"r_squared\":{},\"mse\":{},\"msle\ \":{},\"huber\":{}}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/_evaluate\"" + - language: Java + code: | + client.ml().evaluateDataFrame(e -> e + .evaluation(ev -> ev + .regression(r -> r + .actualField("price") + .predictedField("ml.price_prediction") + .metrics(m -> m + .msle(ms -> ms) + .huber(h -> h) + ) + ) + ) + .index("house_price_predictions") + .query(q -> q + .term(t -> t + .field("ml.is_training") + .value(FieldValue.of(true)) + ) + ) + ); diff --git a/specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml b/specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml index b8ff10330c..674937a17e 100644 --- a/specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml +++ b/specification/ml/explain_data_frame_analytics/examples/request/MlExplainDataFrameAnalyticsRequestExample1.yaml @@ -66,3 +66,15 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"source":{"index":"houses_sold_last_10_yrs"},"analysis":{"regression":{"dependent_variable":"price"}}}'' "$ELASTICSEARCH_URL/_ml/data_frame/analytics/_explain"' + - language: Java + code: | + client.ml().explainDataFrameAnalytics(e -> e + .analysis(a -> a + .regression(r -> r + .dependentVariable("price") + ) + ) + .source(s -> s + .index("houses_sold_last_10_yrs") + ) + ); diff --git a/specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml b/specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml index 7a42c7c27e..076e3e7793 100644 --- a/specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml +++ b/specification/ml/flush_job/examples/request/MlFlushJobExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"calc_interim":true}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_flush"' + - language: Java + code: | + client.ml().flushJob(f -> f + .calcInterim(true) + .jobId("low_request_rate") + ); diff --git a/specification/ml/forecast/examples/request/MlForecastExample1.yaml b/specification/ml/forecast/examples/request/MlForecastExample1.yaml index 3956e3c191..281e668467 100644 --- a/specification/ml/forecast/examples/request/MlForecastExample1.yaml +++ b/specification/ml/forecast/examples/request/MlForecastExample1.yaml @@ -37,3 +37,11 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"duration":"10d"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_forecast"' + - language: Java + code: | + client.ml().forecast(f -> f + .duration(d -> d + .time("10d") + ) + .jobId("low_request_rate") + ); diff --git a/specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml b/specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml index b5a2633cde..01f7964a94 100644 --- a/specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml +++ b/specification/ml/get_buckets/examples/request/MlGetBucketsExample1.yaml @@ -43,3 +43,10 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"anomaly_score":80,"start":"1454530200001"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/buckets"' + - language: Java + code: | + client.ml().getBuckets(g -> g + .anomalyScore(80.0D) + .jobId("low_request_rate") + .start(DateTime.of("1454530200001")) + ); diff --git a/specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml b/specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml index cb284b8c13..7031b45741 100644 --- a/specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml +++ b/specification/ml/get_calendars/examples/request/MlGetCalendarsExample1.yaml @@ -22,3 +22,8 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/calendars/planned-outages"' + - language: Java + code: | + client.ml().getCalendars(g -> g + .calendarId("planned-outages") + ); diff --git a/specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml b/specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml index ea6841ca0b..3184834163 100644 --- a/specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml +++ b/specification/ml/get_categories/examples/request/MlGetCategoriesExample1.yaml @@ -47,3 +47,11 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"page":{"size":1}}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/esxi_log/results/categories"' + - language: Java + code: | + client.ml().getCategories(g -> g + .jobId("esxi_log") + .page(p -> p + .size(1) + ) + ); diff --git a/specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml b/specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml index 0db8a4ae92..5d36ade4ba 100644 --- a/specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml +++ b/specification/ml/get_influencers/examples/request/MlGetInfluencersExample1.yaml @@ -43,3 +43,8 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"sort":"influencer_score","desc":true}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/results/influencers"' + - language: Java + code: | + client.ml().getInfluencers(g -> g + .jobId("high_sum_total_sales") + ); diff --git a/specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml b/specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml index f77ce9fb44..f2b94df12c 100644 --- a/specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml +++ b/specification/ml/get_memory_stats/examples/request/MlGetMemoryStatsExample1.yaml @@ -22,3 +22,5 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/memory/_stats?human"' + - language: Java + code: "\n" diff --git a/specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml b/specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml index 0edf17ef47..d7fb910aa2 100644 --- a/specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml +++ b/specification/ml/get_model_snapshots/examples/request/MlGetModelSnapshotsExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"start":"1575402236000"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/model_snapshots"' + - language: Java + code: | + client.ml().getModelSnapshots(g -> g + .jobId("high_sum_total_sales") + .start(DateTime.of("1575402236000")) + ); diff --git a/specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml b/specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml index aa34212e8f..3fdb7c7946 100644 --- a/specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml +++ b/specification/ml/get_overall_buckets/examples/request/MlGetOverallBucketsExample1.yaml @@ -43,3 +43,10 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"overall_score":80,"start":"1403532000000"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-*/results/overall_buckets"' + - language: Java + code: | + client.ml().getOverallBuckets(g -> g + .jobId("job-*") + .overallScore("80") + .start(DateTime.of("1403532000000")) + ); diff --git a/specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml b/specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml index 56ce97b873..53aae1ce53 100644 --- a/specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml +++ b/specification/ml/get_records/examples/request/MlGetRecordsExample1.yaml @@ -48,3 +48,11 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"sort":"record_score","desc":true,"start":"1454944100000"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/results/records"' + - language: Java + code: | + client.ml().getRecords(g -> g + .desc(true) + .jobId("low_request_rate") + .sort("record_score") + .start(DateTime.of("1454944100000")) + ); diff --git a/specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml b/specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml index bf09a45ecd..b10a3fe433 100644 --- a/specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml +++ b/specification/ml/infer_trained_model/examples/request/MlInferTrainedModelExample1.yaml @@ -54,3 +54,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"docs":[{"text":"The fool doth think he is wise, but the wise man knows himself to be a fool."}]}'' "$ELASTICSEARCH_URL/_ml/trained_models/lang_ident_model_1/_infer"' + - language: Java + code: | + client.ml().inferTrainedModel(i -> i + .docs(Map.of("text", JsonData.fromJson("\"The fool doth think he is wise, but the wise man knows himself to be a fool.\""))) + .modelId("lang_ident_model_1") + ); diff --git a/specification/ml/info/examples/request/MlInfoExample1.yaml b/specification/ml/info/examples/request/MlInfoExample1.yaml index ee8002d87b..7ed33a8249 100644 --- a/specification/ml/info/examples/request/MlInfoExample1.yaml +++ b/specification/ml/info/examples/request/MlInfoExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->ml()->info(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/info"' + - language: Java + code: | + client.ml().info(); diff --git a/specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml b/specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml index 1235c16d12..2dcf513e30 100644 --- a/specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml +++ b/specification/ml/open_job/examples/request/MlOpenJobRequestExample1.yaml @@ -37,3 +37,11 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"timeout":"35m"}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01/_open"' + - language: Java + code: | + client.ml().openJob(o -> o + .jobId("job-01") + .timeout(t -> t + .time("35m") + ) + ); diff --git a/specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml b/specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml index 0a6398f6b3..c01e4e4753 100644 --- a/specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml +++ b/specification/ml/post_calendar_events/examples/request/MlPostCalendarEventsExample1.yaml @@ -107,3 +107,18 @@ alternatives: ''{"events":[{"description":"event 1","start_time":1513641600000,"end_time":1513728000000},{"description":"event 2","start_time":1513814400000,"end_time":1513900800000},{"description":"event 3","start_time":1514160000000,"end_time":1514246400000}]}'' "$ELASTICSEARCH_URL/_ml/calendars/planned-outages/events"' + - language: Java + code: | + client.ml().postCalendarEvents(p -> p + .calendarId("planned-outages") + .events(List.of(CalendarEvent.of(c -> c + .description("event 1") + .endTime(DateTime.ofEpochMilli(1513728000000L)) + .startTime(DateTime.ofEpochMilli(1513641600000L))),CalendarEvent.of(c -> c + .description("event 2") + .endTime(DateTime.ofEpochMilli(1513900800000L)) + .startTime(DateTime.ofEpochMilli(1513814400000L))),CalendarEvent.of(c -> c + .description("event 3") + .endTime(DateTime.ofEpochMilli(1514246400000L)) + .startTime(DateTime.ofEpochMilli(1514160000000L))))) + ); diff --git a/specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml b/specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml index fb46ccdb06..535e9c5a29 100644 --- a/specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml +++ b/specification/ml/preview_data_frame_analytics/examples/request/MlPreviewDataFrameAnalyticsExample1.yaml @@ -79,3 +79,17 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"config\":{\"source\":{\"index\":\"houses_sold_last_10_yrs\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"price\ \"}}}}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/_preview\"" + - language: Java + code: | + client.ml().previewDataFrameAnalytics(p -> p + .config(c -> c + .source(s -> s + .index("houses_sold_last_10_yrs") + ) + .analysis(a -> a + .regression(r -> r + .dependentVariable("price") + ) + ) + ) + ); diff --git a/specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml b/specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml index 7360494d2d..27b7fa8c00 100644 --- a/specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml +++ b/specification/ml/preview_datafeed/examples/request/MlPreviewDatafeedExample1.yaml @@ -23,3 +23,8 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-high_sum_total_sales/_preview"' + - language: Java + code: | + client.ml().previewDatafeed(p -> p + .datafeedId("datafeed-high_sum_total_sales") + ); diff --git a/specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml b/specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml index 94a77bccd2..b2cdb84a0e 100644 --- a/specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml +++ b/specification/ml/put_calendar/examples/request/MlPutCalendarExample1.yaml @@ -22,3 +22,8 @@ alternatives: ]); - language: curl code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/calendars/planned-outages"' + - language: Java + code: | + client.ml().putCalendar(p -> p + .calendarId("planned-outages") + ); diff --git a/specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml b/specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml index c6b4145f23..a6de4ea357 100644 --- a/specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml +++ b/specification/ml/put_data_frame_analytics/examples/request/MlPutDataFrameAnalyticsExample1.yaml @@ -211,3 +211,36 @@ alternatives: ield\":\"ml-results\"},\"analysis\":{\"regression\":{\"dependent_variable\":\"FlightDelayMin\",\"training_percent\":90}},\"an\ alyzed_fields\":{\"includes\":[],\"excludes\":[\"FlightNum\"]},\"model_memory_limit\":\"100mb\"}' \"$ELASTICSEARCH_URL/_ml/data_frame/analytics/model-flight-delays-pre\"" + - language: Java + code: | + client.ml().putDataFrameAnalytics(p -> p + .analysis(a -> a + .regression(r -> r + .dependentVariable("FlightDelayMin") + .trainingPercent("90") + ) + ) + .analyzedFields(an -> an + .excludes("FlightNum") + ) + .dest(d -> d + .index("df-flight-delays") + .resultsField("ml-results") + ) + .id("model-flight-delays-pre") + .modelMemoryLimit("100mb") + .source(s -> s + .index("kibana_sample_data_flights") + .query(q -> q + .range(r -> r + .untyped(u -> u + .field("DistanceKilometers") + .gt(JsonData.fromJson("0")) + ) + ) + ) + .source(so -> so + .excludes(List.of("FlightDelay","FlightDelayType")) + ) + ) + ); diff --git a/specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml b/specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml index db371b8bbd..200ffb07fb 100644 --- a/specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml +++ b/specification/ml/put_datafeed/examples/request/MlPutDatafeedExample1.yaml @@ -100,3 +100,5 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"indices":["kibana_sample_data_logs"],"query":{"bool":{"must":[{"match_all":{}}]}},"job_id":"test-job"}'' "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job?pretty"' + - language: Java + code: "\n" diff --git a/specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml b/specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml index 81aaa52d34..babb5c8d0e 100644 --- a/specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml +++ b/specification/ml/put_filter/examples/request/MlPutFilterExample1.yaml @@ -51,3 +51,10 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"description":"A list of safe domains","items":["*.google.com","wikipedia.org"]}'' "$ELASTICSEARCH_URL/_ml/filters/safe_domains"' + - language: Java + code: | + client.ml().putFilter(p -> p + .description("A list of safe domains") + .filterId("safe_domains") + .items(List.of("*.google.com","wikipedia.org")) + ); diff --git a/specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml b/specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml index 479078c1d2..def0a23668 100644 --- a/specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml +++ b/specification/ml/put_job/examples/request/MlPutJobRequestExample1.yaml @@ -243,3 +243,47 @@ alternatives: \"bool\":{\"must\":[{\"match_all\":{}}]}},\"runtime_mappings\":{\"hour_of_day\":{\"type\":\"long\",\"script\":{\"source\":\"e\ mit(doc['\"'\"'timestamp'\"'\"'].value.getHour());\"}}},\"datafeed_id\":\"datafeed-test-job1\"}}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01\"" + - language: Java + code: | + client.ml().putJob(p -> p + .analysisConfig(a -> a + .bucketSpan(b -> b + .time("15m") + ) + .detectors(d -> d + .detectorDescription("Sum of bytes") + .fieldName("bytes") + .function("sum") + ) + ) + .analysisLimits(an -> an + .modelMemoryLimit("11MB") + ) + .dataDescription(d -> d + .timeField("timestamp") + .timeFormat("epoch_ms") + ) + .datafeedConfig(d -> d + .datafeedId("datafeed-test-job1") + .indices("kibana_sample_data_logs") + .query(q -> q + .bool(b -> b + .must(m -> m + .matchAll(ma -> ma) + ) + ) + ) + .runtimeMappings("hour_of_day", r -> r + .script(s -> s + .source("emit(doc['timestamp'].value.getHour());") + ) + .type(RuntimeFieldType.Long) + ) + ) + .jobId("job-01") + .modelPlotConfig(m -> m + .annotationsEnabled(true) + .enabled(true) + ) + .resultsIndexName("test-job1") + ); diff --git a/specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml b/specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml index a10dfa0386..2b49aef59c 100644 --- a/specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml +++ b/specification/ml/put_trained_model_vocabulary/examples/request/MlPutTrainedModelVocabularyExample1.yaml @@ -50,3 +50,9 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"vocabulary":["[PAD]","[unused0]"]}'' "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary"' + - language: Java + code: | + client.ml().putTrainedModelVocabulary(p -> p + .modelId("elastic__distilbert-base-uncased-finetuned-conll03-english") + .vocabulary(List.of("[PAD]","[unused0]")) + ); diff --git a/specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml b/specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml index a1f7042288..42625ed27c 100644 --- a/specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml +++ b/specification/ml/revert_model_snapshot/examples/request/MlRevertModelSnapshotExample1.yaml @@ -42,3 +42,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"delete_intervening_results":true}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1637092688/_revert"' + - language: Java + code: | + client.ml().revertModelSnapshot(r -> r + .deleteInterveningResults(true) + .jobId("low_request_rate") + .snapshotId("1637092688") + ); diff --git a/specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml b/specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml index 6ea05f4fe7..5300ae37df 100644 --- a/specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml +++ b/specification/ml/start_datafeed/examples/request/MlStartDatafeedExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"start":"2019-04-07T18:22:16Z"}'' "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_start"' + - language: Java + code: | + client.ml().startDatafeed(s -> s + .datafeedId("datafeed-low_request_rate") + .start(DateTime.of("2019-04-07T18:22:16Z")) + ); diff --git a/specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml b/specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml index 475c98591a..332e4d4f05 100644 --- a/specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml +++ b/specification/ml/start_trained_model_deployment/examples/request/MlStartTrainedModelDeploymentExample1.yaml @@ -31,3 +31,12 @@ alternatives: - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_start?wait_for=started&timeout=1m"' + - language: Java + code: | + client.ml().startTrainedModelDeployment(s -> s + .modelId("elastic__distilbert-base-uncased-finetuned-conll03-english") + .timeout(t -> t + .offset(1) + ) + .waitFor(DeploymentAllocationState.Started) + ); diff --git a/specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml b/specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml index 4ff7e1c273..66212f8738 100644 --- a/specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml +++ b/specification/ml/stop_datafeed/examples/request/MlStopDatafeedExample1.yaml @@ -37,3 +37,11 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"timeout":"30s"}'' "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_stop"' + - language: Java + code: | + client.ml().stopDatafeed(s -> s + .datafeedId("datafeed-low_request_rate") + .timeout(t -> t + .time("30s") + ) + ); diff --git a/specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml b/specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml index b482998906..ad7cb389ae 100644 --- a/specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml +++ b/specification/ml/update_data_frame_analytics/examples/request/MlUpdateDataFrameAnalyticsExample1.yaml @@ -37,3 +37,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"model_memory_limit":"200mb"}'' "$ELASTICSEARCH_URL/_ml/data_frame/analytics/loganalytics/_update"' + - language: Java + code: | + client.ml().updateDataFrameAnalytics(u -> u + .id("loganalytics") + .modelMemoryLimit("200mb") + ); diff --git a/specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml b/specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml index 25e0a4aa64..8e9675a6ab 100644 --- a/specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml +++ b/specification/ml/update_datafeed/examples/request/MlUpdateDatafeedExample1.yaml @@ -57,3 +57,14 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"geo.src":"US"}}}'' "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-test-job/_update"' + - language: Java + code: | + client.ml().updateDatafeed(u -> u + .datafeedId("datafeed-test-job") + .query(q -> q + .term(t -> t + .field("geo.src") + .value(FieldValue.of("US")) + ) + ) + ); diff --git a/specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml b/specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml index 7b2ebb25e0..da6e3bc182 100644 --- a/specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml +++ b/specification/ml/update_filter/examples/request/MlUpdateFilterExample1.yaml @@ -60,3 +60,11 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"description":"Updated list of domains","add_items":["*.myorg.com"],"remove_items":["wikipedia.org"]}'' "$ELASTICSEARCH_URL/_ml/filters/safe_domains/_update"' + - language: Java + code: | + client.ml().updateFilter(u -> u + .addItems("*.myorg.com") + .description("Updated list of domains") + .filterId("safe_domains") + .removeItems("wikipedia.org") + ); diff --git a/specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml b/specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml index ec54074a6c..eb917fb367 100644 --- a/specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml +++ b/specification/ml/update_job/examples/request/MlUpdateJobExample1.yaml @@ -109,3 +109,23 @@ alternatives: description\"},\"groups\":[\"kibana_sample_data\",\"kibana_sample_web_logs\"],\"model_plot_config\":{\"enabled\":true},\"reno\ rmalization_window_days\":30,\"background_persist_interval\":\"2h\",\"model_snapshot_retention_days\":7,\"results_retention_d\ ays\":60}' \"$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_update\"" + - language: Java + code: | + client.ml().updateJob(u -> u + .backgroundPersistInterval(b -> b + .time("2h") + ) + .description("An updated job") + .detectors(d -> d + .detectorIndex(0) + .description("An updated detector description") + ) + .groups(List.of("kibana_sample_data","kibana_sample_web_logs")) + .jobId("low_request_rate") + .modelPlotConfig(m -> m + .enabled(true) + ) + .modelSnapshotRetentionDays(7L) + .renormalizationWindowDays(30L) + .resultsRetentionDays(60L) + ); diff --git a/specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml b/specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml index 55b5318ca8..86cf128655 100644 --- a/specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml +++ b/specification/ml/update_model_snapshot/examples/request/MlUpdateModelSnapshotExample1.yaml @@ -48,3 +48,11 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"description":"Snapshot 1","retain":true}'' "$ELASTICSEARCH_URL/_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update"' + - language: Java + code: | + client.ml().updateModelSnapshot(u -> u + .description("Snapshot 1") + .jobId("it_ops_new_logs") + .retain(true) + .snapshotId("1491852978") + ); diff --git a/specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml b/specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml index 59f2791346..f8f9d1b3fd 100644 --- a/specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml +++ b/specification/ml/update_trained_model_deployment/examples/request/MlUpdateTrainedModelDeploymentExample1.yaml @@ -39,3 +39,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"number_of_allocations":4}'' "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_update"' + - language: Java + code: | + client.ml().updateTrainedModelDeployment(u -> u + .modelId("elastic__distilbert-base-uncased-finetuned-conll03-english") + .numberOfAllocations(4) + ); diff --git a/specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml b/specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml index ad4084983b..cb82ededbe 100644 --- a/specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml +++ b/specification/nodes/reload_secure_settings/examples/request/ReloadSecureSettingsRequestExample1.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"secure_settings_password":"keystore-password"}'' "$ELASTICSEARCH_URL/_nodes/reload_secure_settings"' + - language: Java + code: | + client.nodes().reloadSecureSettings(r -> r + .secureSettingsPassword("keystore-password") + ); diff --git a/specification/nodes/stats/examples/request/NodesStatsExample1.yaml b/specification/nodes/stats/examples/request/NodesStatsExample1.yaml index 7591c512a8..678c6053bf 100644 --- a/specification/nodes/stats/examples/request/NodesStatsExample1.yaml +++ b/specification/nodes/stats/examples/request/NodesStatsExample1.yaml @@ -27,3 +27,5 @@ alternatives: - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_nodes/stats/process?filter_path=**.max_file_descriptors"' + - language: Java + code: "\n" diff --git a/specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml b/specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml index b5508d313a..4bdec267fb 100644 --- a/specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml +++ b/specification/query_rules/put_rule/examples/request/QueryRulePutRequestExample1.yaml @@ -47,3 +47,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"match_criteria":{"query_string":"puggles"}}'' "$ELASTICSEARCH_URL/_query_rules/my-ruleset/_test"' + - language: Java + code: | + client.queryRules().test(t -> t + .matchCriteria("query_string", JsonData.fromJson("\"puggles\"")) + .rulesetId("my-ruleset") + ); diff --git a/specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml b/specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml index 464b483c13..19dda02f03 100644 --- a/specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml +++ b/specification/query_rules/put_ruleset/examples/request/QueryRulesetPutRequestExample1.yaml @@ -343,3 +343,35 @@ alternatives: ery\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" + - language: Java + code: > + client.queryRules().putRuleset(p -> p + .rules(List.of(QueryRule.queryRuleOf(q -> q + .ruleId("my-rule1") + .type(QueryRuleType.Pinned) + .criteria(List.of(QueryRuleCriteria.of(qu -> qu + .type(QueryRuleCriteriaType.Contains) + .metadata("user_query") + .values(List.of(JsonData.fromJson("\"pugs\""),JsonData.fromJson("\"puggles\"")))),QueryRuleCriteria.of(qu -> qu + .type(QueryRuleCriteriaType.Exact) + .metadata("user_country") + .values(JsonData.fromJson("\"us\""))))) + .actions(a -> a + .ids(List.of("id1","id2")) + )),QueryRule.queryRuleOf(q -> q + .ruleId("my-rule2") + .type(QueryRuleType.Pinned) + .criteria(c -> c + .type(QueryRuleCriteriaType.Fuzzy) + .metadata("user_query") + .values(JsonData.fromJson("\"rescue dogs\"")) + ) + .actions(a -> a + .docs(List.of(PinnedDoc.of(pi -> pi + .id("id3") + .index("index1")),PinnedDoc.of(pi -> pi + .id("id4") + .index("index2")))) + )))) + .rulesetId("my-ruleset") + ); diff --git a/specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml b/specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml index 464b483c13..19dda02f03 100644 --- a/specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml +++ b/specification/query_rules/test/examples/request/QueryRulesetTestRequestExample1.yaml @@ -343,3 +343,35 @@ alternatives: ery\",\"values\":[\"rescue dogs\"]}],\"actions\":{\"docs\":[{\"_index\":\"index1\",\"_id\":\"id3\"},{\"_index\":\"index2\",\"_id\":\"id4\"}]}}]}' \"$ELASTICSEARCH_URL/_query_rules/my-ruleset\"" + - language: Java + code: > + client.queryRules().putRuleset(p -> p + .rules(List.of(QueryRule.queryRuleOf(q -> q + .ruleId("my-rule1") + .type(QueryRuleType.Pinned) + .criteria(List.of(QueryRuleCriteria.of(qu -> qu + .type(QueryRuleCriteriaType.Contains) + .metadata("user_query") + .values(List.of(JsonData.fromJson("\"pugs\""),JsonData.fromJson("\"puggles\"")))),QueryRuleCriteria.of(qu -> qu + .type(QueryRuleCriteriaType.Exact) + .metadata("user_country") + .values(JsonData.fromJson("\"us\""))))) + .actions(a -> a + .ids(List.of("id1","id2")) + )),QueryRule.queryRuleOf(q -> q + .ruleId("my-rule2") + .type(QueryRuleType.Pinned) + .criteria(c -> c + .type(QueryRuleCriteriaType.Fuzzy) + .metadata("user_query") + .values(JsonData.fromJson("\"rescue dogs\"")) + ) + .actions(a -> a + .docs(List.of(PinnedDoc.of(pi -> pi + .id("id3") + .index("index1")),PinnedDoc.of(pi -> pi + .id("id4") + .index("index2")))) + )))) + .rulesetId("my-ruleset") + ); diff --git a/specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml b/specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml index 3d68d621c4..ae074d9546 100644 --- a/specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml +++ b/specification/rollup/put_job/examples/request/CreateRollupJobRequestExample1.yaml @@ -209,3 +209,31 @@ alternatives: ?\",\"page_size\":1000,\"groups\":{\"date_histogram\":{\"field\":\"timestamp\",\"fixed_interval\":\"1h\",\"delay\":\"7d\"},\"\ terms\":{\"fields\":[\"node\"]}},\"metrics\":[{\"field\":\"temperature\",\"metrics\":[\"min\",\"max\",\"sum\"]},{\"field\":\"\ voltage\",\"metrics\":[\"avg\"]}]}' \"$ELASTICSEARCH_URL/_rollup/job/sensor\"" + - language: Java + code: | + client.rollup().putJob(p -> p + .cron("*/30 * * * * ?") + .groups(g -> g + .dateHistogram(d -> d + .delay(de -> de + .time("7d") + ) + .field("timestamp") + .fixedInterval(f -> f + .time("1h") + ) + ) + .terms(t -> t + .fields("node") + ) + ) + .id("sensor") + .indexPattern("sensor-*") + .metrics(List.of(FieldMetric.of(f -> f + .field("temperature") + .metrics(List.of(Metric.Min,Metric.Max,Metric.Sum))),FieldMetric.of(f -> f + .field("voltage") + .metrics(Metric.Avg)))) + .pageSize(1000) + .rollupIndex("sensor_rollup") + ); diff --git a/specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml b/specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml index 05627d44ed..75d049026f 100644 --- a/specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml +++ b/specification/rollup/rollup_search/examples/request/RollupSearchRequestExample1.yaml @@ -83,3 +83,14 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"size":0,"aggregations":{"max_temperature":{"max":{"field":"temperature"}}}}'' "$ELASTICSEARCH_URL/sensor_rollup/_rollup_search"' + - language: Java + code: | + client.rollup().rollupSearch(r -> r + .aggregations("max_temperature", a -> a + .max(m -> m + .field("temperature") + ) + ) + .index("sensor_rollup") + .size(0) + ); diff --git a/specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml b/specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml index 44eab8d221..415f7b0d27 100644 --- a/specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml +++ b/specification/search_application/post_behavioral_analytics_event/examples/request/BehavioralAnalyticsEventPostRequestExample1.yaml @@ -216,3 +216,10 @@ alternatives: term\",\"results\":{\"items\":[{\"document\":{\"id\":\"123\",\"index\":\"products\"}}],\"total_results\":10},\"sort\":{\"name\ \":\"relevance\"},\"search_application\":\"website\"},\"document\":{\"id\":\"123\",\"index\":\"products\"}}' \"$ELASTICSEARCH_URL/_application/analytics/my_analytics_collection/event/search_click\"" + - language: Java + code: > + client.searchApplication().postBehavioralAnalyticsEvent(p -> p + .collectionName("my_analytics_collection") + .eventType(EventType.SearchClick) + .payload(JsonData.fromJson("{\"session\":{\"id\":\"1797ca95-91c9-4e2e-b1bd-9c38e6f386a9\"},\"user\":{\"id\":\"5f26f01a-bbee-4202-9298-81261067abbd\"},\"search\":{\"query\":\"search term\",\"results\":{\"items\":[{\"document\":{\"id\":\"123\",\"index\":\"products\"}}],\"total_results\":10},\"sort\":{\"name\":\"relevance\"},\"search_application\":\"website\"},\"document\":{\"id\":\"123\",\"index\":\"products\"}}")) + ); diff --git a/specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml b/specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml index a2ae24efca..97426feaea 100644 --- a/specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml +++ b/specification/search_application/render_query/examples/request/SearchApplicationsRenderQueryRequestExample1.yaml @@ -95,3 +95,9 @@ alternatives: ''{"params":{"query_string":"my first query","text_fields":[{"name":"title","boost":5},{"name":"description","boost":1}]}}'' "$ELASTICSEARCH_URL/_application/search_application/my-app/_render_query"' + - language: Java + code: > + client.searchApplication().renderQuery(r -> r + .name("my-app") + .params(Map.of("text_fields", JsonData.fromJson("[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]"),"query_string", JsonData.fromJson("\"my first query\""))) + ); diff --git a/specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml b/specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml index bd0d9c9ca1..76d100b7b4 100644 --- a/specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml +++ b/specification/search_application/search/examples/request/SearchApplicationsSearchRequestExample1.yaml @@ -104,3 +104,9 @@ alternatives: ''{"params":{"query_string":"my first query","text_fields":[{"name":"title","boost":5},{"name":"description","boost":1}]}}'' "$ELASTICSEARCH_URL/_application/search_application/my-app/_search"' + - language: Java + code: > + client.searchApplication().search(s -> s + .name("my-app") + .params(Map.of("text_fields", JsonData.fromJson("[{\"name\":\"title\",\"boost\":5},{\"name\":\"description\",\"boost\":1}]"),"query_string", JsonData.fromJson("\"my first query\""))) + ); diff --git a/specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml b/specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml index faf64ee70a..e87ec14a2c 100644 --- a/specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml +++ b/specification/searchable_snapshots/mount/examples/request/SearchableSnapshotsMountSnapshotRequestExample1.yaml @@ -87,3 +87,14 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"index\":\"my_docs\",\"renamed_index\":\"docs\",\"index_settings\":{\"index.number_of_replicas\":0},\"ignore_index_settings\ \":[\"index.refresh_interval\"]}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/my_snapshot/_mount?wait_for_completion=true\"" + - language: Java + code: | + client.searchableSnapshots().mount(m -> m + .ignoreIndexSettings("index.refresh_interval") + .index("my_docs") + .indexSettings("index.number_of_replicas", JsonData.fromJson("0")) + .renamedIndex("docs") + .repository("my_repository") + .snapshot("my_snapshot") + .waitForCompletion(true) + ); diff --git a/specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml b/specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml index 558658b064..f36dfcec8e 100644 --- a/specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml +++ b/specification/security/activate_user_profile/examples/request/ActivateUserProfileRequestExample1.yaml @@ -47,3 +47,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"grant_type":"password","username":"jacknich","password":"l0ng-r4nd0m-p@ssw0rd"}'' "$ELASTICSEARCH_URL/_security/profile/_activate"' + - language: Java + code: | + client.security().activateUserProfile(a -> a + .grantType(GrantType.Password) + .password("l0ng-r4nd0m-p@ssw0rd") + .username("jacknich") + ); diff --git a/specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml b/specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml index 6cf3ecee12..d5a3393892 100644 --- a/specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml +++ b/specification/security/authenticate/examples/request/SecurityAuthenticateRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->security()->authenticate(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_security/_authenticate"' + - language: Java + code: | + client.security().authenticate(); diff --git a/specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml b/specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml index 11c4558937..d8914050e4 100644 --- a/specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml +++ b/specification/security/bulk_delete_role/examples/request/SecurityBulkDeleteRoleRequestExample1.yaml @@ -45,3 +45,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"names":["my_admin_role","my_user_role"]}'' "$ELASTICSEARCH_URL/_security/role"' + - language: Java + code: | + client.security().bulkDeleteRole(b -> b + .names(List.of("my_admin_role","my_user_role")) + ); diff --git a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml index ca4d99991a..13fb34b351 100644 --- a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml +++ b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample1.yaml @@ -420,3 +420,50 @@ alternatives: {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"\ run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" + - language: Java + code: | + client.security().bulkPutRole(b -> b + .roles(Map.of("my_admin_role", RoleDescriptor.of(r -> r + .cluster("all") + .indices(i -> i + .fieldSecurity(f -> f + .grant(List.of("title","body")) + ) + .names(List.of("index1","index2")) + .privileges("all") + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("foo")) + ) + ) + ) + .applications(a -> a + .application("myapp") + .privileges(List.of("admin","read")) + .resources("*") + ) + .metadata("version", JsonData.fromJson("1")) + .runAs("other_user")),"my_user_role", RoleDescriptor.of(ro -> ro + .cluster("all") + .indices(i -> i + .fieldSecurity(f -> f + .grant(List.of("title","body")) + ) + .names("index1") + .privileges("read") + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("foo")) + ) + ) + ) + .applications(a -> a + .application("myapp") + .privileges(List.of("admin","read")) + .resources("*") + ) + .metadata("version", JsonData.fromJson("1")) + .runAs("other_user")))) + ); diff --git a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml index 7c44276294..c9900bd3f4 100644 --- a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml +++ b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample2.yaml @@ -420,3 +420,50 @@ alternatives: {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"\ run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}}}' \"$ELASTICSEARCH_URL/_security/role\"" + - language: Java + code: | + client.security().bulkPutRole(b -> b + .roles(Map.of("my_admin_role", RoleDescriptor.of(r -> r + .cluster("bad_cluster_privilege") + .indices(i -> i + .fieldSecurity(f -> f + .grant(List.of("title","body")) + ) + .names(List.of("index1","index2")) + .privileges("all") + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("foo")) + ) + ) + ) + .applications(a -> a + .application("myapp") + .privileges(List.of("admin","read")) + .resources("*") + ) + .metadata("version", JsonData.fromJson("1")) + .runAs("other_user")),"my_user_role", RoleDescriptor.of(ro -> ro + .cluster("all") + .indices(i -> i + .fieldSecurity(f -> f + .grant(List.of("title","body")) + ) + .names("index1") + .privileges("read") + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("foo")) + ) + ) + ) + .applications(a -> a + .application("myapp") + .privileges(List.of("admin","read")) + .resources("*") + ) + .metadata("version", JsonData.fromJson("1")) + .runAs("other_user")))) + ); diff --git a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml index d4d3100d2a..d9eb94eb0e 100644 --- a/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml +++ b/specification/security/bulk_put_role/examples/request/SecurityBulkPutRoleRequestExample3.yaml @@ -139,3 +139,17 @@ alternatives: '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"v\ iew_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" + - language: Java + code: | + client.security().putRole(p -> p + .name("only_remote_access_role") + .remoteCluster(r -> r + .clusters("my_remote") + .privileges(RemoteClusterPrivilege.MonitorStats) + ) + .remoteIndices(r -> r + .clusters("my_remote") + .names("logs*") + .privileges(List.of("read","read_cross_cluster","view_index_metadata")) + ) + ); diff --git a/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml b/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml index 42f565b009..a8c91131a9 100644 --- a/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml +++ b/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample1.yaml @@ -151,3 +151,18 @@ alternatives: '{\"ids\":[\"VuaCfGcBCdbkQm-e5aOx\",\"H3_AhoIBA9hmeQJdg7ij\"],\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\ \"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}},\"\ expiration\":\"30d\"}' \"$ELASTICSEARCH_URL/_security/api_key/_bulk_update\"" + - language: Java + code: | + client.security().bulkUpdateApiKeys(b -> b + .expiration(e -> e + .time("30d") + ) + .ids(List.of("VuaCfGcBCdbkQm-e5aOx","H3_AhoIBA9hmeQJdg7ij")) + .metadata("environment", JsonData.fromJson("{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}")) + .roleDescriptors("role-a", r -> r + .indices(i -> i + .names("*") + .privileges("write") + ) + ) + ); diff --git a/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml b/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml index 30285fde0b..2f37d7db5d 100644 --- a/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml +++ b/specification/security/bulk_update_api_keys/examples/request/SecurityBulkUpdateApiKeysRequestExample2.yaml @@ -51,3 +51,8 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"ids":["VuaCfGcBCdbkQm-e5aOx","H3_AhoIBA9hmeQJdg7ij"],"role_descriptors":{}}'' "$ELASTICSEARCH_URL/_security/api_key/_bulk_update"' + - language: Java + code: | + client.security().bulkUpdateApiKeys(b -> b + .ids(List.of("VuaCfGcBCdbkQm-e5aOx","H3_AhoIBA9hmeQJdg7ij")) + ); diff --git a/specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml b/specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml index 4a9a9c7259..742dca7bba 100644 --- a/specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml +++ b/specification/security/change_password/examples/request/SecurityChangePasswordRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"password":"new-test-password"}'' "$ELASTICSEARCH_URL/_security/user/jacknich/_password"' + - language: Java + code: | + client.security().changePassword(c -> c + .password("new-test-password") + .username("jacknich") + ); diff --git a/specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml b/specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml index 3c2fae4ea6..5a923a382b 100644 --- a/specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml +++ b/specification/security/create_api_key/examples/request/SecurityCreateApiKeyRequestExample1.yaml @@ -230,3 +230,23 @@ alternatives: \":[\"index-a*\"],\"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"pri\ vileges\":[\"all\"]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\ \":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key\"" + - language: Java + code: > + client.security().createApiKey(c -> c + .expiration(e -> e + .time("1d") + ) + .metadata(Map.of("environment", JsonData.fromJson("{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}"),"application", JsonData.fromJson("\"my-application\""))) + .name("my-api-key") + .roleDescriptors(Map.of("role-b", RoleDescriptor.of(r -> r + .cluster("all") + .indices(i -> i + .names("index-b*") + .privileges("all") + )),"role-a", RoleDescriptor.of(r -> r + .cluster("all") + .indices(i -> i + .names("index-a*") + .privileges("read") + )))) + ); diff --git a/specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml b/specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml index 399b3e5c3c..703024bea3 100644 --- a/specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml +++ b/specification/security/create_cross_cluster_api_key/examples/request/CreateCrossClusterApiKeyRequestExample1.yaml @@ -165,3 +165,20 @@ alternatives: \":[{\"names\":[\"archive*\"]}]},\"metadata\":{\"description\":\"phase one\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}}}' \"$ELASTICSEARCH_URL/_security/cross_cluster/api_key\"" + - language: Java + code: > + client.security().createCrossClusterApiKey(c -> c + .access(a -> a + .replication(r -> r + .names("archive*") + ) + .search(s -> s + .names("logs*") + ) + ) + .expiration(e -> e + .time("1d") + ) + .metadata(Map.of("environment", JsonData.fromJson("{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}"),"description", JsonData.fromJson("\"phase one\""))) + .name("my-cross-cluster-api-key") + ); diff --git a/specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml b/specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml index b9d64ec944..f6e6fa973f 100644 --- a/specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml +++ b/specification/security/delegate_pki/examples/request/SecurityDelegatePkiRequestExample1.yaml @@ -91,3 +91,8 @@ alternatives: 9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD\ 1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==\"]}' \"$ELASTICSEARCH_URL/_security/delegate_pki\"" + - language: Java + code: > + client.security().delegatePki(d -> d + .x509CertificateChain("MIIDeDCCAmCgAwIBAgIUBzj/nGGKxP2iXawsSquHmQjCJmMwDQYJKoZIhvcNAQELBQAwUzErMCkGA1UEAxMiRWxhc3RpY3NlYXJjaCBUZXN0IEludGVybWVkaWF0ZSBDQTEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMB4XDTIzMDcxODE5MjkwNloXDTQzMDcxMzE5MjkwNlowSjEiMCAGA1UEAxMZRWxhc3RpY3NlYXJjaCBUZXN0IENsaWVudDEWMBQGA1UECxMNRWxhc3RpY3NlYXJjaDEMMAoGA1UEChMDb3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAllHL4pQkkfwAm/oLkxYYO+r950DEy1bjH+4viCHzNADLCTWO+lOZJVlNx7QEzJE3QGMdif9CCBBxQFMapA7oUFCLq84fPSQQu5AnvvbltVD9nwVtCs+9ZGDjMKsz98RhSLMFIkxdxi6HkQ3Lfa4ZSI4lvba4oo+T/GveazBDS+NgmKyq00EOXt3tWi1G9vEVItommzXWfv0agJWzVnLMldwkPqsw0W7zrpyT7FZS4iLbQADGceOW8fiauOGMkscu9zAnDR/SbWl/chYioQOdw6ndFLn1YIFPd37xL0WsdsldTpn0vH3YfzgLMffT/3P6YlwBegWzsx6FnM/93Ecb4wIDAQABo00wSzAJBgNVHRMEAjAAMB0GA1UdDgQWBBQKNRwjW+Ad/FN1Rpoqme/5+jrFWzAfBgNVHSMEGDAWgBRcya0c0x/PaI7MbmJVIylWgLqXNjANBgkqhkiG9w0BAQsFAAOCAQEACZ3PF7Uqu47lplXHP6YlzYL2jL0D28hpj5lGtdha4Muw1m/BjDb0Pu8l0NQ1z3AP6AVcvjNDkQq6Y5jeSz0bwQlealQpYfo7EMXjOidrft1GbqOMFmTBLpLA9SvwYGobSTXWTkJzonqVaTcf80HpMgM2uEhodwTcvz6v1WEfeT/HMjmdIsq4ImrOL9RNrcZG6nWfw0HR3JNOgrbfyEztEI471jHznZ336OEcyX7gQuvHE8tOv5+oD1d7s3Xg1yuFp+Ynh+FfOi3hPCuaHA+7F6fLmzMDLVUBAllugst1C3U+L/paD7tqIa4ka+KNPCbSfwazmJrt4XNiivPR4hwH5g==") + ); diff --git a/specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml b/specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml index d94e1f905b..e1c5a346f7 100644 --- a/specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml +++ b/specification/security/enroll_kibana/examples/request/EnrollKibanaRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->security()->enrollKibana(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_security/enroll/kibana"' + - language: Java + code: | + client.security().enrollKibana(); diff --git a/specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml b/specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml index 4a101265d1..0b7e107530 100644 --- a/specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml +++ b/specification/security/get_builtin_privileges/examples/request/SecurityGetBuiltinPrivilegesRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->security()->getBuiltinPrivileges(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_security/privilege/_builtin"' + - language: Java + code: | + client.security().getBuiltinPrivileges(); diff --git a/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml b/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml index 37105f9ee4..ebb4b9f89a 100644 --- a/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml +++ b/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample1.yaml @@ -37,3 +37,8 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"grant_type":"client_credentials"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().getToken(g -> g + .grantType(AccessTokenGrantType.ClientCredentials) + ); diff --git a/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml b/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml index a3d59e66f6..b33982cd33 100644 --- a/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml +++ b/specification/security/get_token/examples/request/GetUserAccessTokenRequestExample2.yaml @@ -49,3 +49,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"grant_type":"password","username":"test_admin","password":"x-pack-test-password"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().getToken(g -> g + .grantType(AccessTokenGrantType.Password) + .password("x-pack-test-password") + .username("test_admin") + ); diff --git a/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml b/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml index b7d5818558..b1e119fe2e 100644 --- a/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml +++ b/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample1.yaml @@ -255,3 +255,28 @@ alternatives: \"privileges\":[\"read\"]}]},\"role-b\":{\"cluster\":[\"all\"],\"indices\":[{\"names\":[\"index-b*\"],\"privileges\":[\"all\"\ ]}]}},\"metadata\":{\"application\":\"my-application\",\"environment\":{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"stag\ ing\"]}}}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" + - language: Java + code: > + client.security().grantApiKey(g -> g + .apiKey(a -> a + .name("my-api-key") + .expiration(e -> e + .time("1d") + ) + .roleDescriptors(Map.of("role-b", RoleDescriptor.of(r -> r + .cluster("all") + .indices(i -> i + .names("index-b*") + .privileges("all") + )),"role-a", RoleDescriptor.of(r -> r + .cluster("all") + .indices(i -> i + .names("index-a*") + .privileges("read") + )))) + .metadata(Map.of("environment", JsonData.fromJson("{\"level\":1,\"trusted\":true,\"tags\":[\"dev\",\"staging\"]}"),"application", JsonData.fromJson("\"my-application\""))) + ) + .grantType(ApiKeyGrantType.Password) + .password("x-pack-test-password") + .username("test_admin") + ); diff --git a/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml b/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml index a7e3ba5abd..eb6ea7c222 100644 --- a/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml +++ b/specification/security/grant_api_key/examples/request/SecurityGrantApiKeyRequestExample2.yaml @@ -68,3 +68,14 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"grant_type\":\"password\",\"username\":\"test_admin\",\"password\":\"x-pack-test-password\",\"run_as\":\"test_user\",\"ap\ i_key\":{\"name\":\"another-api-key\"}}' \"$ELASTICSEARCH_URL/_security/api_key/grant\"" + - language: Java + code: | + client.security().grantApiKey(g -> g + .apiKey(a -> a + .name("another-api-key") + ) + .grantType(ApiKeyGrantType.Password) + .password("x-pack-test-password") + .runAs("test_user") + .username("test_admin") + ); diff --git a/specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml b/specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml index cb6ff1eeaa..ce8bcfc7a8 100644 --- a/specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml +++ b/specification/security/has_privileges/examples/request/SecurityHasPrivilegesRequestExample1.yaml @@ -179,3 +179,18 @@ alternatives: \":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"application\":[{\"application\":\"inventory_manager\",\"privileges\ \":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/1852563\"]}]}' \"$ELASTICSEARCH_URL/_security/user/_has_privileges\"" + - language: Java + code: | + client.security().hasPrivileges(h -> h + .application(a -> a + .application("inventory_manager") + .privileges(List.of("read","data:write/inventory")) + .resources("product/1852563") + ) + .cluster(List.of("monitor","manage")) + .index(List.of(IndexPrivilegesCheck.of(i -> i + .names(List.of("suppliers","products")) + .privileges("read")),IndexPrivilegesCheck.of(i -> i + .names("inventory") + .privileges(List.of("read","write"))))) + ); diff --git a/specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml b/specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml index 85f9d53e1a..ac947427f8 100644 --- a/specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml +++ b/specification/security/has_privileges_user_profile/examples/request/HasPrivilegesUserProfileRequestExample1.yaml @@ -218,3 +218,21 @@ alternatives: \",\"products\"],\"privileges\":[\"create_doc\"]},{\"names\":[\"inventory\"],\"privileges\":[\"read\",\"write\"]}],\"applicat\ ion\":[{\"application\":\"inventory_manager\",\"privileges\":[\"read\",\"data:write/inventory\"],\"resources\":[\"product/185\ 2563\"]}]}}' \"$ELASTICSEARCH_URL/_security/profile/_has_privileges\"" + - language: Java + code: > + client.security().hasPrivilegesUserProfile(h -> h + .privileges(p -> p + .application(a -> a + .application("inventory_manager") + .privileges(List.of("read","data:write/inventory")) + .resources("product/1852563") + ) + .cluster(List.of("monitor","create_snapshot","manage_ml")) + .index(List.of(IndexPrivilegesCheck.of(i -> i + .names(List.of("suppliers","products")) + .privileges("create_doc")),IndexPrivilegesCheck.of(i -> i + .names("inventory") + .privileges(List.of("read","write"))))) + ) + .uids(List.of("u_LQPnxDxEjIH0GOUoFkZr5Y57YUwSkL9Joiq-g4OCbPc_0","u_rzRnxDgEHIH0GOUoFkZr5Y27YUwSk19Joiq=g4OCxxB_1","u_does-not-exist_0")) + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml index f76c3cb92c..876c5a2e1f 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample1.yaml @@ -41,3 +41,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"ids":["VuaCfGcBCdbkQm-e5aOx"]}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .ids("VuaCfGcBCdbkQm-e5aOx") + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml index d2d0282f9a..38f30b5781 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample2.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"name":"my-api-key"}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .name("my-api-key") + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml index 1417d399b9..e0a9f45d98 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample3.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"realm_name":"native1"}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .realmName("native1") + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml index 3cc518865a..bf032bf505 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample4.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"username":"myuser"}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .username("myuser") + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml index 0e81676efc..59da02e605 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample5.yaml @@ -46,3 +46,9 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"ids":["VuaCfGcBCdbkQm-e5aOx"],"owner":"true"}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .ids("VuaCfGcBCdbkQm-e5aOx") + .owner(true) + ); diff --git a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml index 8f3617d64e..4e1ca7a69b 100644 --- a/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml +++ b/specification/security/invalidate_api_key/examples/request/SecurityInvalidateApiKeyRequestExample6.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"username":"myuser","realm_name":"native1"}'' "$ELASTICSEARCH_URL/_security/api_key"' + - language: Java + code: | + client.security().invalidateApiKey(i -> i + .realmName("native1") + .username("myuser") + ); diff --git a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml index 31e2282815..03a3377aab 100644 --- a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml +++ b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample1.yaml @@ -38,3 +38,8 @@ alternatives: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"token":"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ=="}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().invalidateToken(i -> i + .token("dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==") + ); diff --git a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml index 29ecda455d..4178e2ad85 100644 --- a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml +++ b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample2.yaml @@ -36,3 +36,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"refresh_token":"vLBPvmAB6KvwvJZr27cS"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().invalidateToken(i -> i + .refreshToken("vLBPvmAB6KvwvJZr27cS") + ); diff --git a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml index 3d6f386897..56be7892b4 100644 --- a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml +++ b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample3.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"realm_name":"saml1"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().invalidateToken(i -> i + .realmName("saml1") + ); diff --git a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml index 5c30fbbd27..394b3fe35b 100644 --- a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml +++ b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample4.yaml @@ -35,3 +35,8 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"username":"myuser"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().invalidateToken(i -> i + .username("myuser") + ); diff --git a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml index a23798d23f..22096cc198 100644 --- a/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml +++ b/specification/security/invalidate_token/examples/request/SecurityInvalidateTokenRequestExample5.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X DELETE -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"username":"myuser","realm_name":"saml1"}'' "$ELASTICSEARCH_URL/_security/oauth2/token"' + - language: Java + code: | + client.security().invalidateToken(i -> i + .realmName("saml1") + .username("myuser") + ); diff --git a/specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml b/specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml index c384c4207b..f992ece613 100644 --- a/specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml +++ b/specification/security/oidc_authenticate/examples/request/OidcAuthenticateRequestExample1.yaml @@ -56,3 +56,11 @@ alternatives: '{\"redirect_uri\":\"https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIA\ t3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"state\":\"4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I\",\"nonce\":\"WaBPH0KqPVdG5HHdSx\ PRjfoZbXMCicm5v1OiAj0DUFM\",\"realm\":\"oidc1\"}' \"$ELASTICSEARCH_URL/_security/oidc/authenticate\"" + - language: Java + code: > + client.security().oidcAuthenticate(o -> o + .nonce("WaBPH0KqPVdG5HHdSxPRjfoZbXMCicm5v1OiAj0DUFM") + .realm("oidc1") + .redirectUri("https://oidc-kibana.elastic.co:5603/api/security/oidc/callback?code=jtI3Ntt8v3_XvcLzCFGq&state=4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I") + .state("4dbrihtIAt3wBTwo6DxK-vdk-sSyDBV8Yf0AjdkdT5I") + ); diff --git a/specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml b/specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml index a7f378c83c..e845727c8e 100644 --- a/specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml +++ b/specification/security/oidc_logout/examples/request/OidcLogoutRequestExample1.yaml @@ -42,3 +42,9 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"token\":\"dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==\",\"re\ fresh_token\":\"vLBPvmAB6KvwvJZr27cS\"}' \"$ELASTICSEARCH_URL/_security/oidc/logout\"" + - language: Java + code: | + client.security().oidcLogout(o -> o + .refreshToken("vLBPvmAB6KvwvJZr27cS") + .token("dGhpcyBpcyBub3QgYSByZWFsIHRva2VuIGJ1dCBpdCBpcyBvbmx5IHRlc3QgZGF0YS4gZG8gbm90IHRyeSB0byByZWFkIHRva2VuIQ==") + ); diff --git a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml index e0a4568ffb..9c23cb51f5 100644 --- a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml +++ b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample1.yaml @@ -36,3 +36,8 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"realm":"oidc1"}'' "$ELASTICSEARCH_URL/_security/oidc/prepare"' + - language: Java + code: | + client.security().oidcPrepareAuthentication(o -> o + .realm("oidc1") + ); diff --git a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml index 9d32573994..e07f48c4ec 100644 --- a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml +++ b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample2.yaml @@ -48,3 +48,10 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"realm\":\"oidc1\",\"state\":\"lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO\",\"nonce\":\"zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvlu\ YhZ5\"}' \"$ELASTICSEARCH_URL/_security/oidc/prepare\"" + - language: Java + code: | + client.security().oidcPrepareAuthentication(o -> o + .nonce("zOBXLJGUooRrbLbQk5YCcyC8AXw3iloynvluYhZ5") + .realm("oidc1") + .state("lGYK0EcSLjqH6pkT5EVZjC6eIW5YCGgywj2sxROO") + ); diff --git a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml index d4518d61f9..91b15b4f9d 100644 --- a/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml +++ b/specification/security/oidc_prepare_authentication/examples/request/OidcPrepareAuthenticationRequestExample3.yaml @@ -43,3 +43,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"iss":"http://127.0.0.1:8080","login_hint":"this_is_an_opaque_string"}'' "$ELASTICSEARCH_URL/_security/oidc/prepare"' + - language: Java + code: | + client.security().oidcPrepareAuthentication(o -> o + .iss("http://127.0.0.1:8080") + .loginHint("this_is_an_opaque_string") + ); diff --git a/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml b/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml index 3805b1d904..79ada2eea4 100644 --- a/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml +++ b/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample1.yaml @@ -90,3 +90,11 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"myapp":{"read":{"actions":["data:read/*","action:login"],"metadata":{"description":"Read access to myapp"}}}}'' "$ELASTICSEARCH_URL/_security/privilege"' + - language: Java + code: | + client.security().putPrivileges(p -> p + .privileges("myapp", "read", pr -> pr + .actions(List.of("data:read/*","action:login")) + .metadata("description", JsonData.fromJson("\"Read access to myapp\"")) + ) + ); diff --git a/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml b/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml index 1e961adaf0..647b36f6e6 100644 --- a/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml +++ b/specification/security/put_privileges/examples/request/SecurityPutPrivilegesRequestExample2.yaml @@ -125,3 +125,11 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"app01\":{\"read\":{\"actions\":[\"action:login\",\"data:read/*\"]},\"write\":{\"actions\":[\"action:login\",\"data:write/*\ \"]}},\"app02\":{\"all\":{\"actions\":[\"*\"]}}}' \"$ELASTICSEARCH_URL/_security/privilege\"" + - language: Java + code: | + client.security().putPrivileges(p -> p + .privileges(Map.of("app02", "all", pr -> pr + .actions("*"),"app01", Map.of("read", Actions.of(a -> a + .actions(List.of("action:login","data:read/*"))),"write", Actions.of(a -> a + .actions(List.of("action:login","data:write/*")))))) + ); diff --git a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml index 2488f685ae..428adb69ab 100644 --- a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml +++ b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample1.yaml @@ -205,3 +205,30 @@ alternatives: \"grant\":[\"title\",\"body\"]},\"query\":\"{\\\"match\\\": {\\\"title\\\": \\\"foo\\\"}}\"}],\"applications\":[{\"application\":\"myapp\",\"privileges\":[\"admin\",\"read\"],\"resources\":[\"*\"]}],\"\ run_as\":[\"other_user\"],\"metadata\":{\"version\":1}}' \"$ELASTICSEARCH_URL/_security/role/my_admin_role\"" + - language: Java + code: | + client.security().putRole(p -> p + .applications(a -> a + .application("myapp") + .privileges(List.of("admin","read")) + .resources("*") + ) + .cluster("all") + .description("Grants full access to all management features within the cluster.") + .indices(i -> i + .fieldSecurity(f -> f + .grant(List.of("title","body")) + ) + .names(List.of("index1","index2")) + .privileges("all") + .query(q -> q + .match(m -> m + .field("title") + .query(FieldValue.of("foo")) + ) + ) + ) + .metadata("version", JsonData.fromJson("1")) + .name("my_admin_role") + .runAs("other_user") + ); diff --git a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml index 92375913ff..2c278e2b53 100644 --- a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml +++ b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample2.yaml @@ -91,3 +91,13 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cluster\":[\"cluster:monitor/main\"],\"indices\":[{\"names\":[\"test\"],\"privileges\":[\"read\",\"indices:admin/get\"]}]\ }' \"$ELASTICSEARCH_URL/_security/role/cli_or_drivers_minimal\"" + - language: Java + code: | + client.security().putRole(p -> p + .cluster("cluster:monitor/main") + .indices(i -> i + .names("test") + .privileges(List.of("read","indices:admin/get")) + ) + .name("cli_or_drivers_minimal") + ); diff --git a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml index d4d3100d2a..d9eb94eb0e 100644 --- a/specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml +++ b/specification/security/put_role/examples/request/SecurityPutRoleRequestExample3.yaml @@ -139,3 +139,17 @@ alternatives: '{\"remote_indices\":[{\"clusters\":[\"my_remote\"],\"names\":[\"logs*\"],\"privileges\":[\"read\",\"read_cross_cluster\",\"v\ iew_index_metadata\"]}],\"remote_cluster\":[{\"clusters\":[\"my_remote\"],\"privileges\":[\"monitor_stats\"]}]}' \"$ELASTICSEARCH_URL/_security/role/only_remote_access_role\"" + - language: Java + code: | + client.security().putRole(p -> p + .name("only_remote_access_role") + .remoteCluster(r -> r + .clusters("my_remote") + .privileges(RemoteClusterPrivilege.MonitorStats) + ) + .remoteIndices(r -> r + .clusters("my_remote") + .names("logs*") + .privileges(List.of("read","read_cross_cluster","view_index_metadata")) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml index 6856069214..02c2944668 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample1.yaml @@ -90,3 +90,16 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"roles":["user"],"enabled":true,"rules":{"field":{"username":"*"}},"metadata":{"version":1}}'' "$ELASTICSEARCH_URL/_security/role_mapping/mapping1"' + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .metadata("version", JsonData.fromJson("1")) + .name("mapping1") + .roles("user") + .rules(r -> r + .field(f -> f + .username("*") + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml index 9461487455..254698022c 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample2.yaml @@ -87,3 +87,15 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"roles":["user","admin"],"enabled":true,"rules":{"field":{"username":["esadmin01","esadmin02"]}}}'' "$ELASTICSEARCH_URL/_security/role_mapping/mapping2"' + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping2") + .roles(List.of("user","admin")) + .rules(r -> r + .field(f -> f + .username(List.of("esadmin01","esadmin02")) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml index 43f2d08044..4eb34b3d8d 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample3.yaml @@ -75,3 +75,15 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"roles":["ldap-user"],"enabled":true,"rules":{"field":{"realm.name":"ldap1"}}}'' "$ELASTICSEARCH_URL/_security/role_mapping/mapping3"' + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping3") + .roles("ldap-user") + .rules(r -> r + .field(f -> f + ._Custom(JsonData.fromJson("\"ldap1\"")) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml index 34f256f667..d0986c0443 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample4.yaml @@ -125,3 +125,19 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"any\":[{\"field\":{\"username\":\"esadmin\"}},{\"field\":{\"groups\ \":\"cn=admins,dc=example,dc=com\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping4\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping4") + .roles("superuser") + .rules(r -> r + .any(List.of(RoleMappingRule.of(ro -> ro + .field(NamedValue.of("username",List.of(FieldValue.of("esadmin")) + ))), RoleMappingRule.of(rol -> rol + .field(NamedValue.of("groups",List.of(FieldValue.of("cn=admins,dc=example,dc=com")) + ))) + ) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml index 9a6993a6e9..8826e23ac5 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample5.yaml @@ -103,3 +103,20 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\ \"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping5\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping5") + .roleTemplates(r -> r + .format(TemplateFormat.Json) + .template(t -> t + .source("{{#tojson}}groups{{/tojson}}") + ) + ) + .rules(r -> r + .field(f -> f + ._Custom(JsonData.fromJson("\"saml1\"")) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml index 3fe8c33a3e..ab94bb7c4e 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample6.yaml @@ -112,3 +112,20 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_templates\":[{\"template\":{\"source\":\"{{#tojson}}groups{{/tojson}}\"},\"format\":\"json\"}],\"rules\":{\"field\":{\ \"realm.name\":\"saml1\"}},\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping6\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping6") + .roleTemplates(r -> r + .format(TemplateFormat.Json) + .template(t -> t + .source("{{#tojson}}groups{{/tojson}}") + ) + ) + .rules(r -> r + .field(f -> f + ._Custom(JsonData.fromJson("\"saml1\"")) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml index c5c9d32bc1..68065aad06 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample7.yaml @@ -114,3 +114,19 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"roles\":[\"ldap-example-user\"],\"enabled\":true,\"rules\":{\"all\":[{\"field\":{\"dn\":\"*,ou=subtree,dc=example,dc=com\ \"}},{\"field\":{\"realm.name\":\"ldap1\"}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping7\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping7") + .roles("ldap-example-user") + .rules(r -> r + .all(List.of(RoleMappingRule.of(ro -> ro + .field(NamedValue.of("dn",List.of(FieldValue.of("*,ou=subtree,dc=example,dc=com")) + ))), RoleMappingRule.of(rol -> rol + .field(NamedValue.of("realm.name",List.of(FieldValue.of("ldap1")) + ))) + ) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml index 4743124637..b536b8f441 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample8.yaml @@ -215,3 +215,33 @@ alternatives: '{\"roles\":[\"superuser\"],\"enabled\":true,\"rules\":{\"all\":[{\"any\":[{\"field\":{\"dn\":\"*,ou=admin,dc=example,dc=com\ \"}},{\"field\":{\"username\":[\"es-admin\",\"es-system\"]}}]},{\"field\":{\"groups\":\"cn=people,dc=example,dc=com\"}},{\"ex\ cept\":{\"field\":{\"metadata.terminated_date\":null}}}]}}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping8\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping8") + .roles("superuser") + .rules(r -> r + .all(List.of(RoleMappingRule.of(ro -> ro + .any(List.of(RoleMappingRule.of(rol -> rol + .field(NamedValue.of("dn", List.of(FieldValue.of("*,ou=admin," + + "dc=example,dc=com")) + )) + ), RoleMappingRule.of(role -> role + .field(NamedValue.of("username", List.of(FieldValue.of("es-admin"), + FieldValue.of("es-system")) + )))), RoleMappingRule.of(roleM -> roleM + .field(NamedValue.of("groups", List.of(FieldValue.of("cn=people," + + "dc=example,dc=com")) + )), RoleMappingRule.of(roleMa -> roleMa + .except(e -> e + .field(NamedValue.of("metadata.terminated_date", + List.of(FieldValue.of(null)) + ) + )))) + ) + ) + ) + ) + ) + ); diff --git a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml index e46aa0c91c..fc7aca1455 100644 --- a/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml +++ b/specification/security/put_role_mapping/examples/request/SecurityPutRoleMappingRequestExample9.yaml @@ -117,3 +117,21 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"rules\":{\"field\":{\"realm.name\":\"cloud-saml\"}},\"role_templates\":[{\"template\":{\"source\":\"saml_user\"}},{\"temp\ late\":{\"source\":\"_user_{{username}}\"}}],\"enabled\":true}' \"$ELASTICSEARCH_URL/_security/role_mapping/mapping9\"" + - language: Java + code: | + client.security().putRoleMapping(p -> p + .enabled(true) + .name("mapping9") + .roleTemplates(List.of(RoleTemplate.of(r -> r + .template(t -> t + .source("saml_user") + )),RoleTemplate.of(r -> r + .template(t -> t + .source("_user_{{username}}") + )))) + .rules(r -> r + .field(f -> f + ._Custom(JsonData.fromJson("\"cloud-saml\"")) + ) + ) + ); diff --git a/specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml b/specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml index 50cd7da5b5..32e52bf8d1 100644 --- a/specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml +++ b/specification/security/put_user/examples/request/SecurityPutUserRequestExample1.yaml @@ -80,3 +80,13 @@ alternatives: ''{"password":"l0ng-r4nd0m-p@ssw0rd","roles":["admin","other_role1"],"full_name":"Jack Nicholson","email":"jacknich@example.com","metadata":{"intelligence":7}}'' "$ELASTICSEARCH_URL/_security/user/jacknich"' + - language: Java + code: | + client.security().putUser(p -> p + .email("jacknich@example.com") + .fullName("Jack Nicholson") + .metadata("intelligence", JsonData.fromJson("7")) + .password("l0ng-r4nd0m-p@ssw0rd") + .roles(List.of("admin","other_role1")) + .username("jacknich") + ); diff --git a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml index cc28952d41..11ec85a421 100644 --- a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml +++ b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample1.yaml @@ -68,3 +68,13 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"ids":{"values":["VuaCfGcBCdbkQm-e5aOx"]}}}'' "$ELASTICSEARCH_URL/_security/_query/api_key?with_limited_by=true"' + - language: Java + code: | + client.security().queryApiKeys(q -> q + .query(qu -> qu + .ids(i -> i + .values("VuaCfGcBCdbkQm-e5aOx") + ) + ) + .withLimitedBy(true) + ); diff --git a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml index 8f3866d3cc..c593fb136d 100644 --- a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml +++ b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample2.yaml @@ -263,3 +263,46 @@ alternatives: \"term\":{\"name\":\"app1-key-01\"}}],\"filter\":[{\"wildcard\":{\"username\":\"org-*-user\"}},{\"term\":{\"metadata.environm\ ent\":\"production\"}}]}},\"from\":20,\"size\":10,\"sort\":[{\"creation\":{\"order\":\"desc\",\"format\":\"date_time\"}},\"na\ me\"]}' \"$ELASTICSEARCH_URL/_security/_query/api_key\"" + - language: Java + code: | + client.security().queryApiKeys(q -> q + .from(20) + .query(qu -> qu + .bool(b -> b + .filter(List.of(Query.of(que -> que + .wildcard(w -> w + .field("username") + .value("org-*-user") + )),Query.of(quer -> quer + .term(t -> t + .field("metadata.environment") + .value(FieldValue.of("production")) + )))) + .must(List.of(Query.of(query -> query + .prefix(p -> p + .field("name") + .value("app1-key-") + )),Query.of(query1 -> query1 + .term(t -> t + .field("invalidated") + .value(FieldValue.of("false")) + )))) + .mustNot(m -> m + .term(t -> t + .field("name") + .value(FieldValue.of("app1-key-01")) + ) + ) + ) + ) + .size(10) + .sort(List.of(SortOptions.of(s -> s + .field(f -> f + .field("creation") + .order(SortOrder.Desc) + .format("date_time") + )),SortOptions.of(so -> so + .field(f -> f + .field("name") + )))) + ); diff --git a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml index 3de94c849f..0040fb82a5 100644 --- a/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml +++ b/specification/security/query_api_keys/examples/request/QueryApiKeysRequestExample3.yaml @@ -65,3 +65,13 @@ alternatives: code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"term":{"name":{"value":"application-key-1"}}}}'' "$ELASTICSEARCH_URL/_security/_query/api_key"' + - language: Java + code: | + client.security().queryApiKeys(q -> q + .query(qu -> qu + .term(t -> t + .field("name") + .value(FieldValue.of("application-key-1")) + ) + ) + ); diff --git a/specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml b/specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml index 1f891fefb1..f2495e4fb9 100644 --- a/specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml +++ b/specification/security/query_role/examples/request/QueryRolesRequestExample1.yaml @@ -41,3 +41,12 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"sort":["name"]}'' "$ELASTICSEARCH_URL/_security/_query/role"' + - language: Java + code: | + client.security().queryRole(q -> q + .sort(s -> s + .field(f -> f + .field("name") + ) + ) + ); diff --git a/specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml b/specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml index 7f6b4c1cac..d64d48d5c0 100644 --- a/specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml +++ b/specification/security/query_role/examples/request/QueryRolesRequestExample2.yaml @@ -73,3 +73,14 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"match":{"description":{"query":"user access"}}},"size":1}'' "$ELASTICSEARCH_URL/_security/_query/role"' + - language: Java + code: | + client.security().queryRole(q -> q + .query(qu -> qu + .match(m -> m + .field("description") + .query(FieldValue.of("user access")) + ) + ) + .size(1) + ); diff --git a/specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml b/specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml index d70f3eb41d..ac83a0f9a7 100644 --- a/specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml +++ b/specification/security/query_user/examples/request/SecurityQueryUserRequestExample1.yaml @@ -61,3 +61,14 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":{"prefix":{"roles":"other"}}}'' "$ELASTICSEARCH_URL/_security/_query/user?with_profile_uid=true"' + - language: Java + code: | + client.security().queryUser(q -> q + .query(qu -> qu + .prefix(p -> p + .field("roles") + .value("other") + ) + ) + .withProfileUid(true) + ); diff --git a/specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml b/specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml index 8eb102180e..52eb6ce7ac 100644 --- a/specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml +++ b/specification/security/query_user/examples/request/SecurityQueryUserRequestExample2.yaml @@ -192,3 +192,34 @@ alternatives: '{\"query\":{\"bool\":{\"must\":[{\"wildcard\":{\"email\":\"*example.com\"}},{\"term\":{\"enabled\":true}}],\"filter\":[{\"wi\ ldcard\":{\"roles\":\"*other*\"}}]}},\"from\":1,\"size\":2,\"sort\":[{\"username\":{\"order\":\"desc\"}}]}' \"$ELASTICSEARCH_URL/_security/_query/user\"" + - language: Java + code: | + client.security().queryUser(q -> q + .from(1) + .query(qu -> qu + .bool(b -> b + .filter(f -> f + .wildcard(w -> w + .field("roles") + .value("*other*") + ) + ) + .must(List.of(Query.of(que -> que + .wildcard(w -> w + .field("email") + .value("*example.com") + )),Query.of(quer -> quer + .term(t -> t + .field("enabled") + .value(FieldValue.of(true)) + )))) + ) + ) + .size(2) + .sort(s -> s + .field(fi -> fi + .field("username") + .order(SortOrder.Desc) + ) + ) + ); diff --git a/specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml b/specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml index 0ec7232a66..e038bad142 100644 --- a/specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml +++ b/specification/security/saml_authenticate/examples/request/SamlAuthenticateRequestExample1.yaml @@ -51,3 +51,9 @@ alternatives: '{\"content\":\"PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVyb\ jpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....\",\"ids\":[\"4fee3b046395c4e751011e97f8900b5273d56685\"]}' \"$ELASTICSEARCH_URL/_security/saml/authenticate\"" + - language: Java + code: > + client.security().samlAuthenticate(s -> s + .content("PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6cHJvdG9jb2wiIHhtbG5zOnNhbWw9InVybjpvYXNpczpuYW1lczp0YzpTQU1MOjIuMD.....") + .ids("4fee3b046395c4e751011e97f8900b5273d56685") + ); diff --git a/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml b/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml index 25f91c2474..0be3224f98 100644 --- a/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml +++ b/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample1.yaml @@ -55,3 +55,10 @@ alternatives: '{\"realm\":\"saml1\",\"ids\":[\"_1c368075e0b3...\"],\"query_string\":\"SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2\ Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...\"}' \"$ELASTICSEARCH_URL/_security/saml/complete_logout\"" + - language: Java + code: > + client.security().samlCompleteLogout(s -> s + .ids("_1c368075e0b3...") + .queryString("SAMLResponse=fZHLasMwEEVbfb1bf...&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1&Signature=CuCmFn%2BLqnaZGZJqK...") + .realm("saml1") + ); diff --git a/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml b/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml index 3f7ece2c10..ed2f2c0189 100644 --- a/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml +++ b/specification/security/saml_complete_logout/examples/request/SamlCompleteLogoutRequestExample2.yaml @@ -53,3 +53,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"realm":"saml1","ids":["_1c368075e0b3..."],"content":"PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46..."}'' "$ELASTICSEARCH_URL/_security/saml/complete_logout"' + - language: Java + code: | + client.security().samlCompleteLogout(s -> s + .content("PHNhbWxwOkxvZ291dFJlc3BvbnNlIHhtbG5zOnNhbWxwPSJ1cm46...") + .ids("_1c368075e0b3...") + .realm("saml1") + ); diff --git a/specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml b/specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml index 5a4b85ab69..ce8506c932 100644 --- a/specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml +++ b/specification/security/saml_invalidate/examples/request/SamlInvalidateRequestExample1.yaml @@ -49,3 +49,9 @@ alternatives: rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTV\ A7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D\",\"realm\":\"saml1\"}' \"$ELASTICSEARCH_URL/_security/saml/invalidate\"" + - language: Java + code: > + client.security().samlInvalidate(s -> s + .queryString("SAMLRequest=nZFda4MwFIb%2FiuS%2BmviRpqFaClKQdbvo2g12M2KMraCJ9cRR9utnW4Wyi13sMie873MeznJ1aWrnS3VQGR0j4mLkKC1NUeljjA77zYyhVbIE0dR%2By7fmaHq7U%2BdegXWGpAZ%2B%2F4pR32luBFTAtWgUcCv56%2Fp5y30X87Yz1khTIycdgpUW9kY7WdsC9zxoXTvMvWuVV98YyMnSGH2SYE5pwALBIr9QKiwDGpW0oGVUznGeMyJZKFkQ4jBf5HnhUymjIhzCAL3KNFihbYx8TBYzzGaY7EnIyZwHzCWMfiDnbRIftkSjJr%2BFu0e9v%2B0EgOquRiiZjKpiVFp6j50T4WXoyNJ%2FEWC9fdqc1t%2F1%2B2F3aUpjzhPiXpqMz1%2FHSn4A&SigAlg=http%3A%2F%2Fwww.w3.org%2F2001%2F04%2Fxmldsig-more%23rsa-sha256&Signature=MsAYz2NFdovMG2mXf6TSpu5vlQQyEJAg%2B4KCwBqJTmrb3yGXKUtIgvjqf88eCAK32v3eN8vupjPC8LglYmke1ZnjK0%2FKxzkvSjTVA7mMQe2AQdKbkyC038zzRq%2FYHcjFDE%2Bz0qISwSHZY2NyLePmwU7SexEXnIz37jKC6NMEhus%3D") + .realm("saml1") + ); diff --git a/specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml b/specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml index 6c081d9dc9..da5f7612a8 100644 --- a/specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml +++ b/specification/security/saml_logout/examples/request/SamlLogoutRequestExample1.yaml @@ -43,3 +43,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"token":"46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3","refresh_token":"mJdXLtmvTUSpoLwMvdBt_w"}'' "$ELASTICSEARCH_URL/_security/saml/logout"' + - language: Java + code: | + client.security().samlLogout(s -> s + .refreshToken("mJdXLtmvTUSpoLwMvdBt_w") + .token("46ToAxZVaXVVZTVKOVF5YU04ZFJVUDVSZlV3") + ); diff --git a/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml b/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml index 0a0e4d41e0..e96e9e97f6 100644 --- a/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml +++ b/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample1.yaml @@ -36,3 +36,8 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"realm":"saml1"}'' "$ELASTICSEARCH_URL/_security/saml/prepare"' + - language: Java + code: | + client.security().samlPrepareAuthentication(s -> s + .realm("saml1") + ); diff --git a/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml b/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml index 28494ffa37..cf65eaba71 100644 --- a/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml +++ b/specification/security/saml_prepare_authentication/examples/request/SamlPrepareAuthenticationRequestExample2.yaml @@ -37,3 +37,8 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"acs":"https://kibana.org/api/security/saml/callback"}'' "$ELASTICSEARCH_URL/_security/saml/prepare"' + - language: Java + code: | + client.security().samlPrepareAuthentication(s -> s + .acs("https://kibana.org/api/security/saml/callback") + ); diff --git a/specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml b/specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml index 9ddbc9ba31..fece8d78cc 100644 --- a/specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml +++ b/specification/security/saml_service_provider_metadata/examples/request/SamlServiceProviderMetadataRequestExample1.yaml @@ -23,3 +23,8 @@ alternatives: - language: curl code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data"' + - language: Java + code: | + client.security().updateUserProfileData(u -> u + .uid("u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0") + ); diff --git a/specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml b/specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml index 519860ec84..7f5a719312 100644 --- a/specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml +++ b/specification/security/suggest_user_profiles/examples/request/SuggestUserProfilesRequestExample1.yaml @@ -93,3 +93,12 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"name\":\"jack\",\"hint\":{\"uids\":[\"u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0\",\"u_79HkWkwmnBH5gqFKwoxggWPjEBOur\ 1zLPXQPEl1VBW0_0\"],\"labels\":{\"direction\":[\"north\",\"east\"]}}}' \"$ELASTICSEARCH_URL/_security/profile/_suggest\"" + - language: Java + code: | + client.security().suggestUserProfiles(s -> s + .hint(h -> h + .uids(List.of("u_8RKO7AKfEbSiIHZkZZ2LJy2MUSDPWDr3tMI_CkIGApU_0","u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0")) + .labels("direction", List.of("north","east")) + ) + .name("jack") + ); diff --git a/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml b/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml index 462eb35033..0c485a87f3 100644 --- a/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml +++ b/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample1.yaml @@ -139,3 +139,15 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"role_descriptors\":{\"role-a\":{\"indices\":[{\"names\":[\"*\"],\"privileges\":[\"write\"]}]}},\"metadata\":{\"environment\ \":{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}}}' \"$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx\"" + - language: Java + code: | + client.security().updateApiKey(u -> u + .id("VuaCfGcBCdbkQm-e5aOx") + .metadata("environment", JsonData.fromJson("{\"level\":2,\"trusted\":true,\"tags\":[\"production\"]}")) + .roleDescriptors("role-a", r -> r + .indices(i -> i + .names("*") + .privileges("write") + ) + ) + ); diff --git a/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml b/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml index d2f488d2a0..c70a01f546 100644 --- a/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml +++ b/specification/security/update_api_key/examples/request/UpdateApiKeyRequestExample2.yaml @@ -41,3 +41,8 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"role_descriptors":{}}'' "$ELASTICSEARCH_URL/_security/api_key/VuaCfGcBCdbkQm-e5aOx"' + - language: Java + code: | + client.security().updateApiKey(u -> u + .id("VuaCfGcBCdbkQm-e5aOx") + ); diff --git a/specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml b/specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml index f5b1092dd7..02042fbef4 100644 --- a/specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml +++ b/specification/security/update_cross_cluster_api_key/examples/request/UpdateCrossClusterApiKeyRequestExample1.yaml @@ -93,3 +93,14 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"access":{"replication":[{"names":["archive"]}]},"metadata":{"application":"replication"}}'' "$ELASTICSEARCH_URL/_security/cross_cluster/api_key/VuaCfGcBCdbkQm-e5aOx"' + - language: Java + code: | + client.security().updateCrossClusterApiKey(u -> u + .access(a -> a + .replication(r -> r + .names("archive") + ) + ) + .id("VuaCfGcBCdbkQm-e5aOx") + .metadata("application", JsonData.fromJson("\"replication\"")) + ); diff --git a/specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml b/specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml index 2d18a88449..5b0e1e14db 100644 --- a/specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml +++ b/specification/security/update_settings/examples/request/SecurityUpdateSettingsRequestExample1.yaml @@ -76,3 +76,10 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"security\":{\"index.auto_expand_replicas\":\"0-all\"},\"security-tokens\":{\"index.auto_expand_replicas\":\"0-all\"},\"se\ curity-profile\":{\"index.auto_expand_replicas\":\"0-all\"}}' \"$ELASTICSEARCH_URL/_security/settings\"" + - language: Java + code: | + client.security().updateSettings(u -> u + .security(s -> s) + .securityProfile(s -> s) + .securityTokens(s -> s) + ); diff --git a/specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml b/specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml index 83528e80e9..81d1a91ade 100644 --- a/specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml +++ b/specification/security/update_user_profile_data/examples/request/UpdateUserProfileDataRequestExample1.yaml @@ -77,3 +77,10 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"labels":{"direction":"east"},"data":{"app1":{"theme":"default"}}}'' "$ELASTICSEARCH_URL/_security/profile/u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0/_data"' + - language: Java + code: | + client.security().updateUserProfileData(u -> u + .data("app1", JsonData.fromJson("{\"theme\":\"default\"}")) + .labels("direction", JsonData.fromJson("\"east\"")) + .uid("u_P_0BMHgaOK3p7k-PFWUCbw9dQ-UFjt01oWJ_Dp2PmPc_0") + ); diff --git a/specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml b/specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml index dcd0208995..7fb729e55e 100644 --- a/specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml +++ b/specification/shutdown/put_node/examples/request/ShutdownPutNodeRequestExample1.yaml @@ -55,3 +55,11 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"restart","reason":"Demonstrating how the node shutdown API works","allocation_delay":"20m"}'' "$ELASTICSEARCH_URL/_nodes/USpTGYaBSIKbgSUJR2Z9lg/shutdown"' + - language: Java + code: | + client.shutdown().putNode(p -> p + .allocationDelay("20m") + .nodeId("USpTGYaBSIKbgSUJR2Z9lg") + .reason("Demonstrating how the node shutdown API works") + .type(Type.Restart) + ); diff --git a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml index eb29b97d82..eed3a471cd 100644 --- a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml +++ b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample1.yaml @@ -105,3 +105,14 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"docs\":[{\"_id\":123,\"_index\":\"my-index\",\"_source\":{\"foo\":\"bar\"}},{\"_id\":456,\"_index\":\"my-index\",\"_source\ \":{\"foo\":\"rab\"}}]}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + - language: Java + code: | + client.simulate().ingest(i -> i + .docs(List.of(Document.of(d -> d + .id("123") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"bar\"}"))),Document.of(d -> d + .id("456") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"rab\"}"))))) + ); diff --git a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml index d0c997f00e..3aa330b5c5 100644 --- a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml +++ b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample2.yaml @@ -156,3 +156,21 @@ alternatives: '{\"docs\":[{\"_index\":\"my-index\",\"_id\":123,\"_source\":{\"foo\":\"bar\"}},{\"_index\":\"my-index\",\"_id\":456,\"_source\ \":{\"foo\":\"rab\"}}],\"pipeline_substitutions\":{\"my-pipeline\":{\"processors\":[{\"uppercase\":{\"field\":\"foo\"}}]}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + - language: Java + code: | + client.simulate().ingest(i -> i + .docs(List.of(Document.of(d -> d + .id("123") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"bar\"}"))),Document.of(d -> d + .id("456") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"rab\"}"))))) + .pipelineSubstitutions("my-pipeline", p -> p + .processors(pr -> pr + .uppercase(u -> u + .field("foo") + ) + ) + ) + ); diff --git a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml index 759886476a..b9f2b724a3 100644 --- a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml +++ b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample3.yaml @@ -202,3 +202,26 @@ alternatives: \"_source\":{\"bar\":\"rab\"}}],\"component_template_substitutions\":{\"my-mappings_template\":{\"template\":{\"mappings\":{\ \"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyword\"},\"bar\":{\"type\":\"keyword\"}}}}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + - language: Java + code: | + client.simulate().ingest(i -> i + .componentTemplateSubstitutions("my-mappings_template", c -> c + .template(t -> t + .mappings(m -> m + .dynamic(DynamicMapping.Strict) + .properties(Map.of("bar", Property.of(p -> p + .keyword(k -> k + )),"foo", Property.of(pr -> pr + .keyword(k -> k + )))) + ) + ) + ) + .docs(List.of(Document.of(d -> d + .id("123") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"foo\"}"))),Document.of(d -> d + .id("456") + .index("my-index") + .source(JsonData.fromJson("{\"bar\":\"rab\"}"))))) + ); diff --git a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml index 2bd2df773b..3bf9cf177e 100644 --- a/specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml +++ b/specification/simulate/ingest/examples/request/SimulateIngestRequestExample4.yaml @@ -333,3 +333,45 @@ alternatives: },\"index_template_substitutions\":{\"my-index-template\":{\"index_patterns\":[\"my-index-*\"],\"composed_of\":[\"component_t\ emplate_1\",\"component_template_2\"]}},\"mapping_addition\":{\"dynamic\":\"strict\",\"properties\":{\"foo\":{\"type\":\"keyw\ ord\"}}}}' \"$ELASTICSEARCH_URL/_ingest/_simulate\"" + - language: Java + code: | + client.simulate().ingest(i -> i + .componentTemplateSubstitutions("my-component-template", c -> c + .template(t -> t + .settings("index", s -> s + .defaultPipeline("my-pipeline") + ) + .mappings(m -> m + .dynamic(DynamicMapping.True) + .properties("field3", p -> p + .keyword(k -> k) + ) + ) + ) + ) + .docs(List.of(Document.of(d -> d + .id("id") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"bar\"}"))),Document.of(d -> d + .id("id") + .index("my-index") + .source(JsonData.fromJson("{\"foo\":\"rab\"}"))))) + .indexTemplateSubstitutions("my-index-template", in -> in + .indexPatterns("my-index-*") + .composedOf(List.of("component_template_1","component_template_2")) + ) + .mappingAddition(m -> m + .dynamic(DynamicMapping.Strict) + .properties("foo", p -> p + .keyword(k -> k) + ) + ) + .pipelineSubstitutions("my-pipeline", p -> p + .processors(pr -> pr + .set(s -> s + .field("field3") + .value(JsonData.fromJson("\"value3\"")) + ) + ) + ) + ); diff --git a/specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml b/specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml index ff6ff39fd1..b0bf8ec330 100644 --- a/specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml +++ b/specification/slm/get_lifecycle/examples/request/GetSnapshotLifecycleRequestExample1.yaml @@ -26,3 +26,5 @@ alternatives: ]); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_slm/policy/daily-snapshots?human"' + - language: Java + code: "\n" diff --git a/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml b/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml index cecb416f3c..168a3eb6c9 100644 --- a/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml +++ b/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample1 copy.yaml @@ -127,3 +127,23 @@ alternatives: ?\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\"important\"],\"i\ gnore_unavailable\":false,\"include_global_state\":false},\"retention\":{\"expire_after\":\"30d\",\"min_count\":5,\"max_count\ \":50}}' \"$ELASTICSEARCH_URL/_slm/policy/daily-snapshots\"" + - language: Java + code: | + client.slm().putLifecycle(p -> p + .config(c -> c + .ignoreUnavailable(false) + .indices(List.of("data-*","important")) + .includeGlobalState(false) + ) + .name("") + .policyId("daily-snapshots") + .repository("my_repository") + .retention(r -> r + .expireAfter(e -> e + .time("30d") + ) + .maxCount(50) + .minCount(5) + ) + .schedule("0 30 1 * * ?") + ); diff --git a/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml b/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml index acd0dccdd0..8614799892 100644 --- a/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml +++ b/specification/slm/put_lifecycle/examples/request/PutSnapshotLifecycleRequestExample2.yaml @@ -77,3 +77,14 @@ alternatives: "curl -X PUT -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"schedule\":\"1h\",\"name\":\"\",\"repository\":\"my_repository\",\"config\":{\"indices\":[\"data-*\",\ \"important\"]}}' \"$ELASTICSEARCH_URL/_slm/policy/hourly-snapshots\"" + - language: Java + code: | + client.slm().putLifecycle(p -> p + .config(c -> c + .indices(List.of("data-*","important")) + ) + .name("") + .policyId("hourly-snapshots") + .repository("my_repository") + .schedule("1h") + ); diff --git a/specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml b/specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml index dde0b16284..a9e23dd61a 100644 --- a/specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml +++ b/specification/snapshot/clone/examples/request/SnapshotCloneRequestExample1.yaml @@ -50,3 +50,11 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"indices":"index_a,index_b"}'' "$ELASTICSEARCH_URL/_snapshot/my_repository/source_snapshot/_clone/target_snapshot"' + - language: Java + code: | + client.snapshot().clone(c -> c + .indices("index_a,index_b") + .repository("my_repository") + .snapshot("source_snapshot") + .targetSnapshot("target_snapshot") + ); diff --git a/specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml b/specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml index 81fa6ab5ea..78dd22decb 100644 --- a/specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml +++ b/specification/snapshot/create/examples/request/SnapshotCreateRequestExample1.yaml @@ -86,3 +86,14 @@ alternatives: '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"metadata\":{\"taken_by\":\"use\ r123\",\"taken_because\":\"backup before upgrading\"}}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2?wait_for_completion=true\"" + - language: Java + code: > + client.snapshot().create(c -> c + .ignoreUnavailable(true) + .includeGlobalState(false) + .indices("index_1,index_2") + .metadata(Map.of("taken_by", JsonData.fromJson("\"user123\""),"taken_because", JsonData.fromJson("\"backup before upgrading\""))) + .repository("my_repository") + .snapshot("snapshot_2") + .waitForCompletion(true) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml index 74fea999a7..70ea0d2093 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample1.yaml @@ -62,3 +62,15 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"fs","settings":{"location":"my_backup_location"}}'' "$ELASTICSEARCH_URL/_snapshot/my_repository"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_repository") + .repository(r -> r + .fs(f -> f + .settings(s -> s + .location("my_backup_location") + ) + ) + ) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml index 4bc38615d4..8aa32b79cc 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample2.yaml @@ -62,3 +62,15 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"azure","settings":{"client":"secondary"}}'' "$ELASTICSEARCH_URL/_snapshot/my_backup"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_backup") + .repository(r -> r + .azure(a -> a + .settings(s -> s + .client("secondary") + ) + ) + ) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml index 7e8de1b8e5..71ee4e27d4 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample3.yaml @@ -69,3 +69,16 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"gcs","settings":{"bucket":"my_other_bucket","base_path":"dev"}}'' "$ELASTICSEARCH_URL/_snapshot/my_gcs_repository"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_gcs_repository") + .repository(r -> r + .gcs(g -> g + .settings(s -> s + .bucket("my_other_bucket") + .basePath("dev") + ) + ) + ) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml index b119c6d1ea..9259b7de22 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample4.yaml @@ -62,3 +62,15 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"s3","settings":{"bucket":"my-bucket"}}'' "$ELASTICSEARCH_URL/_snapshot/my_s3_repository"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_s3_repository") + .repository(r -> r + .s3(s -> s + .settings(se -> se + .bucket("my-bucket") + ) + ) + ) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml index 22642c1576..6123067a49 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample5.yaml @@ -69,3 +69,15 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"source","settings":{"delegate_type":"fs","location":"my_backup_repository"}}'' "$ELASTICSEARCH_URL/_snapshot/my_src_only_repository"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_src_only_repository") + .repository(r -> r + .source(s -> s + .settings(se -> se + .delegateType("fs") + ) + ) + ) + ); diff --git a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml index 0d99e1c5cf..7fb8458cdf 100644 --- a/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml +++ b/specification/snapshot/create_repository/examples/request/SnapshotCreateRepositoryRequestExample6.yaml @@ -63,3 +63,15 @@ alternatives: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"type":"url","settings":{"url":"file:/mount/backups/my_fs_backup_location"}}'' "$ELASTICSEARCH_URL/_snapshot/my_read_only_url_repository"' + - language: Java + code: | + client.snapshot().createRepository(c -> c + .name("my_read_only_url_repository") + .repository(r -> r + .url(u -> u + .settings(s -> s + .url("file:/mount/backups/my_fs_backup_location") + ) + ) + ) + ); diff --git a/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml b/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml index 5c5be823f0..ed016c71fc 100644 --- a/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml +++ b/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample1.yaml @@ -83,3 +83,16 @@ alternatives: '{\"indices\":\"index_1,index_2\",\"ignore_unavailable\":true,\"include_global_state\":false,\"rename_pattern\":\"index_(.+)\ \",\"rename_replacement\":\"restored_index_$1\",\"include_aliases\":false}' \"$ELASTICSEARCH_URL/_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true\"" + - language: Java + code: | + client.snapshot().restore(r -> r + .ignoreUnavailable(true) + .includeAliases(false) + .includeGlobalState(false) + .indices("index_1,index_2") + .renamePattern("index_(.+)") + .renameReplacement("restored_index_$1") + .repository("my_repository") + .snapshot("snapshot_2") + .waitForCompletion(true) + ); diff --git a/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml b/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml index e97a7197d8..1c4ee51885 100644 --- a/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml +++ b/specification/snapshot/restore/examples/request/SnapshotRestoreRequestExample2.yaml @@ -36,3 +36,7 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"indices":"index_1"}'' "$ELASTICSEARCH_URL/_cluster/settings"' + - language: Java + code: | + client.cluster().putSettings(); + diff --git a/specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml b/specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml index 9019c75fa8..dfabd56618 100644 --- a/specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml +++ b/specification/sql/clear_cursor/examples/request/ClearSqlCursorRequestExample1.yaml @@ -39,3 +39,8 @@ alternatives: "curl -X POST -H \"Authorization: ApiKey $ELASTIC_API_KEY\" -H \"Content-Type: application/json\" -d '{\"cursor\":\"sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy\ 9f///w8=\"}' \"$ELASTICSEARCH_URL/_sql/close\"" + - language: Java + code: > + client.sql().clearCursor(c -> c + .cursor("sDXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAAEWYUpOYklQMHhRUEtld3RsNnFtYU1hQQ==:BAFmBGRhdGUBZgVsaWtlcwFzB21lc3NhZ2UBZgR1c2Vy9f///w8=") + ); diff --git a/specification/sql/query/examples/request/QuerySqlRequestExample1.yaml b/specification/sql/query/examples/request/QuerySqlRequestExample1.yaml index 0458614bc6..f44edbacb7 100644 --- a/specification/sql/query/examples/request/QuerySqlRequestExample1.yaml +++ b/specification/sql/query/examples/request/QuerySqlRequestExample1.yaml @@ -40,3 +40,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":"SELECT * FROM library ORDER BY page_count DESC LIMIT 5"}'' "$ELASTICSEARCH_URL/_sql?format=txt"' + - language: Java + code: | + client.sql().query(q -> q + .format(SqlFormat.Txt) + .query("SELECT * FROM library ORDER BY page_count DESC LIMIT 5") + ); diff --git a/specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml b/specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml index 78720d7f83..1c4df256a9 100644 --- a/specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml +++ b/specification/sql/translate/examples/request/TranslateSqlRequestExample1.yaml @@ -42,3 +42,9 @@ alternatives: code: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"query":"SELECT * FROM library ORDER BY page_count DESC","fetch_size":10}'' "$ELASTICSEARCH_URL/_sql/translate"' + - language: Java + code: | + client.sql().translate(t -> t + .fetchSize(10) + .query("SELECT * FROM library ORDER BY page_count DESC") + ); diff --git a/specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml b/specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml index 49b591baf5..63f231f759 100644 --- a/specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml +++ b/specification/ssl/certificates/examples/request/GetCertificatesRequestExample1.yaml @@ -10,3 +10,6 @@ alternatives: code: $resp = $client->ssl()->certificates(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_ssl/certificates"' + - language: Java + code: | + client.ssl().certificates(); diff --git a/specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml b/specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml index 7fe8950e01..ce251be05c 100644 --- a/specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml +++ b/specification/synonyms/put_synonym_rule/examples/request/SynonymRulePutRequestExample1.yaml @@ -44,3 +44,10 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"synonyms":"hello, hi, howdy"}'' "$ELASTICSEARCH_URL/_synonyms/my-synonyms-set/test-1"' + - language: Java + code: | + client.synonyms().putSynonymRule(p -> p + .ruleId("test-1") + .setId("my-synonyms-set") + .synonyms("hello, hi, howdy") + ); diff --git a/specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml b/specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml index 915db8a301..847f6bbbd6 100644 --- a/specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml +++ b/specification/text_structure/find_message_structure/examples/request/FindMessageStructureRequestExample1.yaml @@ -202,3 +202,8 @@ alternatives: discovery type [multi-node] and seed hosts providers [settings]","[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized","[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ..."]}'' "$ELASTICSEARCH_URL/_text_structure/find_message_structure"' + - language: Java + code: > + client.textStructure().findMessageStructure(f -> f + .messages(List.of("[2024-03-05T10:52:36,256][INFO ][o.a.l.u.VectorUtilPanamaProvider] [laptop] Java vector incubator API enabled; uses preferredBitSize=128","[2024-03-05T10:52:41,038][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-url]","[2024-03-05T10:52:41,042][INFO ][o.e.p.PluginsService ] [laptop] loaded module [rest-root]","[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-core]","[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-redact]","[2024-03-05T10:52:41,043][INFO ][o.e.p.PluginsService ] [laptop] loaded module [ingest-user-agent]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-monitoring]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [repository-s3]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-analytics]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-ent-search]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-autoscaling]","[2024-03-05T10:52:41,044][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-painless]]","[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [lang-expression]","[2024-03-05T10:52:41,059][INFO ][o.e.p.PluginsService ] [laptop] loaded module [x-pack-eql]","[2024-03-05T10:52:43,291][INFO ][o.e.e.NodeEnvironment ] [laptop] heap size [16gb], compressed ordinary object pointers [true]","[2024-03-05T10:52:46,098][INFO ][o.e.x.s.Security ] [laptop] Security is enabled","[2024-03-05T10:52:47,227][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] Profiling is enabled","[2024-03-05T10:52:47,259][INFO ][o.e.x.p.ProfilingPlugin ] [laptop] profiling index templates will not be installed or reinstalled","[2024-03-05T10:52:47,755][INFO ][o.e.i.r.RecoverySettings ] [laptop] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]","[2024-03-05T10:52:47,787][INFO ][o.e.d.DiscoveryModule ] [laptop] using discovery type [multi-node] and seed hosts providers [settings]","[2024-03-05T10:52:49,188][INFO ][o.e.n.Node ] [laptop] initialized","[2024-03-05T10:52:49,199][INFO ][o.e.n.Node ] [laptop] starting ...")) + ); diff --git a/specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml b/specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml index b6da867dcb..2d7ece0c5f 100644 --- a/specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml +++ b/specification/text_structure/test_grok_pattern/examples/request/TestGrokPatternRequestExample1.yaml @@ -58,3 +58,9 @@ alternatives: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"grok_pattern":"Hello %{WORD:first_name} %{WORD:last_name}","text":["Hello John Doe","this does not match"]}'' "$ELASTICSEARCH_URL/_text_structure/test_grok_pattern"' + - language: Java + code: | + client.textStructure().testGrokPattern(t -> t + .grokPattern("Hello %{WORD:first_name} %{WORD:last_name}") + .text(List.of("Hello John Doe","this does not match")) + ); diff --git a/specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml b/specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml index 4a75c24f54..fc9b79008a 100644 --- a/specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml +++ b/specification/transform/preview_transform/examples/request/PreviewTransformRequestExample1.yaml @@ -122,3 +122,23 @@ alternatives: '{\"source\":{\"index\":\"kibana_sample_data_ecommerce\"},\"pivot\":{\"group_by\":{\"customer_id\":{\"terms\":{\"field\":\"cu\ stomer_id\",\"missing_bucket\":true}}},\"aggregations\":{\"max_price\":{\"max\":{\"field\":\"taxful_total_price\"}}}}}' \"$ELASTICSEARCH_URL/_transform/_preview\"" + - language: Java + code: | + client.transform().previewTransform(p -> p + .pivot(pi -> pi + .aggregations("max_price", a -> a + .max(m -> m + .field("taxful_total_price") + ) + ) + .groupBy("customer_id", g -> g + .terms(t -> t + .field("customer_id") + .missingBucket(true) + ) + ) + ) + .source(s -> s + .index("kibana_sample_data_ecommerce") + ) + ); diff --git a/specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml b/specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml index 3145efdf83..65b0fd8809 100644 --- a/specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml +++ b/specification/transform/put_transform/examples/request/PutTransformRequestExample1.yaml @@ -246,3 +246,54 @@ alternatives: Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform1\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\ \"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}},\"retention_policy\":{\"time\":{\"field\":\"order_date\ \",\"max_age\":\"30d\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform1\"" + - language: Java + code: | + client.transform().putTransform(p -> p + .description("Maximum priced ecommerce data by customer_id in Asia") + .dest(d -> d + .index("kibana_sample_data_ecommerce_transform1") + .pipeline("add_timestamp_pipeline") + ) + .frequency(f -> f + .time("5m") + ) + .pivot(pi -> pi + .aggregations("max_price", a -> a + .max(m -> m + .field("taxful_total_price") + ) + ) + .groupBy("customer_id", g -> g + .terms(t -> t + .field("customer_id") + .missingBucket(true) + ) + ) + ) + .retentionPolicy(r -> r + .time(t -> t + .field("order_date") + .maxAge(m -> m + .time("30d") + ) + ) + ) + .source(s -> s + .index("kibana_sample_data_ecommerce") + .query(q -> q + .term(te -> te + .field("geoip.continent_name") + .value(FieldValue.of("Asia")) + ) + ) + ) + .sync(sy -> sy + .time(ti -> ti + .delay(d -> d + .time("60s") + ) + .field("order_date") + ) + ) + .transformId("ecommerce_transform1") + ); diff --git a/specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml b/specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml index e2346b0101..d321bfbcd7 100644 --- a/specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml +++ b/specification/transform/put_transform/examples/request/PutTransformRequestExample2.yaml @@ -127,3 +127,30 @@ alternatives: \"},\"description\":\"Latest order for each customer\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform2\"},\"frequency\":\"5m\",\"sync\":{\"time\":{\"field\ \":\"order_date\",\"delay\":\"60s\"}}}' \"$ELASTICSEARCH_URL/_transform/ecommerce_transform2\"" + - language: Java + code: | + client.transform().putTransform(p -> p + .description("Latest order for each customer") + .dest(d -> d + .index("kibana_sample_data_ecommerce_transform2") + ) + .frequency(f -> f + .time("5m") + ) + .latest(l -> l + .sort("order_date") + .uniqueKey("customer_id") + ) + .source(s -> s + .index("kibana_sample_data_ecommerce") + ) + .sync(s -> s + .time(t -> t + .delay(d -> d + .time("60s") + ) + .field("order_date") + ) + ) + .transformId("ecommerce_transform2") + ); diff --git a/specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml b/specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml index c1a710e65b..c3ae5f363f 100644 --- a/specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml +++ b/specification/transform/update_transform/examples/request/UpdateTransformRequestExample1.yaml @@ -246,3 +246,41 @@ alternatives: Asia\",\"dest\":{\"index\":\"kibana_sample_data_ecommerce_transform1\",\"pipeline\":\"add_timestamp_pipeline\"},\"frequency\":\ \"5m\",\"sync\":{\"time\":{\"field\":\"order_date\",\"delay\":\"60s\"}},\"retention_policy\":{\"time\":{\"field\":\"order_date\ \",\"max_age\":\"30d\"}}}' \"$ELASTICSEARCH_URL/_transform/simple-kibana-ecomm-pivot/_update\"" + - language: Java + code: | + client.transform().updateTransform(u -> u + .description("Maximum priced ecommerce data by customer_id in Asia") + .dest(d -> d + .index("kibana_sample_data_ecommerce_transform1") + .pipeline("add_timestamp_pipeline") + ) + .frequency(f -> f + .time("5m") + ) + .retentionPolicy(r -> r + .time(t -> t + .field("order_date") + .maxAge(m -> m + .time("30d") + ) + ) + ) + .source(s -> s + .index("kibana_sample_data_ecommerce") + .query(q -> q + .term(te -> te + .field("geoip.continent_name") + .value(FieldValue.of("Asia")) + ) + ) + ) + .sync(sy -> sy + .time(ti -> ti + .delay(d -> d + .time("60s") + ) + .field("order_date") + ) + ) + .transformId("simple-kibana-ecomm-pivot") + ); diff --git a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml index 59772b0d92..14e4abe6a6 100644 --- a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml +++ b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample1.yaml @@ -100,3 +100,16 @@ alternatives: '{\"trigger_data\":{\"triggered_time\":\"now\",\"scheduled_time\":\"now\"},\"alternative_input\":{\"foo\":\"bar\"},\"ignore_c\ ondition\":true,\"action_modes\":{\"my-action\":\"force_simulate\"},\"record_execution\":true}' \"$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute\"" + - language: Java + code: | + client.watcher().executeWatch(e -> e + .actionModes("my-action", ActionExecutionMode.ForceSimulate) + .alternativeInput("foo", JsonData.fromJson("\"bar\"")) + .id("my_watch") + .ignoreCondition(true) + .recordExecution(true) + .triggerData(t -> t + .scheduledTime(DateTime.of("now")) + .triggeredTime(DateTime.of("now")) + ) + ); diff --git a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml index 4dd81bfbf1..e951d831e3 100644 --- a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml +++ b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample2.yaml @@ -56,3 +56,9 @@ alternatives: 'curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"action_modes":{"action1":"force_simulate","action2":"skip"}}'' "$ELASTICSEARCH_URL/_watcher/watch/my_watch/_execute"' + - language: Java + code: | + client.watcher().executeWatch(e -> e + .actionModes(Map.of("action1", ActionExecutionMode.ForceSimulate,"action2", ActionExecutionMode.Skip)) + .id("my_watch") + ); diff --git a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml index 5f28afbbbd..01daac5faa 100644 --- a/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml +++ b/specification/watcher/execute_watch/examples/request/WatcherExecuteRequestExample3.yaml @@ -206,3 +206,39 @@ alternatives: ody\":{\"query\":{\"match\":{\"message\":\"error\"}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\ \"actions\":{\"log_error\":{\"logging\":{\"text\":\"Found {{ctx.payload.hits.total}} errors in the logs\"}}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/_execute\"" + - language: Java + code: | + client.watcher().executeWatch(e -> e + .watch(w -> w + .actions("log_error", a -> a + .logging(l -> l + .text("Found {{ctx.payload.hits.total}} errors in the logs") + ) + ) + .condition(c -> c + .compare(NamedValue.of("ctx.payload.hits.total",Pair.of(ConditionOp.Gt,FieldValue.of(0)))) + ) + .input(i -> i + .search(s -> s + .request(r -> r + .body(b -> b + .query(q -> q + .match(m -> m + .field("message") + .query(FieldValue.of("error")) + ) + ) + ) + .indices("logs") + ) + ) + ) + .trigger(t -> t + .schedule(sc -> sc + .interval(in -> in + .time("10s") + ) + ) + ) + ) + ); diff --git a/specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml b/specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml index e14ffb530f..8e707307c3 100644 --- a/specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml +++ b/specification/watcher/put_watch/examples/request/WatcherPutWatchRequestExample1.yaml @@ -274,3 +274,50 @@ alternatives: r.triggered_time}}\"}}}}}}}}},\"condition\":{\"compare\":{\"ctx.payload.hits.total\":{\"gt\":0}}},\"actions\":{\"email_admin\ \":{\"email\":{\"to\":\"admin@domain.host.com\",\"subject\":\"404 recently encountered\"}}}}' \"$ELASTICSEARCH_URL/_watcher/watch/my-watch\"" + - language: Java + code: | + client.watcher().putWatch(p -> p + .actions("email_admin", a -> a + .email(e -> e + .subject("404 recently encountered") + .to("admin@domain.host.com") + ) + ) + .condition(c -> c + .compare(NamedValue.of("ctx.payload.hits.total",Pair.of(ConditionOp.Gt,FieldValue.of(0)))) + ) + .id("my-watch") + .input(i -> i + .search(s -> s + .request(r -> r + .body(b -> b + .query(q -> q + .bool(bo -> bo + .filter(f -> f + .range(ra -> ra + .untyped(u -> u + .field("@timestamp") + .from(JsonData.fromJson("\"{{ctx.trigger.scheduled_time}}||-5m\"")) + .to(JsonData.fromJson("\"{{ctx.trigger.triggered_time}}\"")) + ) + ) + ) + .must(m -> m + .match(ma -> ma + .field("response") + .query(FieldValue.of(404)) + ) + ) + ) + ) + ) + .indices("logstash*") + ) + ) + ) + .trigger(t -> t + .schedule(sc -> sc + .cron("0 0/1 * * * ?") + ) + ) + ); diff --git a/specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml b/specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml index bebbe5da3f..f635d6798c 100644 --- a/specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml +++ b/specification/watcher/query_watches/examples/request/WatcherQueryWatchesRequestExample1.yaml @@ -10,3 +10,7 @@ alternatives: code: $resp = $client->watcher()->queryWatches(); - language: curl code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_watcher/_query/watches"' + - language: Java + code: | + client.watcher().queryWatches(); + diff --git a/specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml b/specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml index 5f5efd1a82..72bb3a01c2 100644 --- a/specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml +++ b/specification/watcher/update_settings/examples/request/WatcherUpdateSettingsRequestExample1.yaml @@ -33,3 +33,8 @@ alternatives: code: 'curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d ''{"index.auto_expand_replicas":"0-4"}'' "$ELASTICSEARCH_URL/_watcher/settings"' + - language: Java + code: | + client.watcher().updateSettings(u -> u + .indexAutoExpandReplicas("0-4") + );