-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
635 additions
and
585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/rule_registry/server/event_log/log/event_log_definition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { ILMPolicy, defaultIlmPolicy } from '../elasticsearch'; | ||
import { EventSchema, FieldMap, Schema } from '../event_schema'; | ||
import { EventLogOptions, IEventLogDefinition } from './public_api'; | ||
|
||
export class EventLogDefinition<TMap extends FieldMap> implements IEventLogDefinition<TMap> { | ||
public readonly eventLogName: string; | ||
public readonly eventSchema: EventSchema<TMap>; | ||
public readonly ilmPolicy: ILMPolicy; | ||
|
||
constructor(options: EventLogOptions<TMap>) { | ||
this.eventLogName = options.name; | ||
this.eventSchema = options.schema; | ||
this.ilmPolicy = options.ilmPolicy ?? defaultIlmPolicy; | ||
} | ||
|
||
public defineChild<TExtMap extends FieldMap = TMap>( | ||
options: EventLogOptions<TExtMap> | ||
): IEventLogDefinition<TMap & TExtMap> { | ||
// TODO: validate name (can't contain "-" and ".") | ||
const childName = `${this.eventLogName}.${options.name}`; | ||
const childSchema = Schema.combine(this.eventSchema, options.schema); | ||
const childPolicy = options.ilmPolicy ?? this.ilmPolicy; | ||
|
||
return new EventLogDefinition({ | ||
name: childName, | ||
schema: childSchema, | ||
ilmPolicy: childPolicy, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.