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)]
91 pub struct CreateProfile(RequestBuilder<crate::model::CreateProfileRequest>);
92
93 impl CreateProfile {
94 pub(crate) fn new(
95 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
96 ) -> Self {
97 Self(RequestBuilder::new(stub))
98 }
99
100 pub fn with_request<V: Into<crate::model::CreateProfileRequest>>(mut self, v: V) -> Self {
102 self.0.request = v.into();
103 self
104 }
105
106 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
108 self.0.options = v.into();
109 self
110 }
111
112 pub async fn send(self) -> Result<crate::model::Profile> {
114 (*self.0.stub)
115 .create_profile(self.0.request, self.0.options)
116 .await
117 .map(gax::response::Response::into_body)
118 }
119
120 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
122 self.0.request.parent = v.into();
123 self
124 }
125
126 pub fn set_deployment<T>(mut self, v: T) -> Self
128 where
129 T: std::convert::Into<crate::model::Deployment>,
130 {
131 self.0.request.deployment = std::option::Option::Some(v.into());
132 self
133 }
134
135 pub fn set_or_clear_deployment<T>(mut self, v: std::option::Option<T>) -> Self
137 where
138 T: std::convert::Into<crate::model::Deployment>,
139 {
140 self.0.request.deployment = v.map(|x| x.into());
141 self
142 }
143
144 pub fn set_profile_type<T, V>(mut self, v: T) -> Self
146 where
147 T: std::iter::IntoIterator<Item = V>,
148 V: std::convert::Into<crate::model::ProfileType>,
149 {
150 use std::iter::Iterator;
151 self.0.request.profile_type = v.into_iter().map(|i| i.into()).collect();
152 self
153 }
154 }
155
156 #[doc(hidden)]
157 impl gax::options::internal::RequestBuilder for CreateProfile {
158 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
159 &mut self.0.options
160 }
161 }
162
163 #[derive(Clone, Debug)]
180 pub struct CreateOfflineProfile(RequestBuilder<crate::model::CreateOfflineProfileRequest>);
181
182 impl CreateOfflineProfile {
183 pub(crate) fn new(
184 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
185 ) -> Self {
186 Self(RequestBuilder::new(stub))
187 }
188
189 pub fn with_request<V: Into<crate::model::CreateOfflineProfileRequest>>(
191 mut self,
192 v: V,
193 ) -> Self {
194 self.0.request = v.into();
195 self
196 }
197
198 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
200 self.0.options = v.into();
201 self
202 }
203
204 pub async fn send(self) -> Result<crate::model::Profile> {
206 (*self.0.stub)
207 .create_offline_profile(self.0.request, self.0.options)
208 .await
209 .map(gax::response::Response::into_body)
210 }
211
212 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
214 self.0.request.parent = v.into();
215 self
216 }
217
218 pub fn set_profile<T>(mut self, v: T) -> Self
220 where
221 T: std::convert::Into<crate::model::Profile>,
222 {
223 self.0.request.profile = std::option::Option::Some(v.into());
224 self
225 }
226
227 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
229 where
230 T: std::convert::Into<crate::model::Profile>,
231 {
232 self.0.request.profile = v.map(|x| x.into());
233 self
234 }
235 }
236
237 #[doc(hidden)]
238 impl gax::options::internal::RequestBuilder for CreateOfflineProfile {
239 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
240 &mut self.0.options
241 }
242 }
243
244 #[derive(Clone, Debug)]
261 pub struct UpdateProfile(RequestBuilder<crate::model::UpdateProfileRequest>);
262
263 impl UpdateProfile {
264 pub(crate) fn new(
265 stub: std::sync::Arc<dyn super::super::stub::dynamic::ProfilerService>,
266 ) -> Self {
267 Self(RequestBuilder::new(stub))
268 }
269
270 pub fn with_request<V: Into<crate::model::UpdateProfileRequest>>(mut self, v: V) -> Self {
272 self.0.request = v.into();
273 self
274 }
275
276 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
278 self.0.options = v.into();
279 self
280 }
281
282 pub async fn send(self) -> Result<crate::model::Profile> {
284 (*self.0.stub)
285 .update_profile(self.0.request, self.0.options)
286 .await
287 .map(gax::response::Response::into_body)
288 }
289
290 pub fn set_profile<T>(mut self, v: T) -> Self
292 where
293 T: std::convert::Into<crate::model::Profile>,
294 {
295 self.0.request.profile = std::option::Option::Some(v.into());
296 self
297 }
298
299 pub fn set_or_clear_profile<T>(mut self, v: std::option::Option<T>) -> Self
301 where
302 T: std::convert::Into<crate::model::Profile>,
303 {
304 self.0.request.profile = v.map(|x| x.into());
305 self
306 }
307
308 pub fn set_update_mask<T>(mut self, v: T) -> Self
310 where
311 T: std::convert::Into<wkt::FieldMask>,
312 {
313 self.0.request.update_mask = std::option::Option::Some(v.into());
314 self
315 }
316
317 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
319 where
320 T: std::convert::Into<wkt::FieldMask>,
321 {
322 self.0.request.update_mask = v.map(|x| x.into());
323 self
324 }
325 }
326
327 #[doc(hidden)]
328 impl gax::options::internal::RequestBuilder for UpdateProfile {
329 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
330 &mut self.0.options
331 }
332 }
333}
334
335pub mod export_service {
336 use crate::Result;
337
338 pub type ClientBuilder =
352 gax::client_builder::ClientBuilder<client::Factory, gaxi::options::Credentials>;
353
354 pub(crate) mod client {
355 use super::super::super::client::ExportService;
356 pub struct Factory;
357 impl gax::client_builder::internal::ClientFactory for Factory {
358 type Client = ExportService;
359 type Credentials = gaxi::options::Credentials;
360 async fn build(
361 self,
362 config: gaxi::options::ClientConfig,
363 ) -> gax::client_builder::Result<Self::Client> {
364 Self::Client::new(config).await
365 }
366 }
367 }
368
369 #[derive(Clone, Debug)]
371 pub(crate) struct RequestBuilder<R: std::default::Default> {
372 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
373 request: R,
374 options: gax::options::RequestOptions,
375 }
376
377 impl<R> RequestBuilder<R>
378 where
379 R: std::default::Default,
380 {
381 pub(crate) fn new(
382 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
383 ) -> Self {
384 Self {
385 stub,
386 request: R::default(),
387 options: gax::options::RequestOptions::default(),
388 }
389 }
390 }
391
392 #[derive(Clone, Debug)]
413 pub struct ListProfiles(RequestBuilder<crate::model::ListProfilesRequest>);
414
415 impl ListProfiles {
416 pub(crate) fn new(
417 stub: std::sync::Arc<dyn super::super::stub::dynamic::ExportService>,
418 ) -> Self {
419 Self(RequestBuilder::new(stub))
420 }
421
422 pub fn with_request<V: Into<crate::model::ListProfilesRequest>>(mut self, v: V) -> Self {
424 self.0.request = v.into();
425 self
426 }
427
428 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
430 self.0.options = v.into();
431 self
432 }
433
434 pub async fn send(self) -> Result<crate::model::ListProfilesResponse> {
436 (*self.0.stub)
437 .list_profiles(self.0.request, self.0.options)
438 .await
439 .map(gax::response::Response::into_body)
440 }
441
442 pub fn by_page(
444 self,
445 ) -> impl gax::paginator::Paginator<crate::model::ListProfilesResponse, gax::error::Error>
446 {
447 use std::clone::Clone;
448 let token = self.0.request.page_token.clone();
449 let execute = move |token: String| {
450 let mut builder = self.clone();
451 builder.0.request = builder.0.request.set_page_token(token);
452 builder.send()
453 };
454 gax::paginator::internal::new_paginator(token, execute)
455 }
456
457 pub fn by_item(
459 self,
460 ) -> impl gax::paginator::ItemPaginator<crate::model::ListProfilesResponse, gax::error::Error>
461 {
462 use 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 gax::options::internal::RequestBuilder for ListProfiles {
489 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
490 &mut self.0.options
491 }
492 }
493}