forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate savedObjects routes to core (elastic#56734)
* migrate `get` route * migrate `create` route * migrate `delete` route * migrate `find` route * migrate `update` route * migrate `bulk_get` route * migrate `bulk_create` route * remove route-related mixin tests * migrate `bulk_update` route * fix expectTypeRequired assertion * migrate `log_legacy_imports` route * migrate `export` route * fix karma tests * array is better than object in some situations. * remove prototype pollution tests * adapt ftr assertions * adapt ftr assertions * adapt yet more ftr assertions * migrate `import` route * fix test tests * fix getSortedObjectsForExport usages * fix snapshots * fix so ui exports usages due to merge * create router with prefix * creates `savedObjects` namespace config in addition to `migrations` * migrate `resolve_import_errors` route * remove old types file * fix FTR assertion * remove types parameter from copy_to_space * move route tests to integration_tests * use byteSize instead of number * fix unit tests * add has_reference query parameter Co-authored-by: Mikhail Shustov <[email protected]>
- Loading branch information
1 parent
7efe873
commit ff7cd43
Showing
74 changed files
with
2,091 additions
and
2,509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { IRouter } from '../../http'; | ||
|
||
export const registerBulkCreateRoute = (router: IRouter) => { | ||
router.post( | ||
{ | ||
path: '/_bulk_create', | ||
validate: { | ||
query: schema.object({ | ||
overwrite: schema.boolean({ defaultValue: false }), | ||
}), | ||
body: schema.arrayOf( | ||
schema.object({ | ||
type: schema.string(), | ||
id: schema.maybe(schema.string()), | ||
attributes: schema.recordOf(schema.string(), schema.any()), | ||
version: schema.maybe(schema.string()), | ||
migrationVersion: schema.maybe(schema.recordOf(schema.string(), schema.string())), | ||
references: schema.maybe( | ||
schema.arrayOf( | ||
schema.object({ | ||
name: schema.string(), | ||
type: schema.string(), | ||
id: schema.string(), | ||
}) | ||
) | ||
), | ||
}) | ||
), | ||
}, | ||
}, | ||
router.handleLegacyErrors(async (context, req, res) => { | ||
const { overwrite } = req.query; | ||
const result = await context.core.savedObjects.client.bulkCreate(req.body, { overwrite }); | ||
return res.ok({ body: result }); | ||
}) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { IRouter } from '../../http'; | ||
|
||
export const registerBulkUpdateRoute = (router: IRouter) => { | ||
router.put( | ||
{ | ||
path: '/_bulk_update', | ||
validate: { | ||
body: schema.arrayOf( | ||
schema.object({ | ||
type: schema.string(), | ||
id: schema.string(), | ||
attributes: schema.recordOf(schema.string(), schema.any()), | ||
version: schema.maybe(schema.string()), | ||
references: schema.maybe( | ||
schema.arrayOf( | ||
schema.object({ | ||
name: schema.string(), | ||
type: schema.string(), | ||
id: schema.string(), | ||
}) | ||
) | ||
), | ||
}) | ||
), | ||
}, | ||
}, | ||
router.handleLegacyErrors(async (context, req, res) => { | ||
const savedObject = await context.core.savedObjects.client.bulkUpdate(req.body); | ||
return res.ok({ body: savedObject }); | ||
}) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
import { IRouter } from '../../http'; | ||
|
||
export const registerCreateRoute = (router: IRouter) => { | ||
router.post( | ||
{ | ||
path: '/{type}/{id?}', | ||
validate: { | ||
params: schema.object({ | ||
type: schema.string(), | ||
id: schema.maybe(schema.string()), | ||
}), | ||
query: schema.object({ | ||
overwrite: schema.boolean({ defaultValue: false }), | ||
}), | ||
body: schema.object({ | ||
attributes: schema.recordOf(schema.string(), schema.any()), | ||
migrationVersion: schema.maybe(schema.recordOf(schema.string(), schema.string())), | ||
references: schema.maybe( | ||
schema.arrayOf( | ||
schema.object({ | ||
name: schema.string(), | ||
type: schema.string(), | ||
id: schema.string(), | ||
}) | ||
) | ||
), | ||
}), | ||
}, | ||
}, | ||
router.handleLegacyErrors(async (context, req, res) => { | ||
const { type, id } = req.params; | ||
const { overwrite } = req.query; | ||
const { attributes, migrationVersion, references } = req.body; | ||
|
||
const options = { id, overwrite, migrationVersion, references }; | ||
const result = await context.core.savedObjects.client.create(type, attributes, options); | ||
return res.ok({ body: result }); | ||
}) | ||
); | ||
}; |
Oops, something went wrong.