-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Cases] API to return a case's connectors information #147295
Changes from 11 commits
205b237
866f353
0e1a260
b8fe694
5350d7d
57fb9e5
bcd0f84
792a5e1
cd86aad
2804c40
5f97d1a
b36100b
f37447d
3ca464f
860142f
093e749
9f95db3
13972dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,36 @@ const existsSchema = s.object({ | |
}) | ||
), | ||
}); | ||
|
||
const rangeSchema = s.object({ | ||
range: s.recordOf( | ||
s.string(), | ||
s.object({ | ||
lt: s.maybe(s.string()), | ||
lte: s.maybe(s.string()), | ||
gt: s.maybe(s.string()), | ||
gte: s.maybe(s.string()), | ||
}) | ||
), | ||
}); | ||
|
||
const termValueSchema = s.object({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are needed for the filter used here: https://github.com/elastic/kibana/pull/147295/files#diff-94dd88fd0956fc92263b02e7ea005e640da97008a8c22d7acd8a13fe2eb11c70R174 |
||
term: s.recordOf(s.string(), s.object({ value: s.string() })), | ||
}); | ||
|
||
const nestedSchema = s.object({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are needed for the filter here: https://github.com/elastic/kibana/pull/147295/files#diff-94dd88fd0956fc92263b02e7ea005e640da97008a8c22d7acd8a13fe2eb11c70R168 |
||
nested: s.object({ | ||
path: s.string(), | ||
query: s.object({ | ||
bool: s.object({ | ||
filter: s.arrayOf(termValueSchema), | ||
}), | ||
}), | ||
}), | ||
}); | ||
|
||
const arraySchema = s.arrayOf(s.oneOf([nestedSchema, rangeSchema])); | ||
|
||
// TODO: it would be great if we could recursively build the schema since the aggregation have be nested | ||
// For more details see how the types are defined in the elasticsearch javascript client: | ||
// https://github.com/elastic/elasticsearch-js/blob/4ad5daeaf401ce8ebb28b940075e0a67e56ff9ce/src/api/typesWithBodyKey.ts#L5295 | ||
|
@@ -70,7 +100,7 @@ const boolSchema = s.object({ | |
must_not: s.oneOf([termSchema, existsSchema]), | ||
}), | ||
s.object({ | ||
filter: s.oneOf([termSchema, existsSchema]), | ||
filter: s.oneOf([termSchema, existsSchema, arraySchema]), | ||
}), | ||
]), | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ export async function deleteAll( | |
concurrency: MAX_CONCURRENT_SEARCHES, | ||
}); | ||
|
||
await userActionService.bulkCreateAttachmentDeletion({ | ||
await userActionService.creator.bulkCreateAttachmentDeletion({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All methods related to creating a user action or audit logging were moved to a new class. This class is accessible through the original user action service class via the |
||
caseId: caseID, | ||
attachments: comments.saved_objects.map((comment) => ({ | ||
id: comment.id, | ||
|
@@ -150,7 +150,7 @@ export async function deleteComment( | |
refresh: false, | ||
}); | ||
|
||
await userActionService.createUserAction({ | ||
await userActionService.creator.createUserAction({ | ||
type: ActionTypes.comment, | ||
action: Actions.delete, | ||
caseId: id, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import type { | |
SavedObjectsClientContract, | ||
IBasePath, | ||
} from '@kbn/core/server'; | ||
import type { ISavedObjectsSerializer } from '@kbn/core-saved-objects-server'; | ||
import { SECURITY_EXTENSION_ID } from '@kbn/core-saved-objects-server'; | ||
import type { | ||
AuditLogger, | ||
|
@@ -119,8 +120,11 @@ export class CasesClientFactory { | |
excludedExtensions: [SECURITY_EXTENSION_ID], | ||
}); | ||
|
||
const savedObjectsSerializer = savedObjectsService.createSerializer(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now use top hits aggregations that return a raw elasticsearch version of a saved object document. To interact with that document we need to convert it to a saved object. This serializer does the conversion for us so we're passing it through to the user action service. |
||
|
||
const services = this.createServices({ | ||
unsecuredSavedObjectsClient, | ||
savedObjectsSerializer, | ||
esClient: scopedClusterClient, | ||
request, | ||
auditLogger, | ||
|
@@ -152,11 +156,13 @@ export class CasesClientFactory { | |
|
||
private createServices({ | ||
unsecuredSavedObjectsClient, | ||
savedObjectsSerializer, | ||
esClient, | ||
request, | ||
auditLogger, | ||
}: { | ||
unsecuredSavedObjectsClient: SavedObjectsClientContract; | ||
savedObjectsSerializer: ISavedObjectsSerializer; | ||
esClient: ElasticsearchClient; | ||
request: KibanaRequest; | ||
auditLogger: AuditLogger; | ||
|
@@ -201,6 +207,7 @@ export class CasesClientFactory { | |
log: this.logger, | ||
persistableStateAttachmentTypeRegistry: this.options.persistableStateAttachmentTypeRegistry, | ||
unsecuredSavedObjectsClient, | ||
savedObjectsSerializer, | ||
auditLogger, | ||
}), | ||
attachmentService, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are needed for a filter used here: https://github.com/elastic/kibana/pull/147295/files#diff-94dd88fd0956fc92263b02e7ea005e640da97008a8c22d7acd8a13fe2eb11c70R161