diff --git a/x-pack/plugins/ingest_manager/CHANGELOG.md b/x-pack/plugins/ingest_manager/CHANGELOG.md new file mode 100644 index 0000000000000..b336c65b7c4b9 --- /dev/null +++ b/x-pack/plugins/ingest_manager/CHANGELOG.md @@ -0,0 +1,7 @@ +# Changelog +Significant or breaking changes to the Ingest Manager API will be documented in this file + +## 2020-03-30 + +### Breaking Changes +* Change EPM file path route from epm/packages/{pkgkey}/{filePath*} to epm/packages/{packageName}/{packageVersion}/{filePath*} [#61910](https://github.com/elastic/kibana/pull/61910) \ No newline at end of file diff --git a/x-pack/plugins/ingest_manager/common/constants/routes.ts b/x-pack/plugins/ingest_manager/common/constants/routes.ts index 5bf7c910168c0..a31d38a723c2c 100644 --- a/x-pack/plugins/ingest_manager/common/constants/routes.ts +++ b/x-pack/plugins/ingest_manager/common/constants/routes.ts @@ -13,12 +13,13 @@ export const FLEET_API_ROOT = `${API_ROOT}/fleet`; // EPM API routes const EPM_PACKAGES_MANY = `${EPM_API_ROOT}/packages`; const EPM_PACKAGES_ONE = `${EPM_PACKAGES_MANY}/{pkgkey}`; +const EPM_PACKAGES_FILE = `${EPM_PACKAGES_MANY}/{pkgName}/{pkgVersion}`; export const EPM_API_ROUTES = { LIST_PATTERN: EPM_PACKAGES_MANY, INFO_PATTERN: EPM_PACKAGES_ONE, INSTALL_PATTERN: EPM_PACKAGES_ONE, DELETE_PATTERN: EPM_PACKAGES_ONE, - FILEPATH_PATTERN: `${EPM_PACKAGES_ONE}/{filePath*}`, + FILEPATH_PATTERN: `${EPM_PACKAGES_FILE}/{filePath*}`, CATEGORIES_PATTERN: `${EPM_API_ROOT}/categories`, }; diff --git a/x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts index 727d26b5868de..48f37a4d65ac6 100644 --- a/x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts @@ -75,8 +75,7 @@ export const getFileHandler: RequestHandler { try { - const { pkgkey, filePath } = request.params; - const [pkgName, pkgVersion] = pkgkey.split('-'); + const { pkgName, pkgVersion, filePath } = request.params; const registryResponse = await getFile(`/package/${pkgName}/${pkgVersion}/${filePath}`); const contentType = registryResponse.headers.get('Content-Type'); const customResponseObj: CustomHttpResponseOptions = { diff --git a/x-pack/plugins/ingest_manager/server/types/rest_spec/epm.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/epm.ts index 2ca83276b0228..3ed6ee553a507 100644 --- a/x-pack/plugins/ingest_manager/server/types/rest_spec/epm.ts +++ b/x-pack/plugins/ingest_manager/server/types/rest_spec/epm.ts @@ -13,7 +13,8 @@ export const GetPackagesRequestSchema = { export const GetFileRequestSchema = { params: schema.object({ - pkgkey: schema.string(), + pkgName: schema.string(), + pkgVersion: schema.string(), filePath: schema.string(), }), }; diff --git a/x-pack/test/epm_api_integration/apis/file.ts b/x-pack/test/epm_api_integration/apis/file.ts index c67f472e8fb78..11ab906aa0ea4 100644 --- a/x-pack/test/epm_api_integration/apis/file.ts +++ b/x-pack/test/epm_api_integration/apis/file.ts @@ -28,7 +28,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest .get( - '/api/ingest_manager/epm/packages/auditd-2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png' + '/api/ingest_manager/epm/packages/auditd/2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'image/png') @@ -46,7 +46,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest - .get('/api/ingest_manager/epm/packages/auditd-2.0.4/img/icon.svg') + .get('/api/ingest_manager/epm/packages/auditd/2.0.4/img/icon.svg') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'image/svg'); }); @@ -60,7 +60,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest .get( - '/api/ingest_manager/epm/packages/auditd-2.0.4/auditbeat/rules/sample-rules-linux-32bit.conf' + '/api/ingest_manager/epm/packages/auditd/2.0.4/auditbeat/rules/sample-rules-linux-32bit.conf' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') @@ -78,7 +78,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest - .get('/api/ingest_manager/epm/packages/auditd-2.0.4/auditbeat/config/config.yml') + .get('/api/ingest_manager/epm/packages/auditd/2.0.4/auditbeat/config/config.yml') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'text/yaml; charset=UTF-8') .expect(200); @@ -94,7 +94,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest .get( - '/api/ingest_manager/epm/packages/auditd-2.0.4/kibana/visualization/b21e0c70-c252-11e7-8692-232bd1143e8a-ecs.json' + '/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/visualization/b21e0c70-c252-11e7-8692-232bd1143e8a-ecs.json' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') @@ -111,7 +111,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest .get( - '/api/ingest_manager/epm/packages/auditd-2.0.4/kibana/dashboard/7de391b0-c1ca-11e7-8995-936807a28b16-ecs.json' + '/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/dashboard/7de391b0-c1ca-11e7-8995-936807a28b16-ecs.json' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') @@ -126,7 +126,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest - .get('/api/ingest_manager/epm/packages/auditd-2.0.4/kibana/index-pattern/auditbeat-*.json') + .get('/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/index-pattern/auditbeat-*.json') .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8') .expect(200); @@ -141,7 +141,7 @@ export default function({ getService }: FtrProviderContext) { const supertest = getService('supertest'); await supertest .get( - '/api/ingest_manager/epm/packages/auditd-2.0.4/kibana/search/0f10c430-c1c3-11e7-8995-936807a28b16-ecs.json' + '/api/ingest_manager/epm/packages/auditd/2.0.4/kibana/search/0f10c430-c1c3-11e7-8995-936807a28b16-ecs.json' ) .set('kbn-xsrf', 'xxx') .expect('Content-Type', 'application/json; charset=utf-8')