mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [Changes deprecated SO HTTP APIs deprecation field to object (#197936)](https://github.com/elastic/kibana/pull/197936) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Christiane (Tina) Heiligers","email":"christiane.heiligers@elastic.co"},"sourceCommit":{"committedDate":"2024-11-07T20:49:05Z","message":"Changes deprecated SO HTTP APIs deprecation field to object (#197936)\n\nfix https://github.com/elastic/kibana/issues/197721.\r\n\r\nThe route deprecation field changed from a boolean to an object, where\r\nthe object contains information that is used in deprecation issues that\r\nthe Upgrade Assistant shows.\r\n\r\nThis PR makes the necessary changes in the deprecated Saved Objects HTTP\r\nAPIs.\r\n\r\nThis PR also includes a release notes entry for the API deprecations\r\nthat was missing.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### How to test this:\r\n\r\n- Pull PR, run es against a trial license and start kibana as usual.\r\n- Make a curl request to Kibana to get the config saved object: \r\n\r\n```\r\ncurl --location 'localhost:5601/abc/api/saved_objects/config/9.0.0' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept-Encoding: gzip, deflate, br' \\\r\n--header 'kbn-xsrf: kibana' \\\r\n--header 'Kbn-Version: 9.0.0' \\\r\n--header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ=='\r\n```\r\n\r\n- Navigate to Upgrade Assistant and observe Kibana has at least 1\r\ndeprecation warning.\r\n- View Kibana's warnings, you should see a warning entry for `The \"GET\r\n/api/saved_objects/{type}/{id}\" route is deprecated`\r\n\r\n\r\n\r\n- click on the deprecation and you should see more detail about the\r\ndeprecated API that's been used in the flyout:\r\n\r\n\r\n\r\n- resolve the deprecation warning\r\n- Kibana should continue to issue requests to the deprecated SO HTTP\r\nAPIs because these APIs have not been removed yet.\r\n\r\n\r\n### Risk Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| End user concern from the deprecation warning that says the routes\r\nhave been deprecated | Low | Low | The APIs have been deprecated since\r\n8.7 and recommends using public APIs instead. |\r\n\r\n### For maintainers\r\n\r\n- [x] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0df2e9838119d202eba0c6b2bcb7068b160f6005","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:deprecation","Team:Core","Feature:Saved Objects","backport missing","v9.0.0","docs","backport:prev-minor","Epic:Deprecations","Feature:OAS","v8.17.0"],"number":197936,"url":"https://github.com/elastic/kibana/pull/197936","mergeCommit":{"message":"Changes deprecated SO HTTP APIs deprecation field to object (#197936)\n\nfix https://github.com/elastic/kibana/issues/197721.\r\n\r\nThe route deprecation field changed from a boolean to an object, where\r\nthe object contains information that is used in deprecation issues that\r\nthe Upgrade Assistant shows.\r\n\r\nThis PR makes the necessary changes in the deprecated Saved Objects HTTP\r\nAPIs.\r\n\r\nThis PR also includes a release notes entry for the API deprecations\r\nthat was missing.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### How to test this:\r\n\r\n- Pull PR, run es against a trial license and start kibana as usual.\r\n- Make a curl request to Kibana to get the config saved object: \r\n\r\n```\r\ncurl --location 'localhost:5601/abc/api/saved_objects/config/9.0.0' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept-Encoding: gzip, deflate, br' \\\r\n--header 'kbn-xsrf: kibana' \\\r\n--header 'Kbn-Version: 9.0.0' \\\r\n--header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ=='\r\n```\r\n\r\n- Navigate to Upgrade Assistant and observe Kibana has at least 1\r\ndeprecation warning.\r\n- View Kibana's warnings, you should see a warning entry for `The \"GET\r\n/api/saved_objects/{type}/{id}\" route is deprecated`\r\n\r\n\r\n\r\n- click on the deprecation and you should see more detail about the\r\ndeprecated API that's been used in the flyout:\r\n\r\n\r\n\r\n- resolve the deprecation warning\r\n- Kibana should continue to issue requests to the deprecated SO HTTP\r\nAPIs because these APIs have not been removed yet.\r\n\r\n\r\n### Risk Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| End user concern from the deprecation warning that says the routes\r\nhave been deprecated | Low | Low | The APIs have been deprecated since\r\n8.7 and recommends using public APIs instead. |\r\n\r\n### For maintainers\r\n\r\n- [x] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0df2e9838119d202eba0c6b2bcb7068b160f6005"}},"sourceBranch":"main","suggestedTargetBranches":["8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197936","number":197936,"mergeCommit":{"message":"Changes deprecated SO HTTP APIs deprecation field to object (#197936)\n\nfix https://github.com/elastic/kibana/issues/197721.\r\n\r\nThe route deprecation field changed from a boolean to an object, where\r\nthe object contains information that is used in deprecation issues that\r\nthe Upgrade Assistant shows.\r\n\r\nThis PR makes the necessary changes in the deprecated Saved Objects HTTP\r\nAPIs.\r\n\r\nThis PR also includes a release notes entry for the API deprecations\r\nthat was missing.\r\n\r\n\r\n### Checklist\r\n\r\n- [x] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [x]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n\r\n\r\n### How to test this:\r\n\r\n- Pull PR, run es against a trial license and start kibana as usual.\r\n- Make a curl request to Kibana to get the config saved object: \r\n\r\n```\r\ncurl --location 'localhost:5601/abc/api/saved_objects/config/9.0.0' \\\r\n--header 'Content-Type: application/json' \\\r\n--header 'Accept-Encoding: gzip, deflate, br' \\\r\n--header 'kbn-xsrf: kibana' \\\r\n--header 'Kbn-Version: 9.0.0' \\\r\n--header 'Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ=='\r\n```\r\n\r\n- Navigate to Upgrade Assistant and observe Kibana has at least 1\r\ndeprecation warning.\r\n- View Kibana's warnings, you should see a warning entry for `The \"GET\r\n/api/saved_objects/{type}/{id}\" route is deprecated`\r\n\r\n\r\n\r\n- click on the deprecation and you should see more detail about the\r\ndeprecated API that's been used in the flyout:\r\n\r\n\r\n\r\n- resolve the deprecation warning\r\n- Kibana should continue to issue requests to the deprecated SO HTTP\r\nAPIs because these APIs have not been removed yet.\r\n\r\n\r\n### Risk Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes |\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n| End user concern from the deprecation warning that says the routes\r\nhave been deprecated | Low | Low | The APIs have been deprecated since\r\n8.7 and recommends using public APIs instead. |\r\n\r\n### For maintainers\r\n\r\n- [x] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"0df2e9838119d202eba0c6b2bcb7068b160f6005"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
29a31f4b2f
commit
7fd01150f8
52 changed files with 606 additions and 118 deletions
|
@ -1419,6 +1419,35 @@ The `/agent_status` Fleet API now returns the following statuses:
|
|||
* `active` — All active
|
||||
====
|
||||
|
||||
[discrete]
|
||||
[[kibana-150267]]
|
||||
.Deprecated Saved objects APIs. (8.7)
|
||||
[%collapsible]
|
||||
====
|
||||
*Details* +
|
||||
The following saved objects APIs have been deprecated.
|
||||
|
||||
[source,text]
|
||||
--
|
||||
/api/saved_objects/{type}/{id}
|
||||
/api/saved_objects/resolve/{type}/{id}
|
||||
/api/saved_objects/{type}/{id?}
|
||||
/api/saved_objects/{type}/{id}
|
||||
/api/saved_objects/_find
|
||||
/api/saved_objects/{type}/{id}
|
||||
/api/saved_objects/_bulk_get
|
||||
/api/saved_objects/_bulk_create
|
||||
/api/saved_objects/_bulk_resolve
|
||||
/api/saved_objects/_bulk_update
|
||||
/api/saved_objects/_bulk_delete
|
||||
--
|
||||
|
||||
For more information, refer to ({kibana-pull}150267[#150267]).
|
||||
|
||||
*Impact* +
|
||||
Use dedicated public APIs instead, for example use <<data-views-api>> to manage Data Views.
|
||||
====
|
||||
|
||||
[discrete]
|
||||
[[deprecation-119494]]
|
||||
.Updates Fleet API to improve consistency. (8.0)
|
||||
|
|
|
@ -112,7 +112,7 @@ tags:
|
|||
description: Kibana role management
|
||||
url: https://www.elastic.co/guide/en/kibana/8.x/kibana-role-management.html
|
||||
- description: |
|
||||
Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
To manage a specific type of saved object, use the corresponding APIs.
|
||||
For example, use:
|
||||
|
@ -18040,7 +18040,7 @@ paths:
|
|||
schema:
|
||||
type: object
|
||||
description: |
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
'400':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
|
@ -18072,7 +18072,7 @@ paths:
|
|||
schema:
|
||||
type: object
|
||||
description: |
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
'400':
|
||||
content:
|
||||
application/json; Elastic-Api-Version=2023-10-31:
|
||||
|
|
|
@ -309,6 +309,7 @@ export class Server {
|
|||
elasticsearch: elasticsearchServiceSetup,
|
||||
deprecations: deprecationsSetup,
|
||||
coreUsageData: coreUsageDataSetup,
|
||||
docLinks: docLinksSetup,
|
||||
});
|
||||
|
||||
const uiSettingsSetup = await this.uiSettings.setup({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerBulkCreateRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.post(
|
||||
|
@ -38,8 +39,7 @@ export const registerBulkCreateRoute = (
|
|||
summary: `Create saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
query: schema.object({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerBulkDeleteRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.post(
|
||||
|
@ -38,8 +39,7 @@ export const registerBulkDeleteRoute = (
|
|||
summary: `Delete saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
body: schema.arrayOf(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerBulkGetRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.post(
|
||||
|
@ -38,8 +39,7 @@ export const registerBulkGetRoute = (
|
|||
summary: `Get saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
body: schema.arrayOf(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerBulkResolveRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.post(
|
||||
|
@ -38,8 +39,7 @@ export const registerBulkResolveRoute = (
|
|||
summary: `Resolve saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
description: `Retrieve multiple Kibana saved objects by ID, using any legacy URL aliases if they exist.
|
||||
Under certain circumstances, when Kibana is upgraded, saved object migrations may necessitate regenerating some object IDs to enable new features. When an object's ID is regenerated, a legacy URL alias is created for that object, preserving its old ID. In such a scenario, that object can be retrieved with the bulk resolve API using either its new ID or its old ID.`,
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerBulkUpdateRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.put(
|
||||
|
@ -38,8 +39,7 @@ export const registerBulkUpdateRoute = (
|
|||
summary: `Update saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
body: schema.arrayOf(
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerCreateRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.post(
|
||||
|
@ -38,8 +39,7 @@ export const registerCreateRoute = (
|
|||
summary: `Create a saved object`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
params: schema.object({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerDeleteRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.delete(
|
||||
|
@ -38,8 +39,7 @@ export const registerDeleteRoute = (
|
|||
summary: `Delete a saved object`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
params: schema.object({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -21,11 +21,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerFindRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const referenceSchema = schema.object({
|
||||
type: schema.string(),
|
||||
|
@ -42,8 +43,7 @@ export const registerFindRoute = (
|
|||
summary: `Search for saved objects`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
query: schema.object({
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -24,11 +24,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerGetRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.get(
|
||||
|
@ -38,8 +39,7 @@ export const registerGetRoute = (
|
|||
summary: `Get a saved object`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
params: schema.object({
|
||||
|
|
|
@ -14,6 +14,8 @@ import type {
|
|||
IKibanaMigrator,
|
||||
} from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import { DocLinksServiceSetup } from '@kbn/core-doc-links-server';
|
||||
import { RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import type { InternalSavedObjectsRequestHandlerContext } from '../internal_types';
|
||||
import { registerGetRoute } from './get';
|
||||
import { registerResolveRoute } from './resolve';
|
||||
|
@ -43,6 +45,7 @@ export function registerRoutes({
|
|||
kibanaVersion,
|
||||
kibanaIndex,
|
||||
isServerless,
|
||||
docLinks,
|
||||
}: {
|
||||
http: InternalHttpServiceSetup;
|
||||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
|
@ -52,28 +55,105 @@ export function registerRoutes({
|
|||
kibanaVersion: string;
|
||||
kibanaIndex: string;
|
||||
isServerless: boolean;
|
||||
docLinks: DocLinksServiceSetup;
|
||||
}) {
|
||||
const router =
|
||||
http.createRouter<InternalSavedObjectsRequestHandlerContext>('/api/saved_objects/');
|
||||
|
||||
const internalOnServerless = isServerless ? 'internal' : 'public';
|
||||
const deprecationInfo: RouteDeprecationInfo = {
|
||||
documentationUrl: `${docLinks.links.management.savedObjectsApiList}`,
|
||||
severity: 'warning' as const, // will not break deployment upon upgrade
|
||||
reason: {
|
||||
type: 'deprecate' as const,
|
||||
},
|
||||
};
|
||||
|
||||
registerGetRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerResolveRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
const legacyDeprecationInfo = {
|
||||
documentationUrl: `${docLinks.links.kibana.dashboardImportExport}`,
|
||||
severity: 'warning' as const, // will not break deployment upon upgrade
|
||||
reason: {
|
||||
type: 'remove' as const, // no alternative for posting `.json`, requires file format change to `.ndjson`
|
||||
},
|
||||
};
|
||||
|
||||
registerGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerFindRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerBulkGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerBulkCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerBulkResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerBulkUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerBulkDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
deprecationInfo,
|
||||
});
|
||||
registerDeleteRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerFindRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerUpdateRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerBulkGetRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerBulkCreateRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerBulkResolveRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerBulkUpdateRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
registerBulkDeleteRoute(router, { config, coreUsageData, logger, access: internalOnServerless });
|
||||
|
||||
registerExportRoute(router, { config, coreUsageData });
|
||||
registerImportRoute(router, { config, coreUsageData });
|
||||
|
@ -85,12 +165,14 @@ export function registerRoutes({
|
|||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
legacyDeprecationInfo,
|
||||
});
|
||||
registerLegacyExportRoute(legacyRouter, {
|
||||
kibanaVersion,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access: internalOnServerless,
|
||||
legacyDeprecationInfo,
|
||||
});
|
||||
|
||||
const internalRouter = http.createRouter<InternalSavedObjectsRequestHandlerContext>(
|
||||
|
|
|
@ -11,7 +11,7 @@ import moment from 'moment';
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import type { InternalSavedObjectRouter } from '../../internal_types';
|
||||
import { exportDashboards } from './lib';
|
||||
|
||||
|
@ -22,11 +22,13 @@ export const registerLegacyExportRoute = (
|
|||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
legacyDeprecationInfo,
|
||||
}: {
|
||||
kibanaVersion: string;
|
||||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
legacyDeprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
) => {
|
||||
router.get(
|
||||
|
@ -39,6 +41,7 @@ export const registerLegacyExportRoute = (
|
|||
},
|
||||
options: {
|
||||
access,
|
||||
deprecated: legacyDeprecationInfo,
|
||||
tags: ['api'],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@ import { schema } from '@kbn/config-schema';
|
|||
import type { Logger } from '@kbn/logging';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-server';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import type { InternalSavedObjectRouter } from '../../internal_types';
|
||||
import { importDashboards } from './lib';
|
||||
|
||||
|
@ -22,11 +22,13 @@ export const registerLegacyImportRoute = (
|
|||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
legacyDeprecationInfo,
|
||||
}: {
|
||||
maxImportPayloadBytes: number;
|
||||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
legacyDeprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
) => {
|
||||
router.post(
|
||||
|
@ -50,6 +52,7 @@ export const registerLegacyImportRoute = (
|
|||
body: {
|
||||
maxBytes: maxImportPayloadBytes,
|
||||
},
|
||||
deprecated: legacyDeprecationInfo,
|
||||
},
|
||||
},
|
||||
async (context, request, response) => {
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal';
|
||||
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -20,11 +20,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerResolveRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.get(
|
||||
|
@ -34,8 +35,7 @@ export const registerResolveRoute = (
|
|||
summary: `Resolve a saved object`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
description: `Retrieve a single Kibana saved object by ID, using any legacy URL alias if it exists.
|
||||
Under certain circumstances, when Kibana is upgraded, saved object migrations may necessitate regenerating some object IDs to enable new features. When an object's ID is regenerated, a legacy URL alias is created for that object, preserving its old ID. In such a scenario, that object can be retrieved with the resolve API using either its new ID or its old ID.`,
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
import type { RouteAccess } from '@kbn/core-http-server';
|
||||
import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type { SavedObjectsUpdateOptions } from '@kbn/core-saved-objects-api-server';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
|
@ -25,11 +25,12 @@ interface RouteDependencies {
|
|||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
logger: Logger;
|
||||
access: RouteAccess;
|
||||
deprecationInfo: RouteDeprecationInfo;
|
||||
}
|
||||
|
||||
export const registerUpdateRoute = (
|
||||
router: InternalSavedObjectRouter,
|
||||
{ config, coreUsageData, logger, access }: RouteDependencies
|
||||
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
|
||||
) => {
|
||||
const { allowHttpApiAccess } = config;
|
||||
router.put(
|
||||
|
@ -39,8 +40,7 @@ export const registerUpdateRoute = (
|
|||
summary: `Update a saved object`,
|
||||
tags: ['oas-tag:saved objects'],
|
||||
access,
|
||||
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
|
||||
deprecated: true,
|
||||
deprecated: deprecationInfo,
|
||||
},
|
||||
validate: {
|
||||
params: schema.object({
|
||||
|
|
|
@ -98,6 +98,7 @@ describe('SavedObjectsService', () => {
|
|||
elasticsearch: elasticsearchMock,
|
||||
deprecations: deprecationsSetup,
|
||||
coreUsageData: createCoreUsageDataSetupMock(),
|
||||
docLinks: docLinksServiceMock.createSetupContract(),
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -180,6 +181,18 @@ describe('SavedObjectsService', () => {
|
|||
expect(registerRoutesMock).toHaveBeenCalledWith(expect.objectContaining({ kibanaVersion }));
|
||||
});
|
||||
|
||||
it('calls registerRoutes with docLinks', async () => {
|
||||
const coreContext = createCoreContext();
|
||||
const mockedLinks = docLinksServiceMock.createSetupContract();
|
||||
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
await soService.setup(createSetupDeps());
|
||||
|
||||
expect(registerRoutesMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ docLinks: mockedLinks })
|
||||
);
|
||||
});
|
||||
|
||||
describe('#setClientFactoryProvider', () => {
|
||||
it('registers the factory to the clientProvider', async () => {
|
||||
const coreContext = createCoreContext();
|
||||
|
|
|
@ -13,7 +13,7 @@ import type { Logger } from '@kbn/logging';
|
|||
import { stripVersionQualifier } from '@kbn/std';
|
||||
import type { ServiceStatus } from '@kbn/core-status-common';
|
||||
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
|
||||
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
|
||||
import type { DocLinksServiceSetup, DocLinksServiceStart } from '@kbn/core-doc-links-server';
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { InternalHttpServiceSetup } from '@kbn/core-http-server-internal';
|
||||
import type {
|
||||
|
@ -99,6 +99,7 @@ export interface SavedObjectsSetupDeps {
|
|||
elasticsearch: InternalElasticsearchServiceSetup;
|
||||
coreUsageData: InternalCoreUsageDataSetup;
|
||||
deprecations: DeprecationRegistryProvider;
|
||||
docLinks: DocLinksServiceSetup;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
@ -135,7 +136,7 @@ export class SavedObjectsService
|
|||
this.logger.debug('Setting up SavedObjects service');
|
||||
|
||||
this.setupDeps = setupDeps;
|
||||
const { http, elasticsearch, coreUsageData, deprecations } = setupDeps;
|
||||
const { http, elasticsearch, coreUsageData, deprecations, docLinks } = setupDeps;
|
||||
|
||||
const savedObjectsConfig = await firstValueFrom(
|
||||
this.coreContext.configService.atPath<SavedObjectsConfigType>('savedObjects')
|
||||
|
@ -164,6 +165,7 @@ export class SavedObjectsService
|
|||
kibanaIndex: MAIN_SAVED_OBJECT_INDEX,
|
||||
kibanaVersion: this.kibanaVersion,
|
||||
isServerless: this.coreContext.env.packageInfo.buildFlavor === 'serverless',
|
||||
docLinks,
|
||||
});
|
||||
|
||||
registerCoreObjectTypes(this.typeRegistry);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
{
|
||||
"name": "saved objects",
|
||||
"x-displayName": "Saved objects",
|
||||
"description": "Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n* [Data views](../group/endpoint-data-views)\n* [Spaces](https://www.elastic.co/guide/en/kibana/current/spaces-api.html)\n* [Short URLs](https://www.elastic.co/guide/en/kibana/current/short-urls-api.html)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n"
|
||||
"description": "Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n* [Data views](../group/endpoint-data-views)\n* [Spaces](https://www.elastic.co/guide/en/kibana/current/spaces-api.html)\n* [Short URLs](https://www.elastic.co/guide/en/kibana/current/short-urls-api.html)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
|
@ -1423,4 +1423,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ tags:
|
|||
- name: saved objects
|
||||
x-displayName: Saved objects
|
||||
description: |
|
||||
Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
To manage a specific type of saved object, use the corresponding APIs.
|
||||
For example, use:
|
||||
|
@ -216,7 +216,7 @@ paths:
|
|||
responses:
|
||||
'200':
|
||||
description: |
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
@ -248,7 +248,7 @@ paths:
|
|||
responses:
|
||||
'200':
|
||||
description: |
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{
|
||||
"name": "saved objects",
|
||||
"x-displayName": "Saved objects",
|
||||
"description": "Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n[Data views](../group/endpoint-data-views)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n"
|
||||
"description": "Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n[Data views](../group/endpoint-data-views)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
|
@ -358,4 +358,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ tags:
|
|||
- name: saved objects
|
||||
x-displayName: Saved objects
|
||||
description: |
|
||||
Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
To manage a specific type of saved object, use the corresponding APIs.
|
||||
For example, use:
|
||||
|
|
|
@ -12,8 +12,8 @@ tags:
|
|||
- name: saved objects
|
||||
x-displayName: Saved objects
|
||||
description: |
|
||||
Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
To manage a specific type of saved object, use the corresponding APIs.
|
||||
For example, use:
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ tags:
|
|||
- name: saved objects
|
||||
x-displayName: Saved objects
|
||||
description: |
|
||||
Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.
|
||||
|
||||
To manage a specific type of saved object, use the corresponding APIs.
|
||||
For example, use:
|
||||
|
||||
|
|
|
@ -359,6 +359,8 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
|
|||
autocompleteSuggestions: `${KIBANA_DOCS}kibana-concepts-analysts.html#autocomplete-suggestions`,
|
||||
secureSavedObject: `${KIBANA_DOCS}xpack-security-secure-saved-objects.html`,
|
||||
xpackSecurity: `${KIBANA_DOCS}xpack-security.html`,
|
||||
restApis: `${KIBANA_DOCS}api.html`,
|
||||
dashboardImportExport: `${KIBANA_DOCS}dashboard-api.html`,
|
||||
},
|
||||
upgradeAssistant: {
|
||||
overview: `${KIBANA_DOCS}upgrade-assistant.html`,
|
||||
|
|
|
@ -317,6 +317,7 @@ export interface DocLinks {
|
|||
readonly autocompleteSuggestions: string;
|
||||
readonly secureSavedObject: string;
|
||||
readonly xpackSecurity: string;
|
||||
readonly dashboardImportExport: string;
|
||||
};
|
||||
readonly upgradeAssistant: {
|
||||
readonly overview: string;
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants, setupServer } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -56,7 +56,14 @@ describe('POST /api/saved_objects/_bulk_create with allowApiAccess true', () =>
|
|||
const logger = loggerMock.create();
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerBulkCreateRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerBulkCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -61,7 +61,13 @@ describe('POST /api/saved_objects/_bulk_delete with allowApiAccess as true', ()
|
|||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
|
||||
registerBulkDeleteRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -58,7 +58,14 @@ describe('POST /api/saved_objects/_bulk_get with allowApiAccess true', () => {
|
|||
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerBulkGetRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerBulkGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -59,7 +59,14 @@ describe('POST /api/saved_objects/_bulk_resolve with allowApiAccess true', () =>
|
|||
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerBulkResolveRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerBulkResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
const testTypes = [
|
||||
|
@ -52,7 +52,14 @@ describe('PUT /api/saved_objects/_bulk_update with allowApiAccess true', () => {
|
|||
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerBulkUpdateRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerBulkUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -58,7 +58,14 @@ describe('POST /api/saved_objects/{type} with allowApiAccess true', () => {
|
|||
const logger = loggerMock.create();
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerCreateRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
handlerContext.savedObjects.typeRegistry.getType.mockImplementation((typename: string) => {
|
||||
return testTypes
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -55,7 +55,14 @@ describe('DELETE /api/saved_objects/{type}/{id} with allowApiAccess true', () =>
|
|||
const logger = loggerMock.create();
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerDeleteRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
registerFindRoute,
|
||||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -72,7 +72,13 @@ describe('GET /api/saved_objects/_find with allowApiAccess true', () => {
|
|||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
|
||||
registerFindRoute(router, { config, coreUsageData, logger, access });
|
||||
registerFindRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
const testTypes = [
|
||||
|
@ -80,7 +80,14 @@ describe('GET /api/saved_objects/{type}/{id} with allowApiAccess true', () => {
|
|||
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerGetRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
|
||||
|
@ -81,7 +81,13 @@ describe('GET /api/saved_objects/resolve/{type}/{id} with allowApiAccess true',
|
|||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
|
||||
registerResolveRoute(router, { config, coreUsageData, logger, access });
|
||||
registerResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from '../routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -56,7 +56,14 @@ describe('PUT /api/saved_objects/{type}/{id?} with allowApiAccess true', () => {
|
|||
|
||||
const config = setupConfig(true);
|
||||
const access = 'public';
|
||||
registerUpdateRoute(router, { config, coreUsageData, logger, access });
|
||||
|
||||
registerUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants, setupServer } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -37,6 +37,7 @@ describe('POST /api/saved_objects/_bulk_create', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -57,11 +58,18 @@ describe('POST /api/saved_objects/_bulk_create', () => {
|
|||
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'post');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerBulkCreateRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -190,4 +198,24 @@ describe('POST /api/saved_objects/_bulk_create', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation config to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.post('/api/saved_objects/_bulk_create')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send([
|
||||
{
|
||||
id: 'abc1234',
|
||||
type: 'index-pattern',
|
||||
attributes: {
|
||||
title: 'foo',
|
||||
},
|
||||
references: [],
|
||||
},
|
||||
])
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_delete', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -59,11 +60,18 @@ describe('POST /api/saved_objects/_bulk_delete', () => {
|
|||
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'post');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerBulkDeleteRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -158,4 +166,21 @@ describe('POST /api/saved_objects/_bulk_delete', () => {
|
|||
.expect(400);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.post('/api/saved_objects/_bulk_delete')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send([
|
||||
{
|
||||
id: 'hiddenID',
|
||||
type: 'hidden-from-http',
|
||||
},
|
||||
])
|
||||
.expect(400);
|
||||
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_get', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -57,11 +58,18 @@ describe('POST /api/saved_objects/_bulk_get', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'post');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerBulkGetRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -146,4 +154,20 @@ describe('POST /api/saved_objects/_bulk_get', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation config to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.post('/api/saved_objects/_bulk_get')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send([
|
||||
{
|
||||
id: 'abc123',
|
||||
type: 'index-pattern',
|
||||
},
|
||||
])
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_resolve', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -58,11 +59,17 @@ describe('POST /api/saved_objects/_bulk_resolve', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'post');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerBulkResolveRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -150,4 +157,20 @@ describe('POST /api/saved_objects/_bulk_resolve', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.post('/api/saved_objects/_bulk_resolve')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send([
|
||||
{
|
||||
id: 'abc123',
|
||||
type: 'index-pattern',
|
||||
},
|
||||
])
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
const testTypes = [
|
||||
|
@ -37,6 +37,7 @@ describe('PUT /api/saved_objects/_bulk_update', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -56,11 +57,18 @@ describe('PUT /api/saved_objects/_bulk_update', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'put');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerBulkUpdateRoute(router, { config, coreUsageData, logger, access });
|
||||
registerBulkUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -177,6 +185,7 @@ describe('PUT /api/saved_objects/_bulk_update', () => {
|
|||
},
|
||||
])
|
||||
.expect(400);
|
||||
|
||||
expect(result.body.message).toContain('Unsupported saved object type(s):');
|
||||
});
|
||||
|
||||
|
@ -201,5 +210,35 @@ describe('PUT /api/saved_objects/_bulk_update', () => {
|
|||
])
|
||||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.put('/api/saved_objects/_bulk_update')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send([
|
||||
{
|
||||
type: 'visualization',
|
||||
id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab',
|
||||
attributes: {
|
||||
title: 'An existing visualization',
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'dashboard',
|
||||
id: 'be3733a0-9efe-11e7-acb3-3dab96693fab',
|
||||
attributes: {
|
||||
title: 'An existing dashboard',
|
||||
},
|
||||
},
|
||||
])
|
||||
.expect(200);
|
||||
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -36,6 +36,7 @@ describe('POST /api/saved_objects/{type}', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
const clientResponse = {
|
||||
id: 'logstash-*',
|
||||
|
@ -58,10 +59,18 @@ describe('POST /api/saved_objects/{type}', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'post');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerCreateRoute(router, { config, coreUsageData, logger, access });
|
||||
registerCreateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
handlerContext.savedObjects.typeRegistry.getType.mockImplementation((typename: string) => {
|
||||
return testTypes
|
||||
|
@ -172,4 +181,19 @@ describe('POST /api/saved_objects/{type}', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.post('/api/saved_objects/index-pattern')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send({
|
||||
attributes: {
|
||||
title: 'Logging test',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -37,6 +37,7 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -55,9 +56,17 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'delete');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
registerDeleteRoute(router, { config, coreUsageData, logger, access });
|
||||
registerDeleteRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -120,4 +129,13 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.delete('/api/saved_objects/index-pattern/logstash-*')
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ import {
|
|||
registerFindRoute,
|
||||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -42,6 +42,7 @@ describe('GET /api/saved_objects/_find', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
const clientResponse = {
|
||||
total: 0,
|
||||
|
@ -71,11 +72,18 @@ describe('GET /api/saved_objects/_find', () => {
|
|||
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'get');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerFindRoute(router, { config, coreUsageData, logger, access });
|
||||
registerFindRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -448,4 +456,14 @@ describe('GET /api/saved_objects/_find', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.get('/api/saved_objects/_find?type=foo&type=bar')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
const testTypes = [
|
||||
|
@ -41,6 +41,7 @@ describe('GET /api/saved_objects/{type}/{id}', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
const coreContext = createCoreContext({ coreId });
|
||||
|
@ -80,10 +81,18 @@ describe('GET /api/saved_objects/{type}/{id}', () => {
|
|||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
|
||||
registrationSpy = jest.spyOn(router, 'get');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerGetRoute(router, { config, coreUsageData, logger, access });
|
||||
registerGetRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -140,4 +149,14 @@ describe('GET /api/saved_objects/{type}/{id}', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.get('/api/saved_objects/index-pattern/logstash-*')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -41,6 +41,7 @@ import {
|
|||
registerLegacyExportRoute,
|
||||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { legacyDeprecationMock } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
|
@ -58,11 +59,13 @@ describe('POST /api/dashboards/export', () => {
|
|||
coreUsageStatsClient = coreUsageStatsClientMock.create();
|
||||
coreUsageStatsClient.incrementLegacyDashboardsExport.mockRejectedValue(new Error('Oh no!')); // intentionally throw this error, which is swallowed, so we can assert that the operation does not fail
|
||||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
|
||||
registerLegacyExportRoute(router, {
|
||||
kibanaVersion: 'mockversion',
|
||||
coreUsageData,
|
||||
logger: loggerMock.create(),
|
||||
access: 'public',
|
||||
legacyDeprecationInfo: legacyDeprecationMock,
|
||||
});
|
||||
|
||||
handlerContext.savedObjects.client.bulkGet
|
||||
|
|
|
@ -41,6 +41,7 @@ import {
|
|||
registerLegacyImportRoute,
|
||||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { legacyDeprecationMock } from '../routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
|
@ -58,11 +59,13 @@ describe('POST /api/dashboards/import', () => {
|
|||
coreUsageStatsClient = coreUsageStatsClientMock.create();
|
||||
coreUsageStatsClient.incrementLegacyDashboardsImport.mockRejectedValue(new Error('Oh no!')); // intentionally throw this error, which is swallowed, so we can assert that the operation does not fail
|
||||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
|
||||
registerLegacyImportRoute(router, {
|
||||
maxImportPayloadBytes: 26214400,
|
||||
coreUsageData,
|
||||
logger: loggerMock.create(),
|
||||
access: 'public',
|
||||
legacyDeprecationInfo: legacyDeprecationMock,
|
||||
});
|
||||
|
||||
handlerContext.savedObjects.client.bulkCreate.mockResolvedValueOnce({
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
const coreId = Symbol('core');
|
||||
|
||||
|
@ -42,6 +42,7 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
const coreContext = createCoreContext({ coreId });
|
||||
|
@ -79,10 +80,18 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'get');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
|
||||
registerResolveRoute(router, { config, coreUsageData, logger, access });
|
||||
registerResolveRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -138,4 +147,14 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.get('/api/saved_objects/resolve/index-pattern/logstash-*')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,3 +15,19 @@ export function setupConfig(allowAccess: boolean = false) {
|
|||
} as SavedObjectConfig;
|
||||
return config;
|
||||
}
|
||||
|
||||
export const deprecationMock = {
|
||||
documentationUrl: 'http://elastic.co',
|
||||
severity: 'warning' as const,
|
||||
reason: {
|
||||
type: 'deprecate' as const,
|
||||
},
|
||||
};
|
||||
|
||||
export const legacyDeprecationMock = {
|
||||
documentationUrl: 'http://elastic.co',
|
||||
severity: 'warning' as const,
|
||||
reason: {
|
||||
type: 'remove' as const,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
type InternalSavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server-internal';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { setupConfig } from './routes_test_utils';
|
||||
import { deprecationMock, setupConfig } from './routes_test_utils';
|
||||
|
||||
type SetupServerReturn = Awaited<ReturnType<typeof setupServer>>;
|
||||
|
||||
|
@ -37,6 +37,7 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => {
|
|||
let savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
||||
let coreUsageStatsClient: jest.Mocked<ICoreUsageStatsClient>;
|
||||
let loggerWarnSpy: jest.SpyInstance;
|
||||
let registrationSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
const clientResponse = {
|
||||
|
@ -66,10 +67,17 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => {
|
|||
const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient);
|
||||
const logger = loggerMock.create();
|
||||
loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation();
|
||||
registrationSpy = jest.spyOn(router, 'put');
|
||||
|
||||
const config = setupConfig();
|
||||
const access = 'public';
|
||||
registerUpdateRoute(router, { config, coreUsageData, logger, access });
|
||||
registerUpdateRoute(router, {
|
||||
config,
|
||||
coreUsageData,
|
||||
logger,
|
||||
access,
|
||||
deprecationInfo: deprecationMock,
|
||||
});
|
||||
|
||||
await server.start();
|
||||
});
|
||||
|
@ -141,4 +149,15 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => {
|
|||
.expect(200);
|
||||
expect(loggerWarnSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('passes deprecation configuration to the router arguments', async () => {
|
||||
await supertest(httpSetup.server.listener)
|
||||
.put('/api/saved_objects/index-pattern/logstash-*')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.send({ attributes: { title: 'Logging test' }, version: 'log' })
|
||||
.expect(200);
|
||||
expect(registrationSpy.mock.calls[0][0]).toMatchObject({
|
||||
options: { deprecated: deprecationMock },
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue