1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::collections::HashMap;

use reqwest::StatusCode;
use serde::Serialize;
use serde_json::value::Value as JsonValue;

#[derive(Serialize)]
pub struct StructuredLogsIngestRequest<'a> {
    pub tags: HashMap<String, String>,
    pub events: &'a [StructuredLogEvent],
}

#[derive(Serialize, Clone)]
pub struct StructuredLogEvent {
    pub timestamp: u128,
    pub attributes: JsonValue,
}

impl StructuredLogEvent {
    pub fn new(timestamp: u128, attributes: JsonValue) -> Self {
        Self { timestamp, attributes }
    }
}

#[derive(Debug)]
pub enum IngestStructuredDataError {
    FailedSendingRequest,
    RequestStatusCodeDidNotIndicateSuccess(StatusCode),
}