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