diff --git a/x-pack/legacy/plugins/task_manager/plugin.test.ts b/x-pack/legacy/plugins/task_manager/plugin.test.ts index bb77dc2fe6e29..49945ca500315 100644 --- a/x-pack/legacy/plugins/task_manager/plugin.test.ts +++ b/x-pack/legacy/plugins/task_manager/plugin.test.ts @@ -42,11 +42,11 @@ describe('Task Manager Plugin', () => { expect(setupResult).toMatchInlineSnapshot(` Object { "addMiddleware": [Function], + "ensureScheduling": [Function], "fetch": [Function], "registerTaskDefinitions": [Function], "remove": [Function], "schedule": [Function], - "scheduleIfNotExists": [Function], } `); }); diff --git a/x-pack/legacy/plugins/task_manager/plugin.ts b/x-pack/legacy/plugins/task_manager/plugin.ts index 61566b1de5181..1db6c37a7d995 100644 --- a/x-pack/legacy/plugins/task_manager/plugin.ts +++ b/x-pack/legacy/plugins/task_manager/plugin.ts @@ -11,7 +11,7 @@ export interface PluginSetupContract { fetch: TaskManager['fetch']; remove: TaskManager['remove']; schedule: TaskManager['schedule']; - scheduleIfNotExists: TaskManager['scheduleIfNotExists']; + ensureScheduling: TaskManager['ensureScheduling']; addMiddleware: TaskManager['addMiddleware']; registerTaskDefinitions: TaskManager['registerTaskDefinitions']; } @@ -60,7 +60,7 @@ export class Plugin { fetch: (...args) => taskManager.fetch(...args), remove: (...args) => taskManager.remove(...args), schedule: (...args) => taskManager.schedule(...args), - scheduleIfNotExists: (...args) => taskManager.scheduleIfNotExists(...args), + ensureScheduling: (...args) => taskManager.ensureScheduling(...args), addMiddleware: (...args) => taskManager.addMiddleware(...args), registerTaskDefinitions: (...args) => taskManager.registerTaskDefinitions(...args), }; diff --git a/x-pack/legacy/plugins/task_manager/task_manager.test.ts b/x-pack/legacy/plugins/task_manager/task_manager.test.ts index 80e64a16b2975..5682bdd4aa6c2 100644 --- a/x-pack/legacy/plugins/task_manager/task_manager.test.ts +++ b/x-pack/legacy/plugins/task_manager/task_manager.test.ts @@ -136,7 +136,7 @@ describe('TaskManager', () => { client.start(); - const result = await client.scheduleIfNotExists({ + const result = await client.ensureScheduling({ id: 'my-foo-id', taskType: 'foo', params: {}, @@ -162,7 +162,7 @@ describe('TaskManager', () => { client.start(); return expect( - client.scheduleIfNotExists({ + client.ensureScheduling({ id: 'my-foo-id', taskType: 'foo', params: {}, diff --git a/x-pack/legacy/plugins/task_manager/task_manager.ts b/x-pack/legacy/plugins/task_manager/task_manager.ts index 2f2becd202d74..0bd57aa9a9d52 100644 --- a/x-pack/legacy/plugins/task_manager/task_manager.ts +++ b/x-pack/legacy/plugins/task_manager/task_manager.ts @@ -228,7 +228,7 @@ export class TaskManager { * @param task - The task being scheduled. * @returns {Promise} */ - public async scheduleIfNotExists( + public async ensureScheduling( taskInstance: ExistingTaskInstance, options?: any ): Promise { diff --git a/x-pack/test/plugin_api_integration/plugins/task_manager/init_routes.js b/x-pack/test/plugin_api_integration/plugins/task_manager/init_routes.js index 07d0c8391fce6..74d6c17debba8 100644 --- a/x-pack/test/plugin_api_integration/plugins/task_manager/init_routes.js +++ b/x-pack/test/plugin_api_integration/plugins/task_manager/init_routes.js @@ -39,7 +39,7 @@ export function initRoutes(server) { state: Joi.object().optional(), id: Joi.string().optional() }), - scheduleIfNotExists: Joi.boolean() + ensureScheduling: Joi.boolean() .default(false) .optional(), }), @@ -47,15 +47,15 @@ export function initRoutes(server) { }, async handler(request) { try { - const { scheduleIfNotExists = false, task: taskFields } = request.payload; + const { ensureScheduling = false, task: taskFields } = request.payload; const task = { ...taskFields, scope: [scope], }; const taskResult = await ( - scheduleIfNotExists - ? taskManager.scheduleIfNotExists(task, { request }) + ensureScheduling + ? taskManager.ensureScheduling(task, { request }) : taskManager.schedule(task, { request }) ); diff --git a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js index ef21dd2786294..172ac1265beff 100644 --- a/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js +++ b/x-pack/test/plugin_api_integration/test_suites/task_manager/task_manager_integration.js @@ -68,7 +68,7 @@ export default function ({ getService }) { function scheduleTaskIfNotExists(task) { return supertest.post('/api/sample_tasks') .set('kbn-xsrf', 'xxx') - .send({ task, scheduleIfNotExists: true }) + .send({ task, ensureScheduling: true }) .expect(200) .then((response) => response.body); }