-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba8563a
commit f640226
Showing
9 changed files
with
148 additions
and
59 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...core-saved-objects-api-server-internal/src/lib/apis/collect_multinamespaces_references.ts
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,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { | ||
SavedObjectsCollectMultiNamespaceReferencesObject, | ||
SavedObjectsCollectMultiNamespaceReferencesOptions, | ||
SavedObjectsCollectMultiNamespaceReferencesResponse, | ||
} from '@kbn/core-saved-objects-api-server'; | ||
import { ApiExecutionContext } from './types'; | ||
import { collectMultiNamespaceReferences } from '../collect_multi_namespace_references'; | ||
|
||
export interface PerformCreateParams<T = unknown> { | ||
objects: SavedObjectsCollectMultiNamespaceReferencesObject[]; | ||
options: SavedObjectsCollectMultiNamespaceReferencesOptions; | ||
} | ||
|
||
export const performCollectMultiNamespaceReferences = async <T>( | ||
{ objects, options }: PerformCreateParams<T>, | ||
{ registry, helpers, allowedTypes, client, serializer, extensions = {} }: ApiExecutionContext | ||
): Promise<SavedObjectsCollectMultiNamespaceReferencesResponse> => { | ||
const { common: commonHelper } = helpers; | ||
const { securityExtension } = extensions; | ||
|
||
const namespace = commonHelper.getCurrentNamespace(options.namespace); | ||
return collectMultiNamespaceReferences({ | ||
registry, | ||
allowedTypes, | ||
client, | ||
serializer, | ||
getIndexForType: commonHelper.getIndexForType.bind(commonHelper), | ||
createPointInTimeFinder: commonHelper.createPointInTimeFinder.bind(commonHelper), | ||
securityExtension, | ||
objects, | ||
options: { ...options, namespace }, | ||
}); | ||
}; |
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
55 changes: 55 additions & 0 deletions
55
...aved-objects/core-saved-objects-api-server-internal/src/lib/apis/update_objects_spaces.ts
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,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { | ||
SavedObjectsUpdateObjectsSpacesObject, | ||
SavedObjectsUpdateObjectsSpacesOptions, | ||
SavedObjectsUpdateObjectsSpacesResponse, | ||
} from '@kbn/core-saved-objects-api-server'; | ||
import { ApiExecutionContext } from './types'; | ||
import { updateObjectsSpaces } from '../update_objects_spaces'; | ||
|
||
export interface PerformCreateParams<T = unknown> { | ||
objects: SavedObjectsUpdateObjectsSpacesObject[]; | ||
spacesToAdd: string[]; | ||
spacesToRemove: string[]; | ||
options: SavedObjectsUpdateObjectsSpacesOptions; | ||
} | ||
|
||
export const performUpdateObjectsSpaces = async <T>( | ||
{ objects, spacesToAdd, spacesToRemove, options }: PerformCreateParams<T>, | ||
{ | ||
registry, | ||
helpers, | ||
allowedTypes, | ||
client, | ||
serializer, | ||
logger, | ||
mappings, | ||
extensions = {}, | ||
}: ApiExecutionContext | ||
): Promise<SavedObjectsUpdateObjectsSpacesResponse> => { | ||
const { common: commonHelper } = helpers; | ||
const { securityExtension } = extensions; | ||
|
||
const namespace = commonHelper.getCurrentNamespace(options.namespace); | ||
return updateObjectsSpaces({ | ||
mappings, | ||
registry, | ||
allowedTypes, | ||
client, | ||
serializer, | ||
logger, | ||
getIndexForType: commonHelper.getIndexForType.bind(commonHelper), | ||
securityExtension, | ||
objects, | ||
spacesToAdd, | ||
spacesToRemove, | ||
options: { ...options, namespace }, | ||
}); | ||
}; |
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