Skip to content

Commit 8eb7f05

Browse files
authored
Merge branch 'main' into api-examples-pt6
2 parents 02db0ac + df2dbc1 commit 8eb7f05

File tree

36 files changed

+1863
-5228
lines changed

36 files changed

+1863
-5228
lines changed

.github/download-artifacts/index.js

Lines changed: 22 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,21 @@ const downloadedSpec = join(esFolder, 'rest-api-spec', 'api')
4040
const specFolder = join(__dirname, '..', '..', 'specification', '_json_spec')
4141

4242
async function downloadArtifacts (opts) {
43-
if (typeof opts.version !== 'string' && typeof opts.branch !== 'string') {
44-
throw new Error('Missing version or branch')
43+
if (typeof opts.branch !== 'string') {
44+
throw new Error('Missing branch')
4545
}
4646

47-
core.info('Checking out spec and test')
47+
core.info('Resolving artifact URL')
4848

49-
core.info('Resolving version')
5049
let resolved
5150
try {
52-
resolved = await resolve(opts.version || fromBranch(opts.branch), opts.hash)
51+
resolved = await resolve(opts.branch)
5352
} catch (err) {
5453
core.error(err.message)
5554
process.exit(1)
5655
}
5756

58-
opts.version = resolved.version
59-
core.info(`Resolved version ${opts.version}`)
57+
core.info(`Resolved artifact URL for ${resolved.commit_url}`)
6058

6159
core.info('Cleanup')
6260
await rm(esFolder)
@@ -96,74 +94,29 @@ async function downloadArtifacts (opts) {
9694
core.info('Done')
9795
}
9896

99-
async function resolve (version, hash) {
100-
if (version === 'latest') {
101-
const response = await fetch('https://artifacts-api.elastic.co/v1/versions')
102-
if (!response.ok) {
103-
throw new Error(`unexpected response ${response.statusText}`)
104-
}
105-
const { versions } = await response.json()
106-
version = versions.pop()
97+
async function resolve (branch) {
98+
if (branch == 'main') {
99+
branch = 'master'
107100
}
108-
109-
core.info(`Resolving version ${version}`)
110-
const response = await fetch(`https://artifacts-api.elastic.co/v1/versions/${version}`)
101+
const url = `https://artifacts-snapshot.elastic.co/elasticsearch/latest/${branch}.json`
102+
const response = await fetch(url)
111103
if (!response.ok) {
112-
throw new Error(`unexpected response ${response.statusText}`)
104+
throw new Error(`Unexpected response. Invalid version? ${url}: ${response.statusText}`)
113105
}
114-
115106
const data = await response.json()
116-
const esBuilds = data.version.builds
117-
.filter(build => build.projects.elasticsearch != null)
118-
.map(build => {
119-
return {
120-
projects: build.projects.elasticsearch,
121-
buildId: build.build_id,
122-
date: build.start_time,
123-
version: build.version
124-
}
125-
})
126-
.sort((a, b) => {
127-
const dA = new Date(a.date)
128-
const dB = new Date(b.date)
129-
if (dA > dB) return -1
130-
if (dA < dB) return 1
131-
return 0
132-
})
133-
134-
if (hash != null) {
135-
const build = esBuilds.find(build => build.projects.commit_hash === hash)
136-
if (!build) {
137-
throw new Error(`Can't find any build with hash '${hash}'`)
138-
}
139-
const zipKey = Object.keys(build.projects.packages).find(key => key.startsWith('rest-resources-zip-') && key.endsWith('.zip'))
140-
return {
141-
url: build.projects.packages[zipKey].url,
142-
id: build.buildId,
143-
hash: build.projects.commit_hash,
144-
version: build.version
145-
}
146-
}
147107

148-
const lastBuild = esBuilds[0]
149-
const zipKey = Object.keys(lastBuild.projects.packages).find(key => key.startsWith('rest-resources-zip-') && key.endsWith('.zip'))
150-
return {
151-
url: lastBuild.projects.packages[zipKey].url,
152-
id: lastBuild.buildId,
153-
hash: lastBuild.projects.commit_hash,
154-
version: lastBuild.version
108+
let manifest_url = data.manifest_url
109+
const manifestResponse = await fetch(manifest_url)
110+
if (!manifestResponse.ok) {
111+
throw new Error(`Unexpected manifestResponse. ${manifest_url}: ${manifestResponse.statusText}`)
155112
}
156-
}
113+
const manifestData = await manifestResponse.json()
114+
const elasticsearch = manifestData.projects.elasticsearch
115+
const restResourceName = `rest-resources-zip-${manifestData.version}.zip`
157116

158-
function fromBranch (branch) {
159-
if (branch === 'main') {
160-
return 'latest'
161-
} else if (branch === '7.x') {
162-
return '7.x-SNAPSHOT'
163-
} else if ((branch.startsWith('7.') || branch.startsWith('8.')) && !isNaN(Number(branch.split('.')[1]))) {
164-
return `${branch}-SNAPSHOT`
165-
} else {
166-
throw new Error(`Cannot derive version from branch '${branch}'`)
117+
return {
118+
url: elasticsearch.packages[restResourceName].url,
119+
commit_url: elasticsearch.commit_url,
167120
}
168121
}
169122

@@ -172,7 +125,7 @@ async function main (options) {
172125
}
173126

174127
const options = minimist(process.argv.slice(2), {
175-
string: ['id', 'version', 'hash', 'branch']
128+
string: ['branch']
176129
})
177130
main(options).catch(t => {
178131
core.error(t)

.github/workflows/update-rest-api-json.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
branch: ['main', '8.14', '8.15', '7.17']
16+
branch: ['main', '8.x', '8.15', '7.17']
1717

1818
steps:
1919
- uses: actions/checkout@v4
@@ -37,7 +37,7 @@ jobs:
3737
3838
- name: Generate output
3939
run: |
40-
SKIP_VERSION_UPDATE=true make contrib
40+
make contrib
4141
4242
- name: Debug git status
4343
run: |

compiler-rs/clients_schema_to_openapi/package-lock.json

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

compiler-rs/clients_schema_to_openapi/src/paths.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ pub fn add_endpoint(
4747
}
4848

4949
// Namespace
50-
// let namespace = match endpoint.name.split_once('.') {
51-
// Some((ns, _)) => ns,
52-
// None => "core",
53-
//};
50+
let namespace = match endpoint.name.split_once('.') {
51+
Some((ns, _)) => ns,
52+
None => &endpoint.name,
53+
};
5454

5555
// Will we produce multiple paths? If true, we will register components for reuse across paths
5656
let is_multipath = endpoint.urls.len() > 1 || endpoint.urls.iter().any(|u| u.methods.len() > 1);
@@ -196,10 +196,11 @@ pub fn add_endpoint(
196196

197197
// Create the operation, it will be repeated if we have several methods
198198
let operation = openapiv3::Operation {
199-
tags: vec![endpoint.name.clone()],
199+
tags: vec![namespace.to_string()],
200200
summary: sum_desc.summary,
201201
description: sum_desc.description,
202-
external_docs: tac.convert_external_docs(endpoint),
202+
// external_docs: tac.convert_external_docs(endpoint),
203+
external_docs: None, // Need values that differ from client purposes
203204
operation_id: None, // set in clone_operation below with operation_counter
204205
parameters,
205206
request_body: request_body.clone(),
-105 Bytes
Binary file not shown.

docs/overlays/elasticsearch-openapi-overlays.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ actions:
4040
examples:
4141
resetFeaturesResponseExample1:
4242
$ref: "../../specification/features/reset_features/ResetFeaturesResponseExample1.json"
43-
- target: "$.components['requestBodies']['cluster.allocation_explain']"
43+
- target: "$.components['requestBodies']['cluster.allocation_explain']"
4444
description: "Add examples for cluster allocation explain operation"
4545
update:
4646
content:

0 commit comments

Comments
 (0)