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