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