Skip to content

Commit

Permalink
rename actionType attribute 'description' to 'name' (#51661)
Browse files Browse the repository at this point in the history
resolves #49826
  • Loading branch information
pmuellr authored Dec 3, 2019
1 parent 07aa71d commit 36e7bc3
Show file tree
Hide file tree
Showing 36 changed files with 156 additions and 156 deletions.
6 changes: 3 additions & 3 deletions x-pack/legacy/plugins/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Payload:

|Property|Description|Type|
|---|---|---|
|description|A description to reference and search in the future. This value will be used to populate dropdowns.|string|
|name|A name to reference and search in the future. This value will be used to populate dropdowns.|string|
|actionTypeId|The id value of the action type you want to call when the action executes.|string|
|config|The configuration the action type expects. See related action type to see what attributes are expected. This will also validate against the action type if config validation is defined.|object|
|secrets|The secrets the action type expects. See related action type to see what attributes are expected. This will also validate against the action type if secrets validation is defined.|object|
Expand Down Expand Up @@ -139,7 +139,7 @@ Payload:

|Property|Description|Type|
|---|---|---|
|description|A description to reference and search in the future. This value will be used to populate dropdowns.|string|
|name|A name to reference and search in the future. This value will be used to populate dropdowns.|string|
|config|The configuration the action type expects. See related action type to see what attributes are expected. This will also validate against the action type if config validation is defined.|object|
|secrets|The secrets the action type expects. See related action type to see what attributes are expected. This will also validate against the action type if secrets validation is defined.|object|

Expand Down Expand Up @@ -301,7 +301,7 @@ $ kbn-action create .slack "post to slack" '{"webhookUrl": "https://hooks.slack.
"id": "d6f1e228-1806-4a72-83ac-e06f3d5c2fbe",
"attributes": {
"actionTypeId": ".slack",
"description": "post to slack",
"name": "post to slack",
"config": {}
},
"references": [],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/mappings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"action": {
"properties": {
"description": {
"name": {
"type": "text"
},
"actionTypeId": {
Expand Down
38 changes: 19 additions & 19 deletions x-pack/legacy/plugins/actions/server/actions_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('create()', () => {
id: '1',
type: 'type',
attributes: {
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {},
},
Expand All @@ -64,15 +64,15 @@ describe('create()', () => {
savedObjectsClient.create.mockResolvedValueOnce(savedObjectCreateResult);
const result = await actionsClient.create({
action: {
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {},
secrets: {},
},
});
expect(result).toEqual({
id: '1',
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {},
});
Expand All @@ -83,7 +83,7 @@ describe('create()', () => {
Object {
"actionTypeId": "my-action-type",
"config": Object {},
"description": "my description",
"name": "my name",
"secrets": Object {},
},
]
Expand All @@ -104,7 +104,7 @@ describe('create()', () => {
await expect(
actionsClient.create({
action: {
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {},
secrets: {},
Expand All @@ -119,7 +119,7 @@ describe('create()', () => {
await expect(
actionsClient.create({
action: {
description: 'my description',
name: 'my name',
actionTypeId: 'unregistered-action-type',
config: {},
secrets: {},
Expand All @@ -140,7 +140,7 @@ describe('create()', () => {
id: '1',
type: 'type',
attributes: {
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {
a: true,
Expand All @@ -153,7 +153,7 @@ describe('create()', () => {
});
const result = await actionsClient.create({
action: {
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {
a: true,
Expand All @@ -165,7 +165,7 @@ describe('create()', () => {
});
expect(result).toEqual({
id: '1',
description: 'my description',
name: 'my name',
actionTypeId: 'my-action-type',
config: {
a: true,
Expand All @@ -184,7 +184,7 @@ describe('create()', () => {
"b": true,
"c": true,
},
"description": "my description",
"name": "my name",
"secrets": Object {},
},
]
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('update()', () => {
type: 'action',
attributes: {
actionTypeId: 'my-action-type',
description: 'my description',
name: 'my name',
config: {},
secrets: {},
},
Expand All @@ -310,15 +310,15 @@ describe('update()', () => {
const result = await actionsClient.update({
id: 'my-action',
action: {
description: 'my description',
name: 'my name',
config: {},
secrets: {},
},
});
expect(result).toEqual({
id: 'my-action',
actionTypeId: 'my-action-type',
description: 'my description',
name: 'my name',
config: {},
});
expect(savedObjectsClient.update).toHaveBeenCalledTimes(1);
Expand All @@ -329,7 +329,7 @@ describe('update()', () => {
Object {
"actionTypeId": "my-action-type",
"config": Object {},
"description": "my description",
"name": "my name",
"secrets": Object {},
},
]
Expand Down Expand Up @@ -366,7 +366,7 @@ describe('update()', () => {
actionsClient.update({
id: 'my-action',
action: {
description: 'my description',
name: 'my name',
config: {},
secrets: {},
},
Expand Down Expand Up @@ -395,7 +395,7 @@ describe('update()', () => {
type: 'action',
attributes: {
actionTypeId: 'my-action-type',
description: 'my description',
name: 'my name',
config: {
a: true,
b: true,
Expand All @@ -408,7 +408,7 @@ describe('update()', () => {
const result = await actionsClient.update({
id: 'my-action',
action: {
description: 'my description',
name: 'my name',
config: {
a: true,
b: true,
Expand All @@ -420,7 +420,7 @@ describe('update()', () => {
expect(result).toEqual({
id: 'my-action',
actionTypeId: 'my-action-type',
description: 'my description',
name: 'my name',
config: {
a: true,
b: true,
Expand All @@ -439,7 +439,7 @@ describe('update()', () => {
"b": true,
"c": true,
},
"description": "my description",
"name": "my name",
"secrets": Object {},
},
]
Expand Down
16 changes: 8 additions & 8 deletions x-pack/legacy/plugins/actions/server/actions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { validateConfig, validateSecrets } from './lib';
import { ActionResult, FindActionResult, RawAction } from './types';

interface ActionUpdate extends SavedObjectAttributes {
description: string;
name: string;
config: SavedObjectAttributes;
secrets: SavedObjectAttributes;
}
Expand Down Expand Up @@ -87,22 +87,22 @@ export class ActionsClient {
* Create an action
*/
public async create({ action }: CreateOptions): Promise<ActionResult> {
const { actionTypeId, description, config, secrets } = action;
const { actionTypeId, name, config, secrets } = action;
const actionType = this.actionTypeRegistry.get(actionTypeId);
const validatedActionTypeConfig = validateConfig(actionType, config);
const validatedActionTypeSecrets = validateSecrets(actionType, secrets);

const result = await this.savedObjectsClient.create('action', {
actionTypeId,
description,
name,
config: validatedActionTypeConfig as SavedObjectAttributes,
secrets: validatedActionTypeSecrets as SavedObjectAttributes,
});

return {
id: result.id,
actionTypeId: result.attributes.actionTypeId,
description: result.attributes.description,
name: result.attributes.name,
config: result.attributes.config,
};
}
Expand All @@ -113,22 +113,22 @@ export class ActionsClient {
public async update({ id, action }: UpdateOptions): Promise<ActionResult> {
const existingObject = await this.savedObjectsClient.get('action', id);
const { actionTypeId } = existingObject.attributes;
const { description, config, secrets } = action;
const { name, config, secrets } = action;
const actionType = this.actionTypeRegistry.get(actionTypeId);
const validatedActionTypeConfig = validateConfig(actionType, config);
const validatedActionTypeSecrets = validateSecrets(actionType, secrets);

const result = await this.savedObjectsClient.update('action', id, {
actionTypeId,
description,
name,
config: validatedActionTypeConfig as SavedObjectAttributes,
secrets: validatedActionTypeSecrets as SavedObjectAttributes,
});

return {
id,
actionTypeId: result.attributes.actionTypeId as string,
description: result.attributes.description as string,
name: result.attributes.name as string,
config: result.attributes.config as Record<string, any>,
};
}
Expand All @@ -142,7 +142,7 @@ export class ActionsClient {
return {
id,
actionTypeId: result.attributes.actionTypeId as string,
description: result.attributes.description as string,
name: result.attributes.name as string,
config: result.attributes.config as Record<string, any>,
};
}
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ActionExecutor {

// Ensure user can read the action before processing
const {
attributes: { actionTypeId, config, description },
attributes: { actionTypeId, config, name },
} = await services.savedObjectsClient.get<RawAction>('action', actionId);
// Only get encrypted attributes here, the remaining attributes can be fetched in
// the savedObjectsClient call
Expand Down Expand Up @@ -95,7 +95,7 @@ export class ActionExecutor {
}

let result: ActionTypeExecutorResult | null = null;
const actionLabel = `${actionId} - ${actionTypeId} - ${description}`;
const actionLabel = `${actionId} - ${actionTypeId} - ${name}`;

try {
result = await actionType.executor({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/actions/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class Plugin {
plugins.encryptedSavedObjects.registerType({
type: 'action',
attributesToEncrypt: new Set(['secrets']),
attributesToExcludeFromAAD: new Set(['description']),
attributesToExcludeFromAAD: new Set(['name']),
});
plugins.encryptedSavedObjects.registerType({
type: 'action_task_params',
Expand Down
8 changes: 4 additions & 4 deletions x-pack/legacy/plugins/actions/server/routes/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ it('creates an action with proper parameters', async () => {
method: 'POST',
url: '/api/action',
payload: {
description: 'My description',
name: 'My name',
actionTypeId: 'abc',
config: { foo: true },
secrets: {},
},
};
const createResult = {
id: '1',
description: 'My description',
name: 'My name',
actionTypeId: 'abc',
config: { foo: true },
};
Expand All @@ -38,7 +38,7 @@ it('creates an action with proper parameters', async () => {
const response = JSON.parse(payload);
expect(response).toEqual({
id: '1',
description: 'My description',
name: 'My name',
actionTypeId: 'abc',
config: { foo: true },
});
Expand All @@ -51,7 +51,7 @@ it('creates an action with proper parameters', async () => {
"config": Object {
"foo": true,
},
"description": "My description",
"name": "My name",
"secrets": Object {},
},
},
Expand Down
4 changes: 2 additions & 2 deletions x-pack/legacy/plugins/actions/server/routes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface CreateRequest extends WithoutQueryAndParams<Hapi.Request> {
id?: string;
};
payload: {
description: string;
name: string;
actionTypeId: string;
config: Record<string, any>;
secrets: Record<string, any>;
Expand All @@ -34,7 +34,7 @@ export const createActionRoute = {
},
payload: Joi.object()
.keys({
description: Joi.string().required(),
name: Joi.string().required(),
actionTypeId: Joi.string().required(),
config: Joi.object().default({}),
secrets: Joi.object().default({}),
Expand Down
12 changes: 6 additions & 6 deletions x-pack/legacy/plugins/actions/server/routes/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ it('sends proper arguments to action find function', async () => {
'page=1&' +
'search=text*&' +
'default_search_operator=AND&' +
'search_fields=description&' +
'sort_field=description&' +
'fields=description',
'search_fields=name&' +
'sort_field=name&' +
'fields=name',
};
const expectedResult = {
total: 0,
Expand All @@ -46,17 +46,17 @@ it('sends proper arguments to action find function', async () => {
"options": Object {
"defaultSearchOperator": "AND",
"fields": Array [
"description",
"name",
],
"filter": undefined,
"hasReference": undefined,
"page": 1,
"perPage": 1,
"search": "text*",
"searchFields": Array [
"description",
"name",
],
"sortField": "description",
"sortField": "name",
},
},
]
Expand Down
Loading

0 comments on commit 36e7bc3

Please sign in to comment.