google_cloud_profiler_v2/
builder.rs1pub mod profiler_service {
18 use crate::Result;
19
20 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
34
35 pub(crate) mod client {
36 use super::super::super::client::ProfilerService;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = ProfilerService;
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 #[derive(Clone, Debug)]
52 pub(crate) struct RequestBuilder<R: std::default::Default> {
53 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
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::ProfilerService>,
64 ) -> Self {
65 Self {
66 stub,
67 request: R::default(),
68 options: crate::RequestOptions::default(),
69 }
70 }
71 }
72
73 #[derive(Clone, Debug)]
90 pub struct CreateProfile(RequestBuilder<crate::model::CreateProfileRequest>);
91
92 impl CreateProfile {
93 pub(crate) fn new(
94 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
95 ) -> Self {
96 Self(RequestBuilder::new(stub))
97 }
98
99 pub fn with_request<V: Into<crate::model::CreateProfileRequest>>(mut self, v: V) -> Self {
101 self.0.request = v.into();
102 self
103 }
104
105 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107 self.0.options = v.into();
108 self
109 }
110
111 pub async fn send(self) -> Result<crate::model::Profile> {
113 (*self.0.stub)
114 .create_profile(self.0.request, self.0.options)
115 .await
116 .map(crate::Response::into_body)
117 }
118
119 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
121 self.0.request.parent = v.into();
122 self
123 }
124
125 pub fn set_deployment<T>(mut self, v: T) -> Self
127 where
128 T: std::convert::Into<crate::model::Deployment>,
129 {
130 self.0.request.deployment = std::option::Option::Some(v.into());
131 self
132 }
133
134 pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
136 where
137 T: std::convert::Into<crate::model::Deployment>,
138 {
139 self.0.request.deployment = v.map(|x| x.into());
140 self
141 }
142
143 pub fn set_profile_type<T, V>(mut self, v: T) -> Self
145 where
146 T: std::iter::IntoIterator<Item = V>,
147 V: std::convert::Into<crate::model::ProfileType>,
148 {
149 use std::iter::Iterator;
150 self.0.request.profile_type = v.into_iter().map(|i| i.into()).collect();
151 self
152 }
153 }
154
155 #[doc(hidden)]
156 impl crate::RequestBuilder for CreateProfile {
157 fn request_options(&mut self) -> &mut crate::RequestOptions {
158 &mut self.0.options
159 }
160 }
161
162 #[derive(Clone, Debug)]
179 pub struct CreateOfflineProfile(RequestBuilder<crate::model::CreateOfflineProfileRequest>);
180
181 impl CreateOfflineProfile {
182 pub(crate) fn new(
183 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
184 ) -> Self {
185 Self(RequestBuilder::new(stub))
186 }
187
188 pub fn with_request<V: Into<crate::model::CreateOfflineProfileRequest>>(
190 mut self,
191 v: V,
192 ) -> Self {
193 self.0.request = v.into();
194 self
195 }
196
197 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
199 self.0.options = v.into();
200 self
201 }
202
203 pub async fn send(self) -> Result<crate::model::Profile> {
205 (*self.0.stub)
206 .create_offline_profile(self.0.request, self.0.options)
207 .await
208 .map(crate::Response::into_body)
209 }
210
211 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
213 self.0.request.parent = v.into();
214 self
215 }
216
217 pub fn set_profile<T>(mut self, v: T) -> Self
219 where
220 T: std::convert::Into<crate::model::Profile>,
221 {
222 self.0.request.profile = std::option::Option::Some(v.into());
223 self
224 }
225
226 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
228 where
229 T: std::convert::Into<crate::model::Profile>,
230 {
231 self.0.request.profile = v.map(|x| x.into());
232 self
233 }
234 }
235
236 #[doc(hidden)]
237 impl crate::RequestBuilder for CreateOfflineProfile {
238 fn request_options(&mut self) -> &mut crate::RequestOptions {
239 &mut self.0.options
240 }
241 }
242
243 #[derive(Clone, Debug)]
260 pub struct UpdateProfile(RequestBuilder<crate::model::UpdateProfileRequest>);
261
262 impl UpdateProfile {
263 pub(crate) fn new(
264 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
265 ) -> Self {
266 Self(RequestBuilder::new(stub))
267 }
268
269 pub fn with_request<V: Into<crate::model::UpdateProfileRequest>>(mut self, v: V) -> Self {
271 self.0.request = v.into();
272 self
273 }
274
275 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
277 self.0.options = v.into();
278 self
279 }
280
281 pub async fn send(self) -> Result<crate::model::Profile> {
283 (*self.0.stub)
284 .update_profile(self.0.request, self.0.options)
285 .await
286 .map(crate::Response::into_body)
287 }
288
289 pub fn set_profile<T>(mut self, v: T) -> Self
291 where
292 T: std::convert::Into<crate::model::Profile>,
293 {
294 self.0.request.profile = std::option::Option::Some(v.into());
295 self
296 }
297
298 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
300 where
301 T: std::convert::Into<crate::model::Profile>,
302 {
303 self.0.request.profile = v.map(|x| x.into());
304 self
305 }
306
307 pub fn set_update_mask<T>(mut self, v: T) -> Self
309 where
310 T: std::convert::Into<wkt::FieldMask>,
311 {
312 self.0.request.update_mask = std::option::Option::Some(v.into());
313 self
314 }
315
316 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
318 where
319 T: std::convert::Into<wkt::FieldMask>,
320 {
321 self.0.request.update_mask = v.map(|x| x.into());
322 self
323 }
324 }
325
326 #[doc(hidden)]
327 impl crate::RequestBuilder for UpdateProfile {
328 fn request_options(&mut self) -> &mut crate::RequestOptions {
329 &mut self.0.options
330 }
331 }
332}
333
334pub mod export_service {
335 use crate::Result;
336
337 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
351
352 pub(crate) mod client {
353 use super::super::super::client::ExportService;
354 pub struct Factory;
355 impl crate::ClientFactory for Factory {
356 type Client = ExportService;
357 type Credentials = gaxi::options::Credentials;
358 async fn build(
359 self,
360 config: gaxi::options::ClientConfig,
361 ) -> crate::ClientBuilderResult<Self::Client> {
362 Self::Client::new(config).await
363 }
364 }
365 }
366
367 #[derive(Clone, Debug)]
369 pub(crate) struct RequestBuilder<R: std::default::Default> {
370 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
371 request: R,
372 options: crate::RequestOptions,
373 }
374
375 impl<R> RequestBuilder<R>
376 where
377 R: std::default::Default,
378 {
379 pub(crate) fn new(
380 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
381 ) -> Self {
382 Self {
383 stub,
384 request: R::default(),
385 options: crate::RequestOptions::default(),
386 }
387 }
388 }
389
390 #[derive(Clone, Debug)]
411 pub struct ListProfiles(RequestBuilder<crate::model::ListProfilesRequest>);
412
413 impl ListProfiles {
414 pub(crate) fn new(
415 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
416 ) -> Self {
417 Self(RequestBuilder::new(stub))
418 }
419
420 pub fn with_request<V: Into<crate::model::ListProfilesRequest>>(mut self, v: V) -> Self {
422 self.0.request = v.into();
423 self
424 }
425
426 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
428 self.0.options = v.into();
429 self
430 }
431
432 pub async fn send(self) -> Result<crate::model::ListProfilesResponse> {
434 (*self.0.stub)
435 .list_profiles(self.0.request, self.0.options)
436 .await
437 .map(crate::Response::into_body)
438 }
439
440 pub fn by_page(
442 self,
443 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListProfilesResponse, crate::Error>
444 {
445 use std::clone::Clone;
446 let token = self.0.request.page_token.clone();
447 let execute = move |token: String| {
448 let mut builder = self.clone();
449 builder.0.request = builder.0.request.set_page_token(token);
450 builder.send()
451 };
452 google_cloud_gax::paginator::internal::new_paginator(token, execute)
453 }
454
455 pub fn by_item(
457 self,
458 ) -> impl google_cloud_gax::paginator::ItemPaginator<
459 crate::model::ListProfilesResponse,
460 crate::Error,
461 > {
462 use google_cloud_gax::paginator::Paginator;
463 self.by_page().items()
464 }
465
466 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
470 self.0.request.parent = v.into();
471 self
472 }
473
474 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
476 self.0.request.page_size = v.into();
477 self
478 }
479
480 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
482 self.0.request.page_token = v.into();
483 self
484 }
485 }
486
487 #[doc(hidden)]
488 impl crate::RequestBuilder for ListProfiles {
489 fn request_options(&mut self) -> &mut crate::RequestOptions {
490 &mut self.0.options
491 }
492 }
493}