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