nile_client_rs/models/
aggregation_request.rs

1/*
2 * Nile API
3 *
4 * Making SaaS chill.
5 *
6 * The version of the OpenAPI document: 0.1.0-fdd7cd5
7 * Contact: support@thenile.dev
8 * Generated by: https://openapi-generator.tech
9 */
10
11#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
12pub struct AggregationRequest {
13    /// The size of the bucket
14    #[serde(rename = "bucket_size", skip_serializing_if = "Option::is_none")]
15    pub bucket_size: Option<BucketSize>,
16    /// Number of buckets to return. Defaults to 3 if not provided.
17    #[serde(rename = "buckets", skip_serializing_if = "Option::is_none")]
18    pub buckets: Option<i32>,
19    /// An ISO-8601 formatted date-time, i.e., 2018-11-13T20:20:39+00:00, that the aggregation should start at. This time will be truncated based on bucket_size, i.e., if bucket_size is 1h, then the start_time will be truncated to the nearest hour.
20    #[serde(rename = "start_time")]
21    pub start_time: String,
22    /// The Nile organization id to aggregate on
23    #[serde(rename = "organization_id", skip_serializing_if = "Option::is_none")]
24    pub organization_id: Option<String>,
25    /// The optional Nile instance id to aggregate on
26    #[serde(rename = "instance_id", skip_serializing_if = "Option::is_none")]
27    pub instance_id: Option<String>,
28}
29
30impl AggregationRequest {
31    pub fn new(start_time: String) -> AggregationRequest {
32        AggregationRequest {
33            bucket_size: None,
34            buckets: None,
35            start_time,
36            organization_id: None,
37            instance_id: None,
38        }
39    }
40}
41
42/// The size of the bucket
43#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
44pub enum BucketSize {
45    #[serde(rename = "1h")]
46    Variant1h,
47    #[serde(rename = "1d")]
48    Variant1d,
49    #[serde(rename = "10m")]
50    Variant10m,
51}
52
53impl Default for BucketSize {
54    fn default() -> BucketSize {
55        Self::Variant1h
56    }
57}
58
59use serde::{Deserialize, Serialize};