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
17/// Request and client builders for [ProfilerService][crate::client::ProfilerService].
18pub mod profiler_service {
19 use crate::Result;
20
21 /// A builder for [ProfilerService][crate::client::ProfilerService].
22 ///
23 /// ```
24 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
25 /// # use google_cloud_profiler_v2::*;
26 /// # use builder::profiler_service::ClientBuilder;
27 /// # use client::ProfilerService;
28 /// let builder : ClientBuilder = ProfilerService::builder();
29 /// let client = builder
30 /// .with_endpoint("https://cloudprofiler.googleapis.com")
31 /// .build().await?;
32 /// # Ok(()) }
33 /// ```
34 pub type ClientBuilder = crate::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 crate::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 ) -> crate::ClientBuilderResult<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: crate::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: crate::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() -> google_cloud_profiler_v2::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<crate::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(crate::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 crate::RequestBuilder for CreateProfile {
158 fn request_options(&mut self) -> &mut crate::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() -> google_cloud_profiler_v2::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<crate::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(crate::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 crate::RequestBuilder for CreateOfflineProfile {
239 fn request_options(&mut self) -> &mut crate::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() -> google_cloud_profiler_v2::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<crate::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(crate::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 crate::RequestBuilder for UpdateProfile {
329 fn request_options(&mut self) -> &mut crate::RequestOptions {
330 &mut self.0.options
331 }
332 }
333}
334
335/// Request and client builders for [ExportService][crate::client::ExportService].
336pub mod export_service {
337 use crate::Result;
338
339 /// A builder for [ExportService][crate::client::ExportService].
340 ///
341 /// ```
342 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
343 /// # use google_cloud_profiler_v2::*;
344 /// # use builder::export_service::ClientBuilder;
345 /// # use client::ExportService;
346 /// let builder : ClientBuilder = ExportService::builder();
347 /// let client = builder
348 /// .with_endpoint("https://cloudprofiler.googleapis.com")
349 /// .build().await?;
350 /// # Ok(()) }
351 /// ```
352 pub type ClientBuilder = crate::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 crate::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 ) -> crate::ClientBuilderResult<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: crate::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: crate::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() -> google_cloud_profiler_v2::Result<()> {
398 /// use google_cloud_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<crate::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(crate::Response::into_body)
440 }
441
442 /// Streams each page in the collection.
443 pub fn by_page(
444 self,
445 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListProfilesResponse, crate::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 google_cloud_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 google_cloud_gax::paginator::ItemPaginator<
461 crate::model::ListProfilesResponse,
462 crate::Error,
463 > {
464 use google_cloud_gax::paginator::Paginator;
465 self.by_page().items()
466 }
467
468 /// Sets the value of [parent][crate::model::ListProfilesRequest::parent].
469 ///
470 /// This is a **required** field for requests.
471 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
472 self.0.request.parent = v.into();
473 self
474 }
475
476 /// Sets the value of [page_size][crate::model::ListProfilesRequest::page_size].
477 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
478 self.0.request.page_size = v.into();
479 self
480 }
481
482 /// Sets the value of [page_token][crate::model::ListProfilesRequest::page_token].
483 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
484 self.0.request.page_token = v.into();
485 self
486 }
487 }
488
489 #[doc(hidden)]
490 impl crate::RequestBuilder for ListProfiles {
491 fn request_options(&mut self) -> &mut crate::RequestOptions {
492 &mut self.0.options
493 }
494 }
495}