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