Skip to content

Commit

Permalink
Updating connector apis
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Sep 12, 2024
1 parent 3181644 commit 4c77dc6
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 24 deletions.
107 changes: 83 additions & 24 deletions x-pack/plugins/actions/common/routes/connector/response/schemas/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,93 @@
import { schema } from '@kbn/config-schema';

export const connectorResponseSchema = schema.object({
id: schema.string(),
name: schema.string(),
config: schema.maybe(schema.recordOf(schema.string(), schema.any())),
connector_type_id: schema.string(),
is_missing_secrets: schema.maybe(schema.boolean()),
is_preconfigured: schema.boolean(),
is_deprecated: schema.boolean(),
is_system_action: schema.boolean(),
id: schema.string({
meta: {
description: 'The identifier for the connector.',
},
}),
name: schema.string({
meta: {
description: ' The name of the rule.',
},
}),
config: schema.maybe(
schema.recordOf(schema.string(), schema.any(), {
meta: { description: 'The configurations for the connector.' },
})
),
connector_type_id: schema.string({
meta: { description: 'The connector type identifier.' },
}),
is_missing_secrets: schema.maybe(
schema.boolean({ meta: { description: 'Indicates whether the connector is missing secrets.' } })
),
is_preconfigured: schema.boolean({
meta: { description: 'Indicates whether the connector is preconfigured.' },
}),
is_deprecated: schema.boolean({
meta: { description: 'Indicates whether the connector is deprecated.' },
}),
is_system_action: schema.boolean({
meta: { description: 'Indicates whether the connector is system action.' },
}),
});

export const allConnectorsResponseSchema = connectorResponseSchema.extends({
referenced_by_count: schema.number(),
referenced_by_count: schema.number({
meta: {
description: ' The number of rules that are currently using the connector.',
},
}),
});

export const connectorTypesResponseSchema = schema.object({
id: schema.string(),
name: schema.string(),
enabled: schema.boolean(),
enabled_in_config: schema.boolean(),
enabled_in_license: schema.boolean(),
minimum_license_required: schema.oneOf([
schema.literal('basic'),
schema.literal('standard'),
schema.literal('gold'),
schema.literal('platinum'),
schema.literal('enterprise'),
schema.literal('trial'),
]),
supported_feature_ids: schema.arrayOf(schema.string()),
is_system_action_type: schema.boolean(),
id: schema.string({
meta: {
description: 'The identifier for the connector.',
},
}),
name: schema.string({
meta: {
description: ' The name of the rule.',
},
}),
enabled: schema.boolean({
meta: {
description: 'Indicates whether the connector is enabled.',
},
}),
enabled_in_config: schema.boolean({
meta: {
description: 'Indicates whether the connector is enabled through the configs.',
},
}),
enabled_in_license: schema.boolean({
meta: {
description: 'Indicates whether the connector is enabled through the license.',
},
}),
minimum_license_required: schema.oneOf(
[
schema.literal('basic'),
schema.literal('standard'),
schema.literal('gold'),
schema.literal('platinum'),
schema.literal('enterprise'),
schema.literal('trial'),
],
{
meta: {
description: 'The minimum license required to enable the connector.',
},
}
),
supported_feature_ids: schema.arrayOf(schema.string(), {
meta: {
description: 'The minimum license required to enable the connector.',
},
}),
is_system_action_type: schema.boolean({
meta: { description: 'Indicates whether the action is a system action.' },
}),
});
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/connector/get/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getConnectorParamsSchemaV1,
GetConnectorParamsV1,
} from '../../../../common/routes/connector/apis/get';
import { connectorResponseSchemaV1 } from '../../../../common/routes/connector/response';
import { transformGetConnectorResponseV1 } from './transforms';
import { ILicenseState } from '../../../lib';
import { BASE_ACTION_API_PATH } from '../../../../common';
Expand All @@ -34,6 +35,7 @@ export const getConnectorRoute = (
},
response: {
200: {
body: () => connectorResponseSchemaV1,
description: 'Indicates a successful call.',
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ILicenseState, validateEmptyStrings } from '../lib';
import { BASE_ACTION_API_PATH, RewriteRequestCase, RewriteResponseCase } from '../../common';
import { verifyAccessAndContext } from './verify_access_and_context';
import { CreateOptions } from '../actions_client';
import { connectorResponseSchemaV1 } from '../../common/routes/connector/response';

export const bodySchema = schema.object({
name: schema.string({
Expand Down Expand Up @@ -76,6 +77,7 @@ export const createActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ActionTypeExecutorResult, ActionsRequestHandlerContext } from '../types
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { asHttpRequestExecutionSource } from '../lib/action_execution_source';
import { verifyAccessAndContext } from './verify_access_and_context';
import { connectorResponseSchemaV1 } from '../../common/routes/connector/response';

const paramSchema = schema.object({
id: schema.string({
Expand Down Expand Up @@ -56,6 +57,7 @@ export const executeActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/legacy/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ILicenseState } from '../../lib';
import { BASE_ACTION_API_PATH } from '../../../common';
import { verifyAccessAndContext } from '../verify_access_and_context';
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';

export const bodySchema = schema.object({
name: schema.string({
Expand Down Expand Up @@ -46,6 +47,7 @@ export const createActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/legacy/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ActionTypeExecutorResult, ActionsRequestHandlerContext } from '../../ty
import { BASE_ACTION_API_PATH } from '../../../common';
import { asHttpRequestExecutionSource } from '../../lib/action_execution_source';
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';

const paramSchema = schema.object({
id: schema.string({
Expand Down Expand Up @@ -47,6 +48,7 @@ export const executeActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/legacy/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ILicenseState, verifyApiAccess } from '../../lib';
import { BASE_ACTION_API_PATH } from '../../../common';
import { ActionsRequestHandlerContext } from '../../types';
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';

const paramSchema = schema.object({
id: schema.string({
Expand Down Expand Up @@ -40,6 +41,7 @@ export const getActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/legacy/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ILicenseState, verifyApiAccess, isErrorThatHandlesItsOwnResponse } from
import { BASE_ACTION_API_PATH } from '../../../common';
import { ActionsRequestHandlerContext } from '../../types';
import { trackLegacyRouteUsage } from '../../lib/track_legacy_route_usage';
import { connectorResponseSchemaV1 } from '../../../common/routes/connector/response';

const paramSchema = schema.object({
id: schema.string({
Expand Down Expand Up @@ -47,6 +48,7 @@ export const updateActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/actions/server/routes/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ILicenseState, validateEmptyStrings } from '../lib';
import { BASE_ACTION_API_PATH, RewriteResponseCase } from '../../common';
import { ActionResult, ActionsRequestHandlerContext } from '../types';
import { verifyAccessAndContext } from './verify_access_and_context';
import { connectorResponseSchemaV1 } from '../../common/routes/connector/response';

const paramSchema = schema.object({
id: schema.string({
Expand Down Expand Up @@ -67,6 +68,7 @@ export const updateActionRoute = (
response: {
200: {
description: 'Indicates a successful call.',
body: () => connectorResponseSchemaV1,
},
},
},
Expand Down

0 comments on commit 4c77dc6

Please sign in to comment.