Skip to content

Commit 4ee4650

Browse files
use request converter to generate python examples (elastic#2643)
* use request converter to generate examples * updated examples * use correct license
1 parent 47dcd2b commit 4ee4650

File tree

3,177 files changed

+67293
-3976
lines changed

Some content is hidden

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

3,177 files changed

+67293
-3976
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ share/python-wheels/
2525
.installed.cfg
2626
*.egg
2727
MANIFEST
28+
node_modules
2829

2930
# PyInstaller
3031
# Usually these files are written by a python script from a template
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// rest-api/security/clear-cache.asciidoc:69
3+
4+
[source, python]
5+
----
6+
resp = client.security.clear_cached_realms(
7+
realms="default_file,ldap1",
8+
)
9+
print(resp)
10+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// indices/forcemerge.asciidoc:210
3+
4+
[source, python]
5+
----
6+
resp = client.indices.forcemerge(
7+
index=".ds-my-data-stream-2099.03.07-000001",
8+
max_num_segments="1",
9+
)
10+
print(resp)
11+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// query-dsl/pinned-query.asciidoc:13
3+
4+
[source, python]
5+
----
6+
resp = client.search(
7+
query={
8+
"pinned": {
9+
"ids": [
10+
"1",
11+
"4",
12+
"100"
13+
],
14+
"organic": {
15+
"match": {
16+
"description": "iphone"
17+
}
18+
}
19+
}
20+
},
21+
)
22+
print(resp)
23+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// analysis/tokenfilters/stemmer-tokenfilter.asciidoc:85
3+
4+
[source, python]
5+
----
6+
resp = client.indices.create(
7+
index="my-index-000001",
8+
settings={
9+
"analysis": {
10+
"analyzer": {
11+
"my_analyzer": {
12+
"tokenizer": "whitespace",
13+
"filter": [
14+
"stemmer"
15+
]
16+
}
17+
}
18+
}
19+
},
20+
)
21+
print(resp)
22+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// watcher/example-watches/example-watch-clusterstatus.asciidoc:193
3+
4+
[source, python]
5+
----
6+
resp = client.watcher.put_watch(
7+
id="cluster_health_watch",
8+
trigger={
9+
"schedule": {
10+
"interval": "10s"
11+
}
12+
},
13+
input={
14+
"http": {
15+
"request": {
16+
"host": "localhost",
17+
"port": 9200,
18+
"path": "/_cluster/health"
19+
}
20+
}
21+
},
22+
condition={
23+
"compare": {
24+
"ctx.payload.status": {
25+
"eq": "red"
26+
}
27+
}
28+
},
29+
actions={
30+
"send_email": {
31+
"email": {
32+
33+
"subject": "Cluster Status Warning",
34+
"body": "Cluster status is RED"
35+
}
36+
}
37+
},
38+
)
39+
print(resp)
40+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// migration/apis/feature-migration.asciidoc:152
3+
4+
[source, python]
5+
----
6+
resp = client.migration.post_feature_upgrade()
7+
print(resp)
8+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// scripting/common-script-uses.asciidoc:107
3+
4+
[source, python]
5+
----
6+
resp = client.search(
7+
index="my-index",
8+
query={
9+
"match": {
10+
"http.clientip": "40.135.0.0"
11+
}
12+
},
13+
fields=[
14+
"http.clientip"
15+
],
16+
)
17+
print(resp)
18+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// indices/shard-stores.asciidoc:134
3+
4+
[source, python]
5+
----
6+
resp = client.indices.shard_stores()
7+
print(resp)
8+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// search/search-your-data/search-template.asciidoc:443
3+
4+
[source, python]
5+
----
6+
resp = client.render_search_template(
7+
source="{ \"query\": {{#toJson}}my_query{{/toJson}} }",
8+
params={
9+
"my_query": {
10+
"match_all": {}
11+
}
12+
},
13+
)
14+
print(resp)
15+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// analysis/tokenfilters/asciifolding-tokenfilter.asciidoc:21
3+
4+
[source, python]
5+
----
6+
resp = client.indices.analyze(
7+
tokenizer="standard",
8+
filter=[
9+
"asciifolding"
10+
],
11+
text="açaí à la carte",
12+
)
13+
print(resp)
14+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// analysis/analyzers/lang-analyzer.asciidoc:1204
3+
4+
[source, python]
5+
----
6+
resp = client.indices.create(
7+
index="italian_example",
8+
settings={
9+
"analysis": {
10+
"filter": {
11+
"italian_elision": {
12+
"type": "elision",
13+
"articles": [
14+
"c",
15+
"l",
16+
"all",
17+
"dall",
18+
"dell",
19+
"nell",
20+
"sull",
21+
"coll",
22+
"pell",
23+
"gl",
24+
"agl",
25+
"dagl",
26+
"degl",
27+
"negl",
28+
"sugl",
29+
"un",
30+
"m",
31+
"t",
32+
"s",
33+
"v",
34+
"d"
35+
],
36+
"articles_case": True
37+
},
38+
"italian_stop": {
39+
"type": "stop",
40+
"stopwords": "_italian_"
41+
},
42+
"italian_keywords": {
43+
"type": "keyword_marker",
44+
"keywords": [
45+
"esempio"
46+
]
47+
},
48+
"italian_stemmer": {
49+
"type": "stemmer",
50+
"language": "light_italian"
51+
}
52+
},
53+
"analyzer": {
54+
"rebuilt_italian": {
55+
"tokenizer": "standard",
56+
"filter": [
57+
"italian_elision",
58+
"lowercase",
59+
"italian_stop",
60+
"italian_keywords",
61+
"italian_stemmer"
62+
]
63+
}
64+
}
65+
}
66+
},
67+
)
68+
print(resp)
69+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// inference/service-elasticsearch.asciidoc:111
3+
4+
[source, python]
5+
----
6+
resp = client.perform_request(
7+
"PUT",
8+
"/_inference/text_embedding/my-e5-model",
9+
headers={"Content-Type": "application/json"},
10+
body={
11+
"service": "elasticsearch",
12+
"service_settings": {
13+
"num_allocations": 1,
14+
"num_threads": 1,
15+
"model_id": ".multilingual-e5-small"
16+
}
17+
},
18+
)
19+
print(resp)
20+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// ingest/common-log-format-example.asciidoc:161
3+
4+
[source, python]
5+
----
6+
resp = client.indices.put_index_template(
7+
name="my-data-stream-template",
8+
index_patterns=[
9+
"my-data-stream*"
10+
],
11+
data_stream={},
12+
priority=500,
13+
)
14+
print(resp)
15+
----
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// This file is autogenerated, DO NOT EDIT
12
// aggregations/bucket/filter-aggregation.asciidoc:58
23

34
[source, python]
@@ -6,10 +7,18 @@ resp = client.search(
67
index="sales",
78
size="0",
89
filter_path="aggregations",
9-
body={
10-
"query": {"term": {"type": "t-shirt"}},
11-
"aggs": {"avg_price": {"avg": {"field": "price"}}},
10+
query={
11+
"term": {
12+
"type": "t-shirt"
13+
}
14+
},
15+
aggs={
16+
"avg_price": {
17+
"avg": {
18+
"field": "price"
19+
}
20+
}
1221
},
1322
)
1423
print(resp)
15-
----
24+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// alias.asciidoc:52
3+
4+
[source, python]
5+
----
6+
resp = client.indices.update_aliases(
7+
actions=[
8+
{
9+
"add": {
10+
"index": "logs-*",
11+
"alias": "logs"
12+
}
13+
}
14+
],
15+
)
16+
print(resp)
17+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// analysis/tokenfilters/asciifolding-tokenfilter.asciidoc:118
3+
4+
[source, python]
5+
----
6+
resp = client.indices.create(
7+
index="asciifold_example",
8+
settings={
9+
"analysis": {
10+
"analyzer": {
11+
"standard_asciifolding": {
12+
"tokenizer": "standard",
13+
"filter": [
14+
"my_ascii_folding"
15+
]
16+
}
17+
},
18+
"filter": {
19+
"my_ascii_folding": {
20+
"type": "asciifolding",
21+
"preserve_original": True
22+
}
23+
}
24+
}
25+
},
26+
)
27+
print(resp)
28+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// transform/apis/start-transform.asciidoc:79
3+
4+
[source, python]
5+
----
6+
resp = client.transform.start_transform(
7+
transform_id="ecommerce_transform",
8+
)
9+
print(resp)
10+
----
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This file is autogenerated, DO NOT EDIT
2+
// aggregations.asciidoc:36
3+
4+
[source, python]
5+
----
6+
resp = client.search(
7+
index="my-index-000001",
8+
aggs={
9+
"my-agg-name": {
10+
"terms": {
11+
"field": "my-field"
12+
}
13+
}
14+
},
15+
)
16+
print(resp)
17+
----

0 commit comments

Comments
 (0)