Skip to main content

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    /// # async fn sample() -> gax::client_builder::Result<()> {
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    /// # 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    /// ```
78    /// # use google_cloud_profiler_v2::builder::profiler_service::CreateProfile;
79    /// # async fn sample() -> gax::Result<()> {
80    ///
81    /// let builder = prepare_request_builder();
82    /// let response = builder.send().await?;
83    /// # Ok(()) }
84    ///
85    /// fn prepare_request_builder() -> CreateProfile {
86    ///   # panic!();
87    ///   // ... details omitted ...
88    /// }
89    /// ```
90    #[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        /// Sets the full request, replacing any prior values.
101        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        /// Sets all the options, replacing any prior values.
107        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        /// Sends the request.
113        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        /// Sets the value of [parent][crate::model::CreateProfileRequest::parent].
121        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        /// Sets the value of [deployment][crate::model::CreateProfileRequest::deployment].
127        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        /// Sets or clears the value of [deployment][crate::model::CreateProfileRequest::deployment].
136        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        /// Sets the value of [profile_type][crate::model::CreateProfileRequest::profile_type].
145        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    /// The request builder for [ProfilerService::create_offline_profile][crate::client::ProfilerService::create_offline_profile] calls.
164    ///
165    /// # Example
166    /// ```
167    /// # use google_cloud_profiler_v2::builder::profiler_service::CreateOfflineProfile;
168    /// # async fn sample() -> gax::Result<()> {
169    ///
170    /// let builder = prepare_request_builder();
171    /// let response = builder.send().await?;
172    /// # Ok(()) }
173    ///
174    /// fn prepare_request_builder() -> CreateOfflineProfile {
175    ///   # panic!();
176    ///   // ... details omitted ...
177    /// }
178    /// ```
179    #[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        /// Sets the full request, replacing any prior values.
190        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        /// Sets all the options, replacing any prior values.
199        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        /// Sends the request.
205        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        /// Sets the value of [parent][crate::model::CreateOfflineProfileRequest::parent].
213        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        /// Sets the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
219        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        /// Sets or clears the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
228        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    /// The request builder for [ProfilerService::update_profile][crate::client::ProfilerService::update_profile] calls.
245    ///
246    /// # Example
247    /// ```
248    /// # use google_cloud_profiler_v2::builder::profiler_service::UpdateProfile;
249    /// # async fn sample() -> gax::Result<()> {
250    ///
251    /// let builder = prepare_request_builder();
252    /// let response = builder.send().await?;
253    /// # Ok(()) }
254    ///
255    /// fn prepare_request_builder() -> UpdateProfile {
256    ///   # panic!();
257    ///   // ... details omitted ...
258    /// }
259    /// ```
260    #[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        /// Sets the full request, replacing any prior values.
271        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        /// Sets all the options, replacing any prior values.
277        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        /// Sends the request.
283        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        /// Sets the value of [profile][crate::model::UpdateProfileRequest::profile].
291        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        /// Sets or clears the value of [profile][crate::model::UpdateProfileRequest::profile].
300        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        /// Sets the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
309        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        /// Sets or clears the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
318        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    /// A builder for [ExportService][crate::client::ExportService].
339    ///
340    /// ```
341    /// # async fn sample() -> gax::client_builder::Result<()> {
342    /// # use google_cloud_profiler_v2::*;
343    /// # use builder::export_service::ClientBuilder;
344    /// # use client::ExportService;
345    /// let builder : ClientBuilder = ExportService::builder();
346    /// let client = builder
347    ///     .with_endpoint("https://cloudprofiler.googleapis.com")
348    ///     .build().await?;
349    /// # Ok(()) }
350    /// ```
351    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    /// Common implementation for [crate::client::ExportService] request builders.
370    #[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    /// The request builder for [ExportService::list_profiles][crate::client::ExportService::list_profiles] calls.
393    ///
394    /// # Example
395    /// ```
396    /// # use google_cloud_profiler_v2::builder::export_service::ListProfiles;
397    /// # async fn sample() -> gax::Result<()> {
398    /// use gax::paginator::ItemPaginator;
399    ///
400    /// let builder = prepare_request_builder();
401    /// let mut items = builder.by_item();
402    /// while let Some(result) = items.next().await {
403    ///   let item = result?;
404    /// }
405    /// # Ok(()) }
406    ///
407    /// fn prepare_request_builder() -> ListProfiles {
408    ///   # panic!();
409    ///   // ... details omitted ...
410    /// }
411    /// ```
412    #[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        /// Sets the full request, replacing any prior values.
423        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        /// Sets all the options, replacing any prior values.
429        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        /// Sends the request.
435        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        /// Streams each page in the collection.
443        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        /// Streams each item in the collection.
458        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        /// Sets the value of [parent][crate::model::ListProfilesRequest::parent].
467        ///
468        /// This is a **required** field for requests.
469        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        /// Sets the value of [page_size][crate::model::ListProfilesRequest::page_size].
475        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        /// Sets the value of [page_token][crate::model::ListProfilesRequest::page_token].
481        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}