google_cloud_profiler_v2/
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 profiler_service {
18    use crate::Result;
19
20    /// A builder for [ProfilerService][crate::client::ProfilerService].
21    ///
22    /// ```
23    /// # tokio_test::block_on(async {
24    /// # use google_cloud_profiler_v2::*;
25    /// # use builder::profiler_service::ClientBuilder;
26    /// # use client::ProfilerService;
27    /// let builder : ClientBuilder = ProfilerService::builder();
28    /// let client = builder
29    ///     .with_endpoint("https://cloudprofiler.googleapis.com")
30    ///     .build().await?;
31    /// # gax::client_builder::Result::<()>::Ok(()) });
32    /// ```
33    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    /// Common implementation for [crate::client::ProfilerService] request builders.
52    #[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    /// The request builder for [ProfilerService::create_profile][crate::client::ProfilerService::create_profile] calls.
75    ///
76    /// # Example
77    /// ```no_run
78    /// # use google_cloud_profiler_v2::builder;
79    /// use builder::profiler_service::CreateProfile;
80    /// # tokio_test::block_on(async {
81    ///
82    /// let builder = prepare_request_builder();
83    /// let response = builder.send().await?;
84    /// # gax::Result::<()>::Ok(()) });
85    ///
86    /// fn prepare_request_builder() -> CreateProfile {
87    ///   # panic!();
88    ///   // ... details omitted ...
89    /// }
90    /// ```
91    #[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        /// Sets the full request, replacing any prior values.
102        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        /// Sets all the options, replacing any prior values.
108        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        /// Sends the request.
114        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        /// Sets the value of [parent][crate::model::CreateProfileRequest::parent].
122        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        /// Sets the value of [deployment][crate::model::CreateProfileRequest::deployment].
128        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        /// Sets or clears the value of [deployment][crate::model::CreateProfileRequest::deployment].
137        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        /// Sets the value of [profile_type][crate::model::CreateProfileRequest::profile_type].
146        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    /// The request builder for [ProfilerService::create_offline_profile][crate::client::ProfilerService::create_offline_profile] calls.
165    ///
166    /// # Example
167    /// ```no_run
168    /// # use google_cloud_profiler_v2::builder;
169    /// use builder::profiler_service::CreateOfflineProfile;
170    /// # tokio_test::block_on(async {
171    ///
172    /// let builder = prepare_request_builder();
173    /// let response = builder.send().await?;
174    /// # gax::Result::<()>::Ok(()) });
175    ///
176    /// fn prepare_request_builder() -> CreateOfflineProfile {
177    ///   # panic!();
178    ///   // ... details omitted ...
179    /// }
180    /// ```
181    #[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        /// Sets the full request, replacing any prior values.
192        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        /// Sets all the options, replacing any prior values.
201        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        /// Sends the request.
207        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        /// Sets the value of [parent][crate::model::CreateOfflineProfileRequest::parent].
215        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        /// Sets the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
221        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        /// Sets or clears the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
230        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    /// The request builder for [ProfilerService::update_profile][crate::client::ProfilerService::update_profile] calls.
247    ///
248    /// # Example
249    /// ```no_run
250    /// # use google_cloud_profiler_v2::builder;
251    /// use builder::profiler_service::UpdateProfile;
252    /// # tokio_test::block_on(async {
253    ///
254    /// let builder = prepare_request_builder();
255    /// let response = builder.send().await?;
256    /// # gax::Result::<()>::Ok(()) });
257    ///
258    /// fn prepare_request_builder() -> UpdateProfile {
259    ///   # panic!();
260    ///   // ... details omitted ...
261    /// }
262    /// ```
263    #[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        /// Sets the full request, replacing any prior values.
274        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        /// Sets all the options, replacing any prior values.
280        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        /// Sends the request.
286        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        /// Sets the value of [profile][crate::model::UpdateProfileRequest::profile].
294        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        /// Sets or clears the value of [profile][crate::model::UpdateProfileRequest::profile].
303        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        /// Sets the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
312        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        /// Sets or clears the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
321        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    /// A builder for [ExportService][crate::client::ExportService].
342    ///
343    /// ```
344    /// # tokio_test::block_on(async {
345    /// # use google_cloud_profiler_v2::*;
346    /// # use builder::export_service::ClientBuilder;
347    /// # use client::ExportService;
348    /// let builder : ClientBuilder = ExportService::builder();
349    /// let client = builder
350    ///     .with_endpoint("https://cloudprofiler.googleapis.com")
351    ///     .build().await?;
352    /// # gax::client_builder::Result::<()>::Ok(()) });
353    /// ```
354    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    /// Common implementation for [crate::client::ExportService] request builders.
373    #[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    /// The request builder for [ExportService::list_profiles][crate::client::ExportService::list_profiles] calls.
396    ///
397    /// # Example
398    /// ```no_run
399    /// # use google_cloud_profiler_v2::builder;
400    /// use builder::export_service::ListProfiles;
401    /// # tokio_test::block_on(async {
402    /// use gax::paginator::ItemPaginator;
403    ///
404    /// let builder = prepare_request_builder();
405    /// let mut items = builder.by_item();
406    /// while let Some(result) = items.next().await {
407    ///   let item = result?;
408    /// }
409    /// # gax::Result::<()>::Ok(()) });
410    ///
411    /// fn prepare_request_builder() -> ListProfiles {
412    ///   # panic!();
413    ///   // ... details omitted ...
414    /// }
415    /// ```
416    #[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        /// Sets the full request, replacing any prior values.
427        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        /// Sets all the options, replacing any prior values.
433        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        /// Sends the request.
439        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        /// Streams each page in the collection.
447        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        /// Streams each item in the collection.
462        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        /// Sets the value of [parent][crate::model::ListProfilesRequest::parent].
471        ///
472        /// This is a **required** field for requests.
473        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        /// Sets the value of [page_size][crate::model::ListProfilesRequest::page_size].
479        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        /// Sets the value of [page_token][crate::model::ListProfilesRequest::page_token].
485        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}