google_cloud_profiler_v2/
builder.rs1pub mod profiler_service {
18 use crate::Result;
19
20 pub type ClientBuilder =
34 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::ProfilerService;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = ProfilerService;
41 type Credentials = gaxi::options::Credentials;
42 async fn build(
43 self,
44 config: gaxi::options::ClientConfig,
45 ) -> gax::client_builder::Result<Self::Client> {
46 Self::Client::new(config).await
47 }
48 }
49 }
50
51 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
55 request: R,
56 options: gax::options::RequestOptions,
57 }
58
59 impl<R> RequestBuilder<R>
60 where
61 R: std::default::Default,
62 {
63 pub(crate) fn new(
64 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
65 ) -> Self {
66 Self {
67 stub,
68 request: R::default(),
69 options: gax::options::RequestOptions::default(),
70 }
71 }
72 }
73
74 #[derive(Clone, Debug)]
92 pub struct CreateProfile(RequestBuilder<crate::model::CreateProfileRequest>);
93
94 impl CreateProfile {
95 pub(crate) fn new(
96 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
97 ) -> Self {
98 Self(RequestBuilder::new(stub))
99 }
100
101 pub fn with_request<V: Into<crate::model::CreateProfileRequest>>(mut self, v: V) -> Self {
103 self.0.request = v.into();
104 self
105 }
106
107 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
109 self.0.options = v.into();
110 self
111 }
112
113 pub async fn send(self) -> Result<crate::model::Profile> {
115 (*self.0.stub)
116 .create_profile(self.0.request, self.0.options)
117 .await
118 .map(gax::response::Response::into_body)
119 }
120
121 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
123 self.0.request.parent = v.into();
124 self
125 }
126
127 pub fn set_deployment<T>(mut self, v: T) -> Self
129 where
130 T: std::convert::Into<crate::model::Deployment>,
131 {
132 self.0.request.deployment = std::option::Option::Some(v.into());
133 self
134 }
135
136 pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
138 where
139 T: std::convert::Into<crate::model::Deployment>,
140 {
141 self.0.request.deployment = v.map(|x| x.into());
142 self
143 }
144
145 pub fn set_profile_type<T, V>(mut self, v: T) -> Self
147 where
148 T: std::iter::IntoIterator<Item = V>,
149 V: std::convert::Into<crate::model::ProfileType>,
150 {
151 use std::iter::Iterator;
152 self.0.request.profile_type = v.into_iter().map(|i| i.into()).collect();
153 self
154 }
155 }
156
157 #[doc(hidden)]
158 impl gax::options::internal::RequestBuilder for CreateProfile {
159 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
160 &mut self.0.options
161 }
162 }
163
164 #[derive(Clone, Debug)]
182 pub struct CreateOfflineProfile(RequestBuilder<crate::model::CreateOfflineProfileRequest>);
183
184 impl CreateOfflineProfile {
185 pub(crate) fn new(
186 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
187 ) -> Self {
188 Self(RequestBuilder::new(stub))
189 }
190
191 pub fn with_request<V: Into<crate::model::CreateOfflineProfileRequest>>(
193 mut self,
194 v: V,
195 ) -> Self {
196 self.0.request = v.into();
197 self
198 }
199
200 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
202 self.0.options = v.into();
203 self
204 }
205
206 pub async fn send(self) -> Result<crate::model::Profile> {
208 (*self.0.stub)
209 .create_offline_profile(self.0.request, self.0.options)
210 .await
211 .map(gax::response::Response::into_body)
212 }
213
214 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
216 self.0.request.parent = v.into();
217 self
218 }
219
220 pub fn set_profile<T>(mut self, v: T) -> Self
222 where
223 T: std::convert::Into<crate::model::Profile>,
224 {
225 self.0.request.profile = std::option::Option::Some(v.into());
226 self
227 }
228
229 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
231 where
232 T: std::convert::Into<crate::model::Profile>,
233 {
234 self.0.request.profile = v.map(|x| x.into());
235 self
236 }
237 }
238
239 #[doc(hidden)]
240 impl gax::options::internal::RequestBuilder for CreateOfflineProfile {
241 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
242 &mut self.0.options
243 }
244 }
245
246 #[derive(Clone, Debug)]
264 pub struct UpdateProfile(RequestBuilder<crate::model::UpdateProfileRequest>);
265
266 impl UpdateProfile {
267 pub(crate) fn new(
268 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
269 ) -> Self {
270 Self(RequestBuilder::new(stub))
271 }
272
273 pub fn with_request<V: Into<crate::model::UpdateProfileRequest>>(mut self, v: V) -> Self {
275 self.0.request = v.into();
276 self
277 }
278
279 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
281 self.0.options = v.into();
282 self
283 }
284
285 pub async fn send(self) -> Result<crate::model::Profile> {
287 (*self.0.stub)
288 .update_profile(self.0.request, self.0.options)
289 .await
290 .map(gax::response::Response::into_body)
291 }
292
293 pub fn set_profile<T>(mut self, v: T) -> Self
295 where
296 T: std::convert::Into<crate::model::Profile>,
297 {
298 self.0.request.profile = std::option::Option::Some(v.into());
299 self
300 }
301
302 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
304 where
305 T: std::convert::Into<crate::model::Profile>,
306 {
307 self.0.request.profile = v.map(|x| x.into());
308 self
309 }
310
311 pub fn set_update_mask<T>(mut self, v: T) -> Self
313 where
314 T: std::convert::Into<wkt::FieldMask>,
315 {
316 self.0.request.update_mask = std::option::Option::Some(v.into());
317 self
318 }
319
320 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
322 where
323 T: std::convert::Into<wkt::FieldMask>,
324 {
325 self.0.request.update_mask = v.map(|x| x.into());
326 self
327 }
328 }
329
330 #[doc(hidden)]
331 impl gax::options::internal::RequestBuilder for UpdateProfile {
332 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
333 &mut self.0.options
334 }
335 }
336}
337
338pub mod export_service {
339 use crate::Result;
340
341 pub type ClientBuilder =
355 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
356
357 pub(crate) mod client {
358 use super::super::super::client::ExportService;
359 pub struct Factory;
360 impl gax::client_builder::internal::ClientFactory for Factory {
361 type Client = ExportService;
362 type Credentials = gaxi::options::Credentials;
363 async fn build(
364 self,
365 config: gaxi::options::ClientConfig,
366 ) -> gax::client_builder::Result<Self::Client> {
367 Self::Client::new(config).await
368 }
369 }
370 }
371
372 #[derive(Clone, Debug)]
374 pub(crate) struct RequestBuilder<R: std::default::Default> {
375 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
376 request: R,
377 options: gax::options::RequestOptions,
378 }
379
380 impl<R> RequestBuilder<R>
381 where
382 R: std::default::Default,
383 {
384 pub(crate) fn new(
385 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
386 ) -> Self {
387 Self {
388 stub,
389 request: R::default(),
390 options: gax::options::RequestOptions::default(),
391 }
392 }
393 }
394
395 #[derive(Clone, Debug)]
417 pub struct ListProfiles(RequestBuilder<crate::model::ListProfilesRequest>);
418
419 impl ListProfiles {
420 pub(crate) fn new(
421 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
422 ) -> Self {
423 Self(RequestBuilder::new(stub))
424 }
425
426 pub fn with_request<V: Into<crate::model::ListProfilesRequest>>(mut self, v: V) -> Self {
428 self.0.request = v.into();
429 self
430 }
431
432 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
434 self.0.options = v.into();
435 self
436 }
437
438 pub async fn send(self) -> Result<crate::model::ListProfilesResponse> {
440 (*self.0.stub)
441 .list_profiles(self.0.request, self.0.options)
442 .await
443 .map(gax::response::Response::into_body)
444 }
445
446 pub fn by_page(
448 self,
449 ) -> impl gax::paginator::Paginator<crate::model::ListProfilesResponse, gax::error::Error>
450 {
451 use std::clone::Clone;
452 let token = self.0.request.page_token.clone();
453 let execute = move |token: String| {
454 let mut builder = self.clone();
455 builder.0.request = builder.0.request.set_page_token(token);
456 builder.send()
457 };
458 gax::paginator::internal::new_paginator(token, execute)
459 }
460
461 pub fn by_item(
463 self,
464 ) -> impl gax::paginator::ItemPaginator<crate::model::ListProfilesResponse, gax::error::Error>
465 {
466 use gax::paginator::Paginator;
467 self.by_page().items()
468 }
469
470 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
474 self.0.request.parent = v.into();
475 self
476 }
477
478 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
480 self.0.request.page_size = v.into();
481 self
482 }
483
484 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
486 self.0.request.page_token = v.into();
487 self
488 }
489 }
490
491 #[doc(hidden)]
492 impl gax::options::internal::RequestBuilder for ListProfiles {
493 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
494 &mut self.0.options
495 }
496 }
497}