Scripting: add available languages & contexts API#49652
Scripting: add available languages & contexts API#49652stu-elastic merged 4 commits intoelastic:masterfrom
Conversation
Adds `GET /_script_language` to support Kibana dynamic scripting
language selection.
Response contains whether `inline` and/or `stored` scripts are
enabled as determined by the `script.allowed_types` settings.
For each scripting language registered, such as `painless`,
`expression`, `mustache` or custom, available contexts for the language
are included as determined by the `script.allowed_contexts` setting.
Response format:
```
{
"types_allowed": [
"inline",
"stored"
],
"language_contexts": [
{
"language": "expression",
"contexts": [
"aggregation_selector",
"aggs"
...
]
},
{
"language": "painless",
"contexts": [
"aggregation_selector",
"aggs",
"aggs_combine",
...
]
}
...
]
}
```
Fixes: elastic#49463
|
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
jdconrad
left a comment
There was a problem hiding this comment.
This looks great! Thanks for adding this. Just one minor note.
|
|
||
| @Override | ||
| public List<ScriptContext<?>> getSupportedContexts() { | ||
| return List.of(TemplateScript.CONTEXT); |
There was a problem hiding this comment.
Note that if we backport this to a version requiring Java 8, List.of wasn't introduced yet.
There was a problem hiding this comment.
I intend to address that in the backport. No reason to avoid using it here.
|
|
||
| @Override | ||
| public List<ScriptContext<?>> getSupportedContexts() { | ||
| return List.of(ScoreScript.CONTEXT); |
There was a problem hiding this comment.
Same as the comment above.
rjernst
left a comment
There was a problem hiding this comment.
A couple minor comments. Can we please have a javdoc or docs or something with an example of the response structure?
| /** | ||
| * Script contexts supported by this engine. | ||
| */ | ||
| List<ScriptContext<?>> getSupportedContexts(); |
There was a problem hiding this comment.
Why a List when we have the info in Set form already?
|
|
||
| public ScriptLanguagesInfo(StreamInput in) throws IOException { | ||
| typesAllowed = readStringSet(in); | ||
| languageContexts = readStringMapSet(in); |
There was a problem hiding this comment.
this can be readMap(StreamInput::readString, in -> in.readSet(StreamInput::readString)). Similar for the write side. None of the utility read/write methods here should be necessary.
… use readMap(StreamInput::readString
Added to |
Adds `GET /_script_language` to support Kibana dynamic scripting
language selection.
Response contains whether `inline` and/or `stored` scripts are
enabled as determined by the `script.allowed_types` settings.
For each scripting language registered, such as `painless`,
`expression`, `mustache` or custom, available contexts for the language
are included as determined by the `script.allowed_contexts` setting.
Response format:
```
{
"types_allowed": [
"inline",
"stored"
],
"language_contexts": [
{
"language": "expression",
"contexts": [
"aggregation_selector",
"aggs"
...
]
},
{
"language": "painless",
"contexts": [
"aggregation_selector",
"aggs",
"aggs_combine",
...
]
}
...
]
}
```
Fixes: elastic#49463
Adds `GET /_script_language` to support Kibana dynamic scripting
language selection.
Response contains whether `inline` and/or `stored` scripts are
enabled as determined by the `script.allowed_types` settings.
For each scripting language registered, such as `painless`,
`expression`, `mustache` or custom, available contexts for the language
are included as determined by the `script.allowed_contexts` setting.
Response format:
```
{
"types_allowed": [
"inline",
"stored"
],
"language_contexts": [
{
"language": "expression",
"contexts": [
"aggregation_selector",
"aggs"
...
]
},
{
"language": "painless",
"contexts": [
"aggregation_selector",
"aggs",
"aggs_combine",
...
]
}
...
]
}
```
Fixes: #49463
**Backport**
Adds `GET /_script_language` to support Kibana dynamic scripting
language selection.
Response contains whether `inline` and/or `stored` scripts are
enabled as determined by the `script.allowed_types` settings.
For each scripting language registered, such as `painless`,
`expression`, `mustache` or custom, available contexts for the language
are included as determined by the `script.allowed_contexts` setting.
Response format:
```
{
"types_allowed": [
"inline",
"stored"
],
"language_contexts": [
{
"language": "expression",
"contexts": [
"aggregation_selector",
"aggs"
...
]
},
{
"language": "painless",
"contexts": [
"aggregation_selector",
"aggs",
"aggs_combine",
...
]
}
...
]
}
```
Fixes: elastic#49463
Adds
GET /_script_languageto support Kibana dynamic scriptinglanguage selection.
Response contains whether
inlineand/orstoredscripts areenabled as determined by the
script.allowed_typessettings.For each scripting language registered, such as
painless,expression,mustacheor custom, available contexts for the languageare included as determined by the
script.allowed_contextssetting.Response format:
Fixes: #49463