Skip to content

Commit

Permalink
[EPM] update epm filepath route (elastic#61910)
Browse files Browse the repository at this point in the history
* update epm filepath route

* add CHANGELOG

* add title

* fix path in changelog

* fix typo
  • Loading branch information
neptunian committed Mar 31, 2020
1 parent ca6d40b commit 9099c19
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions x-pack/plugins/ingest_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion x-pack/plugins/ingest_manager/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
};

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/ingest_manager/server/routes/epm/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ export const getFileHandler: RequestHandler<TypeOf<typeof GetFileRequestSchema.p
response
) => {
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<typeof registryResponse.body> = {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/ingest_manager/server/types/rest_spec/epm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}),
};
Expand Down
16 changes: 8 additions & 8 deletions x-pack/test/epm_api_integration/apis/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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');
});
Expand All @@ -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')
Expand All @@ -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);
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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);
Expand All @@ -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')
Expand Down

0 comments on commit 9099c19

Please sign in to comment.