Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting][Connectors] Refactor Jira: Generic Implementation (phase one) #73778

Merged
merged 67 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
944b7dd
Create schema
cnasikas Jul 28, 2020
7dad0fb
Create types
cnasikas Jul 29, 2020
0fa0a3e
Transform comments on ServiceNow
cnasikas Jul 30, 2020
aa21313
Fix service
cnasikas Jul 30, 2020
d466e33
Fix validators
cnasikas Jul 30, 2020
c7a63bd
Fix api
cnasikas Jul 30, 2020
2dbe4e8
Fix init
cnasikas Jul 30, 2020
ae3d43a
Init jira ui
cnasikas Jul 30, 2020
d4895bf
Add cases mappings ui
cnasikas Jul 30, 2020
66babbd
Add types (ui)
cnasikas Jul 30, 2020
9f73f58
Add logo
cnasikas Jul 30, 2020
312306f
Add translations (ui)
cnasikas Jul 30, 2020
c2d9712
Add config (ui)
cnasikas Jul 30, 2020
89f5ce5
Create jira connector flyout
cnasikas Jul 30, 2020
7550f46
Create jira alerts flyout
cnasikas Jul 30, 2020
992cf52
Unregister jira connector from security solutions
cnasikas Jul 30, 2020
cc0f84b
Register jira (ui)
cnasikas Jul 30, 2020
5f2a7d7
Filter out non jira case connectors
cnasikas Jul 30, 2020
5267b9f
Implement getCreateIssueMetadata subAction
cnasikas Jul 30, 2020
155986e
Get create issue metadata (ui)
cnasikas Jul 30, 2020
9d95483
Return issue types by name
cnasikas Jul 31, 2020
94c8908
Fetch and populate create issue fields
cnasikas Jul 31, 2020
a00c63a
Push to jira from alerts
cnasikas Aug 2, 2020
3241645
Improve types
cnasikas Aug 4, 2020
cc2af4c
Remove jira from lib
cnasikas Aug 4, 2020
e37d3e7
Improve error reporting
cnasikas Aug 4, 2020
b90acfe
Get default issueType from metadata
cnasikas Aug 4, 2020
e73bc82
Update Jira incident
cnasikas Aug 4, 2020
a1841f2
Support the new API for getting create issue metadata
cnasikas Aug 4, 2020
ecf52b9
Show loading spinner when fetching issue metadata
cnasikas Aug 4, 2020
355acde
Support generics
cnasikas Aug 24, 2020
3a348fc
Fix types
cnasikas Aug 24, 2020
349b6d5
Change desc
cnasikas Aug 24, 2020
77cc488
Create issue type and fields sub actions
cnasikas Aug 25, 2020
cf74bd0
Use new api
cnasikas Aug 25, 2020
8214217
Remove create issue metadata endpoint
cnasikas Aug 25, 2020
f802d4e
Reset fields when changing connector or issueType
cnasikas Aug 25, 2020
7c7bbd1
Improve layout
cnasikas Aug 25, 2020
7d1b8ad
Improve service tests
cnasikas Aug 25, 2020
4ec6e26
Improve api tests
cnasikas Aug 26, 2020
675451b
Create jira_connectors test
cnasikas Aug 26, 2020
140a051
Create jira (ui) test
cnasikas Aug 26, 2020
7afdc5e
Create jira_params test
cnasikas Aug 26, 2020
fef9f15
Add basic integration test
cnasikas Aug 26, 2020
b93bd9f
Add AbortController
cnasikas Aug 30, 2020
ee04cd8
Rename subactions
cnasikas Aug 30, 2020
cf317a4
Add toast notification on error
cnasikas Aug 31, 2020
fa7125c
Improve UX
cnasikas Aug 31, 2020
56ebeaa
Change license
cnasikas Aug 31, 2020
b4f6a7c
Improve README
cnasikas Aug 31, 2020
dfaadca
Fix translations
cnasikas Aug 31, 2020
7610b83
Improvements
cnasikas Aug 31, 2020
a2f2040
Fixes
cnasikas Sep 1, 2020
8dba023
Validate 403 status code
cnasikas Sep 2, 2020
53fb03e
Change maybe to nullable
cnasikas Sep 2, 2020
8be3a5b
Fix grammar
cnasikas Sep 2, 2020
ce33e1b
Improve filtering in case of null dereference
cnasikas Sep 2, 2020
d3a1112
Improve UI
cnasikas Sep 2, 2020
6b8339a
Improve README
cnasikas Sep 4, 2020
1a43d83
Move common types and schema to case folder
cnasikas Sep 4, 2020
c9d843b
Remove findIncidents function
cnasikas Sep 4, 2020
97a67c2
Refactor for inclusive language
cnasikas Sep 4, 2020
f2723d9
Make actionConnector optional
cnasikas Sep 4, 2020
ccd74cb
Move case mappings to its own folder
cnasikas Sep 4, 2020
e8c3a25
Fix i18n
cnasikas Sep 4, 2020
caabc6e
Improve UX when editing an alert
cnasikas Sep 7, 2020
627a3f2
Improve imports
cnasikas Sep 9, 2020
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
165 changes: 95 additions & 70 deletions x-pack/plugins/actions/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ export const IncidentConfigurationSchema = schema.object({
mapping: schema.arrayOf(MapRecordSchema),
});

export const UserSchema = schema.object({
fullName: schema.nullable(schema.string()),
username: schema.nullable(schema.string()),
});

export const EntityInformation = {
createdAt: schema.maybe(schema.string()),
createdBy: schema.maybe(schema.any()),
createdAt: schema.nullable(schema.string()),
createdBy: schema.nullable(UserSchema),
updatedAt: schema.nullable(schema.string()),
updatedBy: schema.nullable(schema.any()),
updatedBy: schema.nullable(UserSchema),
};

export const EntityInformationSchema = schema.object(EntityInformation);

export const CommentSchema = schema.object({
commentId: schema.string(),
comment: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,38 @@

import { TypeOf } from '@kbn/config-schema';
import {
ExecutorSubActionGetIncidentParamsSchema,
ExecutorSubActionHandshakeParamsSchema,
} from './schema';
import { IncidentConfigurationSchema, MapRecordSchema } from './case_shema';
import {
PushToServiceApiParams,
ExternalServiceIncidentResponse,
ExternalServiceParams,
} from './types';
IncidentConfigurationSchema,
MapRecordSchema,
CommentSchema,
EntityInformationSchema,
} from './common_schema';

export interface CreateCommentRequest {
[key: string]: string;
}

export type IncidentConfiguration = TypeOf<typeof IncidentConfigurationSchema>;
export type MapRecord = TypeOf<typeof MapRecordSchema>;
export type Comment = TypeOf<typeof CommentSchema>;
export type EntityInformation = TypeOf<typeof EntityInformationSchema>;

export interface ExternalServiceCommentResponse {
commentId: string;
pushedDate: string;
externalCommentId?: string;
}

export type ExecutorSubActionGetIncidentParams = TypeOf<
typeof ExecutorSubActionGetIncidentParamsSchema
>;

export type ExecutorSubActionHandshakeParams = TypeOf<
typeof ExecutorSubActionHandshakeParamsSchema
>;

export interface PushToServiceResponse extends ExternalServiceIncidentResponse {
comments?: ExternalServiceCommentResponse[];
}

export interface PipedField {
key: string;
value: string;
actionType: string;
pipes: string[];
}

export interface TransformFieldsArgs {
params: PushToServiceApiParams;
export interface TransformFieldsArgs<P, S> {
params: P;
fields: PipedField[];
currentIncident?: ExternalServiceParams;
currentIncident?: S;
}

export interface TransformerArgs {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/actions/server/builtin_action_types/case/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export const buildMap = (mapping: MapRecord[]): Map<string, MapRecord> => {
}, new Map());
};

export const mapParams = (
params: Partial<ExecutorSubActionPushParams>,
mapping: Map<string, MapRecord>
): AnyParams => {
export const mapParams = <T extends {}>(params: T, mapping: Map<string, MapRecord>): AnyParams => {
return Object.keys(params).reduce((prev: AnyParams, curr: string): AnyParams => {
const field = mapping.get(curr);
if (field) {
Expand Down Expand Up @@ -106,7 +103,10 @@ export const createConnectorExecutor = ({
const { comments, externalId, ...restParams } = pushToServiceParams;

const mapping = buildMap(config.casesConfiguration.mapping);
const externalCase = mapParams(restParams, mapping);
const externalCase = mapParams<ExecutorSubActionPushParams>(
restParams as ExecutorSubActionPushParams,
mapping
);

data = await api.pushToService({
externalService,
Expand Down
Loading