From cd293f22098558e0c2b17a256658f5622101d0e5 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Fri, 5 Jun 2020 11:30:10 -0500 Subject: [PATCH] [Transform] Refactor delete transform schema --- .../transform/server/routes/api/schema.ts | 16 ++++++++++++++++ .../transform/server/routes/api/transforms.ts | 11 ++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/transform/server/routes/api/schema.ts b/x-pack/plugins/transform/server/routes/api/schema.ts index 0b994406d324d..499147647b224 100644 --- a/x-pack/plugins/transform/server/routes/api/schema.ts +++ b/x-pack/plugins/transform/server/routes/api/schema.ts @@ -14,3 +14,19 @@ export const schemaTransformId = { export interface SchemaTransformId { transformId: string; } + +export const deleteTransformSchema = schema.object({ + /** + * Delete Transform & Destination Index + */ + transformsInfo: schema.maybe( + schema.arrayOf( + schema.object({ + id: schema.string(), + state: schema.maybe(schema.string()), + }) + ) + ), + deleteDestIndex: schema.maybe(schema.boolean()), + deleteDestIndexPattern: schema.maybe(schema.boolean()), +}); diff --git a/x-pack/plugins/transform/server/routes/api/transforms.ts b/x-pack/plugins/transform/server/routes/api/transforms.ts index 9026069c712a0..0557ccaa2a8d3 100644 --- a/x-pack/plugins/transform/server/routes/api/transforms.ts +++ b/x-pack/plugins/transform/server/routes/api/transforms.ts @@ -29,7 +29,7 @@ import { RouteDependencies } from '../../types'; import { addBasePath } from '../index'; import { isRequestTimeout, fillResultsWithTimeouts, wrapError } from './error_utils'; -import { schemaTransformId, SchemaTransformId } from './schema'; +import { deleteTransformSchema, schemaTransformId, SchemaTransformId } from './schema'; import { registerTransformsAuditMessagesRoutes } from './transforms_audit_messages'; import { IIndexPattern } from '../../../../../../src/plugins/data/common/index_patterns'; @@ -182,14 +182,7 @@ export function registerTransformsRoutes(routeDependencies: RouteDependencies) { { path: addBasePath('delete_transforms'), validate: { - body: schema.maybe(schema.any()), - query: schema.object({ - /** - * Transform Destination Index - */ - deleteDestIndex: schema.maybe(schema.boolean()), - deleteDestIndexPattern: schema.maybe(schema.boolean()), - }), + body: deleteTransformSchema, }, }, license.guardApiRoute(async (ctx, req, res) => {