google_cloud_trace_v1/builder.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
17pub mod trace_service {
18 use crate::Result;
19
20 /// A builder for [TraceService][crate::client::TraceService].
21 ///
22 /// ```
23 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24 /// # use google_cloud_trace_v1::*;
25 /// # use builder::trace_service::ClientBuilder;
26 /// # use client::TraceService;
27 /// let builder : ClientBuilder = TraceService::builder();
28 /// let client = builder
29 /// .with_endpoint("https://cloudtrace.googleapis.com")
30 /// .build().await?;
31 /// # Ok(()) }
32 /// ```
33 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::TraceService;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = TraceService;
40 type Credentials = gaxi::options::Credentials;
41 async fn build(
42 self,
43 config: gaxi::options::ClientConfig,
44 ) -> crate::ClientBuilderResult<Self::Client> {
45 Self::Client::new(config).await
46 }
47 }
48 }
49
50 /// Common implementation for [crate::client::TraceService] request builders.
51 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
54 request: R,
55 options: crate::RequestOptions,
56 }
57
58 impl<R> RequestBuilder<R>
59 where
60 R: std::default::Default,
61 {
62 pub(crate) fn new(
63 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 /// The request builder for [TraceService::list_traces][crate::client::TraceService::list_traces] calls.
74 ///
75 /// # Example
76 /// ```
77 /// # use google_cloud_trace_v1::builder::trace_service::ListTraces;
78 /// # async fn sample() -> google_cloud_trace_v1::Result<()> {
79 /// use google_cloud_gax::paginator::ItemPaginator;
80 ///
81 /// let builder = prepare_request_builder();
82 /// let mut items = builder.by_item();
83 /// while let Some(result) = items.next().await {
84 /// let item = result?;
85 /// }
86 /// # Ok(()) }
87 ///
88 /// fn prepare_request_builder() -> ListTraces {
89 /// # panic!();
90 /// // ... details omitted ...
91 /// }
92 /// ```
93 #[derive(Clone, Debug)]
94 pub struct ListTraces(RequestBuilder<crate::model::ListTracesRequest>);
95
96 impl ListTraces {
97 pub(crate) fn new(
98 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
99 ) -> Self {
100 Self(RequestBuilder::new(stub))
101 }
102
103 /// Sets the full request, replacing any prior values.
104 pub fn with_request<V: Into<crate::model::ListTracesRequest>>(mut self, v: V) -> Self {
105 self.0.request = v.into();
106 self
107 }
108
109 /// Sets all the options, replacing any prior values.
110 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
111 self.0.options = v.into();
112 self
113 }
114
115 /// Sends the request.
116 pub async fn send(self) -> Result<crate::model::ListTracesResponse> {
117 (*self.0.stub)
118 .list_traces(self.0.request, self.0.options)
119 .await
120 .map(crate::Response::into_body)
121 }
122
123 /// Streams each page in the collection.
124 pub fn by_page(
125 self,
126 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListTracesResponse, crate::Error>
127 {
128 use std::clone::Clone;
129 let token = self.0.request.page_token.clone();
130 let execute = move |token: String| {
131 let mut builder = self.clone();
132 builder.0.request = builder.0.request.set_page_token(token);
133 builder.send()
134 };
135 google_cloud_gax::paginator::internal::new_paginator(token, execute)
136 }
137
138 /// Streams each item in the collection.
139 pub fn by_item(
140 self,
141 ) -> impl google_cloud_gax::paginator::ItemPaginator<
142 crate::model::ListTracesResponse,
143 crate::Error,
144 > {
145 use google_cloud_gax::paginator::Paginator;
146 self.by_page().items()
147 }
148
149 /// Sets the value of [project_id][crate::model::ListTracesRequest::project_id].
150 ///
151 /// This is a **required** field for requests.
152 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
153 self.0.request.project_id = v.into();
154 self
155 }
156
157 /// Sets the value of [view][crate::model::ListTracesRequest::view].
158 pub fn set_view<T: Into<crate::model::list_traces_request::ViewType>>(
159 mut self,
160 v: T,
161 ) -> Self {
162 self.0.request.view = v.into();
163 self
164 }
165
166 /// Sets the value of [page_size][crate::model::ListTracesRequest::page_size].
167 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
168 self.0.request.page_size = v.into();
169 self
170 }
171
172 /// Sets the value of [page_token][crate::model::ListTracesRequest::page_token].
173 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
174 self.0.request.page_token = v.into();
175 self
176 }
177
178 /// Sets the value of [start_time][crate::model::ListTracesRequest::start_time].
179 pub fn set_start_time<T>(mut self, v: T) -> Self
180 where
181 T: std::convert::Into<wkt::Timestamp>,
182 {
183 self.0.request.start_time = std::option::Option::Some(v.into());
184 self
185 }
186
187 /// Sets or clears the value of [start_time][crate::model::ListTracesRequest::start_time].
188 pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
189 where
190 T: std::convert::Into<wkt::Timestamp>,
191 {
192 self.0.request.start_time = v.map(|x| x.into());
193 self
194 }
195
196 /// Sets the value of [end_time][crate::model::ListTracesRequest::end_time].
197 pub fn set_end_time<T>(mut self, v: T) -> Self
198 where
199 T: std::convert::Into<wkt::Timestamp>,
200 {
201 self.0.request.end_time = std::option::Option::Some(v.into());
202 self
203 }
204
205 /// Sets or clears the value of [end_time][crate::model::ListTracesRequest::end_time].
206 pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
207 where
208 T: std::convert::Into<wkt::Timestamp>,
209 {
210 self.0.request.end_time = v.map(|x| x.into());
211 self
212 }
213
214 /// Sets the value of [filter][crate::model::ListTracesRequest::filter].
215 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
216 self.0.request.filter = v.into();
217 self
218 }
219
220 /// Sets the value of [order_by][crate::model::ListTracesRequest::order_by].
221 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
222 self.0.request.order_by = v.into();
223 self
224 }
225 }
226
227 #[doc(hidden)]
228 impl crate::RequestBuilder for ListTraces {
229 fn request_options(&mut self) -> &mut crate::RequestOptions {
230 &mut self.0.options
231 }
232 }
233
234 /// The request builder for [TraceService::get_trace][crate::client::TraceService::get_trace] calls.
235 ///
236 /// # Example
237 /// ```
238 /// # use google_cloud_trace_v1::builder::trace_service::GetTrace;
239 /// # async fn sample() -> google_cloud_trace_v1::Result<()> {
240 ///
241 /// let builder = prepare_request_builder();
242 /// let response = builder.send().await?;
243 /// # Ok(()) }
244 ///
245 /// fn prepare_request_builder() -> GetTrace {
246 /// # panic!();
247 /// // ... details omitted ...
248 /// }
249 /// ```
250 #[derive(Clone, Debug)]
251 pub struct GetTrace(RequestBuilder<crate::model::GetTraceRequest>);
252
253 impl GetTrace {
254 pub(crate) fn new(
255 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
256 ) -> Self {
257 Self(RequestBuilder::new(stub))
258 }
259
260 /// Sets the full request, replacing any prior values.
261 pub fn with_request<V: Into<crate::model::GetTraceRequest>>(mut self, v: V) -> Self {
262 self.0.request = v.into();
263 self
264 }
265
266 /// Sets all the options, replacing any prior values.
267 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
268 self.0.options = v.into();
269 self
270 }
271
272 /// Sends the request.
273 pub async fn send(self) -> Result<crate::model::Trace> {
274 (*self.0.stub)
275 .get_trace(self.0.request, self.0.options)
276 .await
277 .map(crate::Response::into_body)
278 }
279
280 /// Sets the value of [project_id][crate::model::GetTraceRequest::project_id].
281 ///
282 /// This is a **required** field for requests.
283 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
284 self.0.request.project_id = v.into();
285 self
286 }
287
288 /// Sets the value of [trace_id][crate::model::GetTraceRequest::trace_id].
289 ///
290 /// This is a **required** field for requests.
291 pub fn set_trace_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
292 self.0.request.trace_id = v.into();
293 self
294 }
295 }
296
297 #[doc(hidden)]
298 impl crate::RequestBuilder for GetTrace {
299 fn request_options(&mut self) -> &mut crate::RequestOptions {
300 &mut self.0.options
301 }
302 }
303
304 /// The request builder for [TraceService::patch_traces][crate::client::TraceService::patch_traces] calls.
305 ///
306 /// # Example
307 /// ```
308 /// # use google_cloud_trace_v1::builder::trace_service::PatchTraces;
309 /// # async fn sample() -> google_cloud_trace_v1::Result<()> {
310 ///
311 /// let builder = prepare_request_builder();
312 /// let response = builder.send().await?;
313 /// # Ok(()) }
314 ///
315 /// fn prepare_request_builder() -> PatchTraces {
316 /// # panic!();
317 /// // ... details omitted ...
318 /// }
319 /// ```
320 #[derive(Clone, Debug)]
321 pub struct PatchTraces(RequestBuilder<crate::model::PatchTracesRequest>);
322
323 impl PatchTraces {
324 pub(crate) fn new(
325 stub: std::sync::Arc<dyn super::super::stub::dynamic::TraceService>,
326 ) -> Self {
327 Self(RequestBuilder::new(stub))
328 }
329
330 /// Sets the full request, replacing any prior values.
331 pub fn with_request<V: Into<crate::model::PatchTracesRequest>>(mut self, v: V) -> Self {
332 self.0.request = v.into();
333 self
334 }
335
336 /// Sets all the options, replacing any prior values.
337 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
338 self.0.options = v.into();
339 self
340 }
341
342 /// Sends the request.
343 pub async fn send(self) -> Result<()> {
344 (*self.0.stub)
345 .patch_traces(self.0.request, self.0.options)
346 .await
347 .map(crate::Response::into_body)
348 }
349
350 /// Sets the value of [project_id][crate::model::PatchTracesRequest::project_id].
351 ///
352 /// This is a **required** field for requests.
353 pub fn set_project_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
354 self.0.request.project_id = v.into();
355 self
356 }
357
358 /// Sets the value of [traces][crate::model::PatchTracesRequest::traces].
359 ///
360 /// This is a **required** field for requests.
361 pub fn set_traces<T>(mut self, v: T) -> Self
362 where
363 T: std::convert::Into<crate::model::Traces>,
364 {
365 self.0.request.traces = std::option::Option::Some(v.into());
366 self
367 }
368
369 /// Sets or clears the value of [traces][crate::model::PatchTracesRequest::traces].
370 ///
371 /// This is a **required** field for requests.
372 pub fn set_or_clear_traces<T>(mut self, v: std::option::Option<T>) -> Self
373 where
374 T: std::convert::Into<crate::model::Traces>,
375 {
376 self.0.request.traces = v.map(|x| x.into());
377 self
378 }
379 }
380
381 #[doc(hidden)]
382 impl crate::RequestBuilder for PatchTraces {
383 fn request_options(&mut self) -> &mut crate::RequestOptions {
384 &mut self.0.options
385 }
386 }
387}