google_cloudtrace2/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18
19 /// Write Trace data for a project or application
20 TraceAppend,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
27 Scope::TraceAppend => "https://www.googleapis.com/auth/trace.append",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::TraceAppend
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all CloudTrace related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_cloudtrace2 as cloudtrace2;
53/// use cloudtrace2::api::Span;
54/// use cloudtrace2::{Result, Error};
55/// # async fn dox() {
56/// use cloudtrace2::{CloudTrace, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
67/// secret,
68/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
69/// ).build().await.unwrap();
70///
71/// let client = hyper_util::client::legacy::Client::builder(
72/// hyper_util::rt::TokioExecutor::new()
73/// )
74/// .build(
75/// hyper_rustls::HttpsConnectorBuilder::new()
76/// .with_native_roots()
77/// .unwrap()
78/// .https_or_http()
79/// .enable_http1()
80/// .build()
81/// );
82/// let mut hub = CloudTrace::new(client, auth);
83/// // As the method needs a request, you would usually fill it with the desired information
84/// // into the respective structure. Some of the parts shown here might not be applicable !
85/// // Values shown here are possibly random and not representative !
86/// let mut req = Span::default();
87///
88/// // You can configure optional parameters by calling the respective setters at will, and
89/// // execute the final call using `doit()`.
90/// // Values shown here are possibly random and not representative !
91/// let result = hub.projects().traces_spans_create_span(req, "name")
92/// .doit().await;
93///
94/// match result {
95/// Err(e) => match e {
96/// // The Error enum provides details about what exactly happened.
97/// // You can also just use its `Debug`, `Display` or `Error` traits
98/// Error::HttpError(_)
99/// |Error::Io(_)
100/// |Error::MissingAPIKey
101/// |Error::MissingToken(_)
102/// |Error::Cancelled
103/// |Error::UploadSizeLimitExceeded(_, _)
104/// |Error::Failure(_)
105/// |Error::BadRequest(_)
106/// |Error::FieldClash(_)
107/// |Error::JsonDecodeError(_, _) => println!("{}", e),
108/// },
109/// Ok(res) => println!("Success: {:?}", res),
110/// }
111/// # }
112/// ```
113#[derive(Clone)]
114pub struct CloudTrace<C> {
115 pub client: common::Client<C>,
116 pub auth: Box<dyn common::GetToken>,
117 _user_agent: String,
118 _base_url: String,
119 _root_url: String,
120}
121
122impl<C> common::Hub for CloudTrace<C> {}
123
124impl<'a, C> CloudTrace<C> {
125 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudTrace<C> {
126 CloudTrace {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://cloudtrace.googleapis.com/".to_string(),
131 _root_url: "https://cloudtrace.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://cloudtrace.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://cloudtrace.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// Text annotation with a set of attributes.
168///
169/// This type is not used in any activity, and only used as *part* of another schema.
170///
171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
172#[serde_with::serde_as]
173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
174pub struct Annotation {
175 /// A set of attributes on the annotation. You can have up to 4 attributes per Annotation.
176 pub attributes: Option<Attributes>,
177 /// A user-supplied message describing the event. The maximum length for the description is 256 bytes.
178 pub description: Option<TruncatableString>,
179}
180
181impl common::Part for Annotation {}
182
183/// The allowed types for `[VALUE]` in a `[KEY]:[VALUE]` attribute.
184///
185/// This type is not used in any activity, and only used as *part* of another schema.
186///
187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
188#[serde_with::serde_as]
189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
190pub struct AttributeValue {
191 /// A Boolean value represented by `true` or `false`.
192 #[serde(rename = "boolValue")]
193 pub bool_value: Option<bool>,
194 /// A 64-bit signed integer.
195 #[serde(rename = "intValue")]
196 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
197 pub int_value: Option<i64>,
198 /// A string up to 256 bytes long.
199 #[serde(rename = "stringValue")]
200 pub string_value: Option<TruncatableString>,
201}
202
203impl common::Part for AttributeValue {}
204
205/// A set of attributes as key-value pairs.
206///
207/// This type is not used in any activity, and only used as *part* of another schema.
208///
209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
210#[serde_with::serde_as]
211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
212pub struct Attributes {
213 /// A set of attributes. Each attribute's key can be up to 128 bytes long. The value can be a string up to 256 bytes, a signed 64-bit integer, or the boolean values `true` or `false`. For example: "/instance_id": { "string_value": { "value": "my-instance" } } "/http/request_bytes": { "int_value": 300 } "example.com/myattribute": { "bool_value": false }
214 #[serde(rename = "attributeMap")]
215 pub attribute_map: Option<HashMap<String, AttributeValue>>,
216 /// The number of attributes that were discarded. Attributes can be discarded because their keys are too long or because there are too many attributes. If this value is 0 then all attributes are valid.
217 #[serde(rename = "droppedAttributesCount")]
218 pub dropped_attributes_count: Option<i32>,
219}
220
221impl common::Part for Attributes {}
222
223/// The request message for the `BatchWriteSpans` method.
224///
225/// # Activities
226///
227/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
228/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
229///
230/// * [traces batch write projects](ProjectTraceBatchWriteCall) (request)
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct BatchWriteSpansRequest {
235 /// Required. A list of new spans. The span names must not match existing spans, otherwise the results are undefined.
236 pub spans: Option<Vec<Span>>,
237}
238
239impl common::RequestValue for BatchWriteSpansRequest {}
240
241/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
242///
243/// # Activities
244///
245/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
246/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
247///
248/// * [traces batch write projects](ProjectTraceBatchWriteCall) (response)
249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
250#[serde_with::serde_as]
251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
252pub struct Empty {
253 _never_set: Option<bool>,
254}
255
256impl common::ResponseResult for Empty {}
257
258/// A pointer from the current span to another span in the same trace or in a different trace. For example, this can be used in batching operations, where a single batch handler processes multiple requests from different traces or when the handler receives a request from a different project.
259///
260/// This type is not used in any activity, and only used as *part* of another schema.
261///
262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
263#[serde_with::serde_as]
264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
265pub struct Link {
266 /// A set of attributes on the link. Up to 32 attributes can be specified per link.
267 pub attributes: Option<Attributes>,
268 /// The `[SPAN_ID]` for a span within a trace.
269 #[serde(rename = "spanId")]
270 pub span_id: Option<String>,
271 /// The `[TRACE_ID]` for a trace within a project.
272 #[serde(rename = "traceId")]
273 pub trace_id: Option<String>,
274 /// The relationship of the current span relative to the linked span.
275 #[serde(rename = "type")]
276 pub type_: Option<String>,
277}
278
279impl common::Part for Link {}
280
281/// A collection of links, which are references from this span to a span in the same or different trace.
282///
283/// This type is not used in any activity, and only used as *part* of another schema.
284///
285#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
286#[serde_with::serde_as]
287#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
288pub struct Links {
289 /// The number of dropped links after the maximum size was enforced. If this value is 0, then no links were dropped.
290 #[serde(rename = "droppedLinksCount")]
291 pub dropped_links_count: Option<i32>,
292 /// A collection of links.
293 pub link: Option<Vec<Link>>,
294}
295
296impl common::Part for Links {}
297
298/// An event describing a message sent/received between Spans.
299///
300/// This type is not used in any activity, and only used as *part* of another schema.
301///
302#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
303#[serde_with::serde_as]
304#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
305pub struct MessageEvent {
306 /// The number of compressed bytes sent or received. If missing, the compressed size is assumed to be the same size as the uncompressed size.
307 #[serde(rename = "compressedSizeBytes")]
308 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
309 pub compressed_size_bytes: Option<i64>,
310 /// An identifier for the MessageEvent's message that can be used to match `SENT` and `RECEIVED` MessageEvents.
311 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
312 pub id: Option<i64>,
313 /// Type of MessageEvent. Indicates whether the message was sent or received.
314 #[serde(rename = "type")]
315 pub type_: Option<String>,
316 /// The number of uncompressed bytes sent or received.
317 #[serde(rename = "uncompressedSizeBytes")]
318 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
319 pub uncompressed_size_bytes: Option<i64>,
320}
321
322impl common::Part for MessageEvent {}
323
324/// Binary module.
325///
326/// This type is not used in any activity, and only used as *part* of another schema.
327///
328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
329#[serde_with::serde_as]
330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
331pub struct Module {
332 /// A unique identifier for the module, usually a hash of its contents (up to 128 bytes).
333 #[serde(rename = "buildId")]
334 pub build_id: Option<TruncatableString>,
335 /// For example: main binary, kernel modules, and dynamic libraries such as libc.so, sharedlib.so (up to 256 bytes).
336 pub module: Option<TruncatableString>,
337}
338
339impl common::Part for Module {}
340
341/// A span represents a single operation within a trace. Spans can be nested to form a trace tree. Often, a trace contains a root span that describes the end-to-end latency, and one or more subspans for its sub-operations. A trace can also contain multiple root spans, or none at all. Spans do not need to be contiguous. There might be gaps or overlaps between spans in a trace.
342///
343/// # Activities
344///
345/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
346/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
347///
348/// * [traces spans create span projects](ProjectTraceSpanCreateSpanCall) (request|response)
349#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
350#[serde_with::serde_as]
351#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
352pub struct Span {
353 /// A set of attributes on the span. You can have up to 32 attributes per span.
354 pub attributes: Option<Attributes>,
355 /// Optional. The number of child spans that were generated while this span was active. If set, allows implementation to detect missing child spans.
356 #[serde(rename = "childSpanCount")]
357 pub child_span_count: Option<i32>,
358 /// Required. A description of the span's operation (up to 128 bytes). Cloud Trace displays the description in the Cloud console. For example, the display name can be a qualified method name or a file name and a line number where the operation is called. A best practice is to use the same display name within an application and at the same call point. This makes it easier to correlate spans in different traces.
359 #[serde(rename = "displayName")]
360 pub display_name: Option<TruncatableString>,
361 /// Required. The end time of the span. On the client side, this is the time kept by the local machine where the span execution ends. On the server side, this is the time when the server application handler stops running.
362 #[serde(rename = "endTime")]
363 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
364 /// Links associated with the span. You can have up to 128 links per Span.
365 pub links: Option<Links>,
366 /// Required. The resource name of the span in the following format: * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]` `[TRACE_ID]` is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero. `[SPAN_ID]` is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. .
367 pub name: Option<String>,
368 /// The `[SPAN_ID]` of this span's parent span. If this is a root span, then this field must be empty.
369 #[serde(rename = "parentSpanId")]
370 pub parent_span_id: Option<String>,
371 /// Optional. Set this parameter to indicate whether this span is in the same process as its parent. If you do not set this parameter, Trace is unable to take advantage of this helpful information.
372 #[serde(rename = "sameProcessAsParentSpan")]
373 pub same_process_as_parent_span: Option<bool>,
374 /// Required. The `[SPAN_ID]` portion of the span's resource name.
375 #[serde(rename = "spanId")]
376 pub span_id: Option<String>,
377 /// Optional. Distinguishes between spans generated in a particular context. For example, two spans with the same name may be distinguished using `CLIENT` (caller) and `SERVER` (callee) to identify an RPC call.
378 #[serde(rename = "spanKind")]
379 pub span_kind: Option<String>,
380 /// Stack trace captured at the start of the span.
381 #[serde(rename = "stackTrace")]
382 pub stack_trace: Option<StackTrace>,
383 /// Required. The start time of the span. On the client side, this is the time kept by the local machine where the span execution starts. On the server side, this is the time when the server's application handler starts running.
384 #[serde(rename = "startTime")]
385 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
386 /// Optional. The final status for this span.
387 pub status: Option<Status>,
388 /// A set of time events. You can have up to 32 annotations and 128 message events per span.
389 #[serde(rename = "timeEvents")]
390 pub time_events: Option<TimeEvents>,
391}
392
393impl common::RequestValue for Span {}
394impl common::ResponseResult for Span {}
395
396/// Represents a single stack frame in a stack trace.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct StackFrame {
404 /// The column number where the function call appears, if available. This is important in JavaScript because of its anonymous functions.
405 #[serde(rename = "columnNumber")]
406 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
407 pub column_number: Option<i64>,
408 /// The name of the source file where the function call appears (up to 256 bytes).
409 #[serde(rename = "fileName")]
410 pub file_name: Option<TruncatableString>,
411 /// The fully-qualified name that uniquely identifies the function or method that is active in this frame (up to 1024 bytes).
412 #[serde(rename = "functionName")]
413 pub function_name: Option<TruncatableString>,
414 /// The line number in `file_name` where the function call appears.
415 #[serde(rename = "lineNumber")]
416 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
417 pub line_number: Option<i64>,
418 /// The binary module from where the code was loaded.
419 #[serde(rename = "loadModule")]
420 pub load_module: Option<Module>,
421 /// An un-mangled function name, if `function_name` is mangled. To get information about name mangling, run [this search](https://www.google.com/search?q=cxx+name+mangling). The name can be fully-qualified (up to 1024 bytes).
422 #[serde(rename = "originalFunctionName")]
423 pub original_function_name: Option<TruncatableString>,
424 /// The version of the deployed source code (up to 128 bytes).
425 #[serde(rename = "sourceVersion")]
426 pub source_version: Option<TruncatableString>,
427}
428
429impl common::Part for StackFrame {}
430
431/// A collection of stack frames, which can be truncated.
432///
433/// This type is not used in any activity, and only used as *part* of another schema.
434///
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct StackFrames {
439 /// The number of stack frames that were dropped because there were too many stack frames. If this value is 0, then no stack frames were dropped.
440 #[serde(rename = "droppedFramesCount")]
441 pub dropped_frames_count: Option<i32>,
442 /// Stack frames in this call stack.
443 pub frame: Option<Vec<StackFrame>>,
444}
445
446impl common::Part for StackFrames {}
447
448/// A call stack appearing in a trace.
449///
450/// This type is not used in any activity, and only used as *part* of another schema.
451///
452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
453#[serde_with::serde_as]
454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
455pub struct StackTrace {
456 /// Stack frames in this stack trace. A maximum of 128 frames are allowed.
457 #[serde(rename = "stackFrames")]
458 pub stack_frames: Option<StackFrames>,
459 /// The hash ID is used to conserve network bandwidth for duplicate stack traces within a single trace. Often multiple spans will have identical stack traces. The first occurrence of a stack trace should contain both the `stackFrame` content and a value in `stackTraceHashId`. Subsequent spans within the same request can refer to that stack trace by only setting `stackTraceHashId`.
460 #[serde(rename = "stackTraceHashId")]
461 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
462 pub stack_trace_hash_id: Option<i64>,
463}
464
465impl common::Part for StackTrace {}
466
467/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
468///
469/// This type is not used in any activity, and only used as *part* of another schema.
470///
471#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
472#[serde_with::serde_as]
473#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
474pub struct Status {
475 /// The status code, which should be an enum value of google.rpc.Code.
476 pub code: Option<i32>,
477 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
478 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
479 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
480 pub message: Option<String>,
481}
482
483impl common::Part for Status {}
484
485/// A time-stamped annotation or message event in the Span.
486///
487/// This type is not used in any activity, and only used as *part* of another schema.
488///
489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
490#[serde_with::serde_as]
491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
492pub struct TimeEvent {
493 /// Text annotation with a set of attributes.
494 pub annotation: Option<Annotation>,
495 /// An event describing a message sent/received between Spans.
496 #[serde(rename = "messageEvent")]
497 pub message_event: Option<MessageEvent>,
498 /// The timestamp indicating the time the event occurred.
499 pub time: Option<chrono::DateTime<chrono::offset::Utc>>,
500}
501
502impl common::Part for TimeEvent {}
503
504/// A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation on the span, consisting of either user-supplied key:value pairs, or details of a message sent/received between Spans.
505///
506/// This type is not used in any activity, and only used as *part* of another schema.
507///
508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
509#[serde_with::serde_as]
510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
511pub struct TimeEvents {
512 /// The number of dropped annotations in all the included time events. If the value is 0, then no annotations were dropped.
513 #[serde(rename = "droppedAnnotationsCount")]
514 pub dropped_annotations_count: Option<i32>,
515 /// The number of dropped message events in all the included time events. If the value is 0, then no message events were dropped.
516 #[serde(rename = "droppedMessageEventsCount")]
517 pub dropped_message_events_count: Option<i32>,
518 /// A collection of `TimeEvent`s.
519 #[serde(rename = "timeEvent")]
520 pub time_event: Option<Vec<TimeEvent>>,
521}
522
523impl common::Part for TimeEvents {}
524
525/// Represents a string that might be shortened to a specified length.
526///
527/// This type is not used in any activity, and only used as *part* of another schema.
528///
529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
530#[serde_with::serde_as]
531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
532pub struct TruncatableString {
533 /// The number of bytes removed from the original string. If this value is 0, then the string was not shortened.
534 #[serde(rename = "truncatedByteCount")]
535 pub truncated_byte_count: Option<i32>,
536 /// The shortened string. For example, if the original string is 500 bytes long and the limit of the string is 128 bytes, then `value` contains the first 128 bytes of the 500-byte string. Truncation always happens on a UTF8 character boundary. If there are multi-byte characters in the string, then the length of the shortened string might be less than the size limit.
537 pub value: Option<String>,
538}
539
540impl common::Part for TruncatableString {}
541
542// ###################
543// MethodBuilders ###
544// #################
545
546/// A builder providing access to all methods supported on *project* resources.
547/// It is not used directly, but through the [`CloudTrace`] hub.
548///
549/// # Example
550///
551/// Instantiate a resource builder
552///
553/// ```test_harness,no_run
554/// extern crate hyper;
555/// extern crate hyper_rustls;
556/// extern crate google_cloudtrace2 as cloudtrace2;
557///
558/// # async fn dox() {
559/// use cloudtrace2::{CloudTrace, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
560///
561/// let secret: yup_oauth2::ApplicationSecret = Default::default();
562/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
563/// secret,
564/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
565/// ).build().await.unwrap();
566///
567/// let client = hyper_util::client::legacy::Client::builder(
568/// hyper_util::rt::TokioExecutor::new()
569/// )
570/// .build(
571/// hyper_rustls::HttpsConnectorBuilder::new()
572/// .with_native_roots()
573/// .unwrap()
574/// .https_or_http()
575/// .enable_http1()
576/// .build()
577/// );
578/// let mut hub = CloudTrace::new(client, auth);
579/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
580/// // like `traces_batch_write(...)` and `traces_spans_create_span(...)`
581/// // to build up your call.
582/// let rb = hub.projects();
583/// # }
584/// ```
585pub struct ProjectMethods<'a, C>
586where
587 C: 'a,
588{
589 hub: &'a CloudTrace<C>,
590}
591
592impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
593
594impl<'a, C> ProjectMethods<'a, C> {
595 /// Create a builder to help you perform the following task:
596 ///
597 /// Creates a new span.
598 ///
599 /// # Arguments
600 ///
601 /// * `request` - No description provided.
602 /// * `name` - Required. The resource name of the span in the following format: * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]` `[TRACE_ID]` is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero. `[SPAN_ID]` is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. .
603 pub fn traces_spans_create_span(
604 &self,
605 request: Span,
606 name: &str,
607 ) -> ProjectTraceSpanCreateSpanCall<'a, C> {
608 ProjectTraceSpanCreateSpanCall {
609 hub: self.hub,
610 _request: request,
611 _name: name.to_string(),
612 _delegate: Default::default(),
613 _additional_params: Default::default(),
614 _scopes: Default::default(),
615 }
616 }
617
618 /// Create a builder to help you perform the following task:
619 ///
620 /// Batch writes new spans to new or existing traces. You cannot update existing spans.
621 ///
622 /// # Arguments
623 ///
624 /// * `request` - No description provided.
625 /// * `name` - Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`.
626 pub fn traces_batch_write(
627 &self,
628 request: BatchWriteSpansRequest,
629 name: &str,
630 ) -> ProjectTraceBatchWriteCall<'a, C> {
631 ProjectTraceBatchWriteCall {
632 hub: self.hub,
633 _request: request,
634 _name: name.to_string(),
635 _delegate: Default::default(),
636 _additional_params: Default::default(),
637 _scopes: Default::default(),
638 }
639 }
640}
641
642// ###################
643// CallBuilders ###
644// #################
645
646/// Creates a new span.
647///
648/// A builder for the *traces.spans.createSpan* method supported by a *project* resource.
649/// It is not used directly, but through a [`ProjectMethods`] instance.
650///
651/// # Example
652///
653/// Instantiate a resource method builder
654///
655/// ```test_harness,no_run
656/// # extern crate hyper;
657/// # extern crate hyper_rustls;
658/// # extern crate google_cloudtrace2 as cloudtrace2;
659/// use cloudtrace2::api::Span;
660/// # async fn dox() {
661/// # use cloudtrace2::{CloudTrace, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
662///
663/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
665/// # secret,
666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
667/// # ).build().await.unwrap();
668///
669/// # let client = hyper_util::client::legacy::Client::builder(
670/// # hyper_util::rt::TokioExecutor::new()
671/// # )
672/// # .build(
673/// # hyper_rustls::HttpsConnectorBuilder::new()
674/// # .with_native_roots()
675/// # .unwrap()
676/// # .https_or_http()
677/// # .enable_http1()
678/// # .build()
679/// # );
680/// # let mut hub = CloudTrace::new(client, auth);
681/// // As the method needs a request, you would usually fill it with the desired information
682/// // into the respective structure. Some of the parts shown here might not be applicable !
683/// // Values shown here are possibly random and not representative !
684/// let mut req = Span::default();
685///
686/// // You can configure optional parameters by calling the respective setters at will, and
687/// // execute the final call using `doit()`.
688/// // Values shown here are possibly random and not representative !
689/// let result = hub.projects().traces_spans_create_span(req, "name")
690/// .doit().await;
691/// # }
692/// ```
693pub struct ProjectTraceSpanCreateSpanCall<'a, C>
694where
695 C: 'a,
696{
697 hub: &'a CloudTrace<C>,
698 _request: Span,
699 _name: String,
700 _delegate: Option<&'a mut dyn common::Delegate>,
701 _additional_params: HashMap<String, String>,
702 _scopes: BTreeSet<String>,
703}
704
705impl<'a, C> common::CallBuilder for ProjectTraceSpanCreateSpanCall<'a, C> {}
706
707impl<'a, C> ProjectTraceSpanCreateSpanCall<'a, C>
708where
709 C: common::Connector,
710{
711 /// Perform the operation you have build so far.
712 pub async fn doit(mut self) -> common::Result<(common::Response, Span)> {
713 use std::borrow::Cow;
714 use std::io::{Read, Seek};
715
716 use common::{url::Params, ToParts};
717 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
718
719 let mut dd = common::DefaultDelegate;
720 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
721 dlg.begin(common::MethodInfo {
722 id: "cloudtrace.projects.traces.spans.createSpan",
723 http_method: hyper::Method::POST,
724 });
725
726 for &field in ["alt", "name"].iter() {
727 if self._additional_params.contains_key(field) {
728 dlg.finished(false);
729 return Err(common::Error::FieldClash(field));
730 }
731 }
732
733 let mut params = Params::with_capacity(4 + self._additional_params.len());
734 params.push("name", self._name);
735
736 params.extend(self._additional_params.iter());
737
738 params.push("alt", "json");
739 let mut url = self.hub._base_url.clone() + "v2/{+name}";
740 if self._scopes.is_empty() {
741 self._scopes
742 .insert(Scope::CloudPlatform.as_ref().to_string());
743 }
744
745 #[allow(clippy::single_element_loop)]
746 for &(find_this, param_name) in [("{+name}", "name")].iter() {
747 url = params.uri_replacement(url, param_name, find_this, true);
748 }
749 {
750 let to_remove = ["name"];
751 params.remove_params(&to_remove);
752 }
753
754 let url = params.parse_with_url(&url);
755
756 let mut json_mime_type = mime::APPLICATION_JSON;
757 let mut request_value_reader = {
758 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
759 common::remove_json_null_values(&mut value);
760 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
761 serde_json::to_writer(&mut dst, &value).unwrap();
762 dst
763 };
764 let request_size = request_value_reader
765 .seek(std::io::SeekFrom::End(0))
766 .unwrap();
767 request_value_reader
768 .seek(std::io::SeekFrom::Start(0))
769 .unwrap();
770
771 loop {
772 let token = match self
773 .hub
774 .auth
775 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
776 .await
777 {
778 Ok(token) => token,
779 Err(e) => match dlg.token(e) {
780 Ok(token) => token,
781 Err(e) => {
782 dlg.finished(false);
783 return Err(common::Error::MissingToken(e));
784 }
785 },
786 };
787 request_value_reader
788 .seek(std::io::SeekFrom::Start(0))
789 .unwrap();
790 let mut req_result = {
791 let client = &self.hub.client;
792 dlg.pre_request();
793 let mut req_builder = hyper::Request::builder()
794 .method(hyper::Method::POST)
795 .uri(url.as_str())
796 .header(USER_AGENT, self.hub._user_agent.clone());
797
798 if let Some(token) = token.as_ref() {
799 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
800 }
801
802 let request = req_builder
803 .header(CONTENT_TYPE, json_mime_type.to_string())
804 .header(CONTENT_LENGTH, request_size as u64)
805 .body(common::to_body(
806 request_value_reader.get_ref().clone().into(),
807 ));
808
809 client.request(request.unwrap()).await
810 };
811
812 match req_result {
813 Err(err) => {
814 if let common::Retry::After(d) = dlg.http_error(&err) {
815 sleep(d).await;
816 continue;
817 }
818 dlg.finished(false);
819 return Err(common::Error::HttpError(err));
820 }
821 Ok(res) => {
822 let (mut parts, body) = res.into_parts();
823 let mut body = common::Body::new(body);
824 if !parts.status.is_success() {
825 let bytes = common::to_bytes(body).await.unwrap_or_default();
826 let error = serde_json::from_str(&common::to_string(&bytes));
827 let response = common::to_response(parts, bytes.into());
828
829 if let common::Retry::After(d) =
830 dlg.http_failure(&response, error.as_ref().ok())
831 {
832 sleep(d).await;
833 continue;
834 }
835
836 dlg.finished(false);
837
838 return Err(match error {
839 Ok(value) => common::Error::BadRequest(value),
840 _ => common::Error::Failure(response),
841 });
842 }
843 let response = {
844 let bytes = common::to_bytes(body).await.unwrap_or_default();
845 let encoded = common::to_string(&bytes);
846 match serde_json::from_str(&encoded) {
847 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
848 Err(error) => {
849 dlg.response_json_decode_error(&encoded, &error);
850 return Err(common::Error::JsonDecodeError(
851 encoded.to_string(),
852 error,
853 ));
854 }
855 }
856 };
857
858 dlg.finished(true);
859 return Ok(response);
860 }
861 }
862 }
863 }
864
865 ///
866 /// Sets the *request* property to the given value.
867 ///
868 /// Even though the property as already been set when instantiating this call,
869 /// we provide this method for API completeness.
870 pub fn request(mut self, new_value: Span) -> ProjectTraceSpanCreateSpanCall<'a, C> {
871 self._request = new_value;
872 self
873 }
874 /// Required. The resource name of the span in the following format: * `projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID]` `[TRACE_ID]` is a unique identifier for a trace within a project; it is a 32-character hexadecimal encoding of a 16-byte array. It should not be zero. `[SPAN_ID]` is a unique identifier for a span within a trace; it is a 16-character hexadecimal encoding of an 8-byte array. It should not be zero. .
875 ///
876 /// Sets the *name* path property to the given value.
877 ///
878 /// Even though the property as already been set when instantiating this call,
879 /// we provide this method for API completeness.
880 pub fn name(mut self, new_value: &str) -> ProjectTraceSpanCreateSpanCall<'a, C> {
881 self._name = new_value.to_string();
882 self
883 }
884 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
885 /// while executing the actual API request.
886 ///
887 /// ````text
888 /// It should be used to handle progress information, and to implement a certain level of resilience.
889 /// ````
890 ///
891 /// Sets the *delegate* property to the given value.
892 pub fn delegate(
893 mut self,
894 new_value: &'a mut dyn common::Delegate,
895 ) -> ProjectTraceSpanCreateSpanCall<'a, C> {
896 self._delegate = Some(new_value);
897 self
898 }
899
900 /// Set any additional parameter of the query string used in the request.
901 /// It should be used to set parameters which are not yet available through their own
902 /// setters.
903 ///
904 /// Please note that this method must not be used to set any of the known parameters
905 /// which have their own setter method. If done anyway, the request will fail.
906 ///
907 /// # Additional Parameters
908 ///
909 /// * *$.xgafv* (query-string) - V1 error format.
910 /// * *access_token* (query-string) - OAuth access token.
911 /// * *alt* (query-string) - Data format for response.
912 /// * *callback* (query-string) - JSONP
913 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
914 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
915 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
916 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
917 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
918 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
919 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
920 pub fn param<T>(mut self, name: T, value: T) -> ProjectTraceSpanCreateSpanCall<'a, C>
921 where
922 T: AsRef<str>,
923 {
924 self._additional_params
925 .insert(name.as_ref().to_string(), value.as_ref().to_string());
926 self
927 }
928
929 /// Identifies the authorization scope for the method you are building.
930 ///
931 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
932 /// [`Scope::CloudPlatform`].
933 ///
934 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
935 /// tokens for more than one scope.
936 ///
937 /// Usually there is more than one suitable scope to authorize an operation, some of which may
938 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
939 /// sufficient, a read-write scope will do as well.
940 pub fn add_scope<St>(mut self, scope: St) -> ProjectTraceSpanCreateSpanCall<'a, C>
941 where
942 St: AsRef<str>,
943 {
944 self._scopes.insert(String::from(scope.as_ref()));
945 self
946 }
947 /// Identifies the authorization scope(s) for the method you are building.
948 ///
949 /// See [`Self::add_scope()`] for details.
950 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTraceSpanCreateSpanCall<'a, C>
951 where
952 I: IntoIterator<Item = St>,
953 St: AsRef<str>,
954 {
955 self._scopes
956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
957 self
958 }
959
960 /// Removes all scopes, and no default scope will be used either.
961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
962 /// for details).
963 pub fn clear_scopes(mut self) -> ProjectTraceSpanCreateSpanCall<'a, C> {
964 self._scopes.clear();
965 self
966 }
967}
968
969/// Batch writes new spans to new or existing traces. You cannot update existing spans.
970///
971/// A builder for the *traces.batchWrite* method supported by a *project* resource.
972/// It is not used directly, but through a [`ProjectMethods`] instance.
973///
974/// # Example
975///
976/// Instantiate a resource method builder
977///
978/// ```test_harness,no_run
979/// # extern crate hyper;
980/// # extern crate hyper_rustls;
981/// # extern crate google_cloudtrace2 as cloudtrace2;
982/// use cloudtrace2::api::BatchWriteSpansRequest;
983/// # async fn dox() {
984/// # use cloudtrace2::{CloudTrace, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
985///
986/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
988/// # secret,
989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
990/// # ).build().await.unwrap();
991///
992/// # let client = hyper_util::client::legacy::Client::builder(
993/// # hyper_util::rt::TokioExecutor::new()
994/// # )
995/// # .build(
996/// # hyper_rustls::HttpsConnectorBuilder::new()
997/// # .with_native_roots()
998/// # .unwrap()
999/// # .https_or_http()
1000/// # .enable_http1()
1001/// # .build()
1002/// # );
1003/// # let mut hub = CloudTrace::new(client, auth);
1004/// // As the method needs a request, you would usually fill it with the desired information
1005/// // into the respective structure. Some of the parts shown here might not be applicable !
1006/// // Values shown here are possibly random and not representative !
1007/// let mut req = BatchWriteSpansRequest::default();
1008///
1009/// // You can configure optional parameters by calling the respective setters at will, and
1010/// // execute the final call using `doit()`.
1011/// // Values shown here are possibly random and not representative !
1012/// let result = hub.projects().traces_batch_write(req, "name")
1013/// .doit().await;
1014/// # }
1015/// ```
1016pub struct ProjectTraceBatchWriteCall<'a, C>
1017where
1018 C: 'a,
1019{
1020 hub: &'a CloudTrace<C>,
1021 _request: BatchWriteSpansRequest,
1022 _name: String,
1023 _delegate: Option<&'a mut dyn common::Delegate>,
1024 _additional_params: HashMap<String, String>,
1025 _scopes: BTreeSet<String>,
1026}
1027
1028impl<'a, C> common::CallBuilder for ProjectTraceBatchWriteCall<'a, C> {}
1029
1030impl<'a, C> ProjectTraceBatchWriteCall<'a, C>
1031where
1032 C: common::Connector,
1033{
1034 /// Perform the operation you have build so far.
1035 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1036 use std::borrow::Cow;
1037 use std::io::{Read, Seek};
1038
1039 use common::{url::Params, ToParts};
1040 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1041
1042 let mut dd = common::DefaultDelegate;
1043 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1044 dlg.begin(common::MethodInfo {
1045 id: "cloudtrace.projects.traces.batchWrite",
1046 http_method: hyper::Method::POST,
1047 });
1048
1049 for &field in ["alt", "name"].iter() {
1050 if self._additional_params.contains_key(field) {
1051 dlg.finished(false);
1052 return Err(common::Error::FieldClash(field));
1053 }
1054 }
1055
1056 let mut params = Params::with_capacity(4 + self._additional_params.len());
1057 params.push("name", self._name);
1058
1059 params.extend(self._additional_params.iter());
1060
1061 params.push("alt", "json");
1062 let mut url = self.hub._base_url.clone() + "v2/{+name}/traces:batchWrite";
1063 if self._scopes.is_empty() {
1064 self._scopes
1065 .insert(Scope::CloudPlatform.as_ref().to_string());
1066 }
1067
1068 #[allow(clippy::single_element_loop)]
1069 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1070 url = params.uri_replacement(url, param_name, find_this, true);
1071 }
1072 {
1073 let to_remove = ["name"];
1074 params.remove_params(&to_remove);
1075 }
1076
1077 let url = params.parse_with_url(&url);
1078
1079 let mut json_mime_type = mime::APPLICATION_JSON;
1080 let mut request_value_reader = {
1081 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1082 common::remove_json_null_values(&mut value);
1083 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1084 serde_json::to_writer(&mut dst, &value).unwrap();
1085 dst
1086 };
1087 let request_size = request_value_reader
1088 .seek(std::io::SeekFrom::End(0))
1089 .unwrap();
1090 request_value_reader
1091 .seek(std::io::SeekFrom::Start(0))
1092 .unwrap();
1093
1094 loop {
1095 let token = match self
1096 .hub
1097 .auth
1098 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1099 .await
1100 {
1101 Ok(token) => token,
1102 Err(e) => match dlg.token(e) {
1103 Ok(token) => token,
1104 Err(e) => {
1105 dlg.finished(false);
1106 return Err(common::Error::MissingToken(e));
1107 }
1108 },
1109 };
1110 request_value_reader
1111 .seek(std::io::SeekFrom::Start(0))
1112 .unwrap();
1113 let mut req_result = {
1114 let client = &self.hub.client;
1115 dlg.pre_request();
1116 let mut req_builder = hyper::Request::builder()
1117 .method(hyper::Method::POST)
1118 .uri(url.as_str())
1119 .header(USER_AGENT, self.hub._user_agent.clone());
1120
1121 if let Some(token) = token.as_ref() {
1122 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1123 }
1124
1125 let request = req_builder
1126 .header(CONTENT_TYPE, json_mime_type.to_string())
1127 .header(CONTENT_LENGTH, request_size as u64)
1128 .body(common::to_body(
1129 request_value_reader.get_ref().clone().into(),
1130 ));
1131
1132 client.request(request.unwrap()).await
1133 };
1134
1135 match req_result {
1136 Err(err) => {
1137 if let common::Retry::After(d) = dlg.http_error(&err) {
1138 sleep(d).await;
1139 continue;
1140 }
1141 dlg.finished(false);
1142 return Err(common::Error::HttpError(err));
1143 }
1144 Ok(res) => {
1145 let (mut parts, body) = res.into_parts();
1146 let mut body = common::Body::new(body);
1147 if !parts.status.is_success() {
1148 let bytes = common::to_bytes(body).await.unwrap_or_default();
1149 let error = serde_json::from_str(&common::to_string(&bytes));
1150 let response = common::to_response(parts, bytes.into());
1151
1152 if let common::Retry::After(d) =
1153 dlg.http_failure(&response, error.as_ref().ok())
1154 {
1155 sleep(d).await;
1156 continue;
1157 }
1158
1159 dlg.finished(false);
1160
1161 return Err(match error {
1162 Ok(value) => common::Error::BadRequest(value),
1163 _ => common::Error::Failure(response),
1164 });
1165 }
1166 let response = {
1167 let bytes = common::to_bytes(body).await.unwrap_or_default();
1168 let encoded = common::to_string(&bytes);
1169 match serde_json::from_str(&encoded) {
1170 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1171 Err(error) => {
1172 dlg.response_json_decode_error(&encoded, &error);
1173 return Err(common::Error::JsonDecodeError(
1174 encoded.to_string(),
1175 error,
1176 ));
1177 }
1178 }
1179 };
1180
1181 dlg.finished(true);
1182 return Ok(response);
1183 }
1184 }
1185 }
1186 }
1187
1188 ///
1189 /// Sets the *request* property to the given value.
1190 ///
1191 /// Even though the property as already been set when instantiating this call,
1192 /// we provide this method for API completeness.
1193 pub fn request(
1194 mut self,
1195 new_value: BatchWriteSpansRequest,
1196 ) -> ProjectTraceBatchWriteCall<'a, C> {
1197 self._request = new_value;
1198 self
1199 }
1200 /// Required. The name of the project where the spans belong. The format is `projects/[PROJECT_ID]`.
1201 ///
1202 /// Sets the *name* path property to the given value.
1203 ///
1204 /// Even though the property as already been set when instantiating this call,
1205 /// we provide this method for API completeness.
1206 pub fn name(mut self, new_value: &str) -> ProjectTraceBatchWriteCall<'a, C> {
1207 self._name = new_value.to_string();
1208 self
1209 }
1210 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1211 /// while executing the actual API request.
1212 ///
1213 /// ````text
1214 /// It should be used to handle progress information, and to implement a certain level of resilience.
1215 /// ````
1216 ///
1217 /// Sets the *delegate* property to the given value.
1218 pub fn delegate(
1219 mut self,
1220 new_value: &'a mut dyn common::Delegate,
1221 ) -> ProjectTraceBatchWriteCall<'a, C> {
1222 self._delegate = Some(new_value);
1223 self
1224 }
1225
1226 /// Set any additional parameter of the query string used in the request.
1227 /// It should be used to set parameters which are not yet available through their own
1228 /// setters.
1229 ///
1230 /// Please note that this method must not be used to set any of the known parameters
1231 /// which have their own setter method. If done anyway, the request will fail.
1232 ///
1233 /// # Additional Parameters
1234 ///
1235 /// * *$.xgafv* (query-string) - V1 error format.
1236 /// * *access_token* (query-string) - OAuth access token.
1237 /// * *alt* (query-string) - Data format for response.
1238 /// * *callback* (query-string) - JSONP
1239 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1240 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
1241 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1242 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1243 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
1244 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1245 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1246 pub fn param<T>(mut self, name: T, value: T) -> ProjectTraceBatchWriteCall<'a, C>
1247 where
1248 T: AsRef<str>,
1249 {
1250 self._additional_params
1251 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1252 self
1253 }
1254
1255 /// Identifies the authorization scope for the method you are building.
1256 ///
1257 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1258 /// [`Scope::CloudPlatform`].
1259 ///
1260 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1261 /// tokens for more than one scope.
1262 ///
1263 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1264 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1265 /// sufficient, a read-write scope will do as well.
1266 pub fn add_scope<St>(mut self, scope: St) -> ProjectTraceBatchWriteCall<'a, C>
1267 where
1268 St: AsRef<str>,
1269 {
1270 self._scopes.insert(String::from(scope.as_ref()));
1271 self
1272 }
1273 /// Identifies the authorization scope(s) for the method you are building.
1274 ///
1275 /// See [`Self::add_scope()`] for details.
1276 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTraceBatchWriteCall<'a, C>
1277 where
1278 I: IntoIterator<Item = St>,
1279 St: AsRef<str>,
1280 {
1281 self._scopes
1282 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1283 self
1284 }
1285
1286 /// Removes all scopes, and no default scope will be used either.
1287 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1288 /// for details).
1289 pub fn clear_scopes(mut self) -> ProjectTraceBatchWriteCall<'a, C> {
1290 self._scopes.clear();
1291 self
1292 }
1293}