Skip to content

Commit

Permalink
[Transform] Refactor delete transform schema
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jun 5, 2020
1 parent d8f901c commit cd293f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
16 changes: 16 additions & 0 deletions x-pack/plugins/transform/server/routes/api/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});
11 changes: 2 additions & 9 deletions x-pack/plugins/transform/server/routes/api/transforms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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) => {
Expand Down

0 comments on commit cd293f2

Please sign in to comment.