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