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