Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
export * from './types';

export const BASE_ACTION_API_PATH = '/api/actions';

export * from './rewrite_request_case';
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/connector_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import { IRouter } from 'kibana/server';
import { ILicenseState } from '../lib';
import { ActionType, BASE_ACTION_API_PATH } from '../../common';
import { ActionType, BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { ActionsRequestHandlerContext } from '../types';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteResponseCase } from './rewrite_request_case';

const rewriteBodyRes: RewriteResponseCase<ActionType[]> = (results) => {
return results.map(({ enabledInConfig, enabledInLicense, minimumLicenseRequired, ...res }) => ({
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import { schema } from '@kbn/config-schema';
import { IRouter } from 'kibana/server';
import { ActionResult, ActionsRequestHandlerContext } from '../types';
import { ILicenseState } from '../lib';
import { BASE_ACTION_API_PATH } from '../../common';
import { BASE_ACTION_API_PATH, RewriteRequestCase, RewriteResponseCase } from '../../common';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteRequestCase, RewriteResponseCase } from './rewrite_request_case';
import { CreateOptions } from '../actions_client';

export const bodySchema = schema.object({
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { IRouter } from 'kibana/server';
import { ILicenseState } from '../lib';

import { ActionTypeExecutorResult, ActionsRequestHandlerContext } from '../types';
import { BASE_ACTION_API_PATH } from '../../common';
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { asHttpRequestExecutionSource } from '../lib/action_execution_source';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteResponseCase } from './rewrite_request_case';

const paramSchema = schema.object({
id: schema.string(),
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import { schema } from '@kbn/config-schema';
import { IRouter } from 'kibana/server';
import { ILicenseState } from '../lib';
import { BASE_ACTION_API_PATH } from '../../common';
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { ActionResult, ActionsRequestHandlerContext } from '../types';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteResponseCase } from './rewrite_request_case';

const paramSchema = schema.object({
id: schema.string(),
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/get_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import { IRouter } from 'kibana/server';
import { ILicenseState } from '../lib';
import { BASE_ACTION_API_PATH } from '../../common';
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { ActionsRequestHandlerContext, FindActionResult } from '../types';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteResponseCase } from './rewrite_request_case';

const rewriteBodyRes: RewriteResponseCase<FindActionResult[]> = (results) => {
return results.map(({ actionTypeId, isPreconfigured, referencedByCount, ...res }) => ({
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/actions/server/routes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import { schema } from '@kbn/config-schema';
import { IRouter } from 'kibana/server';
import { ILicenseState } from '../lib';
import { BASE_ACTION_API_PATH } from '../../common';
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { ActionResult, ActionsRequestHandlerContext } from '../types';
import { verifyAccessAndContext } from './verify_access_and_context';
import { RewriteResponseCase } from './rewrite_request_case';

const paramSchema = schema.object({
id: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Jira API', () => {
const res = await getIssueTypes({ http, signal: abortCtrl.signal, connectorId: 'test' });

expect(res).toEqual(issueTypesResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"issueTypes","subActionParams":{}}}',
signal: abortCtrl.signal,
});
Expand All @@ -121,7 +121,7 @@ describe('Jira API', () => {
});

expect(res).toEqual(fieldsResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"fieldsByIssueType","subActionParams":{"id":"10006"}}}',
signal: abortCtrl.signal,
});
Expand All @@ -140,7 +140,7 @@ describe('Jira API', () => {
});

expect(res).toEqual(issuesResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"issues","subActionParams":{"title":"test issue"}}}',
signal: abortCtrl.signal,
});
Expand All @@ -159,7 +159,7 @@ describe('Jira API', () => {
});

expect(res).toEqual(issuesResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"issue","subActionParams":{"id":"RJ-107"}}}',
signal: abortCtrl.signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function getIssueTypes({
signal: AbortSignal;
connectorId: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'issueTypes', subActionParams: {} },
}),
Expand All @@ -36,7 +36,7 @@ export async function getFieldsByIssueType({
connectorId: string;
id: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'fieldsByIssueType', subActionParams: { id } },
}),
Expand All @@ -55,7 +55,7 @@ export async function getIssues({
connectorId: string;
title: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'issues', subActionParams: { title } },
}),
Expand All @@ -74,7 +74,7 @@ export async function getIssue({
connectorId: string;
id: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'issue', subActionParams: { id } },
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Resilient API', () => {
});

expect(res).toEqual(incidentTypesResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"incidentTypes","subActionParams":{}}}',
signal: abortCtrl.signal,
});
Expand All @@ -79,7 +79,7 @@ describe('Resilient API', () => {
});

expect(res).toEqual(severityResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"severity","subActionParams":{}}}',
signal: abortCtrl.signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function getIncidentTypes({
signal: AbortSignal;
connectorId: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'incidentTypes', subActionParams: {} },
}),
Expand All @@ -34,7 +34,7 @@ export async function getSeverity({
signal: AbortSignal;
connectorId: string;
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'severity', subActionParams: {} },
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('ServiceNow API', () => {
});

expect(res).toEqual(choicesResponse);
expect(http.post).toHaveBeenCalledWith('/api/actions/action/test/_execute', {
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/test/_execute', {
body: '{"params":{"subAction":"getChoices","subActionParams":{"fields":["priority"]}}}',
signal: abortCtrl.signal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getChoices({
connectorId: string;
fields: string[];
}): Promise<Record<string, any>> {
return await http.post(`${BASE_ACTION_API_PATH}/action/${connectorId}/_execute`, {
return await http.post(`${BASE_ACTION_API_PATH}/connector/${connectorId}/_execute`, {
body: JSON.stringify({
params: { subAction: 'getChoices', subActionParams: { fields } },
}),
Expand Down

This file was deleted.

Loading