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() -> google_cloud_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 = 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    /// Common implementation for [crate::client::ProfilerService] request builders.
51    #[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    /// The request builder for [ProfilerService::create_profile][crate::client::ProfilerService::create_profile] calls.
74    ///
75    /// # Example
76    /// ```
77    /// # use google_cloud_profiler_v2::builder::profiler_service::CreateProfile;
78    /// # async fn sample() -> google_cloud_profiler_v2::Result<()> {
79    ///
80    /// let builder = prepare_request_builder();
81    /// let response = builder.send().await?;
82    /// # Ok(()) }
83    ///
84    /// fn prepare_request_builder() -> CreateProfile {
85    ///   # panic!();
86    ///   // ... details omitted ...
87    /// }
88    /// ```
89    #[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        /// Sets the full request, replacing any prior values.
100        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        /// Sets all the options, replacing any prior values.
106        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
107            self.0.options = v.into();
108            self
109        }
110
111        /// Sends the request.
112        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        /// Sets the value of [parent][crate::model::CreateProfileRequest::parent].
120        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        /// Sets the value of [deployment][crate::model::CreateProfileRequest::deployment].
126        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        /// Sets or clears the value of [deployment][crate::model::CreateProfileRequest::deployment].
135        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        /// Sets the value of [profile_type][crate::model::CreateProfileRequest::profile_type].
144        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    /// The request builder for [ProfilerService::create_offline_profile][crate::client::ProfilerService::create_offline_profile] calls.
163    ///
164    /// # Example
165    /// ```
166    /// # use google_cloud_profiler_v2::builder::profiler_service::CreateOfflineProfile;
167    /// # async fn sample() -> google_cloud_profiler_v2::Result<()> {
168    ///
169    /// let builder = prepare_request_builder();
170    /// let response = builder.send().await?;
171    /// # Ok(()) }
172    ///
173    /// fn prepare_request_builder() -> CreateOfflineProfile {
174    ///   # panic!();
175    ///   // ... details omitted ...
176    /// }
177    /// ```
178    #[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        /// Sets the full request, replacing any prior values.
189        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        /// Sets all the options, replacing any prior values.
198        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
199            self.0.options = v.into();
200            self
201        }
202
203        /// Sends the request.
204        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        /// Sets the value of [parent][crate::model::CreateOfflineProfileRequest::parent].
212        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        /// Sets the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
218        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        /// Sets or clears the value of [profile][crate::model::CreateOfflineProfileRequest::profile].
227        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    /// The request builder for [ProfilerService::update_profile][crate::client::ProfilerService::update_profile] calls.
244    ///
245    /// # Example
246    /// ```
247    /// # use google_cloud_profiler_v2::builder::profiler_service::UpdateProfile;
248    /// # async fn sample() -> google_cloud_profiler_v2::Result<()> {
249    ///
250    /// let builder = prepare_request_builder();
251    /// let response = builder.send().await?;
252    /// # Ok(()) }
253    ///
254    /// fn prepare_request_builder() -> UpdateProfile {
255    ///   # panic!();
256    ///   // ... details omitted ...
257    /// }
258    /// ```
259    #[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        /// Sets the full request, replacing any prior values.
270        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        /// Sets all the options, replacing any prior values.
276        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
277            self.0.options = v.into();
278            self
279        }
280
281        /// Sends the request.
282        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        /// Sets the value of [profile][crate::model::UpdateProfileRequest::profile].
290        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        /// Sets or clears the value of [profile][crate::model::UpdateProfileRequest::profile].
299        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        /// Sets the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
308        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        /// Sets or clears the value of [update_mask][crate::model::UpdateProfileRequest::update_mask].
317        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    /// A builder for [ExportService][crate::client::ExportService].
338    ///
339    /// ```
340    /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
341    /// # use google_cloud_profiler_v2::*;
342    /// # use builder::export_service::ClientBuilder;
343    /// # use client::ExportService;
344    /// let builder : ClientBuilder = ExportService::builder();
345    /// let client = builder
346    ///     .with_endpoint("https://cloudprofiler.googleapis.com")
347    ///     .build().await?;
348    /// # Ok(()) }
349    /// ```
350    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    /// Common implementation for [crate::client::ExportService] request builders.
368    #[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    /// The request builder for [ExportService::list_profiles][crate::client::ExportService::list_profiles] calls.
391    ///
392    /// # Example
393    /// ```
394    /// # use google_cloud_profiler_v2::builder::export_service::ListProfiles;
395    /// # async fn sample() -> google_cloud_profiler_v2::Result<()> {
396    /// use google_cloud_gax::paginator::ItemPaginator;
397    ///
398    /// let builder = prepare_request_builder();
399    /// let mut items = builder.by_item();
400    /// while let Some(result) = items.next().await {
401    ///   let item = result?;
402    /// }
403    /// # Ok(()) }
404    ///
405    /// fn prepare_request_builder() -> ListProfiles {
406    ///   # panic!();
407    ///   // ... details omitted ...
408    /// }
409    /// ```
410    #[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        /// Sets the full request, replacing any prior values.
421        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        /// Sets all the options, replacing any prior values.
427        pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
428            self.0.options = v.into();
429            self
430        }
431
432        /// Sends the request.
433        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        /// Streams each page in the collection.
441        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        /// Streams each item in the collection.
456        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        /// 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 crate::RequestBuilder for ListProfiles {
489        fn request_options(&mut self) -> &mut crate::RequestOptions {
490            &mut self.0.options
491        }
492    }
493}