google_cloud_grafeas_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 grafeas {
18 use crate::Result;
19
20 /// A builder for [Grafeas][crate::client::Grafeas].
21 ///
22 /// ```
23 /// # async fn sample() -> google_cloud_gax::client_builder::Result<()> {
24 /// # use google_cloud_grafeas_v1::*;
25 /// # use builder::grafeas::ClientBuilder;
26 /// # use client::Grafeas;
27 /// let builder : ClientBuilder = Grafeas::builder();
28 /// let client = builder
29 /// .with_endpoint("https://containeranalysis.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::Grafeas;
37 pub struct Factory;
38 impl crate::ClientFactory for Factory {
39 type Client = Grafeas;
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::Grafeas] 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::Grafeas>,
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(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
63 Self {
64 stub,
65 request: R::default(),
66 options: crate::RequestOptions::default(),
67 }
68 }
69 }
70
71 /// The request builder for [Grafeas::get_occurrence][crate::client::Grafeas::get_occurrence] calls.
72 ///
73 /// # Example
74 /// ```
75 /// # use google_cloud_grafeas_v1::builder::grafeas::GetOccurrence;
76 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
77 ///
78 /// let builder = prepare_request_builder();
79 /// let response = builder.send().await?;
80 /// # Ok(()) }
81 ///
82 /// fn prepare_request_builder() -> GetOccurrence {
83 /// # panic!();
84 /// // ... details omitted ...
85 /// }
86 /// ```
87 #[derive(Clone, Debug)]
88 pub struct GetOccurrence(RequestBuilder<crate::model::GetOccurrenceRequest>);
89
90 impl GetOccurrence {
91 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
92 Self(RequestBuilder::new(stub))
93 }
94
95 /// Sets the full request, replacing any prior values.
96 pub fn with_request<V: Into<crate::model::GetOccurrenceRequest>>(mut self, v: V) -> Self {
97 self.0.request = v.into();
98 self
99 }
100
101 /// Sets all the options, replacing any prior values.
102 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
103 self.0.options = v.into();
104 self
105 }
106
107 /// Sends the request.
108 pub async fn send(self) -> Result<crate::model::Occurrence> {
109 (*self.0.stub)
110 .get_occurrence(self.0.request, self.0.options)
111 .await
112 .map(crate::Response::into_body)
113 }
114
115 /// Sets the value of [name][crate::model::GetOccurrenceRequest::name].
116 ///
117 /// This is a **required** field for requests.
118 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
119 self.0.request.name = v.into();
120 self
121 }
122 }
123
124 #[doc(hidden)]
125 impl crate::RequestBuilder for GetOccurrence {
126 fn request_options(&mut self) -> &mut crate::RequestOptions {
127 &mut self.0.options
128 }
129 }
130
131 /// The request builder for [Grafeas::list_occurrences][crate::client::Grafeas::list_occurrences] calls.
132 ///
133 /// # Example
134 /// ```
135 /// # use google_cloud_grafeas_v1::builder::grafeas::ListOccurrences;
136 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
137 /// use google_cloud_gax::paginator::ItemPaginator;
138 ///
139 /// let builder = prepare_request_builder();
140 /// let mut items = builder.by_item();
141 /// while let Some(result) = items.next().await {
142 /// let item = result?;
143 /// }
144 /// # Ok(()) }
145 ///
146 /// fn prepare_request_builder() -> ListOccurrences {
147 /// # panic!();
148 /// // ... details omitted ...
149 /// }
150 /// ```
151 #[derive(Clone, Debug)]
152 pub struct ListOccurrences(RequestBuilder<crate::model::ListOccurrencesRequest>);
153
154 impl ListOccurrences {
155 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
156 Self(RequestBuilder::new(stub))
157 }
158
159 /// Sets the full request, replacing any prior values.
160 pub fn with_request<V: Into<crate::model::ListOccurrencesRequest>>(mut self, v: V) -> Self {
161 self.0.request = v.into();
162 self
163 }
164
165 /// Sets all the options, replacing any prior values.
166 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
167 self.0.options = v.into();
168 self
169 }
170
171 /// Sends the request.
172 pub async fn send(self) -> Result<crate::model::ListOccurrencesResponse> {
173 (*self.0.stub)
174 .list_occurrences(self.0.request, self.0.options)
175 .await
176 .map(crate::Response::into_body)
177 }
178
179 /// Streams each page in the collection.
180 pub fn by_page(
181 self,
182 ) -> impl google_cloud_gax::paginator::Paginator<
183 crate::model::ListOccurrencesResponse,
184 crate::Error,
185 > {
186 use std::clone::Clone;
187 let token = self.0.request.page_token.clone();
188 let execute = move |token: String| {
189 let mut builder = self.clone();
190 builder.0.request = builder.0.request.set_page_token(token);
191 builder.send()
192 };
193 google_cloud_gax::paginator::internal::new_paginator(token, execute)
194 }
195
196 /// Streams each item in the collection.
197 pub fn by_item(
198 self,
199 ) -> impl google_cloud_gax::paginator::ItemPaginator<
200 crate::model::ListOccurrencesResponse,
201 crate::Error,
202 > {
203 use google_cloud_gax::paginator::Paginator;
204 self.by_page().items()
205 }
206
207 /// Sets the value of [parent][crate::model::ListOccurrencesRequest::parent].
208 ///
209 /// This is a **required** field for requests.
210 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
211 self.0.request.parent = v.into();
212 self
213 }
214
215 /// Sets the value of [filter][crate::model::ListOccurrencesRequest::filter].
216 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
217 self.0.request.filter = v.into();
218 self
219 }
220
221 /// Sets the value of [page_size][crate::model::ListOccurrencesRequest::page_size].
222 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
223 self.0.request.page_size = v.into();
224 self
225 }
226
227 /// Sets the value of [page_token][crate::model::ListOccurrencesRequest::page_token].
228 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
229 self.0.request.page_token = v.into();
230 self
231 }
232
233 /// Sets the value of [return_partial_success][crate::model::ListOccurrencesRequest::return_partial_success].
234 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
235 self.0.request.return_partial_success = v.into();
236 self
237 }
238 }
239
240 #[doc(hidden)]
241 impl crate::RequestBuilder for ListOccurrences {
242 fn request_options(&mut self) -> &mut crate::RequestOptions {
243 &mut self.0.options
244 }
245 }
246
247 /// The request builder for [Grafeas::delete_occurrence][crate::client::Grafeas::delete_occurrence] calls.
248 ///
249 /// # Example
250 /// ```
251 /// # use google_cloud_grafeas_v1::builder::grafeas::DeleteOccurrence;
252 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
253 ///
254 /// let builder = prepare_request_builder();
255 /// let response = builder.send().await?;
256 /// # Ok(()) }
257 ///
258 /// fn prepare_request_builder() -> DeleteOccurrence {
259 /// # panic!();
260 /// // ... details omitted ...
261 /// }
262 /// ```
263 #[derive(Clone, Debug)]
264 pub struct DeleteOccurrence(RequestBuilder<crate::model::DeleteOccurrenceRequest>);
265
266 impl DeleteOccurrence {
267 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
268 Self(RequestBuilder::new(stub))
269 }
270
271 /// Sets the full request, replacing any prior values.
272 pub fn with_request<V: Into<crate::model::DeleteOccurrenceRequest>>(
273 mut self,
274 v: V,
275 ) -> Self {
276 self.0.request = v.into();
277 self
278 }
279
280 /// Sets all the options, replacing any prior values.
281 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
282 self.0.options = v.into();
283 self
284 }
285
286 /// Sends the request.
287 pub async fn send(self) -> Result<()> {
288 (*self.0.stub)
289 .delete_occurrence(self.0.request, self.0.options)
290 .await
291 .map(crate::Response::into_body)
292 }
293
294 /// Sets the value of [name][crate::model::DeleteOccurrenceRequest::name].
295 ///
296 /// This is a **required** field for requests.
297 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
298 self.0.request.name = v.into();
299 self
300 }
301 }
302
303 #[doc(hidden)]
304 impl crate::RequestBuilder for DeleteOccurrence {
305 fn request_options(&mut self) -> &mut crate::RequestOptions {
306 &mut self.0.options
307 }
308 }
309
310 /// The request builder for [Grafeas::create_occurrence][crate::client::Grafeas::create_occurrence] calls.
311 ///
312 /// # Example
313 /// ```
314 /// # use google_cloud_grafeas_v1::builder::grafeas::CreateOccurrence;
315 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
316 ///
317 /// let builder = prepare_request_builder();
318 /// let response = builder.send().await?;
319 /// # Ok(()) }
320 ///
321 /// fn prepare_request_builder() -> CreateOccurrence {
322 /// # panic!();
323 /// // ... details omitted ...
324 /// }
325 /// ```
326 #[derive(Clone, Debug)]
327 pub struct CreateOccurrence(RequestBuilder<crate::model::CreateOccurrenceRequest>);
328
329 impl CreateOccurrence {
330 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
331 Self(RequestBuilder::new(stub))
332 }
333
334 /// Sets the full request, replacing any prior values.
335 pub fn with_request<V: Into<crate::model::CreateOccurrenceRequest>>(
336 mut self,
337 v: V,
338 ) -> Self {
339 self.0.request = v.into();
340 self
341 }
342
343 /// Sets all the options, replacing any prior values.
344 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
345 self.0.options = v.into();
346 self
347 }
348
349 /// Sends the request.
350 pub async fn send(self) -> Result<crate::model::Occurrence> {
351 (*self.0.stub)
352 .create_occurrence(self.0.request, self.0.options)
353 .await
354 .map(crate::Response::into_body)
355 }
356
357 /// Sets the value of [parent][crate::model::CreateOccurrenceRequest::parent].
358 ///
359 /// This is a **required** field for requests.
360 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
361 self.0.request.parent = v.into();
362 self
363 }
364
365 /// Sets the value of [occurrence][crate::model::CreateOccurrenceRequest::occurrence].
366 ///
367 /// This is a **required** field for requests.
368 pub fn set_occurrence<T>(mut self, v: T) -> Self
369 where
370 T: std::convert::Into<crate::model::Occurrence>,
371 {
372 self.0.request.occurrence = std::option::Option::Some(v.into());
373 self
374 }
375
376 /// Sets or clears the value of [occurrence][crate::model::CreateOccurrenceRequest::occurrence].
377 ///
378 /// This is a **required** field for requests.
379 pub fn set_or_clear_occurrence<T>(mut self, v: std::option::Option<T>) -> Self
380 where
381 T: std::convert::Into<crate::model::Occurrence>,
382 {
383 self.0.request.occurrence = v.map(|x| x.into());
384 self
385 }
386 }
387
388 #[doc(hidden)]
389 impl crate::RequestBuilder for CreateOccurrence {
390 fn request_options(&mut self) -> &mut crate::RequestOptions {
391 &mut self.0.options
392 }
393 }
394
395 /// The request builder for [Grafeas::batch_create_occurrences][crate::client::Grafeas::batch_create_occurrences] calls.
396 ///
397 /// # Example
398 /// ```
399 /// # use google_cloud_grafeas_v1::builder::grafeas::BatchCreateOccurrences;
400 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
401 ///
402 /// let builder = prepare_request_builder();
403 /// let response = builder.send().await?;
404 /// # Ok(()) }
405 ///
406 /// fn prepare_request_builder() -> BatchCreateOccurrences {
407 /// # panic!();
408 /// // ... details omitted ...
409 /// }
410 /// ```
411 #[derive(Clone, Debug)]
412 pub struct BatchCreateOccurrences(RequestBuilder<crate::model::BatchCreateOccurrencesRequest>);
413
414 impl BatchCreateOccurrences {
415 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
416 Self(RequestBuilder::new(stub))
417 }
418
419 /// Sets the full request, replacing any prior values.
420 pub fn with_request<V: Into<crate::model::BatchCreateOccurrencesRequest>>(
421 mut self,
422 v: V,
423 ) -> Self {
424 self.0.request = v.into();
425 self
426 }
427
428 /// Sets all the options, replacing any prior values.
429 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
430 self.0.options = v.into();
431 self
432 }
433
434 /// Sends the request.
435 pub async fn send(self) -> Result<crate::model::BatchCreateOccurrencesResponse> {
436 (*self.0.stub)
437 .batch_create_occurrences(self.0.request, self.0.options)
438 .await
439 .map(crate::Response::into_body)
440 }
441
442 /// Sets the value of [parent][crate::model::BatchCreateOccurrencesRequest::parent].
443 ///
444 /// This is a **required** field for requests.
445 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
446 self.0.request.parent = v.into();
447 self
448 }
449
450 /// Sets the value of [occurrences][crate::model::BatchCreateOccurrencesRequest::occurrences].
451 ///
452 /// This is a **required** field for requests.
453 pub fn set_occurrences<T, V>(mut self, v: T) -> Self
454 where
455 T: std::iter::IntoIterator<Item = V>,
456 V: std::convert::Into<crate::model::Occurrence>,
457 {
458 use std::iter::Iterator;
459 self.0.request.occurrences = v.into_iter().map(|i| i.into()).collect();
460 self
461 }
462 }
463
464 #[doc(hidden)]
465 impl crate::RequestBuilder for BatchCreateOccurrences {
466 fn request_options(&mut self) -> &mut crate::RequestOptions {
467 &mut self.0.options
468 }
469 }
470
471 /// The request builder for [Grafeas::update_occurrence][crate::client::Grafeas::update_occurrence] calls.
472 ///
473 /// # Example
474 /// ```
475 /// # use google_cloud_grafeas_v1::builder::grafeas::UpdateOccurrence;
476 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
477 ///
478 /// let builder = prepare_request_builder();
479 /// let response = builder.send().await?;
480 /// # Ok(()) }
481 ///
482 /// fn prepare_request_builder() -> UpdateOccurrence {
483 /// # panic!();
484 /// // ... details omitted ...
485 /// }
486 /// ```
487 #[derive(Clone, Debug)]
488 pub struct UpdateOccurrence(RequestBuilder<crate::model::UpdateOccurrenceRequest>);
489
490 impl UpdateOccurrence {
491 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
492 Self(RequestBuilder::new(stub))
493 }
494
495 /// Sets the full request, replacing any prior values.
496 pub fn with_request<V: Into<crate::model::UpdateOccurrenceRequest>>(
497 mut self,
498 v: V,
499 ) -> Self {
500 self.0.request = v.into();
501 self
502 }
503
504 /// Sets all the options, replacing any prior values.
505 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
506 self.0.options = v.into();
507 self
508 }
509
510 /// Sends the request.
511 pub async fn send(self) -> Result<crate::model::Occurrence> {
512 (*self.0.stub)
513 .update_occurrence(self.0.request, self.0.options)
514 .await
515 .map(crate::Response::into_body)
516 }
517
518 /// Sets the value of [name][crate::model::UpdateOccurrenceRequest::name].
519 ///
520 /// This is a **required** field for requests.
521 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
522 self.0.request.name = v.into();
523 self
524 }
525
526 /// Sets the value of [occurrence][crate::model::UpdateOccurrenceRequest::occurrence].
527 ///
528 /// This is a **required** field for requests.
529 pub fn set_occurrence<T>(mut self, v: T) -> Self
530 where
531 T: std::convert::Into<crate::model::Occurrence>,
532 {
533 self.0.request.occurrence = std::option::Option::Some(v.into());
534 self
535 }
536
537 /// Sets or clears the value of [occurrence][crate::model::UpdateOccurrenceRequest::occurrence].
538 ///
539 /// This is a **required** field for requests.
540 pub fn set_or_clear_occurrence<T>(mut self, v: std::option::Option<T>) -> Self
541 where
542 T: std::convert::Into<crate::model::Occurrence>,
543 {
544 self.0.request.occurrence = v.map(|x| x.into());
545 self
546 }
547
548 /// Sets the value of [update_mask][crate::model::UpdateOccurrenceRequest::update_mask].
549 pub fn set_update_mask<T>(mut self, v: T) -> Self
550 where
551 T: std::convert::Into<wkt::FieldMask>,
552 {
553 self.0.request.update_mask = std::option::Option::Some(v.into());
554 self
555 }
556
557 /// Sets or clears the value of [update_mask][crate::model::UpdateOccurrenceRequest::update_mask].
558 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
559 where
560 T: std::convert::Into<wkt::FieldMask>,
561 {
562 self.0.request.update_mask = v.map(|x| x.into());
563 self
564 }
565 }
566
567 #[doc(hidden)]
568 impl crate::RequestBuilder for UpdateOccurrence {
569 fn request_options(&mut self) -> &mut crate::RequestOptions {
570 &mut self.0.options
571 }
572 }
573
574 /// The request builder for [Grafeas::get_occurrence_note][crate::client::Grafeas::get_occurrence_note] calls.
575 ///
576 /// # Example
577 /// ```
578 /// # use google_cloud_grafeas_v1::builder::grafeas::GetOccurrenceNote;
579 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
580 ///
581 /// let builder = prepare_request_builder();
582 /// let response = builder.send().await?;
583 /// # Ok(()) }
584 ///
585 /// fn prepare_request_builder() -> GetOccurrenceNote {
586 /// # panic!();
587 /// // ... details omitted ...
588 /// }
589 /// ```
590 #[derive(Clone, Debug)]
591 pub struct GetOccurrenceNote(RequestBuilder<crate::model::GetOccurrenceNoteRequest>);
592
593 impl GetOccurrenceNote {
594 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
595 Self(RequestBuilder::new(stub))
596 }
597
598 /// Sets the full request, replacing any prior values.
599 pub fn with_request<V: Into<crate::model::GetOccurrenceNoteRequest>>(
600 mut self,
601 v: V,
602 ) -> Self {
603 self.0.request = v.into();
604 self
605 }
606
607 /// Sets all the options, replacing any prior values.
608 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
609 self.0.options = v.into();
610 self
611 }
612
613 /// Sends the request.
614 pub async fn send(self) -> Result<crate::model::Note> {
615 (*self.0.stub)
616 .get_occurrence_note(self.0.request, self.0.options)
617 .await
618 .map(crate::Response::into_body)
619 }
620
621 /// Sets the value of [name][crate::model::GetOccurrenceNoteRequest::name].
622 ///
623 /// This is a **required** field for requests.
624 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
625 self.0.request.name = v.into();
626 self
627 }
628 }
629
630 #[doc(hidden)]
631 impl crate::RequestBuilder for GetOccurrenceNote {
632 fn request_options(&mut self) -> &mut crate::RequestOptions {
633 &mut self.0.options
634 }
635 }
636
637 /// The request builder for [Grafeas::get_note][crate::client::Grafeas::get_note] calls.
638 ///
639 /// # Example
640 /// ```
641 /// # use google_cloud_grafeas_v1::builder::grafeas::GetNote;
642 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
643 ///
644 /// let builder = prepare_request_builder();
645 /// let response = builder.send().await?;
646 /// # Ok(()) }
647 ///
648 /// fn prepare_request_builder() -> GetNote {
649 /// # panic!();
650 /// // ... details omitted ...
651 /// }
652 /// ```
653 #[derive(Clone, Debug)]
654 pub struct GetNote(RequestBuilder<crate::model::GetNoteRequest>);
655
656 impl GetNote {
657 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
658 Self(RequestBuilder::new(stub))
659 }
660
661 /// Sets the full request, replacing any prior values.
662 pub fn with_request<V: Into<crate::model::GetNoteRequest>>(mut self, v: V) -> Self {
663 self.0.request = v.into();
664 self
665 }
666
667 /// Sets all the options, replacing any prior values.
668 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
669 self.0.options = v.into();
670 self
671 }
672
673 /// Sends the request.
674 pub async fn send(self) -> Result<crate::model::Note> {
675 (*self.0.stub)
676 .get_note(self.0.request, self.0.options)
677 .await
678 .map(crate::Response::into_body)
679 }
680
681 /// Sets the value of [name][crate::model::GetNoteRequest::name].
682 ///
683 /// This is a **required** field for requests.
684 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
685 self.0.request.name = v.into();
686 self
687 }
688 }
689
690 #[doc(hidden)]
691 impl crate::RequestBuilder for GetNote {
692 fn request_options(&mut self) -> &mut crate::RequestOptions {
693 &mut self.0.options
694 }
695 }
696
697 /// The request builder for [Grafeas::list_notes][crate::client::Grafeas::list_notes] calls.
698 ///
699 /// # Example
700 /// ```
701 /// # use google_cloud_grafeas_v1::builder::grafeas::ListNotes;
702 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
703 /// use google_cloud_gax::paginator::ItemPaginator;
704 ///
705 /// let builder = prepare_request_builder();
706 /// let mut items = builder.by_item();
707 /// while let Some(result) = items.next().await {
708 /// let item = result?;
709 /// }
710 /// # Ok(()) }
711 ///
712 /// fn prepare_request_builder() -> ListNotes {
713 /// # panic!();
714 /// // ... details omitted ...
715 /// }
716 /// ```
717 #[derive(Clone, Debug)]
718 pub struct ListNotes(RequestBuilder<crate::model::ListNotesRequest>);
719
720 impl ListNotes {
721 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
722 Self(RequestBuilder::new(stub))
723 }
724
725 /// Sets the full request, replacing any prior values.
726 pub fn with_request<V: Into<crate::model::ListNotesRequest>>(mut self, v: V) -> Self {
727 self.0.request = v.into();
728 self
729 }
730
731 /// Sets all the options, replacing any prior values.
732 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
733 self.0.options = v.into();
734 self
735 }
736
737 /// Sends the request.
738 pub async fn send(self) -> Result<crate::model::ListNotesResponse> {
739 (*self.0.stub)
740 .list_notes(self.0.request, self.0.options)
741 .await
742 .map(crate::Response::into_body)
743 }
744
745 /// Streams each page in the collection.
746 pub fn by_page(
747 self,
748 ) -> impl google_cloud_gax::paginator::Paginator<crate::model::ListNotesResponse, crate::Error>
749 {
750 use std::clone::Clone;
751 let token = self.0.request.page_token.clone();
752 let execute = move |token: String| {
753 let mut builder = self.clone();
754 builder.0.request = builder.0.request.set_page_token(token);
755 builder.send()
756 };
757 google_cloud_gax::paginator::internal::new_paginator(token, execute)
758 }
759
760 /// Streams each item in the collection.
761 pub fn by_item(
762 self,
763 ) -> impl google_cloud_gax::paginator::ItemPaginator<crate::model::ListNotesResponse, crate::Error>
764 {
765 use google_cloud_gax::paginator::Paginator;
766 self.by_page().items()
767 }
768
769 /// Sets the value of [parent][crate::model::ListNotesRequest::parent].
770 ///
771 /// This is a **required** field for requests.
772 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
773 self.0.request.parent = v.into();
774 self
775 }
776
777 /// Sets the value of [filter][crate::model::ListNotesRequest::filter].
778 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
779 self.0.request.filter = v.into();
780 self
781 }
782
783 /// Sets the value of [page_size][crate::model::ListNotesRequest::page_size].
784 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
785 self.0.request.page_size = v.into();
786 self
787 }
788
789 /// Sets the value of [page_token][crate::model::ListNotesRequest::page_token].
790 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
791 self.0.request.page_token = v.into();
792 self
793 }
794
795 /// Sets the value of [return_partial_success][crate::model::ListNotesRequest::return_partial_success].
796 pub fn set_return_partial_success<T: Into<bool>>(mut self, v: T) -> Self {
797 self.0.request.return_partial_success = v.into();
798 self
799 }
800 }
801
802 #[doc(hidden)]
803 impl crate::RequestBuilder for ListNotes {
804 fn request_options(&mut self) -> &mut crate::RequestOptions {
805 &mut self.0.options
806 }
807 }
808
809 /// The request builder for [Grafeas::delete_note][crate::client::Grafeas::delete_note] calls.
810 ///
811 /// # Example
812 /// ```
813 /// # use google_cloud_grafeas_v1::builder::grafeas::DeleteNote;
814 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
815 ///
816 /// let builder = prepare_request_builder();
817 /// let response = builder.send().await?;
818 /// # Ok(()) }
819 ///
820 /// fn prepare_request_builder() -> DeleteNote {
821 /// # panic!();
822 /// // ... details omitted ...
823 /// }
824 /// ```
825 #[derive(Clone, Debug)]
826 pub struct DeleteNote(RequestBuilder<crate::model::DeleteNoteRequest>);
827
828 impl DeleteNote {
829 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
830 Self(RequestBuilder::new(stub))
831 }
832
833 /// Sets the full request, replacing any prior values.
834 pub fn with_request<V: Into<crate::model::DeleteNoteRequest>>(mut self, v: V) -> Self {
835 self.0.request = v.into();
836 self
837 }
838
839 /// Sets all the options, replacing any prior values.
840 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
841 self.0.options = v.into();
842 self
843 }
844
845 /// Sends the request.
846 pub async fn send(self) -> Result<()> {
847 (*self.0.stub)
848 .delete_note(self.0.request, self.0.options)
849 .await
850 .map(crate::Response::into_body)
851 }
852
853 /// Sets the value of [name][crate::model::DeleteNoteRequest::name].
854 ///
855 /// This is a **required** field for requests.
856 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
857 self.0.request.name = v.into();
858 self
859 }
860 }
861
862 #[doc(hidden)]
863 impl crate::RequestBuilder for DeleteNote {
864 fn request_options(&mut self) -> &mut crate::RequestOptions {
865 &mut self.0.options
866 }
867 }
868
869 /// The request builder for [Grafeas::create_note][crate::client::Grafeas::create_note] calls.
870 ///
871 /// # Example
872 /// ```
873 /// # use google_cloud_grafeas_v1::builder::grafeas::CreateNote;
874 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
875 ///
876 /// let builder = prepare_request_builder();
877 /// let response = builder.send().await?;
878 /// # Ok(()) }
879 ///
880 /// fn prepare_request_builder() -> CreateNote {
881 /// # panic!();
882 /// // ... details omitted ...
883 /// }
884 /// ```
885 #[derive(Clone, Debug)]
886 pub struct CreateNote(RequestBuilder<crate::model::CreateNoteRequest>);
887
888 impl CreateNote {
889 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
890 Self(RequestBuilder::new(stub))
891 }
892
893 /// Sets the full request, replacing any prior values.
894 pub fn with_request<V: Into<crate::model::CreateNoteRequest>>(mut self, v: V) -> Self {
895 self.0.request = v.into();
896 self
897 }
898
899 /// Sets all the options, replacing any prior values.
900 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
901 self.0.options = v.into();
902 self
903 }
904
905 /// Sends the request.
906 pub async fn send(self) -> Result<crate::model::Note> {
907 (*self.0.stub)
908 .create_note(self.0.request, self.0.options)
909 .await
910 .map(crate::Response::into_body)
911 }
912
913 /// Sets the value of [parent][crate::model::CreateNoteRequest::parent].
914 ///
915 /// This is a **required** field for requests.
916 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
917 self.0.request.parent = v.into();
918 self
919 }
920
921 /// Sets the value of [note_id][crate::model::CreateNoteRequest::note_id].
922 ///
923 /// This is a **required** field for requests.
924 pub fn set_note_id<T: Into<std::string::String>>(mut self, v: T) -> Self {
925 self.0.request.note_id = v.into();
926 self
927 }
928
929 /// Sets the value of [note][crate::model::CreateNoteRequest::note].
930 ///
931 /// This is a **required** field for requests.
932 pub fn set_note<T>(mut self, v: T) -> Self
933 where
934 T: std::convert::Into<crate::model::Note>,
935 {
936 self.0.request.note = std::option::Option::Some(v.into());
937 self
938 }
939
940 /// Sets or clears the value of [note][crate::model::CreateNoteRequest::note].
941 ///
942 /// This is a **required** field for requests.
943 pub fn set_or_clear_note<T>(mut self, v: std::option::Option<T>) -> Self
944 where
945 T: std::convert::Into<crate::model::Note>,
946 {
947 self.0.request.note = v.map(|x| x.into());
948 self
949 }
950 }
951
952 #[doc(hidden)]
953 impl crate::RequestBuilder for CreateNote {
954 fn request_options(&mut self) -> &mut crate::RequestOptions {
955 &mut self.0.options
956 }
957 }
958
959 /// The request builder for [Grafeas::batch_create_notes][crate::client::Grafeas::batch_create_notes] calls.
960 ///
961 /// # Example
962 /// ```
963 /// # use google_cloud_grafeas_v1::builder::grafeas::BatchCreateNotes;
964 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
965 ///
966 /// let builder = prepare_request_builder();
967 /// let response = builder.send().await?;
968 /// # Ok(()) }
969 ///
970 /// fn prepare_request_builder() -> BatchCreateNotes {
971 /// # panic!();
972 /// // ... details omitted ...
973 /// }
974 /// ```
975 #[derive(Clone, Debug)]
976 pub struct BatchCreateNotes(RequestBuilder<crate::model::BatchCreateNotesRequest>);
977
978 impl BatchCreateNotes {
979 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
980 Self(RequestBuilder::new(stub))
981 }
982
983 /// Sets the full request, replacing any prior values.
984 pub fn with_request<V: Into<crate::model::BatchCreateNotesRequest>>(
985 mut self,
986 v: V,
987 ) -> Self {
988 self.0.request = v.into();
989 self
990 }
991
992 /// Sets all the options, replacing any prior values.
993 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
994 self.0.options = v.into();
995 self
996 }
997
998 /// Sends the request.
999 pub async fn send(self) -> Result<crate::model::BatchCreateNotesResponse> {
1000 (*self.0.stub)
1001 .batch_create_notes(self.0.request, self.0.options)
1002 .await
1003 .map(crate::Response::into_body)
1004 }
1005
1006 /// Sets the value of [parent][crate::model::BatchCreateNotesRequest::parent].
1007 ///
1008 /// This is a **required** field for requests.
1009 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
1010 self.0.request.parent = v.into();
1011 self
1012 }
1013
1014 /// Sets the value of [notes][crate::model::BatchCreateNotesRequest::notes].
1015 ///
1016 /// This is a **required** field for requests.
1017 pub fn set_notes<T, K, V>(mut self, v: T) -> Self
1018 where
1019 T: std::iter::IntoIterator<Item = (K, V)>,
1020 K: std::convert::Into<std::string::String>,
1021 V: std::convert::Into<crate::model::Note>,
1022 {
1023 self.0.request.notes = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1024 self
1025 }
1026 }
1027
1028 #[doc(hidden)]
1029 impl crate::RequestBuilder for BatchCreateNotes {
1030 fn request_options(&mut self) -> &mut crate::RequestOptions {
1031 &mut self.0.options
1032 }
1033 }
1034
1035 /// The request builder for [Grafeas::update_note][crate::client::Grafeas::update_note] calls.
1036 ///
1037 /// # Example
1038 /// ```
1039 /// # use google_cloud_grafeas_v1::builder::grafeas::UpdateNote;
1040 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
1041 ///
1042 /// let builder = prepare_request_builder();
1043 /// let response = builder.send().await?;
1044 /// # Ok(()) }
1045 ///
1046 /// fn prepare_request_builder() -> UpdateNote {
1047 /// # panic!();
1048 /// // ... details omitted ...
1049 /// }
1050 /// ```
1051 #[derive(Clone, Debug)]
1052 pub struct UpdateNote(RequestBuilder<crate::model::UpdateNoteRequest>);
1053
1054 impl UpdateNote {
1055 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
1056 Self(RequestBuilder::new(stub))
1057 }
1058
1059 /// Sets the full request, replacing any prior values.
1060 pub fn with_request<V: Into<crate::model::UpdateNoteRequest>>(mut self, v: V) -> Self {
1061 self.0.request = v.into();
1062 self
1063 }
1064
1065 /// Sets all the options, replacing any prior values.
1066 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1067 self.0.options = v.into();
1068 self
1069 }
1070
1071 /// Sends the request.
1072 pub async fn send(self) -> Result<crate::model::Note> {
1073 (*self.0.stub)
1074 .update_note(self.0.request, self.0.options)
1075 .await
1076 .map(crate::Response::into_body)
1077 }
1078
1079 /// Sets the value of [name][crate::model::UpdateNoteRequest::name].
1080 ///
1081 /// This is a **required** field for requests.
1082 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1083 self.0.request.name = v.into();
1084 self
1085 }
1086
1087 /// Sets the value of [note][crate::model::UpdateNoteRequest::note].
1088 ///
1089 /// This is a **required** field for requests.
1090 pub fn set_note<T>(mut self, v: T) -> Self
1091 where
1092 T: std::convert::Into<crate::model::Note>,
1093 {
1094 self.0.request.note = std::option::Option::Some(v.into());
1095 self
1096 }
1097
1098 /// Sets or clears the value of [note][crate::model::UpdateNoteRequest::note].
1099 ///
1100 /// This is a **required** field for requests.
1101 pub fn set_or_clear_note<T>(mut self, v: std::option::Option<T>) -> Self
1102 where
1103 T: std::convert::Into<crate::model::Note>,
1104 {
1105 self.0.request.note = v.map(|x| x.into());
1106 self
1107 }
1108
1109 /// Sets the value of [update_mask][crate::model::UpdateNoteRequest::update_mask].
1110 pub fn set_update_mask<T>(mut self, v: T) -> Self
1111 where
1112 T: std::convert::Into<wkt::FieldMask>,
1113 {
1114 self.0.request.update_mask = std::option::Option::Some(v.into());
1115 self
1116 }
1117
1118 /// Sets or clears the value of [update_mask][crate::model::UpdateNoteRequest::update_mask].
1119 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
1120 where
1121 T: std::convert::Into<wkt::FieldMask>,
1122 {
1123 self.0.request.update_mask = v.map(|x| x.into());
1124 self
1125 }
1126 }
1127
1128 #[doc(hidden)]
1129 impl crate::RequestBuilder for UpdateNote {
1130 fn request_options(&mut self) -> &mut crate::RequestOptions {
1131 &mut self.0.options
1132 }
1133 }
1134
1135 /// The request builder for [Grafeas::list_note_occurrences][crate::client::Grafeas::list_note_occurrences] calls.
1136 ///
1137 /// # Example
1138 /// ```
1139 /// # use google_cloud_grafeas_v1::builder::grafeas::ListNoteOccurrences;
1140 /// # async fn sample() -> google_cloud_grafeas_v1::Result<()> {
1141 /// use google_cloud_gax::paginator::ItemPaginator;
1142 ///
1143 /// let builder = prepare_request_builder();
1144 /// let mut items = builder.by_item();
1145 /// while let Some(result) = items.next().await {
1146 /// let item = result?;
1147 /// }
1148 /// # Ok(()) }
1149 ///
1150 /// fn prepare_request_builder() -> ListNoteOccurrences {
1151 /// # panic!();
1152 /// // ... details omitted ...
1153 /// }
1154 /// ```
1155 #[derive(Clone, Debug)]
1156 pub struct ListNoteOccurrences(RequestBuilder<crate::model::ListNoteOccurrencesRequest>);
1157
1158 impl ListNoteOccurrences {
1159 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Grafeas>) -> Self {
1160 Self(RequestBuilder::new(stub))
1161 }
1162
1163 /// Sets the full request, replacing any prior values.
1164 pub fn with_request<V: Into<crate::model::ListNoteOccurrencesRequest>>(
1165 mut self,
1166 v: V,
1167 ) -> Self {
1168 self.0.request = v.into();
1169 self
1170 }
1171
1172 /// Sets all the options, replacing any prior values.
1173 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
1174 self.0.options = v.into();
1175 self
1176 }
1177
1178 /// Sends the request.
1179 pub async fn send(self) -> Result<crate::model::ListNoteOccurrencesResponse> {
1180 (*self.0.stub)
1181 .list_note_occurrences(self.0.request, self.0.options)
1182 .await
1183 .map(crate::Response::into_body)
1184 }
1185
1186 /// Streams each page in the collection.
1187 pub fn by_page(
1188 self,
1189 ) -> impl google_cloud_gax::paginator::Paginator<
1190 crate::model::ListNoteOccurrencesResponse,
1191 crate::Error,
1192 > {
1193 use std::clone::Clone;
1194 let token = self.0.request.page_token.clone();
1195 let execute = move |token: String| {
1196 let mut builder = self.clone();
1197 builder.0.request = builder.0.request.set_page_token(token);
1198 builder.send()
1199 };
1200 google_cloud_gax::paginator::internal::new_paginator(token, execute)
1201 }
1202
1203 /// Streams each item in the collection.
1204 pub fn by_item(
1205 self,
1206 ) -> impl google_cloud_gax::paginator::ItemPaginator<
1207 crate::model::ListNoteOccurrencesResponse,
1208 crate::Error,
1209 > {
1210 use google_cloud_gax::paginator::Paginator;
1211 self.by_page().items()
1212 }
1213
1214 /// Sets the value of [name][crate::model::ListNoteOccurrencesRequest::name].
1215 ///
1216 /// This is a **required** field for requests.
1217 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
1218 self.0.request.name = v.into();
1219 self
1220 }
1221
1222 /// Sets the value of [filter][crate::model::ListNoteOccurrencesRequest::filter].
1223 pub fn set_filter<T: Into<std::string::String>>(mut self, v: T) -> Self {
1224 self.0.request.filter = v.into();
1225 self
1226 }
1227
1228 /// Sets the value of [page_size][crate::model::ListNoteOccurrencesRequest::page_size].
1229 pub fn set_page_size<T: Into<i32>>(mut self, v: T) -> Self {
1230 self.0.request.page_size = v.into();
1231 self
1232 }
1233
1234 /// Sets the value of [page_token][crate::model::ListNoteOccurrencesRequest::page_token].
1235 pub fn set_page_token<T: Into<std::string::String>>(mut self, v: T) -> Self {
1236 self.0.request.page_token = v.into();
1237 self
1238 }
1239 }
1240
1241 #[doc(hidden)]
1242 impl crate::RequestBuilder for ListNoteOccurrences {
1243 fn request_options(&mut self) -> &mut crate::RequestOptions {
1244 &mut self.0.options
1245 }
1246 }
1247}