Skip to content

Commit dc86bd6

Browse files
committed
Merge branch '8.17' into automated/rest-api-spec-update-8.17
2 parents 06ab42d + 9cb5929 commit dc86bd6

File tree

951 files changed

+31011
-7712
lines changed

Some content is hidden

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

951 files changed

+31011
-7712
lines changed

.buildkite/kibana.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Since we're into the current repo, move to the top-level
6+
cd ..
7+
8+
echo "--- Clone elasticsearch-js"
9+
git clone -v -- [email protected]:elastic/elasticsearch-js.git
10+
pushd elasticsearch-js
11+
git checkout $BUILDKITE_BRANCH
12+
popd
13+
14+
echo "--- Clone Kibana"
15+
git clone -v --reference /usr/local/git-references/git-github-com-elastic-kibana-git -- [email protected]:elastic/kibana.git
16+
cd kibana
17+
18+
echo "--- Install Node.js and Yarn"
19+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
20+
set +e # https://github.com/nvm-sh/nvm/issues/3117
21+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
22+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
23+
set -e
24+
25+
nvm install
26+
nvm use
27+
npm install --global yarn
28+
29+
echo "--- Install elasticsearch-js"
30+
pushd ../elasticsearch-js
31+
npm install
32+
npm run build
33+
npm pack
34+
popd
35+
yarn add ../elasticsearch-js/elastic-elasticsearch-*.tgz
36+
37+
echo "--- Bootstrap Kibana"
38+
git --no-pager diff
39+
yarn kbn bootstrap --allow-root
40+
41+
echo "--- Check types"
42+
node scripts/type_check.js

.buildkite/kibana.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
agents:
2+
memory: "24G"
3+
cpu: "4"
4+
ephemeralStorage: 15Gi
5+
6+
7+
steps:
8+
- label: "Run Kibana type checks"
9+
command: .buildkite/kibana.sh

.github/validate-pr/index.js

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,37 @@
1919

2020
/* global argv, path, cd */
2121

22-
'use strict'
22+
import { dirname } from 'path'
23+
import { fileURLToPath } from 'url'
24+
import 'zx/globals'
25+
import assert from 'assert'
26+
import * as core from '@actions/core'
27+
import { copyFile } from 'fs/promises'
28+
import * as github from '@actions/github'
29+
import specification from '../../output/schema/schema.json' assert { type: 'json' }
30+
import { run as getReport } from '../../../clients-flight-recorder/scripts/types-validator/index.js'
31+
import {
32+
getNamespace,
33+
getName
34+
} from '../../../clients-flight-recorder/scripts/types-validator/utils.js'
35+
36+
const __dirname = dirname(fileURLToPath(import.meta.url))
2337

24-
require('zx/globals')
25-
const assert = require('assert')
26-
const core = require('@actions/core')
27-
const { copyFile } = require('fs/promises')
28-
const github = require('@actions/github')
2938
const octokit = github.getOctokit(argv.token)
30-
const specification = require('../../output/schema/schema.json')
31-
const getReport = require('../../../clients-flight-recorder/scripts/types-validator')
32-
const { getNamespace, getName } = require('../../../clients-flight-recorder/scripts/types-validator/utils')
3339

3440
const privateNames = ['_global']
3541
const tick = '`'
36-
const tsValidationPath = path.join(__dirname, '..', '..', '..', 'clients-flight-recorder', 'scripts', 'types-validator')
37-
38-
async function run () {
42+
const tsValidationPath = path.join(
43+
__dirname,
44+
'..',
45+
'..',
46+
'..',
47+
'clients-flight-recorder',
48+
'scripts',
49+
'types-validator'
50+
)
51+
52+
async function run() {
3953
await copyFile(
4054
path.join(__dirname, '..', '..', 'output', 'typescript', 'types.ts'),
4155
path.join(tsValidationPath, 'types.ts')
@@ -53,14 +67,20 @@ async function run () {
5367
per_page: 100
5468
})
5569
if (data.length > 0) {
56-
files.push(...data.map(entry => entry.filename))
70+
files.push(
71+
...data
72+
.filter((entry) => entry.status !== 'deleted')
73+
.map((entry) => entry.filename)
74+
)
5775
page += 1
5876
} else {
5977
break
6078
}
6179
}
6280

63-
const specFiles = files.filter(file => file.includes('specification') && !file.includes('compiler/test'))
81+
const specFiles = files.filter(
82+
(file) => file.includes('specification') && !file.includes('compiler/test')
83+
)
6484
const table = []
6585

6686
cd(tsValidationPath)
@@ -163,7 +183,7 @@ function generateResponse (r) {
163183
return `${r.passingResponse}/${r.totalResponse}`
164184
}
165185

166-
run().catch(err => {
186+
run().catch((err) => {
167187
core.error(err)
168188
process.exit(1)
169189
})

.github/validate-pr/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "validate-pr",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"type": "module",
6+
"exports": "./index.js",
67
"scripts": {
78
"test": "echo \"Error: no test specified\" && exit 1"
89
},

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ setup: ## Install dependencies for contrib target
3939
@make clean-dep
4040
@npm install --prefix compiler
4141
@npm install --prefix typescript-generator
42-
@npm install @stoplight/spectral-cli
42+
@npm install @redocly/cli
4343

4444
clean-dep: ## Clean npm dependencies
4545
@rm -rf compiler/node_modules
@@ -57,19 +57,19 @@ filter-for-serverless: ## Generate the serverless version from the compiled sche
5757
dump-routes: ## Create a new schema with all generics expanded
5858
@npm run dump-routes --prefix compiler
5959

60-
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless ## Pre contribution target
61-
6260
overlay-docs: ## Apply overlays to OpenAPI documents
6361
@npx bump overlay "output/openapi/elasticsearch-openapi.json" "docs/overlays/elasticsearch-openapi-overlays.yaml" > "output/openapi/elasticsearch-openapi.tmp1.json"
6462
@npx bump overlay "output/openapi/elasticsearch-openapi.tmp1.json" "docs/overlays/elasticsearch-shared-overlays.yaml" > "output/openapi/elasticsearch-openapi.tmp2.json"
6563
@npx @redocly/cli bundle output/openapi/elasticsearch-openapi.tmp2.json --ext json -o output/openapi/elasticsearch-openapi.examples.json
6664
rm output/openapi/elasticsearch-openapi.tmp*.json
6765

6866
lint-docs: ## Lint the OpenAPI documents after overlays
69-
@npx @stoplight/spectral-cli lint output/openapi/elasticsearch-*.examples.json --ruleset .spectral.yaml
67+
@npx @redocly/cli lint "output/openapi/elasticsearch-*.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
68+
69+
lint-docs-stateful: ## Lint only the elasticsearch-openapi.examples.json file
70+
@npx @redocly/cli lint "output/openapi/elasticsearch-openapi.examples.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
7071

71-
lint-docs-errs: ## Lint the OpenAPI documents after overlays and return only errors
72-
@npx @stoplight/spectral-cli lint output/openapi/elasticsearch-*.examples.json --ruleset .spectral.yaml -D
72+
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs ## Pre contribution target
7373

7474
help: ## Display help
7575
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

catalog-info.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
3+
apiVersion: backstage.io/v1alpha1
4+
kind: Component
5+
metadata:
6+
name: elasticsearch-specification
7+
8+
spec:
9+
type: library
10+
owner: group:devtools-team
11+
lifecycle: beta
12+
13+
---
14+
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/rre.schema.json
15+
apiVersion: backstage.io/v1alpha1
16+
kind: Resource
17+
metadata:
18+
name: kibana-type-checks-pipeline
19+
description: Run Kibana type checks against the specification
20+
21+
spec:
22+
type: buildkite-pipeline
23+
owner: group:devtools-team
24+
system: buildkite
25+
26+
implementation:
27+
apiVersion: buildkite.elastic.dev/v1
28+
kind: Pipeline
29+
metadata:
30+
name: Kibana type checks
31+
spec:
32+
repository: elastic/elasticsearch-specification
33+
pipeline_file: .buildkite/kibana.yml
34+
provider_settings:
35+
trigger_mode: none
36+
teams:
37+
devtools-team:
38+
access_level: MANAGE_BUILD_AND_READ
39+
everyone:
40+
access_level: READ_ONLY
41+
schedules:
42+
Daily main:
43+
branch: 'main'
44+
cronline: '0 4 * * *'
45+
message: 'Daily run for main branch'
46+
Daily 8.x:
47+
branch: '8.x'
48+
cronline: '0 4 * * *'
49+
message: 'Daily run for 8.x branch'
50+
Daily 8.17:
51+
branch: '8.17'
52+
cronline: '0 4 * * *'
53+
message: 'Daily run for 8.17 branch'
54+
Daily 8.18:
55+
branch: '8.18'
56+
cronline: '0 4 * * *'
57+
message: 'Daily run for 8.18 branch'

compiler/src/model/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ export function hoistRequestAnnotations (
668668
const privileges = [
669669
'all', 'cancel_task', 'create_snapshot', 'grant_api_key', 'manage', 'manage_api_key', 'manage_ccr',
670670
'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines',
671-
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules',
671+
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml', 'manage_search_application', 'manage_search_query_rules', 'manage_search_synonyms',
672672
'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile',
673-
'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',
673+
'manage_watcher', 'monitor', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',
674674
'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client'
675675
]
676676
const values = parseCommaSeparated(value)

docs/add-new-api.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,35 @@ class Response {
153153
]
154154
}
155155
```
156+
157+
### Add endpoint request and response examples
158+
159+
Add an `examples` folder and `request` and `xxx_response` subfolders (where `xxx` is the relevant response code).
160+
161+
These examples are for use in the API documentation and must adhere to the [OpenAPI 3.0 Example object specification](https://spec.openapis.org/oas/v3.0.3#example-object). They must have a `value` field that contains the request or response body.
162+
If there are multiple examples for the endpoint, they must each have a brief `summary` field, which is used as the label for the example. You can also optionaly provide an explanation in a `description` field.
163+
164+
For example:
165+
166+
```yaml
167+
summary: Sequence query
168+
# method_request: GET /my-data-stream/_eql/search
169+
# type: request
170+
description: >
171+
Run `GET /my-data-stream/_eql/search` to search for a sequence of events.
172+
The sequence starts with an event with an `event.category` of `file`, a `file.name` of `cmd.exe`, and a `process.pid` other than `2013`.
173+
It is followed by an event with an `event.category` of `process` and a `process.executable` that contains the substring `regsvr32`.
174+
These events must also share the same `process.pid` value.
175+
value: |-
176+
{
177+
"query": """
178+
sequence by process.pid
179+
[ file where file.name == "cmd.exe" and process.pid != 2013 ]
180+
[ process where stringContains(process.executable, "regsvr32") ]
181+
"""
182+
}
183+
```
184+
185+
NOTE: A good example covers a very common use case or demonstrates a more complex but critical use case.
186+
It involves realistic data sets ( rather than generic "hello world" values).
187+
If it requires detailed setup or explanations, however, it is more appropriate for coverage in longer-form narrative documentation.
File renamed without changes.

docs/linters/redocly.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
extends:
2+
- recommended
3+
rules:
4+
# Built-in rules
5+
# Descriptions
6+
parameter-description: warn
7+
tag-description: warn
8+
operation-description: off
9+
# Document info
10+
info-contact: warn
11+
info-license: warn
12+
no-empty-servers: warn
13+
# Examples
14+
no-invalid-media-type-examples:
15+
severity: off
16+
allowAdditionalProperties: false
17+
no-invalid-schema-examples:
18+
severity: warn
19+
allowAdditionalProperties: false
20+
# Operations
21+
operation-operationId: error
22+
operation-operationId-unique: error
23+
operation-operationId-url-safe: warn
24+
operation-summary: warn
25+
# Parameters
26+
path-parameters-defined: warn
27+
# Paths
28+
no-ambiguous-paths: off
29+
no-identical-paths: warn
30+
path-excludes-patterns:
31+
severity: error
32+
patterns:
33+
- ^\/internal
34+
# Responses
35+
operation-4xx-response: off
36+
operation-2xx-response: off
37+
# Schema
38+
struct: error
39+
spec-components-invalid-map-name: off
40+
spec-strict-refs: off
41+
security-defined: off
42+
# Tags
43+
operation-tag-defined: off
44+
tags-alphabetical: off
45+
operation-singular-tag: off
46+
# Custom rules
47+
rule/operation-summary-length:
48+
subject:
49+
type: Operation
50+
property: summary
51+
message: Operation summary must have a minimum of 5 and maximum of 45 characters
52+
severity: warn
53+
assertions:
54+
maxLength: 45
55+
minLength: 5

0 commit comments

Comments
 (0)