Skip to content

Commit 2147d34

Browse files
committed
Add specification for ESQL Views CRUD
This adds support for (get|put|delete)-view APIs to the specification Relates to elastic/elasticsearch#137818
1 parent 6caf375 commit 2147d34

File tree

14 files changed

+747
-0
lines changed

14 files changed

+747
-0
lines changed

output/schema/schema.json

Lines changed: 363 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/validation-errors.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
"Request: query parameter 'timeout' does not exist in the json spec"
1313
],
1414
"response": []
15+
},
16+
"esql.get_view": {
17+
"request": [
18+
"Request: different number of urls in the json spec",
19+
"Request: path parameter 'name' is optional in the json spec"
20+
],
21+
"response": []
1522
}
1623
},
1724
"generalErrors": [

output/typescript/types.ts

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_doc_ids/table.csv

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ esql-query-params,https://www.elastic.co/docs/explore-analyze/query-filter/langu
230230
esql-returning-localized-results,https://www.elastic.co/docs/explore-analyze/query-filter/languages/esql-rest#esql-locale-param,,
231231
esql-get-query,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-get-query,,
232232
esql-list-queries,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-list-queries,,
233+
esql-get-view,,,
234+
esql-put-view,,,
235+
esql-delete-view,,,
233236
evaluate-dfanalytics,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-evaluate-data-frame,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/evaluate-dfanalytics.html,
234237
execute-enrich-policy-api,https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-enrich-execute-policy,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/execute-enrich-policy-api.html,
235238
execute-watch,https://www.elastic.co/docs/explore-analyze/alerts-cases/watcher/execute-watch,https://www.elastic.co/guide/en/elasticsearch/reference/8.18/watcher-api-execute-watch.html,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"esql.delete_view": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-view-delete",
5+
"description": "Delete a non-materialized VIEW for ESQL."
6+
},
7+
"stability": "experimental",
8+
"visibility": "feature_flag",
9+
"feature_flag": "esql_views",
10+
"headers": {
11+
"accept": [
12+
"application/json"
13+
],
14+
"content_type": [
15+
"application/json"
16+
]
17+
},
18+
"url": {
19+
"paths": [
20+
{
21+
"path": "/_query/view/{name}",
22+
"methods": [
23+
"DELETE"
24+
],
25+
"parts": {
26+
"name": {
27+
"type": "string",
28+
"description": "The name of the view to delete"
29+
}
30+
}
31+
}
32+
]
33+
}
34+
}
35+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"esql.get_view": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-view-get",
5+
"description": "Get a non-materialized VIEW for ESQL."
6+
},
7+
"stability": "experimental",
8+
"visibility": "feature_flag",
9+
"feature_flag": "esql_views",
10+
"headers": {
11+
"accept": [
12+
"application/json"
13+
],
14+
"content_type": [
15+
"application/json"
16+
]
17+
},
18+
"url": {
19+
"paths": [
20+
{
21+
"path": "/_query/view/{name}",
22+
"methods": [
23+
"GET"
24+
],
25+
"parts": {
26+
"name": {
27+
"type": "list",
28+
"description": "A comma-separated list of view names"
29+
}
30+
}
31+
},
32+
{
33+
"path": "/_query/view",
34+
"methods": [
35+
"GET"
36+
]
37+
}
38+
]
39+
}
40+
}
41+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"esql.put_view": {
3+
"documentation": {
4+
"url": "https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-esql-view-put",
5+
"description": "Creates a non-materialized VIEW for ESQL."
6+
},
7+
"stability": "experimental",
8+
"visibility": "feature_flag",
9+
"feature_flag": "esql_views",
10+
"headers": {
11+
"accept": [
12+
"application/json"
13+
],
14+
"content_type": [
15+
"application/json"
16+
]
17+
},
18+
"url": {
19+
"paths": [
20+
{
21+
"path": "/_query/view/{name}",
22+
"methods": [
23+
"PUT"
24+
],
25+
"parts": {
26+
"name": {
27+
"type": "string",
28+
"description": "The name of the view to create or update"
29+
}
30+
}
31+
}
32+
]
33+
},
34+
"body": {
35+
"description": "Use the `query` element to define the ES|QL query to use as a non-materialized VIEW.",
36+
"required": true
37+
}
38+
}
39+
}

specification/esql/_types/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,15 @@
2020
import { FieldValue } from '@_types/common'
2121

2222
export type ESQLParam = FieldValue | FieldValue[]
23+
24+
/**
25+
*
26+
* A non-materialized ES|QL view.
27+
*
28+
*/
29+
export class ESQLView {
30+
/** The name of the ES|QL view */
31+
name: string
32+
/** The ES|QL query */
33+
query: string
34+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { Id, MediaType } from '@_types/common'
22+
23+
/**
24+
* Delete an ES|QL view.
25+
*
26+
* Deletes a stored ES|QL view.
27+
*
28+
* @rest_spec_name esql.delete_view
29+
* @cluster_privileges monitor_esql
30+
* @availability stack since=9.3.0 stability=experimental visibility=feature_flag feature_flag=esql_views
31+
* @availability serverless stability=experimental visibility=feature_flag feature_flag=esql_views
32+
* @doc_id esql-delete-view
33+
*/
34+
export interface Request extends RequestBase {
35+
urls: [
36+
{
37+
path: '/_query/view/{name}'
38+
methods: ['DELETE']
39+
}
40+
]
41+
path_parts: {
42+
/** The view name to remove. */
43+
name: Id
44+
}
45+
request_media_type: MediaType.Json
46+
response_media_type: MediaType.Json
47+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { AcknowledgedResponseBase } from '@_types/Base'
21+
22+
export class Response {
23+
/** @codegen_name result */
24+
body: AcknowledgedResponseBase
25+
}

0 commit comments

Comments
 (0)