org.graylog.plugins.views.search.export.SearchExportJob Maven / Gradle / Ivy
/*
* Copyright (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* .
*/
package org.graylog.plugins.views.search.export;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import javax.validation.constraints.NotEmpty;
@AutoValue
@JsonAutoDetect
public abstract class SearchExportJob implements ExportJob {
static final String TYPE = "search_export";
private static final String FIELD_SEARCH_ID = "search_id";
private static final String FIELD_RESULT_FORMAT = "result_format";
@JsonProperty("type")
public String type() {
return TYPE;
}
@JsonProperty(FIELD_SEARCH_ID)
public abstract String searchId();
@JsonProperty(FIELD_RESULT_FORMAT)
@NotEmpty
public abstract ResultFormat resultFormat();
static SearchExportJob forSearch(String id, String searchId, ResultFormat resultFormat) {
return new AutoValue_SearchExportJob(id, DateTime.now(DateTimeZone.UTC), searchId, resultFormat);
}
@JsonCreator
static SearchExportJob create(
@JsonProperty(FIELD_ID) String id,
@JsonProperty(FIELD_SEARCH_ID) String searchId,
@JsonProperty(FIELD_RESULT_FORMAT) ResultFormat resultFormat
) {
return new AutoValue_SearchExportJob(id,
DateTime.now(DateTimeZone.UTC),
searchId,
resultFormat);
}
}