Skip to main content

google_cloud_trace_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 gaxi;
23extern crate google_cloud_gax;
24extern crate serde;
25extern crate serde_json;
26extern crate serde_with;
27extern crate std;
28extern crate tracing;
29extern crate wkt;
30
31mod debug;
32mod deserialize;
33mod serialize;
34
35/// A trace describes how long it takes for an application to perform an
36/// operation. It consists of a set of spans, each of which represent a single
37/// timed event within the operation.
38#[derive(Clone, Default, PartialEq)]
39#[non_exhaustive]
40pub struct Trace {
41    /// Project ID of the Cloud project where the trace data is stored.
42    pub project_id: std::string::String,
43
44    /// Globally unique identifier for the trace. This identifier is a 128-bit
45    /// numeric value formatted as a 32-byte hex string. For example,
46    /// `382d4f4c6b7bb2f4a972559d9085001d`.
47    pub trace_id: std::string::String,
48
49    /// Collection of spans in the trace.
50    pub spans: std::vec::Vec<crate::model::TraceSpan>,
51
52    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
53}
54
55impl Trace {
56    /// Creates a new default instance.
57    pub fn new() -> Self {
58        std::default::Default::default()
59    }
60
61    /// Sets the value of [project_id][crate::model::Trace::project_id].
62    ///
63    /// # Example
64    /// ```ignore,no_run
65    /// # use google_cloud_trace_v1::model::Trace;
66    /// let x = Trace::new().set_project_id("example");
67    /// ```
68    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
69        self.project_id = v.into();
70        self
71    }
72
73    /// Sets the value of [trace_id][crate::model::Trace::trace_id].
74    ///
75    /// # Example
76    /// ```ignore,no_run
77    /// # use google_cloud_trace_v1::model::Trace;
78    /// let x = Trace::new().set_trace_id("example");
79    /// ```
80    pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
81        self.trace_id = v.into();
82        self
83    }
84
85    /// Sets the value of [spans][crate::model::Trace::spans].
86    ///
87    /// # Example
88    /// ```ignore,no_run
89    /// # use google_cloud_trace_v1::model::Trace;
90    /// use google_cloud_trace_v1::model::TraceSpan;
91    /// let x = Trace::new()
92    ///     .set_spans([
93    ///         TraceSpan::default()/* use setters */,
94    ///         TraceSpan::default()/* use (different) setters */,
95    ///     ]);
96    /// ```
97    pub fn set_spans<T, V>(mut self, v: T) -> Self
98    where
99        T: std::iter::IntoIterator<Item = V>,
100        V: std::convert::Into<crate::model::TraceSpan>,
101    {
102        use std::iter::Iterator;
103        self.spans = v.into_iter().map(|i| i.into()).collect();
104        self
105    }
106}
107
108impl wkt::message::Message for Trace {
109    fn typename() -> &'static str {
110        "type.googleapis.com/google.devtools.cloudtrace.v1.Trace"
111    }
112}
113
114/// List of new or updated traces.
115#[derive(Clone, Default, PartialEq)]
116#[non_exhaustive]
117pub struct Traces {
118    /// List of traces.
119    pub traces: std::vec::Vec<crate::model::Trace>,
120
121    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
122}
123
124impl Traces {
125    /// Creates a new default instance.
126    pub fn new() -> Self {
127        std::default::Default::default()
128    }
129
130    /// Sets the value of [traces][crate::model::Traces::traces].
131    ///
132    /// # Example
133    /// ```ignore,no_run
134    /// # use google_cloud_trace_v1::model::Traces;
135    /// use google_cloud_trace_v1::model::Trace;
136    /// let x = Traces::new()
137    ///     .set_traces([
138    ///         Trace::default()/* use setters */,
139    ///         Trace::default()/* use (different) setters */,
140    ///     ]);
141    /// ```
142    pub fn set_traces<T, V>(mut self, v: T) -> Self
143    where
144        T: std::iter::IntoIterator<Item = V>,
145        V: std::convert::Into<crate::model::Trace>,
146    {
147        use std::iter::Iterator;
148        self.traces = v.into_iter().map(|i| i.into()).collect();
149        self
150    }
151}
152
153impl wkt::message::Message for Traces {
154    fn typename() -> &'static str {
155        "type.googleapis.com/google.devtools.cloudtrace.v1.Traces"
156    }
157}
158
159/// A span represents a single timed event within a trace. Spans can be nested
160/// and form a trace tree. Often, a trace contains a root span that describes the
161/// end-to-end latency of an operation and, optionally, one or more subspans for
162/// its suboperations. Spans do not need to be contiguous. There may be gaps
163/// between spans in a trace.
164#[derive(Clone, Default, PartialEq)]
165#[non_exhaustive]
166pub struct TraceSpan {
167    /// Identifier for the span. Must be a 64-bit integer other than 0 and
168    /// unique within a trace. For example, `2205310701640571284`.
169    pub span_id: u64,
170
171    /// Distinguishes between spans generated in a particular context. For example,
172    /// two spans with the same name may be distinguished using `RPC_CLIENT`
173    /// and `RPC_SERVER` to identify queueing latency associated with the span.
174    pub kind: crate::model::trace_span::SpanKind,
175
176    /// Name of the span. Must be less than 128 bytes. The span name is sanitized
177    /// and displayed in the Stackdriver Trace tool in the
178    /// Google Cloud Platform Console.
179    /// The name may be a method name or some other per-call site name.
180    /// For the same executable and the same call point, a best practice is
181    /// to use a consistent name, which makes it easier to correlate
182    /// cross-trace spans.
183    pub name: std::string::String,
184
185    /// Start time of the span in nanoseconds from the UNIX epoch.
186    pub start_time: std::option::Option<wkt::Timestamp>,
187
188    /// End time of the span in nanoseconds from the UNIX epoch.
189    pub end_time: std::option::Option<wkt::Timestamp>,
190
191    /// Optional. ID of the parent span, if any.
192    pub parent_span_id: u64,
193
194    /// Collection of labels associated with the span. Label keys must be less than
195    /// 128 bytes. Label values must be less than 16 kilobytes (10MB for
196    /// `/stacktrace` values).
197    ///
198    /// Some predefined label keys exist, or you may create your own. When creating
199    /// your own, we recommend the following formats:
200    ///
201    /// * `/category/product/key` for agents of well-known products (e.g.
202    ///   `/db/mongodb/read_size`).
203    /// * `short_host/path/key` for domain-specific keys (e.g.
204    ///   `foo.com/myproduct/bar`)
205    ///
206    /// Predefined labels include:
207    ///
208    /// * `/agent`
209    /// * `/component`
210    /// * `/error/message`
211    /// * `/error/name`
212    /// * `/http/client_city`
213    /// * `/http/client_country`
214    /// * `/http/client_protocol`
215    /// * `/http/client_region`
216    /// * `/http/host`
217    /// * `/http/method`
218    /// * `/http/path`
219    /// * `/http/redirected_url`
220    /// * `/http/request/size`
221    /// * `/http/response/size`
222    /// * `/http/route`
223    /// * `/http/status_code`
224    /// * `/http/url`
225    /// * `/http/user_agent`
226    /// * `/pid`
227    /// * `/stacktrace`
228    /// * `/tid`
229    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
230
231    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
232}
233
234impl TraceSpan {
235    /// Creates a new default instance.
236    pub fn new() -> Self {
237        std::default::Default::default()
238    }
239
240    /// Sets the value of [span_id][crate::model::TraceSpan::span_id].
241    ///
242    /// # Example
243    /// ```ignore,no_run
244    /// # use google_cloud_trace_v1::model::TraceSpan;
245    /// let x = TraceSpan::new().set_span_id(42_u32);
246    /// ```
247    pub fn set_span_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
248        self.span_id = v.into();
249        self
250    }
251
252    /// Sets the value of [kind][crate::model::TraceSpan::kind].
253    ///
254    /// # Example
255    /// ```ignore,no_run
256    /// # use google_cloud_trace_v1::model::TraceSpan;
257    /// use google_cloud_trace_v1::model::trace_span::SpanKind;
258    /// let x0 = TraceSpan::new().set_kind(SpanKind::RpcServer);
259    /// let x1 = TraceSpan::new().set_kind(SpanKind::RpcClient);
260    /// ```
261    pub fn set_kind<T: std::convert::Into<crate::model::trace_span::SpanKind>>(
262        mut self,
263        v: T,
264    ) -> Self {
265        self.kind = v.into();
266        self
267    }
268
269    /// Sets the value of [name][crate::model::TraceSpan::name].
270    ///
271    /// # Example
272    /// ```ignore,no_run
273    /// # use google_cloud_trace_v1::model::TraceSpan;
274    /// let x = TraceSpan::new().set_name("example");
275    /// ```
276    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
277        self.name = v.into();
278        self
279    }
280
281    /// Sets the value of [start_time][crate::model::TraceSpan::start_time].
282    ///
283    /// # Example
284    /// ```ignore,no_run
285    /// # use google_cloud_trace_v1::model::TraceSpan;
286    /// use wkt::Timestamp;
287    /// let x = TraceSpan::new().set_start_time(Timestamp::default()/* use setters */);
288    /// ```
289    pub fn set_start_time<T>(mut self, v: T) -> Self
290    where
291        T: std::convert::Into<wkt::Timestamp>,
292    {
293        self.start_time = std::option::Option::Some(v.into());
294        self
295    }
296
297    /// Sets or clears the value of [start_time][crate::model::TraceSpan::start_time].
298    ///
299    /// # Example
300    /// ```ignore,no_run
301    /// # use google_cloud_trace_v1::model::TraceSpan;
302    /// use wkt::Timestamp;
303    /// let x = TraceSpan::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
304    /// let x = TraceSpan::new().set_or_clear_start_time(None::<Timestamp>);
305    /// ```
306    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
307    where
308        T: std::convert::Into<wkt::Timestamp>,
309    {
310        self.start_time = v.map(|x| x.into());
311        self
312    }
313
314    /// Sets the value of [end_time][crate::model::TraceSpan::end_time].
315    ///
316    /// # Example
317    /// ```ignore,no_run
318    /// # use google_cloud_trace_v1::model::TraceSpan;
319    /// use wkt::Timestamp;
320    /// let x = TraceSpan::new().set_end_time(Timestamp::default()/* use setters */);
321    /// ```
322    pub fn set_end_time<T>(mut self, v: T) -> Self
323    where
324        T: std::convert::Into<wkt::Timestamp>,
325    {
326        self.end_time = std::option::Option::Some(v.into());
327        self
328    }
329
330    /// Sets or clears the value of [end_time][crate::model::TraceSpan::end_time].
331    ///
332    /// # Example
333    /// ```ignore,no_run
334    /// # use google_cloud_trace_v1::model::TraceSpan;
335    /// use wkt::Timestamp;
336    /// let x = TraceSpan::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
337    /// let x = TraceSpan::new().set_or_clear_end_time(None::<Timestamp>);
338    /// ```
339    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
340    where
341        T: std::convert::Into<wkt::Timestamp>,
342    {
343        self.end_time = v.map(|x| x.into());
344        self
345    }
346
347    /// Sets the value of [parent_span_id][crate::model::TraceSpan::parent_span_id].
348    ///
349    /// # Example
350    /// ```ignore,no_run
351    /// # use google_cloud_trace_v1::model::TraceSpan;
352    /// let x = TraceSpan::new().set_parent_span_id(42_u32);
353    /// ```
354    pub fn set_parent_span_id<T: std::convert::Into<u64>>(mut self, v: T) -> Self {
355        self.parent_span_id = v.into();
356        self
357    }
358
359    /// Sets the value of [labels][crate::model::TraceSpan::labels].
360    ///
361    /// # Example
362    /// ```ignore,no_run
363    /// # use google_cloud_trace_v1::model::TraceSpan;
364    /// let x = TraceSpan::new().set_labels([
365    ///     ("key0", "abc"),
366    ///     ("key1", "xyz"),
367    /// ]);
368    /// ```
369    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
370    where
371        T: std::iter::IntoIterator<Item = (K, V)>,
372        K: std::convert::Into<std::string::String>,
373        V: std::convert::Into<std::string::String>,
374    {
375        use std::iter::Iterator;
376        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
377        self
378    }
379}
380
381impl wkt::message::Message for TraceSpan {
382    fn typename() -> &'static str {
383        "type.googleapis.com/google.devtools.cloudtrace.v1.TraceSpan"
384    }
385}
386
387/// Defines additional types related to [TraceSpan].
388pub mod trace_span {
389    #[allow(unused_imports)]
390    use super::*;
391
392    /// Type of span. Can be used to specify additional relationships between spans
393    /// in addition to a parent/child relationship.
394    ///
395    /// # Working with unknown values
396    ///
397    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
398    /// additional enum variants at any time. Adding new variants is not considered
399    /// a breaking change. Applications should write their code in anticipation of:
400    ///
401    /// - New values appearing in future releases of the client library, **and**
402    /// - New values received dynamically, without application changes.
403    ///
404    /// Please consult the [Working with enums] section in the user guide for some
405    /// guidelines.
406    ///
407    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
408    #[derive(Clone, Debug, PartialEq)]
409    #[non_exhaustive]
410    pub enum SpanKind {
411        /// Unspecified.
412        Unspecified,
413        /// Indicates that the span covers server-side handling of an RPC or other
414        /// remote network request.
415        RpcServer,
416        /// Indicates that the span covers the client-side wrapper around an RPC or
417        /// other remote request.
418        RpcClient,
419        /// If set, the enum was initialized with an unknown value.
420        ///
421        /// Applications can examine the value using [SpanKind::value] or
422        /// [SpanKind::name].
423        UnknownValue(span_kind::UnknownValue),
424    }
425
426    #[doc(hidden)]
427    pub mod span_kind {
428        #[allow(unused_imports)]
429        use super::*;
430        #[derive(Clone, Debug, PartialEq)]
431        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
432    }
433
434    impl SpanKind {
435        /// Gets the enum value.
436        ///
437        /// Returns `None` if the enum contains an unknown value deserialized from
438        /// the string representation of enums.
439        pub fn value(&self) -> std::option::Option<i32> {
440            match self {
441                Self::Unspecified => std::option::Option::Some(0),
442                Self::RpcServer => std::option::Option::Some(1),
443                Self::RpcClient => std::option::Option::Some(2),
444                Self::UnknownValue(u) => u.0.value(),
445            }
446        }
447
448        /// Gets the enum value as a string.
449        ///
450        /// Returns `None` if the enum contains an unknown value deserialized from
451        /// the integer representation of enums.
452        pub fn name(&self) -> std::option::Option<&str> {
453            match self {
454                Self::Unspecified => std::option::Option::Some("SPAN_KIND_UNSPECIFIED"),
455                Self::RpcServer => std::option::Option::Some("RPC_SERVER"),
456                Self::RpcClient => std::option::Option::Some("RPC_CLIENT"),
457                Self::UnknownValue(u) => u.0.name(),
458            }
459        }
460    }
461
462    impl std::default::Default for SpanKind {
463        fn default() -> Self {
464            use std::convert::From;
465            Self::from(0)
466        }
467    }
468
469    impl std::fmt::Display for SpanKind {
470        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
471            wkt::internal::display_enum(f, self.name(), self.value())
472        }
473    }
474
475    impl std::convert::From<i32> for SpanKind {
476        fn from(value: i32) -> Self {
477            match value {
478                0 => Self::Unspecified,
479                1 => Self::RpcServer,
480                2 => Self::RpcClient,
481                _ => Self::UnknownValue(span_kind::UnknownValue(
482                    wkt::internal::UnknownEnumValue::Integer(value),
483                )),
484            }
485        }
486    }
487
488    impl std::convert::From<&str> for SpanKind {
489        fn from(value: &str) -> Self {
490            use std::string::ToString;
491            match value {
492                "SPAN_KIND_UNSPECIFIED" => Self::Unspecified,
493                "RPC_SERVER" => Self::RpcServer,
494                "RPC_CLIENT" => Self::RpcClient,
495                _ => Self::UnknownValue(span_kind::UnknownValue(
496                    wkt::internal::UnknownEnumValue::String(value.to_string()),
497                )),
498            }
499        }
500    }
501
502    impl serde::ser::Serialize for SpanKind {
503        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
504        where
505            S: serde::Serializer,
506        {
507            match self {
508                Self::Unspecified => serializer.serialize_i32(0),
509                Self::RpcServer => serializer.serialize_i32(1),
510                Self::RpcClient => serializer.serialize_i32(2),
511                Self::UnknownValue(u) => u.0.serialize(serializer),
512            }
513        }
514    }
515
516    impl<'de> serde::de::Deserialize<'de> for SpanKind {
517        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
518        where
519            D: serde::Deserializer<'de>,
520        {
521            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SpanKind>::new(
522                ".google.devtools.cloudtrace.v1.TraceSpan.SpanKind",
523            ))
524        }
525    }
526}
527
528/// The request message for the `ListTraces` method. All fields are required
529/// unless specified.
530#[derive(Clone, Default, PartialEq)]
531#[non_exhaustive]
532pub struct ListTracesRequest {
533    /// Required. ID of the Cloud project where the trace data is stored.
534    pub project_id: std::string::String,
535
536    /// Optional. Type of data returned for traces in the list. Default is
537    /// `MINIMAL`.
538    pub view: crate::model::list_traces_request::ViewType,
539
540    /// Optional. Maximum number of traces to return. If not specified or <= 0, the
541    /// implementation selects a reasonable value.  The implementation may
542    /// return fewer traces than the requested page size.
543    pub page_size: i32,
544
545    /// Token identifying the page of results to return. If provided, use the
546    /// value of the `next_page_token` field from a previous request.
547    pub page_token: std::string::String,
548
549    /// Start of the time interval (inclusive) during which the trace data was
550    /// collected from the application.
551    pub start_time: std::option::Option<wkt::Timestamp>,
552
553    /// End of the time interval (inclusive) during which the trace data was
554    /// collected from the application.
555    pub end_time: std::option::Option<wkt::Timestamp>,
556
557    /// Optional. A filter against labels for the request.
558    ///
559    /// By default, searches use prefix matching. To specify exact match, prepend
560    /// a plus symbol (`+`) to the search term.
561    /// Multiple terms are ANDed. Syntax:
562    ///
563    /// * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root
564    ///   span starts with `NAME_PREFIX`.
565    /// * `+root:NAME` or `+NAME`: Return traces where any root span's name is
566    ///   exactly `NAME`.
567    /// * `span:NAME_PREFIX`: Return traces where any span starts with
568    ///   `NAME_PREFIX`.
569    /// * `+span:NAME`: Return traces where any span's name is exactly
570    ///   `NAME`.
571    /// * `latency:DURATION`: Return traces whose overall latency is
572    ///   greater or equal to than `DURATION`. Accepted units are nanoseconds
573    ///   (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For
574    ///   example, `latency:24ms` returns traces whose overall latency
575    ///   is greater than or equal to 24 milliseconds.
576    /// * `label:LABEL_KEY`: Return all traces containing the specified
577    ///   label key (exact match, case-sensitive) regardless of the key:value
578    ///   pair's value (including empty values).
579    /// * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified
580    ///   label key (exact match, case-sensitive) whose value starts with
581    ///   `VALUE_PREFIX`. Both a key and a value must be specified.
582    /// * `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair
583    ///   exactly matching the specified text. Both a key and a value must be
584    ///   specified.
585    /// * `method:VALUE`: Equivalent to `/http/method:VALUE`.
586    /// * `url:VALUE`: Equivalent to `/http/url:VALUE`.
587    pub filter: std::string::String,
588
589    /// Optional. Field used to sort the returned traces.
590    /// Can be one of the following:
591    ///
592    /// * `trace_id`
593    /// * `name` (`name` field of root span in the trace)
594    /// * `duration` (difference between `end_time` and `start_time` fields of
595    ///   the root span)
596    /// * `start` (`start_time` field of the root span)
597    ///
598    /// Descending order can be specified by appending `desc` to the sort field
599    /// (for example, `name desc`).
600    ///
601    /// Only one sort field is permitted.
602    pub order_by: std::string::String,
603
604    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
605}
606
607impl ListTracesRequest {
608    /// Creates a new default instance.
609    pub fn new() -> Self {
610        std::default::Default::default()
611    }
612
613    /// Sets the value of [project_id][crate::model::ListTracesRequest::project_id].
614    ///
615    /// # Example
616    /// ```ignore,no_run
617    /// # use google_cloud_trace_v1::model::ListTracesRequest;
618    /// let x = ListTracesRequest::new().set_project_id("example");
619    /// ```
620    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
621        self.project_id = v.into();
622        self
623    }
624
625    /// Sets the value of [view][crate::model::ListTracesRequest::view].
626    ///
627    /// # Example
628    /// ```ignore,no_run
629    /// # use google_cloud_trace_v1::model::ListTracesRequest;
630    /// use google_cloud_trace_v1::model::list_traces_request::ViewType;
631    /// let x0 = ListTracesRequest::new().set_view(ViewType::Minimal);
632    /// let x1 = ListTracesRequest::new().set_view(ViewType::Rootspan);
633    /// let x2 = ListTracesRequest::new().set_view(ViewType::Complete);
634    /// ```
635    pub fn set_view<T: std::convert::Into<crate::model::list_traces_request::ViewType>>(
636        mut self,
637        v: T,
638    ) -> Self {
639        self.view = v.into();
640        self
641    }
642
643    /// Sets the value of [page_size][crate::model::ListTracesRequest::page_size].
644    ///
645    /// # Example
646    /// ```ignore,no_run
647    /// # use google_cloud_trace_v1::model::ListTracesRequest;
648    /// let x = ListTracesRequest::new().set_page_size(42);
649    /// ```
650    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
651        self.page_size = v.into();
652        self
653    }
654
655    /// Sets the value of [page_token][crate::model::ListTracesRequest::page_token].
656    ///
657    /// # Example
658    /// ```ignore,no_run
659    /// # use google_cloud_trace_v1::model::ListTracesRequest;
660    /// let x = ListTracesRequest::new().set_page_token("example");
661    /// ```
662    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
663        self.page_token = v.into();
664        self
665    }
666
667    /// Sets the value of [start_time][crate::model::ListTracesRequest::start_time].
668    ///
669    /// # Example
670    /// ```ignore,no_run
671    /// # use google_cloud_trace_v1::model::ListTracesRequest;
672    /// use wkt::Timestamp;
673    /// let x = ListTracesRequest::new().set_start_time(Timestamp::default()/* use setters */);
674    /// ```
675    pub fn set_start_time<T>(mut self, v: T) -> Self
676    where
677        T: std::convert::Into<wkt::Timestamp>,
678    {
679        self.start_time = std::option::Option::Some(v.into());
680        self
681    }
682
683    /// Sets or clears the value of [start_time][crate::model::ListTracesRequest::start_time].
684    ///
685    /// # Example
686    /// ```ignore,no_run
687    /// # use google_cloud_trace_v1::model::ListTracesRequest;
688    /// use wkt::Timestamp;
689    /// let x = ListTracesRequest::new().set_or_clear_start_time(Some(Timestamp::default()/* use setters */));
690    /// let x = ListTracesRequest::new().set_or_clear_start_time(None::<Timestamp>);
691    /// ```
692    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
693    where
694        T: std::convert::Into<wkt::Timestamp>,
695    {
696        self.start_time = v.map(|x| x.into());
697        self
698    }
699
700    /// Sets the value of [end_time][crate::model::ListTracesRequest::end_time].
701    ///
702    /// # Example
703    /// ```ignore,no_run
704    /// # use google_cloud_trace_v1::model::ListTracesRequest;
705    /// use wkt::Timestamp;
706    /// let x = ListTracesRequest::new().set_end_time(Timestamp::default()/* use setters */);
707    /// ```
708    pub fn set_end_time<T>(mut self, v: T) -> Self
709    where
710        T: std::convert::Into<wkt::Timestamp>,
711    {
712        self.end_time = std::option::Option::Some(v.into());
713        self
714    }
715
716    /// Sets or clears the value of [end_time][crate::model::ListTracesRequest::end_time].
717    ///
718    /// # Example
719    /// ```ignore,no_run
720    /// # use google_cloud_trace_v1::model::ListTracesRequest;
721    /// use wkt::Timestamp;
722    /// let x = ListTracesRequest::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
723    /// let x = ListTracesRequest::new().set_or_clear_end_time(None::<Timestamp>);
724    /// ```
725    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
726    where
727        T: std::convert::Into<wkt::Timestamp>,
728    {
729        self.end_time = v.map(|x| x.into());
730        self
731    }
732
733    /// Sets the value of [filter][crate::model::ListTracesRequest::filter].
734    ///
735    /// # Example
736    /// ```ignore,no_run
737    /// # use google_cloud_trace_v1::model::ListTracesRequest;
738    /// let x = ListTracesRequest::new().set_filter("example");
739    /// ```
740    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
741        self.filter = v.into();
742        self
743    }
744
745    /// Sets the value of [order_by][crate::model::ListTracesRequest::order_by].
746    ///
747    /// # Example
748    /// ```ignore,no_run
749    /// # use google_cloud_trace_v1::model::ListTracesRequest;
750    /// let x = ListTracesRequest::new().set_order_by("example");
751    /// ```
752    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
753        self.order_by = v.into();
754        self
755    }
756}
757
758impl wkt::message::Message for ListTracesRequest {
759    fn typename() -> &'static str {
760        "type.googleapis.com/google.devtools.cloudtrace.v1.ListTracesRequest"
761    }
762}
763
764/// Defines additional types related to [ListTracesRequest].
765pub mod list_traces_request {
766    #[allow(unused_imports)]
767    use super::*;
768
769    /// Type of data returned for traces in the list.
770    ///
771    /// # Working with unknown values
772    ///
773    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
774    /// additional enum variants at any time. Adding new variants is not considered
775    /// a breaking change. Applications should write their code in anticipation of:
776    ///
777    /// - New values appearing in future releases of the client library, **and**
778    /// - New values received dynamically, without application changes.
779    ///
780    /// Please consult the [Working with enums] section in the user guide for some
781    /// guidelines.
782    ///
783    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
784    #[derive(Clone, Debug, PartialEq)]
785    #[non_exhaustive]
786    pub enum ViewType {
787        /// Default is `MINIMAL` if unspecified.
788        Unspecified,
789        /// Minimal view of the trace record that contains only the project
790        /// and trace IDs.
791        Minimal,
792        /// Root span view of the trace record that returns the root spans along
793        /// with the minimal trace data.
794        Rootspan,
795        /// Complete view of the trace record that contains the actual trace data.
796        /// This is equivalent to calling the REST `get` or RPC `GetTrace` method
797        /// using the ID of each listed trace.
798        Complete,
799        /// If set, the enum was initialized with an unknown value.
800        ///
801        /// Applications can examine the value using [ViewType::value] or
802        /// [ViewType::name].
803        UnknownValue(view_type::UnknownValue),
804    }
805
806    #[doc(hidden)]
807    pub mod view_type {
808        #[allow(unused_imports)]
809        use super::*;
810        #[derive(Clone, Debug, PartialEq)]
811        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
812    }
813
814    impl ViewType {
815        /// Gets the enum value.
816        ///
817        /// Returns `None` if the enum contains an unknown value deserialized from
818        /// the string representation of enums.
819        pub fn value(&self) -> std::option::Option<i32> {
820            match self {
821                Self::Unspecified => std::option::Option::Some(0),
822                Self::Minimal => std::option::Option::Some(1),
823                Self::Rootspan => std::option::Option::Some(2),
824                Self::Complete => std::option::Option::Some(3),
825                Self::UnknownValue(u) => u.0.value(),
826            }
827        }
828
829        /// Gets the enum value as a string.
830        ///
831        /// Returns `None` if the enum contains an unknown value deserialized from
832        /// the integer representation of enums.
833        pub fn name(&self) -> std::option::Option<&str> {
834            match self {
835                Self::Unspecified => std::option::Option::Some("VIEW_TYPE_UNSPECIFIED"),
836                Self::Minimal => std::option::Option::Some("MINIMAL"),
837                Self::Rootspan => std::option::Option::Some("ROOTSPAN"),
838                Self::Complete => std::option::Option::Some("COMPLETE"),
839                Self::UnknownValue(u) => u.0.name(),
840            }
841        }
842    }
843
844    impl std::default::Default for ViewType {
845        fn default() -> Self {
846            use std::convert::From;
847            Self::from(0)
848        }
849    }
850
851    impl std::fmt::Display for ViewType {
852        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
853            wkt::internal::display_enum(f, self.name(), self.value())
854        }
855    }
856
857    impl std::convert::From<i32> for ViewType {
858        fn from(value: i32) -> Self {
859            match value {
860                0 => Self::Unspecified,
861                1 => Self::Minimal,
862                2 => Self::Rootspan,
863                3 => Self::Complete,
864                _ => Self::UnknownValue(view_type::UnknownValue(
865                    wkt::internal::UnknownEnumValue::Integer(value),
866                )),
867            }
868        }
869    }
870
871    impl std::convert::From<&str> for ViewType {
872        fn from(value: &str) -> Self {
873            use std::string::ToString;
874            match value {
875                "VIEW_TYPE_UNSPECIFIED" => Self::Unspecified,
876                "MINIMAL" => Self::Minimal,
877                "ROOTSPAN" => Self::Rootspan,
878                "COMPLETE" => Self::Complete,
879                _ => Self::UnknownValue(view_type::UnknownValue(
880                    wkt::internal::UnknownEnumValue::String(value.to_string()),
881                )),
882            }
883        }
884    }
885
886    impl serde::ser::Serialize for ViewType {
887        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
888        where
889            S: serde::Serializer,
890        {
891            match self {
892                Self::Unspecified => serializer.serialize_i32(0),
893                Self::Minimal => serializer.serialize_i32(1),
894                Self::Rootspan => serializer.serialize_i32(2),
895                Self::Complete => serializer.serialize_i32(3),
896                Self::UnknownValue(u) => u.0.serialize(serializer),
897            }
898        }
899    }
900
901    impl<'de> serde::de::Deserialize<'de> for ViewType {
902        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
903        where
904            D: serde::Deserializer<'de>,
905        {
906            deserializer.deserialize_any(wkt::internal::EnumVisitor::<ViewType>::new(
907                ".google.devtools.cloudtrace.v1.ListTracesRequest.ViewType",
908            ))
909        }
910    }
911}
912
913/// The response message for the `ListTraces` method.
914#[derive(Clone, Default, PartialEq)]
915#[non_exhaustive]
916pub struct ListTracesResponse {
917    /// List of trace records as specified by the view parameter.
918    pub traces: std::vec::Vec<crate::model::Trace>,
919
920    /// If defined, indicates that there are more traces that match the request
921    /// and that this value should be passed to the next request to continue
922    /// retrieving additional traces.
923    pub next_page_token: std::string::String,
924
925    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
926}
927
928impl ListTracesResponse {
929    /// Creates a new default instance.
930    pub fn new() -> Self {
931        std::default::Default::default()
932    }
933
934    /// Sets the value of [traces][crate::model::ListTracesResponse::traces].
935    ///
936    /// # Example
937    /// ```ignore,no_run
938    /// # use google_cloud_trace_v1::model::ListTracesResponse;
939    /// use google_cloud_trace_v1::model::Trace;
940    /// let x = ListTracesResponse::new()
941    ///     .set_traces([
942    ///         Trace::default()/* use setters */,
943    ///         Trace::default()/* use (different) setters */,
944    ///     ]);
945    /// ```
946    pub fn set_traces<T, V>(mut self, v: T) -> Self
947    where
948        T: std::iter::IntoIterator<Item = V>,
949        V: std::convert::Into<crate::model::Trace>,
950    {
951        use std::iter::Iterator;
952        self.traces = v.into_iter().map(|i| i.into()).collect();
953        self
954    }
955
956    /// Sets the value of [next_page_token][crate::model::ListTracesResponse::next_page_token].
957    ///
958    /// # Example
959    /// ```ignore,no_run
960    /// # use google_cloud_trace_v1::model::ListTracesResponse;
961    /// let x = ListTracesResponse::new().set_next_page_token("example");
962    /// ```
963    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
964        self.next_page_token = v.into();
965        self
966    }
967}
968
969impl wkt::message::Message for ListTracesResponse {
970    fn typename() -> &'static str {
971        "type.googleapis.com/google.devtools.cloudtrace.v1.ListTracesResponse"
972    }
973}
974
975#[doc(hidden)]
976impl google_cloud_gax::paginator::internal::PageableResponse for ListTracesResponse {
977    type PageItem = crate::model::Trace;
978
979    fn items(self) -> std::vec::Vec<Self::PageItem> {
980        self.traces
981    }
982
983    fn next_page_token(&self) -> std::string::String {
984        use std::clone::Clone;
985        self.next_page_token.clone()
986    }
987}
988
989/// The request message for the `GetTrace` method.
990#[derive(Clone, Default, PartialEq)]
991#[non_exhaustive]
992pub struct GetTraceRequest {
993    /// Required. ID of the Cloud project where the trace data is stored.
994    pub project_id: std::string::String,
995
996    /// Required. ID of the trace to return.
997    pub trace_id: std::string::String,
998
999    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1000}
1001
1002impl GetTraceRequest {
1003    /// Creates a new default instance.
1004    pub fn new() -> Self {
1005        std::default::Default::default()
1006    }
1007
1008    /// Sets the value of [project_id][crate::model::GetTraceRequest::project_id].
1009    ///
1010    /// # Example
1011    /// ```ignore,no_run
1012    /// # use google_cloud_trace_v1::model::GetTraceRequest;
1013    /// let x = GetTraceRequest::new().set_project_id("example");
1014    /// ```
1015    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1016        self.project_id = v.into();
1017        self
1018    }
1019
1020    /// Sets the value of [trace_id][crate::model::GetTraceRequest::trace_id].
1021    ///
1022    /// # Example
1023    /// ```ignore,no_run
1024    /// # use google_cloud_trace_v1::model::GetTraceRequest;
1025    /// let x = GetTraceRequest::new().set_trace_id("example");
1026    /// ```
1027    pub fn set_trace_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1028        self.trace_id = v.into();
1029        self
1030    }
1031}
1032
1033impl wkt::message::Message for GetTraceRequest {
1034    fn typename() -> &'static str {
1035        "type.googleapis.com/google.devtools.cloudtrace.v1.GetTraceRequest"
1036    }
1037}
1038
1039/// The request message for the `PatchTraces` method.
1040#[derive(Clone, Default, PartialEq)]
1041#[non_exhaustive]
1042pub struct PatchTracesRequest {
1043    /// Required. ID of the Cloud project where the trace data is stored.
1044    pub project_id: std::string::String,
1045
1046    /// Required. The body of the message.
1047    pub traces: std::option::Option<crate::model::Traces>,
1048
1049    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1050}
1051
1052impl PatchTracesRequest {
1053    /// Creates a new default instance.
1054    pub fn new() -> Self {
1055        std::default::Default::default()
1056    }
1057
1058    /// Sets the value of [project_id][crate::model::PatchTracesRequest::project_id].
1059    ///
1060    /// # Example
1061    /// ```ignore,no_run
1062    /// # use google_cloud_trace_v1::model::PatchTracesRequest;
1063    /// let x = PatchTracesRequest::new().set_project_id("example");
1064    /// ```
1065    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1066        self.project_id = v.into();
1067        self
1068    }
1069
1070    /// Sets the value of [traces][crate::model::PatchTracesRequest::traces].
1071    ///
1072    /// # Example
1073    /// ```ignore,no_run
1074    /// # use google_cloud_trace_v1::model::PatchTracesRequest;
1075    /// use google_cloud_trace_v1::model::Traces;
1076    /// let x = PatchTracesRequest::new().set_traces(Traces::default()/* use setters */);
1077    /// ```
1078    pub fn set_traces<T>(mut self, v: T) -> Self
1079    where
1080        T: std::convert::Into<crate::model::Traces>,
1081    {
1082        self.traces = std::option::Option::Some(v.into());
1083        self
1084    }
1085
1086    /// Sets or clears the value of [traces][crate::model::PatchTracesRequest::traces].
1087    ///
1088    /// # Example
1089    /// ```ignore,no_run
1090    /// # use google_cloud_trace_v1::model::PatchTracesRequest;
1091    /// use google_cloud_trace_v1::model::Traces;
1092    /// let x = PatchTracesRequest::new().set_or_clear_traces(Some(Traces::default()/* use setters */));
1093    /// let x = PatchTracesRequest::new().set_or_clear_traces(None::<Traces>);
1094    /// ```
1095    pub fn set_or_clear_traces<T>(mut self, v: std::option::Option<T>) -> Self
1096    where
1097        T: std::convert::Into<crate::model::Traces>,
1098    {
1099        self.traces = v.map(|x| x.into());
1100        self
1101    }
1102}
1103
1104impl wkt::message::Message for PatchTracesRequest {
1105    fn typename() -> &'static str {
1106        "type.googleapis.com/google.devtools.cloudtrace.v1.PatchTracesRequest"
1107    }
1108}