|
13 | 13 | import jakarta.validation.Valid; |
14 | 14 | import jakarta.validation.constraints.NotNull; |
15 | 15 | import lombok.Getter; |
| 16 | +import org.hibernate.validator.constraints.time.DurationMax; |
16 | 17 | import org.opensearch.dataprepper.plugins.source.microsoft_office365.auth.AuthenticationConfiguration; |
17 | 18 | import org.opensearch.dataprepper.plugins.source.source_crawler.base.CrawlerSourceConfig; |
18 | 19 |
|
| 20 | +import java.time.Duration; |
| 21 | + |
19 | 22 | /** |
20 | 23 | * Configuration class for Office 365 source plugin. |
21 | 24 | */ |
@@ -46,6 +49,28 @@ public class Office365SourceConfig implements CrawlerSourceConfig { |
46 | 49 | @JsonProperty("acknowledgments") |
47 | 50 | private boolean acknowledgments = false; |
48 | 51 |
|
| 52 | + /** |
| 53 | + * Time range for lookback data collection using ISO 8601 duration format. |
| 54 | + * Specifies how far back in time to collect data from the current time. |
| 55 | + * Default: null (no lookback, only incremental data) |
| 56 | + * Maximum: P7D (7 days due to Office 365 API limitation) |
| 57 | + */ |
| 58 | + @JsonProperty("range") |
| 59 | + @DurationMax(days = 7, message = "Range cannot exceed 7 days due to Office 365 API limitation") |
| 60 | + private Duration range; |
| 61 | + |
| 62 | + /** |
| 63 | + * Gets the look back range as hours for compatibility with existing crawler framework. |
| 64 | + * |
| 65 | + * @return the number of hours to look back, or 0 if no range is specified |
| 66 | + */ |
| 67 | + public int getLookBackHours() { |
| 68 | + if (range == null || range.toHours() <= 0) { |
| 69 | + return 0; |
| 70 | + } |
| 71 | + return (int) range.toHours(); |
| 72 | + } |
| 73 | + |
49 | 74 | @Override |
50 | 75 | public int getNumberOfWorkers() { |
51 | 76 | return NUMBER_OF_WORKERS; |
|
0 commit comments