google_cloud_timeseriesinsights_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate lazy_static;
25extern crate reqwest;
26extern crate rpc;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38/// Mapping of BigQuery columns to timestamp, group_id and dimensions.
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct BigqueryMapping {
42    /// The column which should be used as the event timestamps. If not specified
43    /// 'Timestamp' is used by default. The column may have TIMESTAMP or INT64
44    /// type (the latter is interpreted as microseconds since the Unix epoch).
45    pub timestamp_column: std::string::String,
46
47    /// The column which should be used as the group ID (grouping events into
48    /// sessions). If not specified 'GroupId' is used by default, if the input
49    /// table does not have such a column, random unique group IDs are
50    /// generated automatically (different group ID per input row).
51    pub group_id_column: std::string::String,
52
53    /// The list of columns that should be translated to dimensions. If empty,
54    /// all columns are translated to dimensions. The timestamp and group_id
55    /// columns should not be listed here again. Columns are expected to have
56    /// primitive types (STRING, INT64, FLOAT64 or NUMERIC).
57    pub dimension_column: std::vec::Vec<std::string::String>,
58
59    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
60}
61
62impl BigqueryMapping {
63    pub fn new() -> Self {
64        std::default::Default::default()
65    }
66
67    /// Sets the value of [timestamp_column][crate::model::BigqueryMapping::timestamp_column].
68    pub fn set_timestamp_column<T: std::convert::Into<std::string::String>>(
69        mut self,
70        v: T,
71    ) -> Self {
72        self.timestamp_column = v.into();
73        self
74    }
75
76    /// Sets the value of [group_id_column][crate::model::BigqueryMapping::group_id_column].
77    pub fn set_group_id_column<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
78        self.group_id_column = v.into();
79        self
80    }
81
82    /// Sets the value of [dimension_column][crate::model::BigqueryMapping::dimension_column].
83    pub fn set_dimension_column<T, V>(mut self, v: T) -> Self
84    where
85        T: std::iter::IntoIterator<Item = V>,
86        V: std::convert::Into<std::string::String>,
87    {
88        use std::iter::Iterator;
89        self.dimension_column = v.into_iter().map(|i| i.into()).collect();
90        self
91    }
92}
93
94impl wkt::message::Message for BigqueryMapping {
95    fn typename() -> &'static str {
96        "type.googleapis.com/google.cloud.timeseriesinsights.v1.BigqueryMapping"
97    }
98}
99
100/// A data source consists of multiple [Event][google.cloud.timeseriesinsights.v1.Event] objects stored on
101/// Cloud Storage.  Each Event should be in JSON format, with one Event
102/// per line, also known as JSON Lines format.
103///
104/// [google.cloud.timeseriesinsights.v1.Event]: crate::model::Event
105#[derive(Clone, Default, PartialEq)]
106#[non_exhaustive]
107pub struct DataSource {
108    /// Data source URI.
109    ///
110    /// 1. Google Cloud Storage files (JSON) are defined in the following form.
111    ///    `gs://bucket_name/object_name`. For more information on Cloud Storage URIs,
112    ///    please see <https://cloud.google.com/storage/docs/reference-uris>.
113    pub uri: std::string::String,
114
115    /// For BigQuery inputs defines the columns that should be used for dimensions
116    /// (including time and group ID).
117    pub bq_mapping: std::option::Option<crate::model::BigqueryMapping>,
118
119    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
120}
121
122impl DataSource {
123    pub fn new() -> Self {
124        std::default::Default::default()
125    }
126
127    /// Sets the value of [uri][crate::model::DataSource::uri].
128    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
129        self.uri = v.into();
130        self
131    }
132
133    /// Sets the value of [bq_mapping][crate::model::DataSource::bq_mapping].
134    pub fn set_bq_mapping<T>(mut self, v: T) -> Self
135    where
136        T: std::convert::Into<crate::model::BigqueryMapping>,
137    {
138        self.bq_mapping = std::option::Option::Some(v.into());
139        self
140    }
141
142    /// Sets or clears the value of [bq_mapping][crate::model::DataSource::bq_mapping].
143    pub fn set_or_clear_bq_mapping<T>(mut self, v: std::option::Option<T>) -> Self
144    where
145        T: std::convert::Into<crate::model::BigqueryMapping>,
146    {
147        self.bq_mapping = v.map(|x| x.into());
148        self
149    }
150}
151
152impl wkt::message::Message for DataSource {
153    fn typename() -> &'static str {
154        "type.googleapis.com/google.cloud.timeseriesinsights.v1.DataSource"
155    }
156}
157
158/// A collection of data sources sent for processing.
159#[derive(Clone, Default, PartialEq)]
160#[non_exhaustive]
161pub struct DataSet {
162    /// The dataset name, which will be used for querying, status and unload
163    /// requests. This must be unique within a project.
164    pub name: std::string::String,
165
166    /// [Data dimension names][google.cloud.timeseriesinsights.v1.EventDimension.name] allowed for this `DataSet`.
167    ///
168    /// If left empty, all dimension names are included. This field works as a
169    /// filter to avoid regenerating the data.
170    ///
171    /// [google.cloud.timeseriesinsights.v1.EventDimension.name]: crate::model::EventDimension::name
172    pub data_names: std::vec::Vec<std::string::String>,
173
174    /// Input data.
175    pub data_sources: std::vec::Vec<crate::model::DataSource>,
176
177    /// Dataset state in the system.
178    pub state: crate::model::data_set::State,
179
180    /// Dataset processing status.
181    pub status: std::option::Option<rpc::model::Status>,
182
183    /// Periodically we discard dataset [Event][google.cloud.timeseriesinsights.v1.Event] objects that have
184    /// timestamps older than 'ttl'.  Omitting this field or a zero value means no
185    /// events are discarded.
186    ///
187    /// [google.cloud.timeseriesinsights.v1.Event]: crate::model::Event
188    pub ttl: std::option::Option<wkt::Duration>,
189
190    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
191}
192
193impl DataSet {
194    pub fn new() -> Self {
195        std::default::Default::default()
196    }
197
198    /// Sets the value of [name][crate::model::DataSet::name].
199    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
200        self.name = v.into();
201        self
202    }
203
204    /// Sets the value of [data_names][crate::model::DataSet::data_names].
205    pub fn set_data_names<T, V>(mut self, v: T) -> Self
206    where
207        T: std::iter::IntoIterator<Item = V>,
208        V: std::convert::Into<std::string::String>,
209    {
210        use std::iter::Iterator;
211        self.data_names = v.into_iter().map(|i| i.into()).collect();
212        self
213    }
214
215    /// Sets the value of [data_sources][crate::model::DataSet::data_sources].
216    pub fn set_data_sources<T, V>(mut self, v: T) -> Self
217    where
218        T: std::iter::IntoIterator<Item = V>,
219        V: std::convert::Into<crate::model::DataSource>,
220    {
221        use std::iter::Iterator;
222        self.data_sources = v.into_iter().map(|i| i.into()).collect();
223        self
224    }
225
226    /// Sets the value of [state][crate::model::DataSet::state].
227    pub fn set_state<T: std::convert::Into<crate::model::data_set::State>>(mut self, v: T) -> Self {
228        self.state = v.into();
229        self
230    }
231
232    /// Sets the value of [status][crate::model::DataSet::status].
233    pub fn set_status<T>(mut self, v: T) -> Self
234    where
235        T: std::convert::Into<rpc::model::Status>,
236    {
237        self.status = std::option::Option::Some(v.into());
238        self
239    }
240
241    /// Sets or clears the value of [status][crate::model::DataSet::status].
242    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
243    where
244        T: std::convert::Into<rpc::model::Status>,
245    {
246        self.status = v.map(|x| x.into());
247        self
248    }
249
250    /// Sets the value of [ttl][crate::model::DataSet::ttl].
251    pub fn set_ttl<T>(mut self, v: T) -> Self
252    where
253        T: std::convert::Into<wkt::Duration>,
254    {
255        self.ttl = std::option::Option::Some(v.into());
256        self
257    }
258
259    /// Sets or clears the value of [ttl][crate::model::DataSet::ttl].
260    pub fn set_or_clear_ttl<T>(mut self, v: std::option::Option<T>) -> Self
261    where
262        T: std::convert::Into<wkt::Duration>,
263    {
264        self.ttl = v.map(|x| x.into());
265        self
266    }
267}
268
269impl wkt::message::Message for DataSet {
270    fn typename() -> &'static str {
271        "type.googleapis.com/google.cloud.timeseriesinsights.v1.DataSet"
272    }
273}
274
275/// Defines additional types related to [DataSet].
276pub mod data_set {
277    #[allow(unused_imports)]
278    use super::*;
279
280    /// DataSet state.
281    ///
282    /// # Working with unknown values
283    ///
284    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
285    /// additional enum variants at any time. Adding new variants is not considered
286    /// a breaking change. Applications should write their code in anticipation of:
287    ///
288    /// - New values appearing in future releases of the client library, **and**
289    /// - New values received dynamically, without application changes.
290    ///
291    /// Please consult the [Working with enums] section in the user guide for some
292    /// guidelines.
293    ///
294    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
295    #[derive(Clone, Debug, PartialEq)]
296    #[non_exhaustive]
297    pub enum State {
298        /// Unspecified / undefined state.
299        Unspecified,
300        /// Dataset is unknown to the system; we have never seen this dataset before
301        /// or we have seen this dataset but have fully GC-ed it.
302        Unknown,
303        /// Dataset processing is pending.
304        Pending,
305        /// Dataset is loading.
306        Loading,
307        /// Dataset is loaded and can be queried.
308        Loaded,
309        /// Dataset is unloading.
310        Unloading,
311        /// Dataset is unloaded and is removed from the system.
312        Unloaded,
313        /// Dataset processing failed.
314        Failed,
315        /// If set, the enum was initialized with an unknown value.
316        ///
317        /// Applications can examine the value using [State::value] or
318        /// [State::name].
319        UnknownValue(state::UnknownValue),
320    }
321
322    #[doc(hidden)]
323    pub mod state {
324        #[allow(unused_imports)]
325        use super::*;
326        #[derive(Clone, Debug, PartialEq)]
327        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
328    }
329
330    impl State {
331        /// Gets the enum value.
332        ///
333        /// Returns `None` if the enum contains an unknown value deserialized from
334        /// the string representation of enums.
335        pub fn value(&self) -> std::option::Option<i32> {
336            match self {
337                Self::Unspecified => std::option::Option::Some(0),
338                Self::Unknown => std::option::Option::Some(1),
339                Self::Pending => std::option::Option::Some(2),
340                Self::Loading => std::option::Option::Some(3),
341                Self::Loaded => std::option::Option::Some(4),
342                Self::Unloading => std::option::Option::Some(5),
343                Self::Unloaded => std::option::Option::Some(6),
344                Self::Failed => std::option::Option::Some(7),
345                Self::UnknownValue(u) => u.0.value(),
346            }
347        }
348
349        /// Gets the enum value as a string.
350        ///
351        /// Returns `None` if the enum contains an unknown value deserialized from
352        /// the integer representation of enums.
353        pub fn name(&self) -> std::option::Option<&str> {
354            match self {
355                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
356                Self::Unknown => std::option::Option::Some("UNKNOWN"),
357                Self::Pending => std::option::Option::Some("PENDING"),
358                Self::Loading => std::option::Option::Some("LOADING"),
359                Self::Loaded => std::option::Option::Some("LOADED"),
360                Self::Unloading => std::option::Option::Some("UNLOADING"),
361                Self::Unloaded => std::option::Option::Some("UNLOADED"),
362                Self::Failed => std::option::Option::Some("FAILED"),
363                Self::UnknownValue(u) => u.0.name(),
364            }
365        }
366    }
367
368    impl std::default::Default for State {
369        fn default() -> Self {
370            use std::convert::From;
371            Self::from(0)
372        }
373    }
374
375    impl std::fmt::Display for State {
376        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
377            wkt::internal::display_enum(f, self.name(), self.value())
378        }
379    }
380
381    impl std::convert::From<i32> for State {
382        fn from(value: i32) -> Self {
383            match value {
384                0 => Self::Unspecified,
385                1 => Self::Unknown,
386                2 => Self::Pending,
387                3 => Self::Loading,
388                4 => Self::Loaded,
389                5 => Self::Unloading,
390                6 => Self::Unloaded,
391                7 => Self::Failed,
392                _ => Self::UnknownValue(state::UnknownValue(
393                    wkt::internal::UnknownEnumValue::Integer(value),
394                )),
395            }
396        }
397    }
398
399    impl std::convert::From<&str> for State {
400        fn from(value: &str) -> Self {
401            use std::string::ToString;
402            match value {
403                "STATE_UNSPECIFIED" => Self::Unspecified,
404                "UNKNOWN" => Self::Unknown,
405                "PENDING" => Self::Pending,
406                "LOADING" => Self::Loading,
407                "LOADED" => Self::Loaded,
408                "UNLOADING" => Self::Unloading,
409                "UNLOADED" => Self::Unloaded,
410                "FAILED" => Self::Failed,
411                _ => Self::UnknownValue(state::UnknownValue(
412                    wkt::internal::UnknownEnumValue::String(value.to_string()),
413                )),
414            }
415        }
416    }
417
418    impl serde::ser::Serialize for State {
419        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
420        where
421            S: serde::Serializer,
422        {
423            match self {
424                Self::Unspecified => serializer.serialize_i32(0),
425                Self::Unknown => serializer.serialize_i32(1),
426                Self::Pending => serializer.serialize_i32(2),
427                Self::Loading => serializer.serialize_i32(3),
428                Self::Loaded => serializer.serialize_i32(4),
429                Self::Unloading => serializer.serialize_i32(5),
430                Self::Unloaded => serializer.serialize_i32(6),
431                Self::Failed => serializer.serialize_i32(7),
432                Self::UnknownValue(u) => u.0.serialize(serializer),
433            }
434        }
435    }
436
437    impl<'de> serde::de::Deserialize<'de> for State {
438        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
439        where
440            D: serde::Deserializer<'de>,
441        {
442            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
443                ".google.cloud.timeseriesinsights.v1.DataSet.State",
444            ))
445        }
446    }
447}
448
449/// Represents an event dimension.
450#[derive(Clone, Default, PartialEq)]
451#[non_exhaustive]
452pub struct EventDimension {
453    /// Dimension name.
454    ///
455    /// **NOTE**: `EventDimension` names must be composed of alphanumeric
456    /// characters only, and are case insensitive. Unicode characters are *not*
457    /// supported. The underscore '_' is also allowed.
458    pub name: std::string::String,
459
460    /// Dimension value.
461    ///
462    /// **NOTE**: All entries of the dimension `name` must have the same `value`
463    /// type.
464    pub value: std::option::Option<crate::model::event_dimension::Value>,
465
466    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
467}
468
469impl EventDimension {
470    pub fn new() -> Self {
471        std::default::Default::default()
472    }
473
474    /// Sets the value of [name][crate::model::EventDimension::name].
475    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
476        self.name = v.into();
477        self
478    }
479
480    /// Sets the value of [value][crate::model::EventDimension::value].
481    ///
482    /// Note that all the setters affecting `value` are mutually
483    /// exclusive.
484    pub fn set_value<
485        T: std::convert::Into<std::option::Option<crate::model::event_dimension::Value>>,
486    >(
487        mut self,
488        v: T,
489    ) -> Self {
490        self.value = v.into();
491        self
492    }
493
494    /// The value of [value][crate::model::EventDimension::value]
495    /// if it holds a `StringVal`, `None` if the field is not set or
496    /// holds a different branch.
497    pub fn string_val(&self) -> std::option::Option<&std::string::String> {
498        #[allow(unreachable_patterns)]
499        self.value.as_ref().and_then(|v| match v {
500            crate::model::event_dimension::Value::StringVal(v) => std::option::Option::Some(v),
501            _ => std::option::Option::None,
502        })
503    }
504
505    /// Sets the value of [value][crate::model::EventDimension::value]
506    /// to hold a `StringVal`.
507    ///
508    /// Note that all the setters affecting `value` are
509    /// mutually exclusive.
510    pub fn set_string_val<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
511        self.value =
512            std::option::Option::Some(crate::model::event_dimension::Value::StringVal(v.into()));
513        self
514    }
515
516    /// The value of [value][crate::model::EventDimension::value]
517    /// if it holds a `LongVal`, `None` if the field is not set or
518    /// holds a different branch.
519    pub fn long_val(&self) -> std::option::Option<&i64> {
520        #[allow(unreachable_patterns)]
521        self.value.as_ref().and_then(|v| match v {
522            crate::model::event_dimension::Value::LongVal(v) => std::option::Option::Some(v),
523            _ => std::option::Option::None,
524        })
525    }
526
527    /// Sets the value of [value][crate::model::EventDimension::value]
528    /// to hold a `LongVal`.
529    ///
530    /// Note that all the setters affecting `value` are
531    /// mutually exclusive.
532    pub fn set_long_val<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
533        self.value =
534            std::option::Option::Some(crate::model::event_dimension::Value::LongVal(v.into()));
535        self
536    }
537
538    /// The value of [value][crate::model::EventDimension::value]
539    /// if it holds a `BoolVal`, `None` if the field is not set or
540    /// holds a different branch.
541    pub fn bool_val(&self) -> std::option::Option<&bool> {
542        #[allow(unreachable_patterns)]
543        self.value.as_ref().and_then(|v| match v {
544            crate::model::event_dimension::Value::BoolVal(v) => std::option::Option::Some(v),
545            _ => std::option::Option::None,
546        })
547    }
548
549    /// Sets the value of [value][crate::model::EventDimension::value]
550    /// to hold a `BoolVal`.
551    ///
552    /// Note that all the setters affecting `value` are
553    /// mutually exclusive.
554    pub fn set_bool_val<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
555        self.value =
556            std::option::Option::Some(crate::model::event_dimension::Value::BoolVal(v.into()));
557        self
558    }
559
560    /// The value of [value][crate::model::EventDimension::value]
561    /// if it holds a `DoubleVal`, `None` if the field is not set or
562    /// holds a different branch.
563    pub fn double_val(&self) -> std::option::Option<&f64> {
564        #[allow(unreachable_patterns)]
565        self.value.as_ref().and_then(|v| match v {
566            crate::model::event_dimension::Value::DoubleVal(v) => std::option::Option::Some(v),
567            _ => std::option::Option::None,
568        })
569    }
570
571    /// Sets the value of [value][crate::model::EventDimension::value]
572    /// to hold a `DoubleVal`.
573    ///
574    /// Note that all the setters affecting `value` are
575    /// mutually exclusive.
576    pub fn set_double_val<T: std::convert::Into<f64>>(mut self, v: T) -> Self {
577        self.value =
578            std::option::Option::Some(crate::model::event_dimension::Value::DoubleVal(v.into()));
579        self
580    }
581}
582
583impl wkt::message::Message for EventDimension {
584    fn typename() -> &'static str {
585        "type.googleapis.com/google.cloud.timeseriesinsights.v1.EventDimension"
586    }
587}
588
589/// Defines additional types related to [EventDimension].
590pub mod event_dimension {
591    #[allow(unused_imports)]
592    use super::*;
593
594    /// Dimension value.
595    ///
596    /// **NOTE**: All entries of the dimension `name` must have the same `value`
597    /// type.
598    #[derive(Clone, Debug, PartialEq)]
599    #[non_exhaustive]
600    pub enum Value {
601        /// String representation.
602        ///
603        /// **NOTE**: String values are case insensitive. Unicode characters are
604        /// supported.
605        StringVal(std::string::String),
606        /// Long representation.
607        LongVal(i64),
608        /// Bool representation.
609        BoolVal(bool),
610        /// Double representation.
611        DoubleVal(f64),
612    }
613}
614
615/// Represents an entry in a data source.
616///
617/// Each Event has:
618///
619/// * A timestamp at which the event occurs.
620/// * One or multiple dimensions.
621/// * Optionally, a group ID that allows clients to group logically related
622///   events (for example, all events representing payments transactions done by
623///   a user in a day have the same group ID).  If a group ID is not provided, an
624///   internal one will be generated based on the content and `eventTime`.
625///
626/// **NOTE**:
627///
628/// * Internally, we discretize time in equal-sized chunks and we assume an
629///   event has a 0
630///   [TimeseriesPoint.value][google.cloud.timeseriesinsights.v1.TimeseriesPoint.value]
631///   in a chunk that does not contain any occurrences of an event in the input.
632/// * The number of Events with the same group ID should be limited.
633/// * Group ID *cannot* be queried.
634/// * Group ID does *not* correspond to a user ID or the like. If a user ID is of
635///   interest to be queried, use a user ID `dimension` instead.
636///
637/// [google.cloud.timeseriesinsights.v1.TimeseriesPoint.value]: crate::model::TimeseriesPoint::value
638#[derive(Clone, Default, PartialEq)]
639#[non_exhaustive]
640pub struct Event {
641    /// Event dimensions.
642    pub dimensions: std::vec::Vec<crate::model::EventDimension>,
643
644    /// Event group ID.
645    ///
646    /// **NOTE**: JSON encoding should use a string to hold a 64-bit integer value,
647    /// because a native JSON number holds only 53 binary bits for an integer.
648    pub group_id: i64,
649
650    /// Event timestamp.
651    pub event_time: std::option::Option<wkt::Timestamp>,
652
653    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
654}
655
656impl Event {
657    pub fn new() -> Self {
658        std::default::Default::default()
659    }
660
661    /// Sets the value of [dimensions][crate::model::Event::dimensions].
662    pub fn set_dimensions<T, V>(mut self, v: T) -> Self
663    where
664        T: std::iter::IntoIterator<Item = V>,
665        V: std::convert::Into<crate::model::EventDimension>,
666    {
667        use std::iter::Iterator;
668        self.dimensions = v.into_iter().map(|i| i.into()).collect();
669        self
670    }
671
672    /// Sets the value of [group_id][crate::model::Event::group_id].
673    pub fn set_group_id<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
674        self.group_id = v.into();
675        self
676    }
677
678    /// Sets the value of [event_time][crate::model::Event::event_time].
679    pub fn set_event_time<T>(mut self, v: T) -> Self
680    where
681        T: std::convert::Into<wkt::Timestamp>,
682    {
683        self.event_time = std::option::Option::Some(v.into());
684        self
685    }
686
687    /// Sets or clears the value of [event_time][crate::model::Event::event_time].
688    pub fn set_or_clear_event_time<T>(mut self, v: std::option::Option<T>) -> Self
689    where
690        T: std::convert::Into<wkt::Timestamp>,
691    {
692        self.event_time = v.map(|x| x.into());
693        self
694    }
695}
696
697impl wkt::message::Message for Event {
698    fn typename() -> &'static str {
699        "type.googleapis.com/google.cloud.timeseriesinsights.v1.Event"
700    }
701}
702
703/// Appends events to an existing DataSet.
704#[derive(Clone, Default, PartialEq)]
705#[non_exhaustive]
706pub struct AppendEventsRequest {
707    /// Events to be appended.
708    ///
709    /// Note:
710    ///
711    /// 1. The [DataSet][google.cloud.timeseriesinsights.v1.DataSet] must be shown in a `LOADED` state
712    ///    in the results of `list` method; otherwise, all events from
713    ///    the append request will be dropped, and a `NOT_FOUND` status will be
714    ///    returned.
715    /// 1. All events in a single request must have the same
716    ///    [groupId][google.cloud.timeseriesinsights.v1.Event.group_id] if set; otherwise, an
717    ///    `INVALID_ARGUMENT` status will be returned.
718    /// 1. If [groupId][google.cloud.timeseriesinsights.v1.Event.group_id] is not set (or 0), there
719    ///    should be only 1 event; otherwise, an `INVALID_ARGUMENT` status will be
720    ///    returned.
721    /// 1. The events must be newer than the current time minus
722    ///    [DataSet TTL][google.cloud.timeseriesinsights.v1.DataSet.ttl] or they will be dropped.
723    ///
724    /// [google.cloud.timeseriesinsights.v1.DataSet]: crate::model::DataSet
725    /// [google.cloud.timeseriesinsights.v1.DataSet.ttl]: crate::model::DataSet::ttl
726    /// [google.cloud.timeseriesinsights.v1.Event.group_id]: crate::model::Event::group_id
727    pub events: std::vec::Vec<crate::model::Event>,
728
729    /// Required. The DataSet to which we want to append to in the format of
730    /// "projects/{project}/datasets/{dataset}"
731    pub dataset: std::string::String,
732
733    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
734}
735
736impl AppendEventsRequest {
737    pub fn new() -> Self {
738        std::default::Default::default()
739    }
740
741    /// Sets the value of [events][crate::model::AppendEventsRequest::events].
742    pub fn set_events<T, V>(mut self, v: T) -> Self
743    where
744        T: std::iter::IntoIterator<Item = V>,
745        V: std::convert::Into<crate::model::Event>,
746    {
747        use std::iter::Iterator;
748        self.events = v.into_iter().map(|i| i.into()).collect();
749        self
750    }
751
752    /// Sets the value of [dataset][crate::model::AppendEventsRequest::dataset].
753    pub fn set_dataset<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
754        self.dataset = v.into();
755        self
756    }
757}
758
759impl wkt::message::Message for AppendEventsRequest {
760    fn typename() -> &'static str {
761        "type.googleapis.com/google.cloud.timeseriesinsights.v1.AppendEventsRequest"
762    }
763}
764
765/// Response for an AppendEvents RPC.
766#[derive(Clone, Default, PartialEq)]
767#[non_exhaustive]
768pub struct AppendEventsResponse {
769    /// Dropped events; empty if all events are successfully added.
770    pub dropped_events: std::vec::Vec<crate::model::Event>,
771
772    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
773}
774
775impl AppendEventsResponse {
776    pub fn new() -> Self {
777        std::default::Default::default()
778    }
779
780    /// Sets the value of [dropped_events][crate::model::AppendEventsResponse::dropped_events].
781    pub fn set_dropped_events<T, V>(mut self, v: T) -> Self
782    where
783        T: std::iter::IntoIterator<Item = V>,
784        V: std::convert::Into<crate::model::Event>,
785    {
786        use std::iter::Iterator;
787        self.dropped_events = v.into_iter().map(|i| i.into()).collect();
788        self
789    }
790}
791
792impl wkt::message::Message for AppendEventsResponse {
793    fn typename() -> &'static str {
794        "type.googleapis.com/google.cloud.timeseriesinsights.v1.AppendEventsResponse"
795    }
796}
797
798/// Create a DataSet request.
799#[derive(Clone, Default, PartialEq)]
800#[non_exhaustive]
801pub struct CreateDataSetRequest {
802    /// Required. Client project name which will own this DataSet in the format of
803    /// 'projects/{project}'.
804    pub parent: std::string::String,
805
806    /// Required. Dataset to be loaded.
807    pub dataset: std::option::Option<crate::model::DataSet>,
808
809    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
810}
811
812impl CreateDataSetRequest {
813    pub fn new() -> Self {
814        std::default::Default::default()
815    }
816
817    /// Sets the value of [parent][crate::model::CreateDataSetRequest::parent].
818    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
819        self.parent = v.into();
820        self
821    }
822
823    /// Sets the value of [dataset][crate::model::CreateDataSetRequest::dataset].
824    pub fn set_dataset<T>(mut self, v: T) -> Self
825    where
826        T: std::convert::Into<crate::model::DataSet>,
827    {
828        self.dataset = std::option::Option::Some(v.into());
829        self
830    }
831
832    /// Sets or clears the value of [dataset][crate::model::CreateDataSetRequest::dataset].
833    pub fn set_or_clear_dataset<T>(mut self, v: std::option::Option<T>) -> Self
834    where
835        T: std::convert::Into<crate::model::DataSet>,
836    {
837        self.dataset = v.map(|x| x.into());
838        self
839    }
840}
841
842impl wkt::message::Message for CreateDataSetRequest {
843    fn typename() -> &'static str {
844        "type.googleapis.com/google.cloud.timeseriesinsights.v1.CreateDataSetRequest"
845    }
846}
847
848/// Unload DataSet request from the serving system.
849#[derive(Clone, Default, PartialEq)]
850#[non_exhaustive]
851pub struct DeleteDataSetRequest {
852    /// Required. Dataset name in the format of "projects/{project}/datasets/{dataset}"
853    pub name: std::string::String,
854
855    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
856}
857
858impl DeleteDataSetRequest {
859    pub fn new() -> Self {
860        std::default::Default::default()
861    }
862
863    /// Sets the value of [name][crate::model::DeleteDataSetRequest::name].
864    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
865        self.name = v.into();
866        self
867    }
868}
869
870impl wkt::message::Message for DeleteDataSetRequest {
871    fn typename() -> &'static str {
872        "type.googleapis.com/google.cloud.timeseriesinsights.v1.DeleteDataSetRequest"
873    }
874}
875
876/// List the DataSets created by the current project.
877#[derive(Clone, Default, PartialEq)]
878#[non_exhaustive]
879pub struct ListDataSetsRequest {
880    /// Required. Project owning the DataSet in the format of "projects/{project}".
881    pub parent: std::string::String,
882
883    /// Number of results to return in the list.
884    pub page_size: i32,
885
886    /// Token to provide to skip to a particular spot in the list.
887    pub page_token: std::string::String,
888
889    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
890}
891
892impl ListDataSetsRequest {
893    pub fn new() -> Self {
894        std::default::Default::default()
895    }
896
897    /// Sets the value of [parent][crate::model::ListDataSetsRequest::parent].
898    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
899        self.parent = v.into();
900        self
901    }
902
903    /// Sets the value of [page_size][crate::model::ListDataSetsRequest::page_size].
904    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
905        self.page_size = v.into();
906        self
907    }
908
909    /// Sets the value of [page_token][crate::model::ListDataSetsRequest::page_token].
910    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
911        self.page_token = v.into();
912        self
913    }
914}
915
916impl wkt::message::Message for ListDataSetsRequest {
917    fn typename() -> &'static str {
918        "type.googleapis.com/google.cloud.timeseriesinsights.v1.ListDataSetsRequest"
919    }
920}
921
922/// Created DataSets list response.
923#[derive(Clone, Default, PartialEq)]
924#[non_exhaustive]
925pub struct ListDataSetsResponse {
926    /// The list of created DataSets.
927    pub datasets: std::vec::Vec<crate::model::DataSet>,
928
929    /// Token to receive the next page of results.
930    pub next_page_token: std::string::String,
931
932    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
933}
934
935impl ListDataSetsResponse {
936    pub fn new() -> Self {
937        std::default::Default::default()
938    }
939
940    /// Sets the value of [datasets][crate::model::ListDataSetsResponse::datasets].
941    pub fn set_datasets<T, V>(mut self, v: T) -> Self
942    where
943        T: std::iter::IntoIterator<Item = V>,
944        V: std::convert::Into<crate::model::DataSet>,
945    {
946        use std::iter::Iterator;
947        self.datasets = v.into_iter().map(|i| i.into()).collect();
948        self
949    }
950
951    /// Sets the value of [next_page_token][crate::model::ListDataSetsResponse::next_page_token].
952    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
953        self.next_page_token = v.into();
954        self
955    }
956}
957
958impl wkt::message::Message for ListDataSetsResponse {
959    fn typename() -> &'static str {
960        "type.googleapis.com/google.cloud.timeseriesinsights.v1.ListDataSetsResponse"
961    }
962}
963
964#[doc(hidden)]
965impl gax::paginator::internal::PageableResponse for ListDataSetsResponse {
966    type PageItem = crate::model::DataSet;
967
968    fn items(self) -> std::vec::Vec<Self::PageItem> {
969        self.datasets
970    }
971
972    fn next_page_token(&self) -> std::string::String {
973        use std::clone::Clone;
974        self.next_page_token.clone()
975    }
976}
977
978/// A categorical dimension fixed to a certain value.
979#[derive(Clone, Default, PartialEq)]
980#[non_exhaustive]
981pub struct PinnedDimension {
982    /// The name of the dimension for which we are fixing its value.
983    pub name: std::string::String,
984
985    /// Dimension value.
986    ///
987    /// **NOTE**: The `value` type must match that in the data with the same
988    /// `dimension` as name.
989    pub value: std::option::Option<crate::model::pinned_dimension::Value>,
990
991    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
992}
993
994impl PinnedDimension {
995    pub fn new() -> Self {
996        std::default::Default::default()
997    }
998
999    /// Sets the value of [name][crate::model::PinnedDimension::name].
1000    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1001        self.name = v.into();
1002        self
1003    }
1004
1005    /// Sets the value of [value][crate::model::PinnedDimension::value].
1006    ///
1007    /// Note that all the setters affecting `value` are mutually
1008    /// exclusive.
1009    pub fn set_value<
1010        T: std::convert::Into<std::option::Option<crate::model::pinned_dimension::Value>>,
1011    >(
1012        mut self,
1013        v: T,
1014    ) -> Self {
1015        self.value = v.into();
1016        self
1017    }
1018
1019    /// The value of [value][crate::model::PinnedDimension::value]
1020    /// if it holds a `StringVal`, `None` if the field is not set or
1021    /// holds a different branch.
1022    pub fn string_val(&self) -> std::option::Option<&std::string::String> {
1023        #[allow(unreachable_patterns)]
1024        self.value.as_ref().and_then(|v| match v {
1025            crate::model::pinned_dimension::Value::StringVal(v) => std::option::Option::Some(v),
1026            _ => std::option::Option::None,
1027        })
1028    }
1029
1030    /// Sets the value of [value][crate::model::PinnedDimension::value]
1031    /// to hold a `StringVal`.
1032    ///
1033    /// Note that all the setters affecting `value` are
1034    /// mutually exclusive.
1035    pub fn set_string_val<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1036        self.value =
1037            std::option::Option::Some(crate::model::pinned_dimension::Value::StringVal(v.into()));
1038        self
1039    }
1040
1041    /// The value of [value][crate::model::PinnedDimension::value]
1042    /// if it holds a `BoolVal`, `None` if the field is not set or
1043    /// holds a different branch.
1044    pub fn bool_val(&self) -> std::option::Option<&bool> {
1045        #[allow(unreachable_patterns)]
1046        self.value.as_ref().and_then(|v| match v {
1047            crate::model::pinned_dimension::Value::BoolVal(v) => std::option::Option::Some(v),
1048            _ => std::option::Option::None,
1049        })
1050    }
1051
1052    /// Sets the value of [value][crate::model::PinnedDimension::value]
1053    /// to hold a `BoolVal`.
1054    ///
1055    /// Note that all the setters affecting `value` are
1056    /// mutually exclusive.
1057    pub fn set_bool_val<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
1058        self.value =
1059            std::option::Option::Some(crate::model::pinned_dimension::Value::BoolVal(v.into()));
1060        self
1061    }
1062}
1063
1064impl wkt::message::Message for PinnedDimension {
1065    fn typename() -> &'static str {
1066        "type.googleapis.com/google.cloud.timeseriesinsights.v1.PinnedDimension"
1067    }
1068}
1069
1070/// Defines additional types related to [PinnedDimension].
1071pub mod pinned_dimension {
1072    #[allow(unused_imports)]
1073    use super::*;
1074
1075    /// Dimension value.
1076    ///
1077    /// **NOTE**: The `value` type must match that in the data with the same
1078    /// `dimension` as name.
1079    #[derive(Clone, Debug, PartialEq)]
1080    #[non_exhaustive]
1081    pub enum Value {
1082        /// A string value. This can be used for [dimensions][google.cloud.timeseriesinsights.v1.EventDimension], which
1083        /// have their value field set to [string_val][google.cloud.timeseriesinsights.v1.EventDimension.string_val].
1084        ///
1085        /// [google.cloud.timeseriesinsights.v1.EventDimension]: crate::model::EventDimension
1086        /// [google.cloud.timeseriesinsights.v1.EventDimension.string_val]: crate::model::EventDimension::value
1087        StringVal(std::string::String),
1088        /// A bool value. This can be used for [dimensions][google.cloud.timeseriesinsights.v1.EventDimension], which
1089        /// have their value field set to [bool_val][google.cloud.timeseriesinsights.v1.EventDimension.bool_val].
1090        ///
1091        /// [google.cloud.timeseriesinsights.v1.EventDimension]: crate::model::EventDimension
1092        /// [google.cloud.timeseriesinsights.v1.EventDimension.bool_val]: crate::model::EventDimension::value
1093        BoolVal(bool),
1094    }
1095}
1096
1097/// Parameters that control the sensitivity and other options for the time series
1098/// forecast.
1099#[derive(Clone, Default, PartialEq)]
1100#[non_exhaustive]
1101pub struct ForecastParams {
1102    /// Optional. Penalize variations between the actual and forecasted values smaller than
1103    /// this. For more information about how this parameter affects the score, see
1104    /// the [anomalyScore](EvaluatedSlice.anomaly_score) formula.
1105    ///
1106    /// Intuitively, anomaly scores summarize how statistically significant the
1107    /// change between the actual and forecasted value is compared with what we
1108    /// expect the change to be (see
1109    /// [expectedDeviation](EvaluatedSlice.expected_deviation)). However, in
1110    /// practice, depending on the application, changes smaller than certain
1111    /// absolute values, while statistically significant, may not be important.
1112    ///
1113    /// This parameter allows us to penalize such low absolute value changes.
1114    ///
1115    /// Must be in the (0.0, inf) range.
1116    ///
1117    /// If unspecified, it defaults to 0.000001.
1118    pub noise_threshold: std::option::Option<f64>,
1119
1120    /// Optional. Specifying any known seasonality/periodicity in the time series
1121    /// for the slices we will analyze can improve the quality of the results.
1122    ///
1123    /// If unsure, simply leave it unspecified by not setting a value for this
1124    /// field.
1125    ///
1126    /// If your time series has multiple seasonal patterns, then set it to the most
1127    /// granular one (e.g. if it has daily and weekly patterns, set this to DAILY).
1128    pub seasonality_hint: crate::model::forecast_params::Period,
1129
1130    /// Optional. The length of the returned [forecasted
1131    /// timeseries][EvaluatedSlice.forecast].
1132    ///
1133    /// This duration is currently capped at 100 x
1134    /// [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity].
1135    ///
1136    /// Example: If the detection point is set to "2020-12-27T00:00:00Z", the
1137    /// [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] to "3600s" and the
1138    /// horizon_duration to "10800s", then we will generate 3 time
1139    /// series points (from "2020-12-27T01:00:00Z" to "2020-12-27T04:00:00Z"), for
1140    /// which we will return their forecasted values.
1141    ///
1142    /// Note: The horizon time is only used for forecasting not for anormaly
1143    /// detection. To detect anomalies for multiple points of time,
1144    /// simply send multiple queries with those as
1145    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time].
1146    ///
1147    /// [EvaluatedSlice.forecast]: crate::model::EvaluatedSlice::forecast
1148    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
1149    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]: crate::model::TimeseriesParams::granularity
1150    pub horizon_duration: std::option::Option<wkt::Duration>,
1151
1152    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1153}
1154
1155impl ForecastParams {
1156    pub fn new() -> Self {
1157        std::default::Default::default()
1158    }
1159
1160    /// Sets the value of [noise_threshold][crate::model::ForecastParams::noise_threshold].
1161    pub fn set_noise_threshold<T>(mut self, v: T) -> Self
1162    where
1163        T: std::convert::Into<f64>,
1164    {
1165        self.noise_threshold = std::option::Option::Some(v.into());
1166        self
1167    }
1168
1169    /// Sets or clears the value of [noise_threshold][crate::model::ForecastParams::noise_threshold].
1170    pub fn set_or_clear_noise_threshold<T>(mut self, v: std::option::Option<T>) -> Self
1171    where
1172        T: std::convert::Into<f64>,
1173    {
1174        self.noise_threshold = v.map(|x| x.into());
1175        self
1176    }
1177
1178    /// Sets the value of [seasonality_hint][crate::model::ForecastParams::seasonality_hint].
1179    pub fn set_seasonality_hint<T: std::convert::Into<crate::model::forecast_params::Period>>(
1180        mut self,
1181        v: T,
1182    ) -> Self {
1183        self.seasonality_hint = v.into();
1184        self
1185    }
1186
1187    /// Sets the value of [horizon_duration][crate::model::ForecastParams::horizon_duration].
1188    pub fn set_horizon_duration<T>(mut self, v: T) -> Self
1189    where
1190        T: std::convert::Into<wkt::Duration>,
1191    {
1192        self.horizon_duration = std::option::Option::Some(v.into());
1193        self
1194    }
1195
1196    /// Sets or clears the value of [horizon_duration][crate::model::ForecastParams::horizon_duration].
1197    pub fn set_or_clear_horizon_duration<T>(mut self, v: std::option::Option<T>) -> Self
1198    where
1199        T: std::convert::Into<wkt::Duration>,
1200    {
1201        self.horizon_duration = v.map(|x| x.into());
1202        self
1203    }
1204}
1205
1206impl wkt::message::Message for ForecastParams {
1207    fn typename() -> &'static str {
1208        "type.googleapis.com/google.cloud.timeseriesinsights.v1.ForecastParams"
1209    }
1210}
1211
1212/// Defines additional types related to [ForecastParams].
1213pub mod forecast_params {
1214    #[allow(unused_imports)]
1215    use super::*;
1216
1217    /// A time period of a fixed interval.
1218    ///
1219    /// # Working with unknown values
1220    ///
1221    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1222    /// additional enum variants at any time. Adding new variants is not considered
1223    /// a breaking change. Applications should write their code in anticipation of:
1224    ///
1225    /// - New values appearing in future releases of the client library, **and**
1226    /// - New values received dynamically, without application changes.
1227    ///
1228    /// Please consult the [Working with enums] section in the user guide for some
1229    /// guidelines.
1230    ///
1231    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1232    #[derive(Clone, Debug, PartialEq)]
1233    #[non_exhaustive]
1234    pub enum Period {
1235        /// Unknown or simply not given.
1236        Unspecified,
1237        /// 1 hour
1238        Hourly,
1239        /// 24 hours
1240        Daily,
1241        /// 7 days
1242        Weekly,
1243        /// 30 days
1244        Monthly,
1245        /// 365 days
1246        Yearly,
1247        /// If set, the enum was initialized with an unknown value.
1248        ///
1249        /// Applications can examine the value using [Period::value] or
1250        /// [Period::name].
1251        UnknownValue(period::UnknownValue),
1252    }
1253
1254    #[doc(hidden)]
1255    pub mod period {
1256        #[allow(unused_imports)]
1257        use super::*;
1258        #[derive(Clone, Debug, PartialEq)]
1259        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1260    }
1261
1262    impl Period {
1263        /// Gets the enum value.
1264        ///
1265        /// Returns `None` if the enum contains an unknown value deserialized from
1266        /// the string representation of enums.
1267        pub fn value(&self) -> std::option::Option<i32> {
1268            match self {
1269                Self::Unspecified => std::option::Option::Some(0),
1270                Self::Hourly => std::option::Option::Some(5),
1271                Self::Daily => std::option::Option::Some(1),
1272                Self::Weekly => std::option::Option::Some(2),
1273                Self::Monthly => std::option::Option::Some(3),
1274                Self::Yearly => std::option::Option::Some(4),
1275                Self::UnknownValue(u) => u.0.value(),
1276            }
1277        }
1278
1279        /// Gets the enum value as a string.
1280        ///
1281        /// Returns `None` if the enum contains an unknown value deserialized from
1282        /// the integer representation of enums.
1283        pub fn name(&self) -> std::option::Option<&str> {
1284            match self {
1285                Self::Unspecified => std::option::Option::Some("PERIOD_UNSPECIFIED"),
1286                Self::Hourly => std::option::Option::Some("HOURLY"),
1287                Self::Daily => std::option::Option::Some("DAILY"),
1288                Self::Weekly => std::option::Option::Some("WEEKLY"),
1289                Self::Monthly => std::option::Option::Some("MONTHLY"),
1290                Self::Yearly => std::option::Option::Some("YEARLY"),
1291                Self::UnknownValue(u) => u.0.name(),
1292            }
1293        }
1294    }
1295
1296    impl std::default::Default for Period {
1297        fn default() -> Self {
1298            use std::convert::From;
1299            Self::from(0)
1300        }
1301    }
1302
1303    impl std::fmt::Display for Period {
1304        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1305            wkt::internal::display_enum(f, self.name(), self.value())
1306        }
1307    }
1308
1309    impl std::convert::From<i32> for Period {
1310        fn from(value: i32) -> Self {
1311            match value {
1312                0 => Self::Unspecified,
1313                1 => Self::Daily,
1314                2 => Self::Weekly,
1315                3 => Self::Monthly,
1316                4 => Self::Yearly,
1317                5 => Self::Hourly,
1318                _ => Self::UnknownValue(period::UnknownValue(
1319                    wkt::internal::UnknownEnumValue::Integer(value),
1320                )),
1321            }
1322        }
1323    }
1324
1325    impl std::convert::From<&str> for Period {
1326        fn from(value: &str) -> Self {
1327            use std::string::ToString;
1328            match value {
1329                "PERIOD_UNSPECIFIED" => Self::Unspecified,
1330                "HOURLY" => Self::Hourly,
1331                "DAILY" => Self::Daily,
1332                "WEEKLY" => Self::Weekly,
1333                "MONTHLY" => Self::Monthly,
1334                "YEARLY" => Self::Yearly,
1335                _ => Self::UnknownValue(period::UnknownValue(
1336                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1337                )),
1338            }
1339        }
1340    }
1341
1342    impl serde::ser::Serialize for Period {
1343        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1344        where
1345            S: serde::Serializer,
1346        {
1347            match self {
1348                Self::Unspecified => serializer.serialize_i32(0),
1349                Self::Hourly => serializer.serialize_i32(5),
1350                Self::Daily => serializer.serialize_i32(1),
1351                Self::Weekly => serializer.serialize_i32(2),
1352                Self::Monthly => serializer.serialize_i32(3),
1353                Self::Yearly => serializer.serialize_i32(4),
1354                Self::UnknownValue(u) => u.0.serialize(serializer),
1355            }
1356        }
1357    }
1358
1359    impl<'de> serde::de::Deserialize<'de> for Period {
1360        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1361        where
1362            D: serde::Deserializer<'de>,
1363        {
1364            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Period>::new(
1365                ".google.cloud.timeseriesinsights.v1.ForecastParams.Period",
1366            ))
1367        }
1368    }
1369}
1370
1371/// A point in a time series.
1372#[derive(Clone, Default, PartialEq)]
1373#[non_exhaustive]
1374pub struct TimeseriesPoint {
1375    /// The timestamp of this point.
1376    pub time: std::option::Option<wkt::Timestamp>,
1377
1378    /// The value for this point.
1379    ///
1380    /// It is computed by aggregating all events in the associated slice that are
1381    /// in the `[time, time + granularity]` range (see
1382    /// [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]) using the specified
1383    /// [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric].
1384    ///
1385    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]: crate::model::TimeseriesParams::granularity
1386    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
1387    pub value: std::option::Option<f64>,
1388
1389    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1390}
1391
1392impl TimeseriesPoint {
1393    pub fn new() -> Self {
1394        std::default::Default::default()
1395    }
1396
1397    /// Sets the value of [time][crate::model::TimeseriesPoint::time].
1398    pub fn set_time<T>(mut self, v: T) -> Self
1399    where
1400        T: std::convert::Into<wkt::Timestamp>,
1401    {
1402        self.time = std::option::Option::Some(v.into());
1403        self
1404    }
1405
1406    /// Sets or clears the value of [time][crate::model::TimeseriesPoint::time].
1407    pub fn set_or_clear_time<T>(mut self, v: std::option::Option<T>) -> Self
1408    where
1409        T: std::convert::Into<wkt::Timestamp>,
1410    {
1411        self.time = v.map(|x| x.into());
1412        self
1413    }
1414
1415    /// Sets the value of [value][crate::model::TimeseriesPoint::value].
1416    pub fn set_value<T>(mut self, v: T) -> Self
1417    where
1418        T: std::convert::Into<f64>,
1419    {
1420        self.value = std::option::Option::Some(v.into());
1421        self
1422    }
1423
1424    /// Sets or clears the value of [value][crate::model::TimeseriesPoint::value].
1425    pub fn set_or_clear_value<T>(mut self, v: std::option::Option<T>) -> Self
1426    where
1427        T: std::convert::Into<f64>,
1428    {
1429        self.value = v.map(|x| x.into());
1430        self
1431    }
1432}
1433
1434impl wkt::message::Message for TimeseriesPoint {
1435    fn typename() -> &'static str {
1436        "type.googleapis.com/google.cloud.timeseriesinsights.v1.TimeseriesPoint"
1437    }
1438}
1439
1440/// A time series.
1441#[derive(Clone, Default, PartialEq)]
1442#[non_exhaustive]
1443pub struct Timeseries {
1444    /// The points in this time series, ordered by their timestamp.
1445    pub point: std::vec::Vec<crate::model::TimeseriesPoint>,
1446
1447    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1448}
1449
1450impl Timeseries {
1451    pub fn new() -> Self {
1452        std::default::Default::default()
1453    }
1454
1455    /// Sets the value of [point][crate::model::Timeseries::point].
1456    pub fn set_point<T, V>(mut self, v: T) -> Self
1457    where
1458        T: std::iter::IntoIterator<Item = V>,
1459        V: std::convert::Into<crate::model::TimeseriesPoint>,
1460    {
1461        use std::iter::Iterator;
1462        self.point = v.into_iter().map(|i| i.into()).collect();
1463        self
1464    }
1465}
1466
1467impl wkt::message::Message for Timeseries {
1468    fn typename() -> &'static str {
1469        "type.googleapis.com/google.cloud.timeseriesinsights.v1.Timeseries"
1470    }
1471}
1472
1473/// Forecast result for a given slice.
1474#[derive(Clone, Default, PartialEq)]
1475#[non_exhaustive]
1476pub struct EvaluatedSlice {
1477    /// Values for all categorical dimensions that uniquely identify this slice.
1478    pub dimensions: std::vec::Vec<crate::model::PinnedDimension>,
1479
1480    /// The actual value at the detection time (see
1481    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]).
1482    ///
1483    /// **NOTE**: This value can be an estimate, so it should not be used as a
1484    /// source of truth.
1485    ///
1486    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
1487    pub detection_point_actual: std::option::Option<f64>,
1488
1489    /// The expected value at the detection time, which is obtained by forecasting
1490    /// on the historical time series.
1491    pub detection_point_forecast: std::option::Option<f64>,
1492
1493    /// How much our forecast model expects the detection point actual will
1494    /// deviate from its forecasted value based on how well it fit the input time
1495    /// series.
1496    ///
1497    /// In general, we expect the `detectionPointActual` to
1498    /// be in the `[detectionPointForecast - expectedDeviation,
1499    /// detectionPointForecast + expectedDeviation]` range. The more the actual
1500    /// value is outside this range, the more statistically significant the
1501    /// anomaly is.
1502    ///
1503    /// The expected deviation is always positive.
1504    pub expected_deviation: std::option::Option<f64>,
1505
1506    /// Summarizes how significant the change between the actual and forecasted
1507    /// detection points are compared with the historical patterns observed on the
1508    /// [history][google.cloud.timeseriesinsights.v1.EvaluatedSlice.history] time series.
1509    ///
1510    /// Defined as *|a - f| / (e + nt)*, where:
1511    ///
1512    /// - *a* is the [detectionPointActual][google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_actual].
1513    /// - *f* is the [detectionPointForecast][google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_forecast].
1514    /// - *e* is the [expectedDeviation][google.cloud.timeseriesinsights.v1.EvaluatedSlice.expected_deviation].
1515    /// - *nt` is the [noiseThreshold][google.cloud.timeseriesinsights.v1.ForecastParams.noise_threshold].
1516    ///
1517    /// Anomaly scores between different requests and datasets are comparable. As
1518    /// a guideline, the risk of a slice being an anomaly based on the anomaly
1519    /// score is:
1520    ///
1521    /// - **Very High** if `anomalyScore` > 5.
1522    /// - **High** if the `anomalyScore` is in the [2, 5] range.
1523    /// - **Medium** if the `anomalyScore` is in the [1, 2) range.
1524    /// - **Low** if the `anomalyScore` is < 1.
1525    ///
1526    /// If there were issues evaluating this slice, then the anomaly score will be
1527    /// set to -1.0 and the [status][google.cloud.timeseriesinsights.v1.EvaluatedSlice.status] field will contain details on what
1528    /// went wrong.
1529    ///
1530    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_actual]: crate::model::EvaluatedSlice::detection_point_actual
1531    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.detection_point_forecast]: crate::model::EvaluatedSlice::detection_point_forecast
1532    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.expected_deviation]: crate::model::EvaluatedSlice::expected_deviation
1533    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.history]: crate::model::EvaluatedSlice::history
1534    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.status]: crate::model::EvaluatedSlice::status
1535    /// [google.cloud.timeseriesinsights.v1.ForecastParams.noise_threshold]: crate::model::ForecastParams::noise_threshold
1536    pub anomaly_score: std::option::Option<f64>,
1537
1538    /// The actual values in the `[`
1539    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `-`
1540    /// [forecastHistory][google.cloud.timeseriesinsights.v1.TimeseriesParams.forecast_history]`,`
1541    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `]` time
1542    /// range.
1543    ///
1544    /// **NOTE**: This field is only populated if
1545    /// [returnTimeseries][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries] is true.
1546    ///
1547    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
1548    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries]: crate::model::QueryDataSetRequest::return_timeseries
1549    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.forecast_history]: crate::model::TimeseriesParams::forecast_history
1550    pub history: std::option::Option<crate::model::Timeseries>,
1551
1552    /// The forecasted values in the `[`
1553    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] `+`
1554    /// [granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]`,`
1555    /// [forecastParams.horizonTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.forecast_params] `]` time
1556    /// range.
1557    ///
1558    /// **NOTE**: This field is only populated if
1559    /// [returnTimeseries][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries] is true.
1560    ///
1561    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
1562    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.forecast_params]: crate::model::QueryDataSetRequest::forecast_params
1563    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.return_timeseries]: crate::model::QueryDataSetRequest::return_timeseries
1564    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]: crate::model::TimeseriesParams::granularity
1565    pub forecast: std::option::Option<crate::model::Timeseries>,
1566
1567    /// Evaluation status. Contains an error message if the `anomalyScore` is < 0.
1568    ///
1569    /// Possible error messages:
1570    ///
1571    /// - **"Time series too sparse"**: The returned time series for this slice did
1572    ///   not contain enough data points (we require a minimum of 10).
1573    /// - **"Not enough recent time series points"**: The time series contains the
1574    ///   minimum of 10 points, but there are not enough close in time to the
1575    ///   detection point.
1576    /// - **"Missing detection point data"**: There were not events to be
1577    ///   aggregated within the `[detectionTime, detectionTime + granularity]` time
1578    ///   interval, so we don't have an actual value with which we can compare our
1579    ///   prediction.
1580    /// - **"Data retrieval error"**: We failed to retrieve the time series data
1581    ///   for this slice and could not evaluate it successfully. Should be a
1582    ///   transient error.
1583    /// - **"Internal server error"**: Internal unexpected error.
1584    pub status: std::option::Option<rpc::model::Status>,
1585
1586    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1587}
1588
1589impl EvaluatedSlice {
1590    pub fn new() -> Self {
1591        std::default::Default::default()
1592    }
1593
1594    /// Sets the value of [dimensions][crate::model::EvaluatedSlice::dimensions].
1595    pub fn set_dimensions<T, V>(mut self, v: T) -> Self
1596    where
1597        T: std::iter::IntoIterator<Item = V>,
1598        V: std::convert::Into<crate::model::PinnedDimension>,
1599    {
1600        use std::iter::Iterator;
1601        self.dimensions = v.into_iter().map(|i| i.into()).collect();
1602        self
1603    }
1604
1605    /// Sets the value of [detection_point_actual][crate::model::EvaluatedSlice::detection_point_actual].
1606    pub fn set_detection_point_actual<T>(mut self, v: T) -> Self
1607    where
1608        T: std::convert::Into<f64>,
1609    {
1610        self.detection_point_actual = std::option::Option::Some(v.into());
1611        self
1612    }
1613
1614    /// Sets or clears the value of [detection_point_actual][crate::model::EvaluatedSlice::detection_point_actual].
1615    pub fn set_or_clear_detection_point_actual<T>(mut self, v: std::option::Option<T>) -> Self
1616    where
1617        T: std::convert::Into<f64>,
1618    {
1619        self.detection_point_actual = v.map(|x| x.into());
1620        self
1621    }
1622
1623    /// Sets the value of [detection_point_forecast][crate::model::EvaluatedSlice::detection_point_forecast].
1624    pub fn set_detection_point_forecast<T>(mut self, v: T) -> Self
1625    where
1626        T: std::convert::Into<f64>,
1627    {
1628        self.detection_point_forecast = std::option::Option::Some(v.into());
1629        self
1630    }
1631
1632    /// Sets or clears the value of [detection_point_forecast][crate::model::EvaluatedSlice::detection_point_forecast].
1633    pub fn set_or_clear_detection_point_forecast<T>(mut self, v: std::option::Option<T>) -> Self
1634    where
1635        T: std::convert::Into<f64>,
1636    {
1637        self.detection_point_forecast = v.map(|x| x.into());
1638        self
1639    }
1640
1641    /// Sets the value of [expected_deviation][crate::model::EvaluatedSlice::expected_deviation].
1642    pub fn set_expected_deviation<T>(mut self, v: T) -> Self
1643    where
1644        T: std::convert::Into<f64>,
1645    {
1646        self.expected_deviation = std::option::Option::Some(v.into());
1647        self
1648    }
1649
1650    /// Sets or clears the value of [expected_deviation][crate::model::EvaluatedSlice::expected_deviation].
1651    pub fn set_or_clear_expected_deviation<T>(mut self, v: std::option::Option<T>) -> Self
1652    where
1653        T: std::convert::Into<f64>,
1654    {
1655        self.expected_deviation = v.map(|x| x.into());
1656        self
1657    }
1658
1659    /// Sets the value of [anomaly_score][crate::model::EvaluatedSlice::anomaly_score].
1660    pub fn set_anomaly_score<T>(mut self, v: T) -> Self
1661    where
1662        T: std::convert::Into<f64>,
1663    {
1664        self.anomaly_score = std::option::Option::Some(v.into());
1665        self
1666    }
1667
1668    /// Sets or clears the value of [anomaly_score][crate::model::EvaluatedSlice::anomaly_score].
1669    pub fn set_or_clear_anomaly_score<T>(mut self, v: std::option::Option<T>) -> Self
1670    where
1671        T: std::convert::Into<f64>,
1672    {
1673        self.anomaly_score = v.map(|x| x.into());
1674        self
1675    }
1676
1677    /// Sets the value of [history][crate::model::EvaluatedSlice::history].
1678    pub fn set_history<T>(mut self, v: T) -> Self
1679    where
1680        T: std::convert::Into<crate::model::Timeseries>,
1681    {
1682        self.history = std::option::Option::Some(v.into());
1683        self
1684    }
1685
1686    /// Sets or clears the value of [history][crate::model::EvaluatedSlice::history].
1687    pub fn set_or_clear_history<T>(mut self, v: std::option::Option<T>) -> Self
1688    where
1689        T: std::convert::Into<crate::model::Timeseries>,
1690    {
1691        self.history = v.map(|x| x.into());
1692        self
1693    }
1694
1695    /// Sets the value of [forecast][crate::model::EvaluatedSlice::forecast].
1696    pub fn set_forecast<T>(mut self, v: T) -> Self
1697    where
1698        T: std::convert::Into<crate::model::Timeseries>,
1699    {
1700        self.forecast = std::option::Option::Some(v.into());
1701        self
1702    }
1703
1704    /// Sets or clears the value of [forecast][crate::model::EvaluatedSlice::forecast].
1705    pub fn set_or_clear_forecast<T>(mut self, v: std::option::Option<T>) -> Self
1706    where
1707        T: std::convert::Into<crate::model::Timeseries>,
1708    {
1709        self.forecast = v.map(|x| x.into());
1710        self
1711    }
1712
1713    /// Sets the value of [status][crate::model::EvaluatedSlice::status].
1714    pub fn set_status<T>(mut self, v: T) -> Self
1715    where
1716        T: std::convert::Into<rpc::model::Status>,
1717    {
1718        self.status = std::option::Option::Some(v.into());
1719        self
1720    }
1721
1722    /// Sets or clears the value of [status][crate::model::EvaluatedSlice::status].
1723    pub fn set_or_clear_status<T>(mut self, v: std::option::Option<T>) -> Self
1724    where
1725        T: std::convert::Into<rpc::model::Status>,
1726    {
1727        self.status = v.map(|x| x.into());
1728        self
1729    }
1730}
1731
1732impl wkt::message::Message for EvaluatedSlice {
1733    fn typename() -> &'static str {
1734        "type.googleapis.com/google.cloud.timeseriesinsights.v1.EvaluatedSlice"
1735    }
1736}
1737
1738/// Parameters that control how we slice the dataset and, optionally, filter
1739/// slices that have some specific values on some dimensions (pinned dimensions).
1740#[derive(Clone, Default, PartialEq)]
1741#[non_exhaustive]
1742pub struct SlicingParams {
1743    /// Required. Dimensions over which we will group the events in slices. The names
1744    /// specified here come from the
1745    /// [EventDimension.name][google.cloud.timeseriesinsights.v1.EventDimension.name] field. At least
1746    /// one dimension name must be specified. All dimension names that do not exist
1747    /// in the queried `DataSet` will be ignored.
1748    ///
1749    /// Currently only dimensions that hold string values can be specified here.
1750    ///
1751    /// [google.cloud.timeseriesinsights.v1.EventDimension.name]: crate::model::EventDimension::name
1752    pub dimension_names: std::vec::Vec<std::string::String>,
1753
1754    /// Optional. We will only analyze slices for which
1755    /// [EvaluatedSlice.dimensions][google.cloud.timeseriesinsights.v1.EvaluatedSlice.dimensions] contain all of the
1756    /// following pinned dimensions. A query with a pinned dimension `{ name: "d3"
1757    /// stringVal: "v3" }` will only analyze events which contain the dimension `{
1758    /// name: "d3" stringVal: "v3" }`.
1759    /// The [pinnedDimensions][google.cloud.timeseriesinsights.v1.SlicingParams.pinned_dimensions] and
1760    /// [dimensionNames][google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names] fields can **not**
1761    /// share the same dimension names.
1762    ///
1763    /// Example a valid specification:
1764    ///
1765    /// ```norust
1766    /// {
1767    ///   dimensionNames: ["d1", "d2"],
1768    ///   pinnedDimensions: [
1769    ///     { name: "d3" stringVal: "v3" },
1770    ///     { name: "d4" stringVal: "v4" }
1771    ///   ]
1772    /// }
1773    /// ```
1774    ///
1775    /// In the previous example we will slice the dataset by dimensions "d1",
1776    /// "d2", "d3" and "d4", but we will only analyze slices for which "d3=v3" and
1777    /// "d4=v4".
1778    ///
1779    /// The following example is **invalid** as "d2" is present in both
1780    /// dimensionNames and pinnedDimensions:
1781    ///
1782    /// ```norust
1783    /// {
1784    ///   dimensionNames: ["d1", "d2"],
1785    ///   pinnedDimensions: [
1786    ///     { name: "d2" stringVal: "v2" },
1787    ///     { name: "d4" stringVal: "v4" }
1788    ///   ]
1789    /// }
1790    /// ```
1791    ///
1792    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.dimensions]: crate::model::EvaluatedSlice::dimensions
1793    /// [google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names]: crate::model::SlicingParams::dimension_names
1794    /// [google.cloud.timeseriesinsights.v1.SlicingParams.pinned_dimensions]: crate::model::SlicingParams::pinned_dimensions
1795    pub pinned_dimensions: std::vec::Vec<crate::model::PinnedDimension>,
1796
1797    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1798}
1799
1800impl SlicingParams {
1801    pub fn new() -> Self {
1802        std::default::Default::default()
1803    }
1804
1805    /// Sets the value of [dimension_names][crate::model::SlicingParams::dimension_names].
1806    pub fn set_dimension_names<T, V>(mut self, v: T) -> Self
1807    where
1808        T: std::iter::IntoIterator<Item = V>,
1809        V: std::convert::Into<std::string::String>,
1810    {
1811        use std::iter::Iterator;
1812        self.dimension_names = v.into_iter().map(|i| i.into()).collect();
1813        self
1814    }
1815
1816    /// Sets the value of [pinned_dimensions][crate::model::SlicingParams::pinned_dimensions].
1817    pub fn set_pinned_dimensions<T, V>(mut self, v: T) -> Self
1818    where
1819        T: std::iter::IntoIterator<Item = V>,
1820        V: std::convert::Into<crate::model::PinnedDimension>,
1821    {
1822        use std::iter::Iterator;
1823        self.pinned_dimensions = v.into_iter().map(|i| i.into()).collect();
1824        self
1825    }
1826}
1827
1828impl wkt::message::Message for SlicingParams {
1829    fn typename() -> &'static str {
1830        "type.googleapis.com/google.cloud.timeseriesinsights.v1.SlicingParams"
1831    }
1832}
1833
1834/// Parameters that control how we construct the time series for each slice.
1835#[derive(Clone, Default, PartialEq)]
1836#[non_exhaustive]
1837pub struct TimeseriesParams {
1838    /// Required. How long should we go in the past when fetching the timeline used for
1839    /// forecasting each slice.
1840    ///
1841    /// This is used in combination with the
1842    /// [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] parameter.
1843    /// The time series we construct will have the following time range:
1844    /// `[detectionTime - forecastHistory, detectionTime + granularity]`.
1845    ///
1846    /// The forecast history might be rounded up, so that a multiple of
1847    /// `granularity` is used to process the query.
1848    ///
1849    /// Note: If there are not enough events in the
1850    /// `[detectionTime - forecastHistory, detectionTime + granularity]` time
1851    /// interval, the slice evaluation can fail. For more information, see
1852    /// [EvaluatedSlice.status][google.cloud.timeseriesinsights.v1.EvaluatedSlice.status].
1853    ///
1854    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.status]: crate::model::EvaluatedSlice::status
1855    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
1856    pub forecast_history: std::option::Option<wkt::Duration>,
1857
1858    /// Required. The time granularity of the time series (on the x-axis). Each time series
1859    /// point starting at time T will aggregate all events for a particular slice
1860    /// in *[T, T + granularity)* time windows.
1861    ///
1862    /// Note: The aggregation is decided based on the
1863    /// [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] parameter.
1864    ///
1865    /// This granularity defines the query-time aggregation windows and is not
1866    /// necessarily related to any event time granularity in the raw data (though
1867    /// we do recommend that the query-time granularity is not finer than the
1868    /// ingestion-time one).
1869    ///
1870    /// Currently, the minimal supported granularity is 10 seconds.
1871    ///
1872    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
1873    pub granularity: std::option::Option<wkt::Duration>,
1874
1875    /// Optional. Denotes the [name][google.cloud.timeseriesinsights.v1.EventDimension.name] of a numerical
1876    /// dimension that will have its values aggregated to compute the y-axis of the
1877    /// time series.
1878    ///
1879    /// The aggregation method must also be specified by setting the
1880    /// [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method]
1881    /// field.
1882    ///
1883    /// Note: Currently, if the aggregation method is unspecified, we will
1884    /// default to SUM for backward compatibility reasons, but new implementations
1885    /// should set the
1886    /// [metricAggregationMethod][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method]
1887    /// explicitly.
1888    ///
1889    /// If the metric is unspecified, we will use the number of events that each
1890    /// time series point contains as the point value.
1891    ///
1892    /// Example: Let's assume we have the following three events in our dataset:
1893    ///
1894    /// ```norust
1895    /// {
1896    ///   eventTime: "2020-12-27T00:00:00Z",
1897    ///   dimensions: [
1898    ///     { name: "d1" stringVal: "v1" },
1899    ///     { name: "d2" stringVal: "v2" }
1900    ///     { name: "m1" longVal: 100 }
1901    ///     { name: "m2" longVal: 11 }
1902    ///   ]
1903    /// },
1904    /// {
1905    ///   eventTime: "2020-12-27T00:10:00Z",
1906    ///   dimensions: [
1907    ///     { name: "d1" stringVal: "v1" },
1908    ///     { name: "d2" stringVal: "v2" }
1909    ///     { name: "m1" longVal: 200 }
1910    ///     { name: "m2" longVal: 22 }
1911    ///   ]
1912    /// },
1913    /// {
1914    ///   eventTime: "2020-12-27T00:20:00Z",
1915    ///   dimensions: [
1916    ///     { name: "d1" stringVal: "v1" },
1917    ///     { name: "d2" stringVal: "v2" }
1918    ///     { name: "m1" longVal: 300 }
1919    ///     { name: "m2" longVal: 33 }
1920    ///   ]
1921    /// }
1922    /// ```
1923    ///
1924    /// These events are all within the same hour, spaced 10 minutes between each
1925    /// of them. Assuming our [QueryDataSetRequest][google.cloud.timeseriesinsights.v1.QueryDataSetRequest] had set
1926    /// [slicingParams.dimensionNames][google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names] to ["d1",
1927    /// "d2"] and [timeseries_params.granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] to
1928    /// "3600s", then all the previous events will be aggregated into the same
1929    /// [timeseries point][google.cloud.timeseriesinsights.v1.TimeseriesPoint].
1930    ///
1931    /// The time series point that they're all part of will have the
1932    /// [time][google.cloud.timeseriesinsights.v1.TimeseriesPoint.time] set to "2020-12-27T00:00:00Z" and the
1933    /// [value][google.cloud.timeseriesinsights.v1.TimeseriesPoint.value] populated based on this metric field:
1934    ///
1935    /// - If the metric is set to "m1" and metric_aggregation_method to SUM, then
1936    ///   the value of the point will be 600.
1937    /// - If the metric is set to "m2" and metric_aggregation_method to SUM, then
1938    ///   the value of the point will be 66.
1939    /// - If the metric is set to "m1" and metric_aggregation_method to AVERAGE,
1940    ///   then the value of the point will be 200.
1941    /// - If the metric is set to "m2" and metric_aggregation_method to AVERAGE,
1942    ///   then the value of the point will be 22.
1943    /// - If the metric field is "" or unspecified, then the value of the point
1944    ///   will be 3, as we will simply count the events.
1945    ///
1946    /// [google.cloud.timeseriesinsights.v1.EventDimension.name]: crate::model::EventDimension::name
1947    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest]: crate::model::QueryDataSetRequest
1948    /// [google.cloud.timeseriesinsights.v1.SlicingParams.dimension_names]: crate::model::SlicingParams::dimension_names
1949    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]: crate::model::TimeseriesParams::granularity
1950    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric_aggregation_method]: crate::model::TimeseriesParams::metric_aggregation_method
1951    /// [google.cloud.timeseriesinsights.v1.TimeseriesPoint]: crate::model::TimeseriesPoint
1952    /// [google.cloud.timeseriesinsights.v1.TimeseriesPoint.time]: crate::model::TimeseriesPoint::time
1953    /// [google.cloud.timeseriesinsights.v1.TimeseriesPoint.value]: crate::model::TimeseriesPoint::value
1954    pub metric: std::option::Option<std::string::String>,
1955
1956    /// Optional. Together with the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] field, specifies how
1957    /// we will aggregate multiple events to obtain the value of a time series
1958    /// point. See the [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] documentation for more
1959    /// details.
1960    ///
1961    /// If the metric is not specified or "", then this field will be ignored.
1962    ///
1963    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
1964    pub metric_aggregation_method: crate::model::timeseries_params::AggregationMethod,
1965
1966    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1967}
1968
1969impl TimeseriesParams {
1970    pub fn new() -> Self {
1971        std::default::Default::default()
1972    }
1973
1974    /// Sets the value of [forecast_history][crate::model::TimeseriesParams::forecast_history].
1975    pub fn set_forecast_history<T>(mut self, v: T) -> Self
1976    where
1977        T: std::convert::Into<wkt::Duration>,
1978    {
1979        self.forecast_history = std::option::Option::Some(v.into());
1980        self
1981    }
1982
1983    /// Sets or clears the value of [forecast_history][crate::model::TimeseriesParams::forecast_history].
1984    pub fn set_or_clear_forecast_history<T>(mut self, v: std::option::Option<T>) -> Self
1985    where
1986        T: std::convert::Into<wkt::Duration>,
1987    {
1988        self.forecast_history = v.map(|x| x.into());
1989        self
1990    }
1991
1992    /// Sets the value of [granularity][crate::model::TimeseriesParams::granularity].
1993    pub fn set_granularity<T>(mut self, v: T) -> Self
1994    where
1995        T: std::convert::Into<wkt::Duration>,
1996    {
1997        self.granularity = std::option::Option::Some(v.into());
1998        self
1999    }
2000
2001    /// Sets or clears the value of [granularity][crate::model::TimeseriesParams::granularity].
2002    pub fn set_or_clear_granularity<T>(mut self, v: std::option::Option<T>) -> Self
2003    where
2004        T: std::convert::Into<wkt::Duration>,
2005    {
2006        self.granularity = v.map(|x| x.into());
2007        self
2008    }
2009
2010    /// Sets the value of [metric][crate::model::TimeseriesParams::metric].
2011    pub fn set_metric<T>(mut self, v: T) -> Self
2012    where
2013        T: std::convert::Into<std::string::String>,
2014    {
2015        self.metric = std::option::Option::Some(v.into());
2016        self
2017    }
2018
2019    /// Sets or clears the value of [metric][crate::model::TimeseriesParams::metric].
2020    pub fn set_or_clear_metric<T>(mut self, v: std::option::Option<T>) -> Self
2021    where
2022        T: std::convert::Into<std::string::String>,
2023    {
2024        self.metric = v.map(|x| x.into());
2025        self
2026    }
2027
2028    /// Sets the value of [metric_aggregation_method][crate::model::TimeseriesParams::metric_aggregation_method].
2029    pub fn set_metric_aggregation_method<
2030        T: std::convert::Into<crate::model::timeseries_params::AggregationMethod>,
2031    >(
2032        mut self,
2033        v: T,
2034    ) -> Self {
2035        self.metric_aggregation_method = v.into();
2036        self
2037    }
2038}
2039
2040impl wkt::message::Message for TimeseriesParams {
2041    fn typename() -> &'static str {
2042        "type.googleapis.com/google.cloud.timeseriesinsights.v1.TimeseriesParams"
2043    }
2044}
2045
2046/// Defines additional types related to [TimeseriesParams].
2047pub mod timeseries_params {
2048    #[allow(unused_imports)]
2049    use super::*;
2050
2051    /// Methods by which we can aggregate multiple events by a given
2052    /// [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric].
2053    ///
2054    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
2055    ///
2056    /// # Working with unknown values
2057    ///
2058    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2059    /// additional enum variants at any time. Adding new variants is not considered
2060    /// a breaking change. Applications should write their code in anticipation of:
2061    ///
2062    /// - New values appearing in future releases of the client library, **and**
2063    /// - New values received dynamically, without application changes.
2064    ///
2065    /// Please consult the [Working with enums] section in the user guide for some
2066    /// guidelines.
2067    ///
2068    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2069    #[derive(Clone, Debug, PartialEq)]
2070    #[non_exhaustive]
2071    pub enum AggregationMethod {
2072        /// Unspecified.
2073        Unspecified,
2074        /// Aggregate multiple events by summing up the values found in the
2075        /// [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] dimension.
2076        ///
2077        /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
2078        Sum,
2079        /// Aggregate multiple events by averaging out the values found in the
2080        /// [metric][google.cloud.timeseriesinsights.v1.TimeseriesParams.metric] dimension.
2081        ///
2082        /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.metric]: crate::model::TimeseriesParams::metric
2083        Average,
2084        /// If set, the enum was initialized with an unknown value.
2085        ///
2086        /// Applications can examine the value using [AggregationMethod::value] or
2087        /// [AggregationMethod::name].
2088        UnknownValue(aggregation_method::UnknownValue),
2089    }
2090
2091    #[doc(hidden)]
2092    pub mod aggregation_method {
2093        #[allow(unused_imports)]
2094        use super::*;
2095        #[derive(Clone, Debug, PartialEq)]
2096        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2097    }
2098
2099    impl AggregationMethod {
2100        /// Gets the enum value.
2101        ///
2102        /// Returns `None` if the enum contains an unknown value deserialized from
2103        /// the string representation of enums.
2104        pub fn value(&self) -> std::option::Option<i32> {
2105            match self {
2106                Self::Unspecified => std::option::Option::Some(0),
2107                Self::Sum => std::option::Option::Some(1),
2108                Self::Average => std::option::Option::Some(2),
2109                Self::UnknownValue(u) => u.0.value(),
2110            }
2111        }
2112
2113        /// Gets the enum value as a string.
2114        ///
2115        /// Returns `None` if the enum contains an unknown value deserialized from
2116        /// the integer representation of enums.
2117        pub fn name(&self) -> std::option::Option<&str> {
2118            match self {
2119                Self::Unspecified => std::option::Option::Some("AGGREGATION_METHOD_UNSPECIFIED"),
2120                Self::Sum => std::option::Option::Some("SUM"),
2121                Self::Average => std::option::Option::Some("AVERAGE"),
2122                Self::UnknownValue(u) => u.0.name(),
2123            }
2124        }
2125    }
2126
2127    impl std::default::Default for AggregationMethod {
2128        fn default() -> Self {
2129            use std::convert::From;
2130            Self::from(0)
2131        }
2132    }
2133
2134    impl std::fmt::Display for AggregationMethod {
2135        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2136            wkt::internal::display_enum(f, self.name(), self.value())
2137        }
2138    }
2139
2140    impl std::convert::From<i32> for AggregationMethod {
2141        fn from(value: i32) -> Self {
2142            match value {
2143                0 => Self::Unspecified,
2144                1 => Self::Sum,
2145                2 => Self::Average,
2146                _ => Self::UnknownValue(aggregation_method::UnknownValue(
2147                    wkt::internal::UnknownEnumValue::Integer(value),
2148                )),
2149            }
2150        }
2151    }
2152
2153    impl std::convert::From<&str> for AggregationMethod {
2154        fn from(value: &str) -> Self {
2155            use std::string::ToString;
2156            match value {
2157                "AGGREGATION_METHOD_UNSPECIFIED" => Self::Unspecified,
2158                "SUM" => Self::Sum,
2159                "AVERAGE" => Self::Average,
2160                _ => Self::UnknownValue(aggregation_method::UnknownValue(
2161                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2162                )),
2163            }
2164        }
2165    }
2166
2167    impl serde::ser::Serialize for AggregationMethod {
2168        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2169        where
2170            S: serde::Serializer,
2171        {
2172            match self {
2173                Self::Unspecified => serializer.serialize_i32(0),
2174                Self::Sum => serializer.serialize_i32(1),
2175                Self::Average => serializer.serialize_i32(2),
2176                Self::UnknownValue(u) => u.0.serialize(serializer),
2177            }
2178        }
2179    }
2180
2181    impl<'de> serde::de::Deserialize<'de> for AggregationMethod {
2182        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2183        where
2184            D: serde::Deserializer<'de>,
2185        {
2186            deserializer.deserialize_any(wkt::internal::EnumVisitor::<AggregationMethod>::new(
2187                ".google.cloud.timeseriesinsights.v1.TimeseriesParams.AggregationMethod",
2188            ))
2189        }
2190    }
2191}
2192
2193/// Request for performing a query against a loaded DataSet.
2194#[derive(Clone, Default, PartialEq)]
2195#[non_exhaustive]
2196pub struct QueryDataSetRequest {
2197    /// Required. Loaded DataSet to be queried in the format of
2198    /// "projects/{project}/datasets/{dataset}"
2199    pub name: std::string::String,
2200
2201    /// Required. This is the point in time that we want to probe for anomalies.
2202    ///
2203    /// The corresponding [TimeseriesPoint][google.cloud.timeseriesinsights.v1.TimeseriesPoint] is referred to as the
2204    /// detection point.
2205    ///
2206    /// **NOTE**: As with any other time series point, the value is given by
2207    /// aggregating all events in the slice that are in the
2208    /// [detectionTime, detectionTime + granularity) time interval, where
2209    /// the granularity is specified in the
2210    /// [timeseriesParams.granularity][google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity] field.
2211    ///
2212    /// [google.cloud.timeseriesinsights.v1.TimeseriesParams.granularity]: crate::model::TimeseriesParams::granularity
2213    /// [google.cloud.timeseriesinsights.v1.TimeseriesPoint]: crate::model::TimeseriesPoint
2214    pub detection_time: std::option::Option<wkt::Timestamp>,
2215
2216    /// How many slices are returned in
2217    /// [QueryDataSetResponse.slices][google.cloud.timeseriesinsights.v1.QueryDataSetResponse.slices].
2218    ///
2219    /// The returned slices are tentatively the ones with the highest
2220    /// [anomaly scores][google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score] in the dataset that match
2221    /// the query, but it is not guaranteed.
2222    ///
2223    /// Reducing this number will improve query performance, both in terms of
2224    /// latency and resource usage.
2225    ///
2226    /// Defaults to 50.
2227    ///
2228    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score]: crate::model::EvaluatedSlice::anomaly_score
2229    /// [google.cloud.timeseriesinsights.v1.QueryDataSetResponse.slices]: crate::model::QueryDataSetResponse::slices
2230    pub num_returned_slices: std::option::Option<i32>,
2231
2232    /// Parameters controlling how we will split the dataset into the slices that
2233    /// we will analyze.
2234    pub slicing_params: std::option::Option<crate::model::SlicingParams>,
2235
2236    /// Parameters controlling how we will build the time series used to predict
2237    /// the [detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time] value for each slice.
2238    ///
2239    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
2240    pub timeseries_params: std::option::Option<crate::model::TimeseriesParams>,
2241
2242    /// Parameters that control the time series forecasting models, such as the
2243    /// sensitivity of the anomaly detection.
2244    pub forecast_params: std::option::Option<crate::model::ForecastParams>,
2245
2246    /// If specified, we will return the actual and forecasted time for all
2247    /// returned slices.
2248    ///
2249    /// The time series are returned in the
2250    /// [EvaluatedSlice.history][google.cloud.timeseriesinsights.v1.EvaluatedSlice.history] and
2251    /// [EvaluatedSlice.forecast][google.cloud.timeseriesinsights.v1.EvaluatedSlice.forecast] fields.
2252    ///
2253    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.forecast]: crate::model::EvaluatedSlice::forecast
2254    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.history]: crate::model::EvaluatedSlice::history
2255    pub return_timeseries: bool,
2256
2257    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2258}
2259
2260impl QueryDataSetRequest {
2261    pub fn new() -> Self {
2262        std::default::Default::default()
2263    }
2264
2265    /// Sets the value of [name][crate::model::QueryDataSetRequest::name].
2266    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2267        self.name = v.into();
2268        self
2269    }
2270
2271    /// Sets the value of [detection_time][crate::model::QueryDataSetRequest::detection_time].
2272    pub fn set_detection_time<T>(mut self, v: T) -> Self
2273    where
2274        T: std::convert::Into<wkt::Timestamp>,
2275    {
2276        self.detection_time = std::option::Option::Some(v.into());
2277        self
2278    }
2279
2280    /// Sets or clears the value of [detection_time][crate::model::QueryDataSetRequest::detection_time].
2281    pub fn set_or_clear_detection_time<T>(mut self, v: std::option::Option<T>) -> Self
2282    where
2283        T: std::convert::Into<wkt::Timestamp>,
2284    {
2285        self.detection_time = v.map(|x| x.into());
2286        self
2287    }
2288
2289    /// Sets the value of [num_returned_slices][crate::model::QueryDataSetRequest::num_returned_slices].
2290    pub fn set_num_returned_slices<T>(mut self, v: T) -> Self
2291    where
2292        T: std::convert::Into<i32>,
2293    {
2294        self.num_returned_slices = std::option::Option::Some(v.into());
2295        self
2296    }
2297
2298    /// Sets or clears the value of [num_returned_slices][crate::model::QueryDataSetRequest::num_returned_slices].
2299    pub fn set_or_clear_num_returned_slices<T>(mut self, v: std::option::Option<T>) -> Self
2300    where
2301        T: std::convert::Into<i32>,
2302    {
2303        self.num_returned_slices = v.map(|x| x.into());
2304        self
2305    }
2306
2307    /// Sets the value of [slicing_params][crate::model::QueryDataSetRequest::slicing_params].
2308    pub fn set_slicing_params<T>(mut self, v: T) -> Self
2309    where
2310        T: std::convert::Into<crate::model::SlicingParams>,
2311    {
2312        self.slicing_params = std::option::Option::Some(v.into());
2313        self
2314    }
2315
2316    /// Sets or clears the value of [slicing_params][crate::model::QueryDataSetRequest::slicing_params].
2317    pub fn set_or_clear_slicing_params<T>(mut self, v: std::option::Option<T>) -> Self
2318    where
2319        T: std::convert::Into<crate::model::SlicingParams>,
2320    {
2321        self.slicing_params = v.map(|x| x.into());
2322        self
2323    }
2324
2325    /// Sets the value of [timeseries_params][crate::model::QueryDataSetRequest::timeseries_params].
2326    pub fn set_timeseries_params<T>(mut self, v: T) -> Self
2327    where
2328        T: std::convert::Into<crate::model::TimeseriesParams>,
2329    {
2330        self.timeseries_params = std::option::Option::Some(v.into());
2331        self
2332    }
2333
2334    /// Sets or clears the value of [timeseries_params][crate::model::QueryDataSetRequest::timeseries_params].
2335    pub fn set_or_clear_timeseries_params<T>(mut self, v: std::option::Option<T>) -> Self
2336    where
2337        T: std::convert::Into<crate::model::TimeseriesParams>,
2338    {
2339        self.timeseries_params = v.map(|x| x.into());
2340        self
2341    }
2342
2343    /// Sets the value of [forecast_params][crate::model::QueryDataSetRequest::forecast_params].
2344    pub fn set_forecast_params<T>(mut self, v: T) -> Self
2345    where
2346        T: std::convert::Into<crate::model::ForecastParams>,
2347    {
2348        self.forecast_params = std::option::Option::Some(v.into());
2349        self
2350    }
2351
2352    /// Sets or clears the value of [forecast_params][crate::model::QueryDataSetRequest::forecast_params].
2353    pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
2354    where
2355        T: std::convert::Into<crate::model::ForecastParams>,
2356    {
2357        self.forecast_params = v.map(|x| x.into());
2358        self
2359    }
2360
2361    /// Sets the value of [return_timeseries][crate::model::QueryDataSetRequest::return_timeseries].
2362    pub fn set_return_timeseries<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2363        self.return_timeseries = v.into();
2364        self
2365    }
2366}
2367
2368impl wkt::message::Message for QueryDataSetRequest {
2369    fn typename() -> &'static str {
2370        "type.googleapis.com/google.cloud.timeseriesinsights.v1.QueryDataSetRequest"
2371    }
2372}
2373
2374/// Response for a query executed by the system.
2375#[derive(Clone, Default, PartialEq)]
2376#[non_exhaustive]
2377pub struct QueryDataSetResponse {
2378    /// Loaded DataSet that was queried.
2379    pub name: std::string::String,
2380
2381    /// Slices sorted in descending order by their
2382    /// [anomalyScore][google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score].
2383    ///
2384    /// At most [numReturnedSlices][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.num_returned_slices]
2385    /// slices are present in this field.
2386    ///
2387    /// [google.cloud.timeseriesinsights.v1.EvaluatedSlice.anomaly_score]: crate::model::EvaluatedSlice::anomaly_score
2388    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.num_returned_slices]: crate::model::QueryDataSetRequest::num_returned_slices
2389    pub slices: std::vec::Vec<crate::model::EvaluatedSlice>,
2390
2391    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2392}
2393
2394impl QueryDataSetResponse {
2395    pub fn new() -> Self {
2396        std::default::Default::default()
2397    }
2398
2399    /// Sets the value of [name][crate::model::QueryDataSetResponse::name].
2400    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2401        self.name = v.into();
2402        self
2403    }
2404
2405    /// Sets the value of [slices][crate::model::QueryDataSetResponse::slices].
2406    pub fn set_slices<T, V>(mut self, v: T) -> Self
2407    where
2408        T: std::iter::IntoIterator<Item = V>,
2409        V: std::convert::Into<crate::model::EvaluatedSlice>,
2410    {
2411        use std::iter::Iterator;
2412        self.slices = v.into_iter().map(|i| i.into()).collect();
2413        self
2414    }
2415}
2416
2417impl wkt::message::Message for QueryDataSetResponse {
2418    fn typename() -> &'static str {
2419        "type.googleapis.com/google.cloud.timeseriesinsights.v1.QueryDataSetResponse"
2420    }
2421}
2422
2423/// Request for evaluateSlice.
2424#[derive(Clone, Default, PartialEq)]
2425#[non_exhaustive]
2426pub struct EvaluateSliceRequest {
2427    /// Required. Loaded DataSet to be queried in the format of
2428    /// "projects/{project}/datasets/{dataset}"
2429    pub dataset: std::string::String,
2430
2431    /// Required. Dimensions with pinned values that specify the slice for which we will
2432    /// fetch the time series.
2433    pub pinned_dimensions: std::vec::Vec<crate::model::PinnedDimension>,
2434
2435    /// Required. This is the point in time that we want to probe for anomalies.
2436    ///
2437    /// See documentation for
2438    /// [QueryDataSetRequest.detectionTime][google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time].
2439    ///
2440    /// [google.cloud.timeseriesinsights.v1.QueryDataSetRequest.detection_time]: crate::model::QueryDataSetRequest::detection_time
2441    pub detection_time: std::option::Option<wkt::Timestamp>,
2442
2443    /// Parameters controlling how we will build the time series used to predict
2444    /// the [detectionTime][google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time] value for this slice.
2445    ///
2446    /// [google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time]: crate::model::EvaluateSliceRequest::detection_time
2447    pub timeseries_params: std::option::Option<crate::model::TimeseriesParams>,
2448
2449    /// Parameters that control the time series forecasting models, such as the
2450    /// sensitivity of the anomaly detection.
2451    pub forecast_params: std::option::Option<crate::model::ForecastParams>,
2452
2453    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2454}
2455
2456impl EvaluateSliceRequest {
2457    pub fn new() -> Self {
2458        std::default::Default::default()
2459    }
2460
2461    /// Sets the value of [dataset][crate::model::EvaluateSliceRequest::dataset].
2462    pub fn set_dataset<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2463        self.dataset = v.into();
2464        self
2465    }
2466
2467    /// Sets the value of [pinned_dimensions][crate::model::EvaluateSliceRequest::pinned_dimensions].
2468    pub fn set_pinned_dimensions<T, V>(mut self, v: T) -> Self
2469    where
2470        T: std::iter::IntoIterator<Item = V>,
2471        V: std::convert::Into<crate::model::PinnedDimension>,
2472    {
2473        use std::iter::Iterator;
2474        self.pinned_dimensions = v.into_iter().map(|i| i.into()).collect();
2475        self
2476    }
2477
2478    /// Sets the value of [detection_time][crate::model::EvaluateSliceRequest::detection_time].
2479    pub fn set_detection_time<T>(mut self, v: T) -> Self
2480    where
2481        T: std::convert::Into<wkt::Timestamp>,
2482    {
2483        self.detection_time = std::option::Option::Some(v.into());
2484        self
2485    }
2486
2487    /// Sets or clears the value of [detection_time][crate::model::EvaluateSliceRequest::detection_time].
2488    pub fn set_or_clear_detection_time<T>(mut self, v: std::option::Option<T>) -> Self
2489    where
2490        T: std::convert::Into<wkt::Timestamp>,
2491    {
2492        self.detection_time = v.map(|x| x.into());
2493        self
2494    }
2495
2496    /// Sets the value of [timeseries_params][crate::model::EvaluateSliceRequest::timeseries_params].
2497    pub fn set_timeseries_params<T>(mut self, v: T) -> Self
2498    where
2499        T: std::convert::Into<crate::model::TimeseriesParams>,
2500    {
2501        self.timeseries_params = std::option::Option::Some(v.into());
2502        self
2503    }
2504
2505    /// Sets or clears the value of [timeseries_params][crate::model::EvaluateSliceRequest::timeseries_params].
2506    pub fn set_or_clear_timeseries_params<T>(mut self, v: std::option::Option<T>) -> Self
2507    where
2508        T: std::convert::Into<crate::model::TimeseriesParams>,
2509    {
2510        self.timeseries_params = v.map(|x| x.into());
2511        self
2512    }
2513
2514    /// Sets the value of [forecast_params][crate::model::EvaluateSliceRequest::forecast_params].
2515    pub fn set_forecast_params<T>(mut self, v: T) -> Self
2516    where
2517        T: std::convert::Into<crate::model::ForecastParams>,
2518    {
2519        self.forecast_params = std::option::Option::Some(v.into());
2520        self
2521    }
2522
2523    /// Sets or clears the value of [forecast_params][crate::model::EvaluateSliceRequest::forecast_params].
2524    pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
2525    where
2526        T: std::convert::Into<crate::model::ForecastParams>,
2527    {
2528        self.forecast_params = v.map(|x| x.into());
2529        self
2530    }
2531}
2532
2533impl wkt::message::Message for EvaluateSliceRequest {
2534    fn typename() -> &'static str {
2535        "type.googleapis.com/google.cloud.timeseriesinsights.v1.EvaluateSliceRequest"
2536    }
2537}
2538
2539/// Request for evaluateTimeseries.
2540#[derive(Clone, Default, PartialEq)]
2541#[non_exhaustive]
2542pub struct EvaluateTimeseriesRequest {
2543    /// Required. Client project name in the format of 'projects/{project}'.
2544    pub parent: std::string::String,
2545
2546    /// Evaluate this time series without requiring it was previously loaded in
2547    /// a data set.
2548    ///
2549    /// The evaluated time series point is the last one, analogous to calling
2550    /// evaluateSlice or query with
2551    /// [detectionTime][google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time] set to
2552    /// `timeseries.point(timeseries.point_size() - 1).time`.
2553    ///
2554    /// The length of the time series must be at least 10.
2555    ///
2556    /// All points must have the same time offset relative to the granularity. For
2557    /// example, if the [granularity][google.cloud.timeseriesinsights.v1.EvaluateTimeseriesRequest.granularity] is "5s", then the following
2558    /// point.time sequences are valid:
2559    ///
2560    /// - "100s", "105s", "120s", "125s" (no offset)
2561    /// - "102s", "107s", "122s", "127s" (offset is "2s")
2562    ///   However, the following sequence is invalid as it has inconsistent offsets:
2563    /// - "100s", "105s", "122s", "127s" (offsets are either "0s" or "2s")
2564    ///
2565    /// [google.cloud.timeseriesinsights.v1.EvaluateSliceRequest.detection_time]: crate::model::EvaluateSliceRequest::detection_time
2566    /// [google.cloud.timeseriesinsights.v1.EvaluateTimeseriesRequest.granularity]: crate::model::EvaluateTimeseriesRequest::granularity
2567    pub timeseries: std::option::Option<crate::model::Timeseries>,
2568
2569    /// The granularity of the time series (time distance between two consecutive
2570    /// points).
2571    pub granularity: std::option::Option<wkt::Duration>,
2572
2573    /// The forecast parameters.
2574    pub forecast_params: std::option::Option<crate::model::ForecastParams>,
2575
2576    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2577}
2578
2579impl EvaluateTimeseriesRequest {
2580    pub fn new() -> Self {
2581        std::default::Default::default()
2582    }
2583
2584    /// Sets the value of [parent][crate::model::EvaluateTimeseriesRequest::parent].
2585    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2586        self.parent = v.into();
2587        self
2588    }
2589
2590    /// Sets the value of [timeseries][crate::model::EvaluateTimeseriesRequest::timeseries].
2591    pub fn set_timeseries<T>(mut self, v: T) -> Self
2592    where
2593        T: std::convert::Into<crate::model::Timeseries>,
2594    {
2595        self.timeseries = std::option::Option::Some(v.into());
2596        self
2597    }
2598
2599    /// Sets or clears the value of [timeseries][crate::model::EvaluateTimeseriesRequest::timeseries].
2600    pub fn set_or_clear_timeseries<T>(mut self, v: std::option::Option<T>) -> Self
2601    where
2602        T: std::convert::Into<crate::model::Timeseries>,
2603    {
2604        self.timeseries = v.map(|x| x.into());
2605        self
2606    }
2607
2608    /// Sets the value of [granularity][crate::model::EvaluateTimeseriesRequest::granularity].
2609    pub fn set_granularity<T>(mut self, v: T) -> Self
2610    where
2611        T: std::convert::Into<wkt::Duration>,
2612    {
2613        self.granularity = std::option::Option::Some(v.into());
2614        self
2615    }
2616
2617    /// Sets or clears the value of [granularity][crate::model::EvaluateTimeseriesRequest::granularity].
2618    pub fn set_or_clear_granularity<T>(mut self, v: std::option::Option<T>) -> Self
2619    where
2620        T: std::convert::Into<wkt::Duration>,
2621    {
2622        self.granularity = v.map(|x| x.into());
2623        self
2624    }
2625
2626    /// Sets the value of [forecast_params][crate::model::EvaluateTimeseriesRequest::forecast_params].
2627    pub fn set_forecast_params<T>(mut self, v: T) -> Self
2628    where
2629        T: std::convert::Into<crate::model::ForecastParams>,
2630    {
2631        self.forecast_params = std::option::Option::Some(v.into());
2632        self
2633    }
2634
2635    /// Sets or clears the value of [forecast_params][crate::model::EvaluateTimeseriesRequest::forecast_params].
2636    pub fn set_or_clear_forecast_params<T>(mut self, v: std::option::Option<T>) -> Self
2637    where
2638        T: std::convert::Into<crate::model::ForecastParams>,
2639    {
2640        self.forecast_params = v.map(|x| x.into());
2641        self
2642    }
2643}
2644
2645impl wkt::message::Message for EvaluateTimeseriesRequest {
2646    fn typename() -> &'static str {
2647        "type.googleapis.com/google.cloud.timeseriesinsights.v1.EvaluateTimeseriesRequest"
2648    }
2649}