Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into chore/bump-jest
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed May 25, 2020
2 parents a5eb920 + d09bd63 commit fa670d4
Show file tree
Hide file tree
Showing 93 changed files with 395 additions and 384 deletions.
24 changes: 12 additions & 12 deletions x-pack/plugins/actions/README.md
Expand Up @@ -27,12 +27,12 @@ Table of Contents
- [Example](#example)
- [RESTful API](#restful-api)
- [`POST /api/action`: Create action](#post-apiaction-create-action)
- [`DELETE /api/action/{id}`: Delete action](#delete-apiactionid-delete-action)
- [`GET /api/action/_getAll`: Get all actions](#get-apiactiongetall-get-all-actions)
- [`GET /api/action/{id}`: Get action](#get-apiactionid-get-action)
- [`GET /api/action/types`: List action types](#get-apiactiontypes-list-action-types)
- [`PUT /api/action/{id}`: Update action](#put-apiactionid-update-action)
- [`POST /api/action/{id}/_execute`: Execute action](#post-apiactionidexecute-execute-action)
- [`DELETE /api/actions/action/{id}`: Delete action](#delete-apiactionid-delete-action)
- [`GET /api/actions`: Get all actions](#get-apiactiongetall-get-all-actions)
- [`GET /api/actions/action/{id}`: Get action](#get-apiactionid-get-action)
- [`GET /api/actions/list_action_types`: List action types](#get-apiactiontypes-list-action-types)
- [`PUT /api/actions/action/{id}`: Update action](#put-apiactionid-update-action)
- [`POST /api/actions/action/{id}/_execute`: Execute action](#post-apiactionidexecute-execute-action)
- [Firing actions](#firing-actions)
- [Example](#example-1)
- [Built-in Action Types](#built-in-action-types)
Expand Down Expand Up @@ -174,35 +174,35 @@ Payload:
| 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 |

### `DELETE /api/action/{id}`: Delete action
### `DELETE /api/actions/action/{id}`: Delete action

Params:

| Property | Description | Type |
| -------- | --------------------------------------------- | ------ |
| id | The id of the action you're trying to delete. | string |

### `GET /api/action/_getAll`: Get all actions
### `GET /api/actions`: Get all actions

No parameters.

Return all actions from saved objects merged with predefined list.
Use the [saved objects API for find](https://www.elastic.co/guide/en/kibana/master/saved-objects-api-find.html) with the proprties: `type: 'action'` and `perPage: 10000`.
List of predefined actions should be set up in Kibana.yaml.

### `GET /api/action/{id}`: Get action
### `GET /api/actions/action/{id}`: Get action

Params:

| Property | Description | Type |
| -------- | ------------------------------------------ | ------ |
| id | The id of the action you're trying to get. | string |

### `GET /api/action/types`: List action types
### `GET /api/actions/list_action_types`: List action types

No parameters.

### `PUT /api/action/{id}`: Update action
### `PUT /api/actions/action/{id}`: Update action

Params:

Expand All @@ -218,7 +218,7 @@ Payload:
| 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 |

### `POST /api/action/{id}/_execute`: Execute action
### `POST /api/actions/action/{id}/_execute`: Execute action

Params:

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/common/index.ts
Expand Up @@ -6,4 +6,4 @@

export * from './types';

export const BASE_ACTION_API_PATH = '/api/action';
export const BASE_ACTION_API_PATH = '/api/actions';
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/create.test.ts
Expand Up @@ -27,7 +27,7 @@ describe('createActionRoute', () => {

const [config, handler] = router.post.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/create.ts
Expand Up @@ -26,7 +26,7 @@ export const bodySchema = schema.object({
export const createActionRoute = (router: IRouter, licenseState: ILicenseState) => {
router.post(
{
path: BASE_ACTION_API_PATH,
path: `${BASE_ACTION_API_PATH}/action`,
validate: {
body: bodySchema,
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/delete.test.ts
Expand Up @@ -27,7 +27,7 @@ describe('deleteActionRoute', () => {

const [config, handler] = router.delete.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/{id}"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/delete.ts
Expand Up @@ -27,7 +27,7 @@ const paramSchema = schema.object({
export const deleteActionRoute = (router: IRouter, licenseState: ILicenseState) => {
router.delete(
{
path: `${BASE_ACTION_API_PATH}/{id}`,
path: `${BASE_ACTION_API_PATH}/action/{id}`,
validate: {
params: paramSchema,
},
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/execute.test.ts
Expand Up @@ -53,7 +53,7 @@ describe('executeActionRoute', () => {

const [config, handler] = router.post.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/{id}/_execute"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}/_execute"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/execute.ts
Expand Up @@ -32,7 +32,7 @@ export const executeActionRoute = (
) => {
router.post(
{
path: `${BASE_ACTION_API_PATH}/{id}/_execute`,
path: `${BASE_ACTION_API_PATH}/action/{id}/_execute`,
validate: {
body: bodySchema,
params: paramSchema,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/get.test.ts
Expand Up @@ -28,7 +28,7 @@ describe('getActionRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/{id}"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/get.ts
Expand Up @@ -22,7 +22,7 @@ const paramSchema = schema.object({
export const getActionRoute = (router: IRouter, licenseState: ILicenseState) => {
router.get(
{
path: `${BASE_ACTION_API_PATH}/{id}`,
path: `${BASE_ACTION_API_PATH}/action/{id}`,
validate: {
params: paramSchema,
},
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/actions/server/routes/get_all.test.ts
Expand Up @@ -28,7 +28,7 @@ describe('getAllActionRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/_getAll"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down Expand Up @@ -63,7 +63,7 @@ describe('getAllActionRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/_getAll"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('getAllActionRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/_getAll"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/get_all.ts
Expand Up @@ -17,7 +17,7 @@ import { BASE_ACTION_API_PATH } from '../../common';
export const getAllActionRoute = (router: IRouter, licenseState: ILicenseState) => {
router.get(
{
path: `${BASE_ACTION_API_PATH}/_getAll`,
path: `${BASE_ACTION_API_PATH}`,
validate: {},
options: {
tags: ['access:actions-read'],
Expand Down
Expand Up @@ -28,7 +28,7 @@ describe('listActionTypesRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/types"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('listActionTypesRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/types"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('listActionTypesRoute', () => {

const [config, handler] = router.get.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/types"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/list_action_types"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/list_action_types.ts
Expand Up @@ -17,7 +17,7 @@ import { BASE_ACTION_API_PATH } from '../../common';
export const listActionTypesRoute = (router: IRouter, licenseState: ILicenseState) => {
router.get(
{
path: `${BASE_ACTION_API_PATH}/types`,
path: `${BASE_ACTION_API_PATH}/list_action_types`,
validate: {},
options: {
tags: ['access:actions-read'],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/update.test.ts
Expand Up @@ -27,7 +27,7 @@ describe('updateActionRoute', () => {

const [config, handler] = router.put.mock.calls[0];

expect(config.path).toMatchInlineSnapshot(`"/api/action/{id}"`);
expect(config.path).toMatchInlineSnapshot(`"/api/actions/action/{id}"`);
expect(config.options).toMatchInlineSnapshot(`
Object {
"tags": Array [
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/actions/server/routes/update.ts
Expand Up @@ -28,7 +28,7 @@ const bodySchema = schema.object({
export const updateActionRoute = (router: IRouter, licenseState: ILicenseState) => {
router.put(
{
path: `${BASE_ACTION_API_PATH}/{id}`,
path: `${BASE_ACTION_API_PATH}/action/{id}`,
validate: {
body: bodySchema,
params: paramSchema,
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/case/common/constants.ts
Expand Up @@ -25,7 +25,7 @@ export const CASE_USER_ACTIONS_URL = `${CASE_DETAILS_URL}/user_actions`;
* Action routes
*/

export const ACTION_URL = '/api/action';
export const ACTION_TYPES_URL = '/api/action/types';
export const ACTION_URL = '/api/actions';
export const ACTION_TYPES_URL = '/api/actions/list_action_types';

export const SUPPORTED_CONNECTORS = ['.servicenow', '.jira'];
Expand Up @@ -61,7 +61,7 @@ export const AlertsConfiguration: React.FC<AlertsConfigurationProps> = (
async function fetchEmailActions() {
const kibanaActions = await Legacy.shims.kfetch({
method: 'GET',
pathname: `/api/action/_getAll`,
pathname: `/api/actions`,
});

const actions = kibanaActions.data.filter(
Expand Down
Expand Up @@ -135,7 +135,7 @@ describe('Step1', () => {

expect(kfetch).toHaveBeenCalledWith({
method: 'POST',
pathname: `/api/action`,
pathname: `/api/actions/action`,
body: JSON.stringify({
name: 'Email action for Stack Monitoring alerts',
actionTypeId: ALERT_ACTION_TYPE_EMAIL,
Expand Down Expand Up @@ -193,7 +193,7 @@ describe('Step1', () => {

expect(kfetch).toHaveBeenCalledWith({
method: 'PUT',
pathname: `/api/action/${emailActions[0].id}`,
pathname: `/api/actions/action/${emailActions[0].id}`,
body: JSON.stringify({
name: emailActions[0].name,
config: omit(data, ['user', 'password']),
Expand All @@ -210,7 +210,7 @@ describe('Step1', () => {
Legacy: {
shims: {
kfetch: jest.fn().mockImplementation((arg) => {
if (arg.pathname === '/api/action/1/_execute') {
if (arg.pathname === '/api/actions/action/1/_execute') {
return { status: 'ok' };
}
return {};
Expand All @@ -236,7 +236,7 @@ describe('Step1', () => {
Legacy: {
shims: {
kfetch: (arg: any) => {
if (arg.pathname === '/api/action/1/_execute') {
if (arg.pathname === '/api/actions/action/1/_execute') {
return { status: 'ok' };
}
return {};
Expand All @@ -260,7 +260,7 @@ describe('Step1', () => {
Legacy: {
shims: {
kfetch: (arg: any) => {
if (arg.pathname === '/api/action/1/_execute') {
if (arg.pathname === '/api/actions/action/1/_execute') {
return { message: 'Very detailed error message' };
}
return {};
Expand Down Expand Up @@ -320,7 +320,7 @@ describe('Step1', () => {

expect(kfetch).toHaveBeenCalledWith({
method: 'DELETE',
pathname: `/api/action/${emailActions[0].id}`,
pathname: `/api/actions/action/${emailActions[0].id}`,
});

expect(customProps.setSelectedEmailActionId).toHaveBeenCalledWith('');
Expand Down
Expand Up @@ -44,7 +44,7 @@ export const Step1: React.FC<GetStep1Props> = (props: GetStep1Props) => {
if (props.editAction) {
await Legacy.shims.kfetch({
method: 'PUT',
pathname: `${BASE_ACTION_API_PATH}/${props.editAction.id}`,
pathname: `${BASE_ACTION_API_PATH}/action/${props.editAction.id}`,
body: JSON.stringify({
name: props.editAction.name,
config: omit(data, ['user', 'password']),
Expand All @@ -55,7 +55,7 @@ export const Step1: React.FC<GetStep1Props> = (props: GetStep1Props) => {
} else {
await Legacy.shims.kfetch({
method: 'POST',
pathname: BASE_ACTION_API_PATH,
pathname: `${BASE_ACTION_API_PATH}/action`,
body: JSON.stringify({
name: i18n.translate('xpack.monitoring.alerts.configuration.emailAction.name', {
defaultMessage: 'Email action for Stack Monitoring alerts',
Expand All @@ -75,7 +75,7 @@ export const Step1: React.FC<GetStep1Props> = (props: GetStep1Props) => {

await Legacy.shims.kfetch({
method: 'DELETE',
pathname: `${BASE_ACTION_API_PATH}/${id}`,
pathname: `${BASE_ACTION_API_PATH}/action/${id}`,
});

if (props.editAction && props.editAction.id === id) {
Expand All @@ -101,7 +101,7 @@ export const Step1: React.FC<GetStep1Props> = (props: GetStep1Props) => {

const result = await Legacy.shims.kfetch({
method: 'POST',
pathname: `${BASE_ACTION_API_PATH}/${props.selectedEmailActionId}/_execute`,
pathname: `${BASE_ACTION_API_PATH}/action/${props.selectedEmailActionId}/_execute`,
body: JSON.stringify({ params }),
});
if (result.status === 'ok') {
Expand Down
Expand Up @@ -21,7 +21,7 @@ import { CASES } from '../urls/navigation';
describe.skip('Cases connectors', () => {
before(() => {
cy.server();
cy.route('POST', '**/api/action').as('createConnector');
cy.route('POST', '**/api/actions/action').as('createConnector');
cy.route('POST', '**/api/cases/configure').as('saveConnector');
});

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/siem/public/cases/containers/api.test.tsx
Expand Up @@ -88,7 +88,7 @@ describe('Case Configuration API', () => {
});
test('check url, method, signal', async () => {
await getActionLicense(abortCtrl.signal);
expect(fetchMock).toHaveBeenCalledWith(`/api/action/types`, {
expect(fetchMock).toHaveBeenCalledWith(`/api/actions/list_action_types`, {
method: 'GET',
signal: abortCtrl.signal,
});
Expand Down Expand Up @@ -416,7 +416,7 @@ describe('Case Configuration API', () => {
const connectorId = 'connectorId';
test('check url, method, signal', async () => {
await pushToService(connectorId, casePushParams, abortCtrl.signal);
expect(fetchMock).toHaveBeenCalledWith(`/api/action/${connectorId}/_execute`, {
expect(fetchMock).toHaveBeenCalledWith(`/api/actions/action/${connectorId}/_execute`, {
method: 'POST',
body: JSON.stringify({
params: { subAction: 'pushToService', subActionParams: casePushParams },
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/siem/public/cases/containers/api.ts
Expand Up @@ -242,7 +242,7 @@ export const pushToService = async (
signal: AbortSignal
): Promise<ServiceConnectorCaseResponse> => {
const response = await KibanaServices.get().http.fetch<ActionTypeExecutorResult>(
`${ACTION_URL}/${connectorId}/_execute`,
`${ACTION_URL}/action/${connectorId}/_execute`,
{
method: 'POST',
body: JSON.stringify({
Expand Down
Expand Up @@ -13,5 +13,5 @@ set -e
# https://github.com/elastic/kibana/blob/master/x-pack/plugins/actions/README.md#get-apiaction_find-find-actions
curl -s -k \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X GET ${KIBANA_URL}${SPACE_URL}/api/action/_getAll \
-X GET ${KIBANA_URL}${SPACE_URL}/api/actions \
| jq .
Expand Up @@ -13,5 +13,5 @@ set -e
# https://github.com/elastic/kibana/blob/master/x-pack/plugins/actions/README.md
curl -s -k \
-u ${ELASTICSEARCH_USERNAME}:${ELASTICSEARCH_PASSWORD} \
-X GET ${KIBANA_URL}${SPACE_URL}/api/action/types \
-X GET ${KIBANA_URL}${SPACE_URL}/api/actions/list_action_types \
| jq .

0 comments on commit fa670d4

Please sign in to comment.