google_cloud_modelarmor_v1/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 model_armor {
18 use crate::Result;
19
20 /// A builder for [ModelArmor][crate::client::ModelArmor].
21 ///
22 /// ```
23 /// # tokio_test::block_on(async {
24 /// # use google_cloud_modelarmor_v1::*;
25 /// # use builder::model_armor::ClientBuilder;
26 /// # use client::ModelArmor;
27 /// let builder : ClientBuilder = ModelArmor::builder();
28 /// let client = builder
29 /// .with_endpoint("https://modelarmor.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::ModelArmor;
38 pub struct Factory;
39 impl gax::client_builder::internal::ClientFactory for Factory {
40 type Client = ModelArmor;
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::ModelArmor] 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::ModelArmor>,
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::ModelArmor>,
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 [ModelArmor::list_templates][crate::client::ModelArmor::list_templates] calls.
75 ///
76 /// # Example
77 /// ```no_run
78 /// # use google_cloud_modelarmor_v1::builder;
79 /// use builder::model_armor::ListTemplates;
80 /// # tokio_test::block_on(async {
81 /// use gax::paginator::ItemPaginator;
82 ///
83 /// let builder = prepare_request_builder();
84 /// let mut items = builder.by_item();
85 /// while let Some(result) = items.next().await {
86 /// let item = result?;
87 /// }
88 /// # gax::Result::<()>::Ok(()) });
89 ///
90 /// fn prepare_request_builder() -> ListTemplates {
91 /// # panic!();
92 /// // ... details omitted ...
93 /// }
94 /// ```
95 #[derive(Clone, Debug)]
96 pub struct ListTemplates(RequestBuilder<crate::model::ListTemplatesRequest>);
97
98 impl ListTemplates {
99 pub(crate) fn new(
100 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
101 ) -> Self {
102 Self(RequestBuilder::new(stub))
103 }
104
105 /// Sets the full request, replacing any prior values.
106 pub fn with_request<V: Into<crate::model::ListTemplatesRequest>>(mut self, v: V) -> Self {
107 self.0.request = v.into();
108 self
109 }
110
111 /// Sets all the options, replacing any prior values.
112 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
113 self.0.options = v.into();
114 self
115 }
116
117 /// Sends the request.
118 pub async fn send(self) -> Result<crate::model::ListTemplatesResponse> {
119 (*self.0.stub)
120 .list_templates(self.0.request, self.0.options)
121 .await
122 .map(gax::response::Response::into_body)
123 }
124
125 /// Streams each page in the collection.
126 pub fn by_page(
127 self,
128 ) -> impl gax::paginator::Paginator<crate::model::ListTemplatesResponse, gax::error::Error>
129 {
130 use std::clone::Clone;
131 let token = self.0.request.page_token.clone();
132 let execute = move |token: String| {
133 let mut builder = self.clone();
134 builder.0.request = builder.0.request.set_page_token(token);
135 builder.send()
136 };
137 gax::paginator::internal::new_paginator(token, execute)
138 }
139
140 /// Streams each item in the collection.
141 pub fn by_item(
142 self,
143 ) -> impl gax::paginator::ItemPaginator<crate::model::ListTemplatesResponse, gax::error::Error>
144 {
145 use gax::paginator::Paginator;
146 self.by_page().items()
147 }
148
149 /// Sets the value of [parent][crate::model::ListTemplatesRequest::parent].
150 ///
151 /// This is a **required** field for requests.
152 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
153 self.0.request.parent = v.into();
154 self
155 }
156
157 /// Sets the value of [page_size][crate::model::ListTemplatesRequest::page_size].
158 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
159 self.0.request.page_size = v.into();
160 self
161 }
162
163 /// Sets the value of [page_token][crate::model::ListTemplatesRequest::page_token].
164 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
165 self.0.request.page_token = v.into();
166 self
167 }
168
169 /// Sets the value of [filter][crate::model::ListTemplatesRequest::filter].
170 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
171 self.0.request.filter = v.into();
172 self
173 }
174
175 /// Sets the value of [order_by][crate::model::ListTemplatesRequest::order_by].
176 pub fn set_order_by<T: Into<std::string::String>>(mut self, v: T) -> Self {
177 self.0.request.order_by = v.into();
178 self
179 }
180 }
181
182 #[doc(hidden)]
183 impl gax::options::internal::RequestBuilder for ListTemplates {
184 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
185 &mut self.0.options
186 }
187 }
188
189 /// The request builder for [ModelArmor::get_template][crate::client::ModelArmor::get_template] calls.
190 ///
191 /// # Example
192 /// ```no_run
193 /// # use google_cloud_modelarmor_v1::builder;
194 /// use builder::model_armor::GetTemplate;
195 /// # tokio_test::block_on(async {
196 ///
197 /// let builder = prepare_request_builder();
198 /// let response = builder.send().await?;
199 /// # gax::Result::<()>::Ok(()) });
200 ///
201 /// fn prepare_request_builder() -> GetTemplate {
202 /// # panic!();
203 /// // ... details omitted ...
204 /// }
205 /// ```
206 #[derive(Clone, Debug)]
207 pub struct GetTemplate(RequestBuilder<crate::model::GetTemplateRequest>);
208
209 impl GetTemplate {
210 pub(crate) fn new(
211 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
212 ) -> Self {
213 Self(RequestBuilder::new(stub))
214 }
215
216 /// Sets the full request, replacing any prior values.
217 pub fn with_request<V: Into<crate::model::GetTemplateRequest>>(mut self, v: V) -> Self {
218 self.0.request = v.into();
219 self
220 }
221
222 /// Sets all the options, replacing any prior values.
223 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
224 self.0.options = v.into();
225 self
226 }
227
228 /// Sends the request.
229 pub async fn send(self) -> Result<crate::model::Template> {
230 (*self.0.stub)
231 .get_template(self.0.request, self.0.options)
232 .await
233 .map(gax::response::Response::into_body)
234 }
235
236 /// Sets the value of [name][crate::model::GetTemplateRequest::name].
237 ///
238 /// This is a **required** field for requests.
239 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
240 self.0.request.name = v.into();
241 self
242 }
243 }
244
245 #[doc(hidden)]
246 impl gax::options::internal::RequestBuilder for GetTemplate {
247 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
248 &mut self.0.options
249 }
250 }
251
252 /// The request builder for [ModelArmor::create_template][crate::client::ModelArmor::create_template] calls.
253 ///
254 /// # Example
255 /// ```no_run
256 /// # use google_cloud_modelarmor_v1::builder;
257 /// use builder::model_armor::CreateTemplate;
258 /// # tokio_test::block_on(async {
259 ///
260 /// let builder = prepare_request_builder();
261 /// let response = builder.send().await?;
262 /// # gax::Result::<()>::Ok(()) });
263 ///
264 /// fn prepare_request_builder() -> CreateTemplate {
265 /// # panic!();
266 /// // ... details omitted ...
267 /// }
268 /// ```
269 #[derive(Clone, Debug)]
270 pub struct CreateTemplate(RequestBuilder<crate::model::CreateTemplateRequest>);
271
272 impl CreateTemplate {
273 pub(crate) fn new(
274 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
275 ) -> Self {
276 Self(RequestBuilder::new(stub))
277 }
278
279 /// Sets the full request, replacing any prior values.
280 pub fn with_request<V: Into<crate::model::CreateTemplateRequest>>(mut self, v: V) -> Self {
281 self.0.request = v.into();
282 self
283 }
284
285 /// Sets all the options, replacing any prior values.
286 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
287 self.0.options = v.into();
288 self
289 }
290
291 /// Sends the request.
292 pub async fn send(self) -> Result<crate::model::Template> {
293 (*self.0.stub)
294 .create_template(self.0.request, self.0.options)
295 .await
296 .map(gax::response::Response::into_body)
297 }
298
299 /// Sets the value of [parent][crate::model::CreateTemplateRequest::parent].
300 ///
301 /// This is a **required** field for requests.
302 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
303 self.0.request.parent = v.into();
304 self
305 }
306
307 /// Sets the value of [template_id][crate::model::CreateTemplateRequest::template_id].
308 ///
309 /// This is a **required** field for requests.
310 pub fn set_template_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
311 self.0.request.template_id = v.into();
312 self
313 }
314
315 /// Sets the value of [template][crate::model::CreateTemplateRequest::template].
316 ///
317 /// This is a **required** field for requests.
318 pub fn set_template<T>(mut self, v: T) -> Self
319 where
320 T: std::convert::Into<crate::model::Template>,
321 {
322 self.0.request.template = std::option::Option::Some(v.into());
323 self
324 }
325
326 /// Sets or clears the value of [template][crate::model::CreateTemplateRequest::template].
327 ///
328 /// This is a **required** field for requests.
329 pub fn set_or_clear_template<T>(mut self, v: std::option::Option<T>) -> Self
330 where
331 T: std::convert::Into<crate::model::Template>,
332 {
333 self.0.request.template = v.map(|x| x.into());
334 self
335 }
336
337 /// Sets the value of [request_id][crate::model::CreateTemplateRequest::request_id].
338 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
339 self.0.request.request_id = v.into();
340 self
341 }
342 }
343
344 #[doc(hidden)]
345 impl gax::options::internal::RequestBuilder for CreateTemplate {
346 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
347 &mut self.0.options
348 }
349 }
350
351 /// The request builder for [ModelArmor::update_template][crate::client::ModelArmor::update_template] calls.
352 ///
353 /// # Example
354 /// ```no_run
355 /// # use google_cloud_modelarmor_v1::builder;
356 /// use builder::model_armor::UpdateTemplate;
357 /// # tokio_test::block_on(async {
358 ///
359 /// let builder = prepare_request_builder();
360 /// let response = builder.send().await?;
361 /// # gax::Result::<()>::Ok(()) });
362 ///
363 /// fn prepare_request_builder() -> UpdateTemplate {
364 /// # panic!();
365 /// // ... details omitted ...
366 /// }
367 /// ```
368 #[derive(Clone, Debug)]
369 pub struct UpdateTemplate(RequestBuilder<crate::model::UpdateTemplateRequest>);
370
371 impl UpdateTemplate {
372 pub(crate) fn new(
373 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
374 ) -> Self {
375 Self(RequestBuilder::new(stub))
376 }
377
378 /// Sets the full request, replacing any prior values.
379 pub fn with_request<V: Into<crate::model::UpdateTemplateRequest>>(mut self, v: V) -> Self {
380 self.0.request = v.into();
381 self
382 }
383
384 /// Sets all the options, replacing any prior values.
385 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
386 self.0.options = v.into();
387 self
388 }
389
390 /// Sends the request.
391 pub async fn send(self) -> Result<crate::model::Template> {
392 (*self.0.stub)
393 .update_template(self.0.request, self.0.options)
394 .await
395 .map(gax::response::Response::into_body)
396 }
397
398 /// Sets the value of [update_mask][crate::model::UpdateTemplateRequest::update_mask].
399 ///
400 /// This is a **required** field for requests.
401 pub fn set_update_mask<T>(mut self, v: T) -> Self
402 where
403 T: std::convert::Into<wkt::FieldMask>,
404 {
405 self.0.request.update_mask = std::option::Option::Some(v.into());
406 self
407 }
408
409 /// Sets or clears the value of [update_mask][crate::model::UpdateTemplateRequest::update_mask].
410 ///
411 /// This is a **required** field for requests.
412 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
413 where
414 T: std::convert::Into<wkt::FieldMask>,
415 {
416 self.0.request.update_mask = v.map(|x| x.into());
417 self
418 }
419
420 /// Sets the value of [template][crate::model::UpdateTemplateRequest::template].
421 ///
422 /// This is a **required** field for requests.
423 pub fn set_template<T>(mut self, v: T) -> Self
424 where
425 T: std::convert::Into<crate::model::Template>,
426 {
427 self.0.request.template = std::option::Option::Some(v.into());
428 self
429 }
430
431 /// Sets or clears the value of [template][crate::model::UpdateTemplateRequest::template].
432 ///
433 /// This is a **required** field for requests.
434 pub fn set_or_clear_template<T>(mut self, v: std::option::Option<T>) -> Self
435 where
436 T: std::convert::Into<crate::model::Template>,
437 {
438 self.0.request.template = v.map(|x| x.into());
439 self
440 }
441
442 /// Sets the value of [request_id][crate::model::UpdateTemplateRequest::request_id].
443 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
444 self.0.request.request_id = v.into();
445 self
446 }
447 }
448
449 #[doc(hidden)]
450 impl gax::options::internal::RequestBuilder for UpdateTemplate {
451 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
452 &mut self.0.options
453 }
454 }
455
456 /// The request builder for [ModelArmor::delete_template][crate::client::ModelArmor::delete_template] calls.
457 ///
458 /// # Example
459 /// ```no_run
460 /// # use google_cloud_modelarmor_v1::builder;
461 /// use builder::model_armor::DeleteTemplate;
462 /// # tokio_test::block_on(async {
463 ///
464 /// let builder = prepare_request_builder();
465 /// let response = builder.send().await?;
466 /// # gax::Result::<()>::Ok(()) });
467 ///
468 /// fn prepare_request_builder() -> DeleteTemplate {
469 /// # panic!();
470 /// // ... details omitted ...
471 /// }
472 /// ```
473 #[derive(Clone, Debug)]
474 pub struct DeleteTemplate(RequestBuilder<crate::model::DeleteTemplateRequest>);
475
476 impl DeleteTemplate {
477 pub(crate) fn new(
478 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
479 ) -> Self {
480 Self(RequestBuilder::new(stub))
481 }
482
483 /// Sets the full request, replacing any prior values.
484 pub fn with_request<V: Into<crate::model::DeleteTemplateRequest>>(mut self, v: V) -> Self {
485 self.0.request = v.into();
486 self
487 }
488
489 /// Sets all the options, replacing any prior values.
490 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
491 self.0.options = v.into();
492 self
493 }
494
495 /// Sends the request.
496 pub async fn send(self) -> Result<()> {
497 (*self.0.stub)
498 .delete_template(self.0.request, self.0.options)
499 .await
500 .map(gax::response::Response::into_body)
501 }
502
503 /// Sets the value of [name][crate::model::DeleteTemplateRequest::name].
504 ///
505 /// This is a **required** field for requests.
506 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
507 self.0.request.name = v.into();
508 self
509 }
510
511 /// Sets the value of [request_id][crate::model::DeleteTemplateRequest::request_id].
512 pub fn set_request_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
513 self.0.request.request_id = v.into();
514 self
515 }
516 }
517
518 #[doc(hidden)]
519 impl gax::options::internal::RequestBuilder for DeleteTemplate {
520 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
521 &mut self.0.options
522 }
523 }
524
525 /// The request builder for [ModelArmor::get_floor_setting][crate::client::ModelArmor::get_floor_setting] calls.
526 ///
527 /// # Example
528 /// ```no_run
529 /// # use google_cloud_modelarmor_v1::builder;
530 /// use builder::model_armor::GetFloorSetting;
531 /// # tokio_test::block_on(async {
532 ///
533 /// let builder = prepare_request_builder();
534 /// let response = builder.send().await?;
535 /// # gax::Result::<()>::Ok(()) });
536 ///
537 /// fn prepare_request_builder() -> GetFloorSetting {
538 /// # panic!();
539 /// // ... details omitted ...
540 /// }
541 /// ```
542 #[derive(Clone, Debug)]
543 pub struct GetFloorSetting(RequestBuilder<crate::model::GetFloorSettingRequest>);
544
545 impl GetFloorSetting {
546 pub(crate) fn new(
547 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
548 ) -> Self {
549 Self(RequestBuilder::new(stub))
550 }
551
552 /// Sets the full request, replacing any prior values.
553 pub fn with_request<V: Into<crate::model::GetFloorSettingRequest>>(mut self, v: V) -> Self {
554 self.0.request = v.into();
555 self
556 }
557
558 /// Sets all the options, replacing any prior values.
559 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
560 self.0.options = v.into();
561 self
562 }
563
564 /// Sends the request.
565 pub async fn send(self) -> Result<crate::model::FloorSetting> {
566 (*self.0.stub)
567 .get_floor_setting(self.0.request, self.0.options)
568 .await
569 .map(gax::response::Response::into_body)
570 }
571
572 /// Sets the value of [name][crate::model::GetFloorSettingRequest::name].
573 ///
574 /// This is a **required** field for requests.
575 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
576 self.0.request.name = v.into();
577 self
578 }
579 }
580
581 #[doc(hidden)]
582 impl gax::options::internal::RequestBuilder for GetFloorSetting {
583 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
584 &mut self.0.options
585 }
586 }
587
588 /// The request builder for [ModelArmor::update_floor_setting][crate::client::ModelArmor::update_floor_setting] calls.
589 ///
590 /// # Example
591 /// ```no_run
592 /// # use google_cloud_modelarmor_v1::builder;
593 /// use builder::model_armor::UpdateFloorSetting;
594 /// # tokio_test::block_on(async {
595 ///
596 /// let builder = prepare_request_builder();
597 /// let response = builder.send().await?;
598 /// # gax::Result::<()>::Ok(()) });
599 ///
600 /// fn prepare_request_builder() -> UpdateFloorSetting {
601 /// # panic!();
602 /// // ... details omitted ...
603 /// }
604 /// ```
605 #[derive(Clone, Debug)]
606 pub struct UpdateFloorSetting(RequestBuilder<crate::model::UpdateFloorSettingRequest>);
607
608 impl UpdateFloorSetting {
609 pub(crate) fn new(
610 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
611 ) -> Self {
612 Self(RequestBuilder::new(stub))
613 }
614
615 /// Sets the full request, replacing any prior values.
616 pub fn with_request<V: Into<crate::model::UpdateFloorSettingRequest>>(
617 mut self,
618 v: V,
619 ) -> Self {
620 self.0.request = v.into();
621 self
622 }
623
624 /// Sets all the options, replacing any prior values.
625 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
626 self.0.options = v.into();
627 self
628 }
629
630 /// Sends the request.
631 pub async fn send(self) -> Result<crate::model::FloorSetting> {
632 (*self.0.stub)
633 .update_floor_setting(self.0.request, self.0.options)
634 .await
635 .map(gax::response::Response::into_body)
636 }
637
638 /// Sets the value of [floor_setting][crate::model::UpdateFloorSettingRequest::floor_setting].
639 ///
640 /// This is a **required** field for requests.
641 pub fn set_floor_setting<T>(mut self, v: T) -> Self
642 where
643 T: std::convert::Into<crate::model::FloorSetting>,
644 {
645 self.0.request.floor_setting = std::option::Option::Some(v.into());
646 self
647 }
648
649 /// Sets or clears the value of [floor_setting][crate::model::UpdateFloorSettingRequest::floor_setting].
650 ///
651 /// This is a **required** field for requests.
652 pub fn set_or_clear_floor_setting<T>(mut self, v: std::option::Option<T>) -> Self
653 where
654 T: std::convert::Into<crate::model::FloorSetting>,
655 {
656 self.0.request.floor_setting = v.map(|x| x.into());
657 self
658 }
659
660 /// Sets the value of [update_mask][crate::model::UpdateFloorSettingRequest::update_mask].
661 pub fn set_update_mask<T>(mut self, v: T) -> Self
662 where
663 T: std::convert::Into<wkt::FieldMask>,
664 {
665 self.0.request.update_mask = std::option::Option::Some(v.into());
666 self
667 }
668
669 /// Sets or clears the value of [update_mask][crate::model::UpdateFloorSettingRequest::update_mask].
670 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
671 where
672 T: std::convert::Into<wkt::FieldMask>,
673 {
674 self.0.request.update_mask = v.map(|x| x.into());
675 self
676 }
677 }
678
679 #[doc(hidden)]
680 impl gax::options::internal::RequestBuilder for UpdateFloorSetting {
681 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
682 &mut self.0.options
683 }
684 }
685
686 /// The request builder for [ModelArmor::sanitize_user_prompt][crate::client::ModelArmor::sanitize_user_prompt] calls.
687 ///
688 /// # Example
689 /// ```no_run
690 /// # use google_cloud_modelarmor_v1::builder;
691 /// use builder::model_armor::SanitizeUserPrompt;
692 /// # tokio_test::block_on(async {
693 ///
694 /// let builder = prepare_request_builder();
695 /// let response = builder.send().await?;
696 /// # gax::Result::<()>::Ok(()) });
697 ///
698 /// fn prepare_request_builder() -> SanitizeUserPrompt {
699 /// # panic!();
700 /// // ... details omitted ...
701 /// }
702 /// ```
703 #[derive(Clone, Debug)]
704 pub struct SanitizeUserPrompt(RequestBuilder<crate::model::SanitizeUserPromptRequest>);
705
706 impl SanitizeUserPrompt {
707 pub(crate) fn new(
708 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
709 ) -> Self {
710 Self(RequestBuilder::new(stub))
711 }
712
713 /// Sets the full request, replacing any prior values.
714 pub fn with_request<V: Into<crate::model::SanitizeUserPromptRequest>>(
715 mut self,
716 v: V,
717 ) -> Self {
718 self.0.request = v.into();
719 self
720 }
721
722 /// Sets all the options, replacing any prior values.
723 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
724 self.0.options = v.into();
725 self
726 }
727
728 /// Sends the request.
729 pub async fn send(self) -> Result<crate::model::SanitizeUserPromptResponse> {
730 (*self.0.stub)
731 .sanitize_user_prompt(self.0.request, self.0.options)
732 .await
733 .map(gax::response::Response::into_body)
734 }
735
736 /// Sets the value of [name][crate::model::SanitizeUserPromptRequest::name].
737 ///
738 /// This is a **required** field for requests.
739 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
740 self.0.request.name = v.into();
741 self
742 }
743
744 /// Sets the value of [user_prompt_data][crate::model::SanitizeUserPromptRequest::user_prompt_data].
745 ///
746 /// This is a **required** field for requests.
747 pub fn set_user_prompt_data<T>(mut self, v: T) -> Self
748 where
749 T: std::convert::Into<crate::model::DataItem>,
750 {
751 self.0.request.user_prompt_data = std::option::Option::Some(v.into());
752 self
753 }
754
755 /// Sets or clears the value of [user_prompt_data][crate::model::SanitizeUserPromptRequest::user_prompt_data].
756 ///
757 /// This is a **required** field for requests.
758 pub fn set_or_clear_user_prompt_data<T>(mut self, v: std::option::Option<T>) -> Self
759 where
760 T: std::convert::Into<crate::model::DataItem>,
761 {
762 self.0.request.user_prompt_data = v.map(|x| x.into());
763 self
764 }
765
766 /// Sets the value of [multi_language_detection_metadata][crate::model::SanitizeUserPromptRequest::multi_language_detection_metadata].
767 pub fn set_multi_language_detection_metadata<T>(mut self, v: T) -> Self
768 where
769 T: std::convert::Into<crate::model::MultiLanguageDetectionMetadata>,
770 {
771 self.0.request.multi_language_detection_metadata = std::option::Option::Some(v.into());
772 self
773 }
774
775 /// Sets or clears the value of [multi_language_detection_metadata][crate::model::SanitizeUserPromptRequest::multi_language_detection_metadata].
776 pub fn set_or_clear_multi_language_detection_metadata<T>(
777 mut self,
778 v: std::option::Option<T>,
779 ) -> Self
780 where
781 T: std::convert::Into<crate::model::MultiLanguageDetectionMetadata>,
782 {
783 self.0.request.multi_language_detection_metadata = v.map(|x| x.into());
784 self
785 }
786 }
787
788 #[doc(hidden)]
789 impl gax::options::internal::RequestBuilder for SanitizeUserPrompt {
790 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
791 &mut self.0.options
792 }
793 }
794
795 /// The request builder for [ModelArmor::sanitize_model_response][crate::client::ModelArmor::sanitize_model_response] calls.
796 ///
797 /// # Example
798 /// ```no_run
799 /// # use google_cloud_modelarmor_v1::builder;
800 /// use builder::model_armor::SanitizeModelResponse;
801 /// # tokio_test::block_on(async {
802 ///
803 /// let builder = prepare_request_builder();
804 /// let response = builder.send().await?;
805 /// # gax::Result::<()>::Ok(()) });
806 ///
807 /// fn prepare_request_builder() -> SanitizeModelResponse {
808 /// # panic!();
809 /// // ... details omitted ...
810 /// }
811 /// ```
812 #[derive(Clone, Debug)]
813 pub struct SanitizeModelResponse(RequestBuilder<crate::model::SanitizeModelResponseRequest>);
814
815 impl SanitizeModelResponse {
816 pub(crate) fn new(
817 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
818 ) -> Self {
819 Self(RequestBuilder::new(stub))
820 }
821
822 /// Sets the full request, replacing any prior values.
823 pub fn with_request<V: Into<crate::model::SanitizeModelResponseRequest>>(
824 mut self,
825 v: V,
826 ) -> Self {
827 self.0.request = v.into();
828 self
829 }
830
831 /// Sets all the options, replacing any prior values.
832 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
833 self.0.options = v.into();
834 self
835 }
836
837 /// Sends the request.
838 pub async fn send(self) -> Result<crate::model::SanitizeModelResponseResponse> {
839 (*self.0.stub)
840 .sanitize_model_response(self.0.request, self.0.options)
841 .await
842 .map(gax::response::Response::into_body)
843 }
844
845 /// Sets the value of [name][crate::model::SanitizeModelResponseRequest::name].
846 ///
847 /// This is a **required** field for requests.
848 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
849 self.0.request.name = v.into();
850 self
851 }
852
853 /// Sets the value of [model_response_data][crate::model::SanitizeModelResponseRequest::model_response_data].
854 ///
855 /// This is a **required** field for requests.
856 pub fn set_model_response_data<T>(mut self, v: T) -> Self
857 where
858 T: std::convert::Into<crate::model::DataItem>,
859 {
860 self.0.request.model_response_data = std::option::Option::Some(v.into());
861 self
862 }
863
864 /// Sets or clears the value of [model_response_data][crate::model::SanitizeModelResponseRequest::model_response_data].
865 ///
866 /// This is a **required** field for requests.
867 pub fn set_or_clear_model_response_data<T>(mut self, v: std::option::Option<T>) -> Self
868 where
869 T: std::convert::Into<crate::model::DataItem>,
870 {
871 self.0.request.model_response_data = v.map(|x| x.into());
872 self
873 }
874
875 /// Sets the value of [user_prompt][crate::model::SanitizeModelResponseRequest::user_prompt].
876 pub fn set_user_prompt<T: Into<std::string::String>>(mut self, v: T) -> Self {
877 self.0.request.user_prompt = v.into();
878 self
879 }
880
881 /// Sets the value of [multi_language_detection_metadata][crate::model::SanitizeModelResponseRequest::multi_language_detection_metadata].
882 pub fn set_multi_language_detection_metadata<T>(mut self, v: T) -> Self
883 where
884 T: std::convert::Into<crate::model::MultiLanguageDetectionMetadata>,
885 {
886 self.0.request.multi_language_detection_metadata = std::option::Option::Some(v.into());
887 self
888 }
889
890 /// Sets or clears the value of [multi_language_detection_metadata][crate::model::SanitizeModelResponseRequest::multi_language_detection_metadata].
891 pub fn set_or_clear_multi_language_detection_metadata<T>(
892 mut self,
893 v: std::option::Option<T>,
894 ) -> Self
895 where
896 T: std::convert::Into<crate::model::MultiLanguageDetectionMetadata>,
897 {
898 self.0.request.multi_language_detection_metadata = v.map(|x| x.into());
899 self
900 }
901 }
902
903 #[doc(hidden)]
904 impl gax::options::internal::RequestBuilder for SanitizeModelResponse {
905 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
906 &mut self.0.options
907 }
908 }
909
910 /// The request builder for [ModelArmor::list_locations][crate::client::ModelArmor::list_locations] calls.
911 ///
912 /// # Example
913 /// ```no_run
914 /// # use google_cloud_modelarmor_v1::builder;
915 /// use builder::model_armor::ListLocations;
916 /// # tokio_test::block_on(async {
917 /// use gax::paginator::ItemPaginator;
918 ///
919 /// let builder = prepare_request_builder();
920 /// let mut items = builder.by_item();
921 /// while let Some(result) = items.next().await {
922 /// let item = result?;
923 /// }
924 /// # gax::Result::<()>::Ok(()) });
925 ///
926 /// fn prepare_request_builder() -> ListLocations {
927 /// # panic!();
928 /// // ... details omitted ...
929 /// }
930 /// ```
931 #[derive(Clone, Debug)]
932 pub struct ListLocations(RequestBuilder<location::model::ListLocationsRequest>);
933
934 impl ListLocations {
935 pub(crate) fn new(
936 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
937 ) -> Self {
938 Self(RequestBuilder::new(stub))
939 }
940
941 /// Sets the full request, replacing any prior values.
942 pub fn with_request<V: Into<location::model::ListLocationsRequest>>(
943 mut self,
944 v: V,
945 ) -> Self {
946 self.0.request = v.into();
947 self
948 }
949
950 /// Sets all the options, replacing any prior values.
951 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
952 self.0.options = v.into();
953 self
954 }
955
956 /// Sends the request.
957 pub async fn send(self) -> Result<location::model::ListLocationsResponse> {
958 (*self.0.stub)
959 .list_locations(self.0.request, self.0.options)
960 .await
961 .map(gax::response::Response::into_body)
962 }
963
964 /// Streams each page in the collection.
965 pub fn by_page(
966 self,
967 ) -> impl gax::paginator::Paginator<location::model::ListLocationsResponse, gax::error::Error>
968 {
969 use std::clone::Clone;
970 let token = self.0.request.page_token.clone();
971 let execute = move |token: String| {
972 let mut builder = self.clone();
973 builder.0.request = builder.0.request.set_page_token(token);
974 builder.send()
975 };
976 gax::paginator::internal::new_paginator(token, execute)
977 }
978
979 /// Streams each item in the collection.
980 pub fn by_item(
981 self,
982 ) -> impl gax::paginator::ItemPaginator<location::model::ListLocationsResponse, gax::error::Error>
983 {
984 use gax::paginator::Paginator;
985 self.by_page().items()
986 }
987
988 /// Sets the value of [name][location::model::ListLocationsRequest::name].
989 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
990 self.0.request.name = v.into();
991 self
992 }
993
994 /// Sets the value of [filter][location::model::ListLocationsRequest::filter].
995 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
996 self.0.request.filter = v.into();
997 self
998 }
999
1000 /// Sets the value of [page_size][location::model::ListLocationsRequest::page_size].
1001 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1002 self.0.request.page_size = v.into();
1003 self
1004 }
1005
1006 /// Sets the value of [page_token][location::model::ListLocationsRequest::page_token].
1007 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1008 self.0.request.page_token = v.into();
1009 self
1010 }
1011 }
1012
1013 #[doc(hidden)]
1014 impl gax::options::internal::RequestBuilder for ListLocations {
1015 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1016 &mut self.0.options
1017 }
1018 }
1019
1020 /// The request builder for [ModelArmor::get_location][crate::client::ModelArmor::get_location] calls.
1021 ///
1022 /// # Example
1023 /// ```no_run
1024 /// # use google_cloud_modelarmor_v1::builder;
1025 /// use builder::model_armor::GetLocation;
1026 /// # tokio_test::block_on(async {
1027 ///
1028 /// let builder = prepare_request_builder();
1029 /// let response = builder.send().await?;
1030 /// # gax::Result::<()>::Ok(()) });
1031 ///
1032 /// fn prepare_request_builder() -> GetLocation {
1033 /// # panic!();
1034 /// // ... details omitted ...
1035 /// }
1036 /// ```
1037 #[derive(Clone, Debug)]
1038 pub struct GetLocation(RequestBuilder<location::model::GetLocationRequest>);
1039
1040 impl GetLocation {
1041 pub(crate) fn new(
1042 stub: std::sync::Arc<dyn super::super::stub::dynamic::ModelArmor>,
1043 ) -> Self {
1044 Self(RequestBuilder::new(stub))
1045 }
1046
1047 /// Sets the full request, replacing any prior values.
1048 pub fn with_request<V: Into<location::model::GetLocationRequest>>(mut self, v: V) -> Self {
1049 self.0.request = v.into();
1050 self
1051 }
1052
1053 /// Sets all the options, replacing any prior values.
1054 pub fn with_options<V: Into<gax::options::RequestOptions>>(mut self, v: V) -> Self {
1055 self.0.options = v.into();
1056 self
1057 }
1058
1059 /// Sends the request.
1060 pub async fn send(self) -> Result<location::model::Location> {
1061 (*self.0.stub)
1062 .get_location(self.0.request, self.0.options)
1063 .await
1064 .map(gax::response::Response::into_body)
1065 }
1066
1067 /// Sets the value of [name][location::model::GetLocationRequest::name].
1068 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1069 self.0.request.name = v.into();
1070 self
1071 }
1072 }
1073
1074 #[doc(hidden)]
1075 impl gax::options::internal::RequestBuilder for GetLocation {
1076 fn request_options(&mut self) -> &mut gax::options::RequestOptions {
1077 &mut self.0.options
1078 }
1079 }
1080}