-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Pass JSON files containing rule filters and scheduled events configuration to autodetect. This change must not be merged until after elastic/ml-cpp#1640 as the C++ backend code must be able to safely consume the new command line options. Relates elastic/ml-cpp#1253 Backports #66736
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 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
36 changes: 36 additions & 0 deletions
36
.../org/elasticsearch/xpack/ml/job/process/autodetect/writer/ScheduledEventToRuleWriter.java
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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
package org.elasticsearch.xpack.ml.job.process.autodetect.writer; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ToXContentObject; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.xpack.core.ml.job.config.DetectionRule; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class ScheduledEventToRuleWriter implements ToXContentObject { | ||
|
||
public static final ParseField DESCRIPTION = new ParseField("description"); | ||
public static final ParseField RULES = new ParseField("rules"); | ||
|
||
private final String description; | ||
private final DetectionRule detectionRule; | ||
|
||
public ScheduledEventToRuleWriter(String description, DetectionRule detectionRule) { | ||
this.description = Objects.requireNonNull(description); | ||
this.detectionRule = Objects.requireNonNull(detectionRule); | ||
} | ||
|
||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(DESCRIPTION.getPreferredName(), description); | ||
builder.array(RULES.getPreferredName(), detectionRule); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
} |