google_cloud_bigquery/write/generated/gapic_storage/
builder.rs1pub mod read {
19 use crate::Result;
20
21 pub type ClientBuilder = crate::ClientBuilder<client::Factory, gaxi::options::Credentials>;
35
36 pub(crate) mod client {
37 use super::super::super::client::Read;
38 pub struct Factory;
39 impl crate::ClientFactory for Factory {
40 type Client = Read;
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 #[derive(Clone, Debug)]
53 pub(crate) struct RequestBuilder<R: std::default::Default> {
54 stub: std::sync::Arc<dyn super::super::stub::dynamic::Read>,
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(stub: std::sync::Arc<dyn super::super::stub::dynamic::Read>) -> Self {
64 Self {
65 stub,
66 request: R::default(),
67 options: crate::RequestOptions::default(),
68 }
69 }
70 }
71
72 #[derive(Clone, Debug)]
89 pub struct CreateReadSession(
90 RequestBuilder<crate::write::generated::gapic_storage::model::CreateReadSessionRequest>,
91 );
92
93 impl CreateReadSession {
94 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Read>) -> Self {
95 Self(RequestBuilder::new(stub))
96 }
97
98 pub fn with_request<
100 V: Into<crate::write::generated::gapic_storage::model::CreateReadSessionRequest>,
101 >(
102 mut self,
103 v: V,
104 ) -> Self {
105 self.0.request = v.into();
106 self
107 }
108
109 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
111 self.0.options = v.into();
112 self
113 }
114
115 pub async fn send(
117 self,
118 ) -> Result<crate::write::generated::gapic_storage::model::ReadSession> {
119 (*self.0.stub)
120 .create_read_session(self.0.request, self.0.options)
121 .await
122 .map(crate::Response::into_body)
123 }
124
125 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
129 self.0.request.parent = v.into();
130 self
131 }
132
133 pub fn set_read_session<T>(mut self, v: T) -> Self
137 where
138 T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadSession>,
139 {
140 self.0.request.read_session = std::option::Option::Some(v.into());
141 self
142 }
143
144 pub fn set_or_clear_read_session<T>(mut self, v: std::option::Option<T>) -> Self
148 where
149 T: std::convert::Into<crate::write::generated::gapic_storage::model::ReadSession>,
150 {
151 self.0.request.read_session = v.map(|x| x.into());
152 self
153 }
154
155 pub fn set_max_stream_count<T: Into<i32>>(mut self, v: T) -> Self {
157 self.0.request.max_stream_count = v.into();
158 self
159 }
160
161 pub fn set_preferred_min_stream_count<T: Into<i32>>(mut self, v: T) -> Self {
163 self.0.request.preferred_min_stream_count = v.into();
164 self
165 }
166 }
167
168 #[doc(hidden)]
169 impl crate::RequestBuilder for CreateReadSession {
170 fn request_options(&mut self) -> &mut crate::RequestOptions {
171 &mut self.0.options
172 }
173 }
174
175 #[derive(Clone, Debug)]
195 pub struct ReadRows(
196 RequestBuilder<crate::write::generated::gapic_storage::model::ReadRowsRequest>,
197 );
198
199 impl ReadRows {
200 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Read>) -> Self {
201 Self(RequestBuilder::new(stub))
202 }
203
204 pub fn with_request<
206 V: Into<crate::write::generated::gapic_storage::model::ReadRowsRequest>,
207 >(
208 mut self,
209 v: V,
210 ) -> Self {
211 self.0.request = v.into();
212 self
213 }
214
215 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
217 self.0.options = v.into();
218 self
219 }
220
221 pub async fn send(
223 self,
224 ) -> Result<
225 google_cloud_gax::streaming::ResponseStream<
226 crate::write::generated::gapic_storage::model::ReadRowsResponse,
227 >,
228 > {
229 (*self.0.stub)
230 .read_rows(self.0.request, self.0.options)
231 .await
232 }
233
234 pub fn set_read_stream<T: Into<std::string::String>>(mut self, v: T) -> Self {
238 self.0.request.read_stream = v.into();
239 self
240 }
241
242 pub fn set_offset<T: Into<i64>>(mut self, v: T) -> Self {
244 self.0.request.offset = v.into();
245 self
246 }
247
248 pub fn set_output_format_serialization_options<T: Into<Option<crate::write::generated::gapic_storage::model::read_rows_request::OutputFormatSerializationOptions>>>(mut self, v: T) ->Self{
253 self.0.request.output_format_serialization_options = v.into();
254 self
255 }
256
257 pub fn set_arrow_serialization_options<
263 T: std::convert::Into<
264 std::boxed::Box<
265 crate::write::generated::gapic_storage::model::ArrowSerializationOptions,
266 >,
267 >,
268 >(
269 mut self,
270 v: T,
271 ) -> Self {
272 self.0.request = self.0.request.set_arrow_serialization_options(v);
273 self
274 }
275 }
276
277 #[doc(hidden)]
278 impl crate::RequestBuilder for ReadRows {
279 fn request_options(&mut self) -> &mut crate::RequestOptions {
280 &mut self.0.options
281 }
282 }
283
284 #[derive(Clone, Debug)]
301 pub struct SplitReadStream(
302 RequestBuilder<crate::write::generated::gapic_storage::model::SplitReadStreamRequest>,
303 );
304
305 impl SplitReadStream {
306 pub(crate) fn new(stub: std::sync::Arc<dyn super::super::stub::dynamic::Read>) -> Self {
307 Self(RequestBuilder::new(stub))
308 }
309
310 pub fn with_request<
312 V: Into<crate::write::generated::gapic_storage::model::SplitReadStreamRequest>,
313 >(
314 mut self,
315 v: V,
316 ) -> Self {
317 self.0.request = v.into();
318 self
319 }
320
321 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
323 self.0.options = v.into();
324 self
325 }
326
327 pub async fn send(
329 self,
330 ) -> Result<crate::write::generated::gapic_storage::model::SplitReadStreamResponse>
331 {
332 (*self.0.stub)
333 .split_read_stream(self.0.request, self.0.options)
334 .await
335 .map(crate::Response::into_body)
336 }
337
338 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
342 self.0.request.name = v.into();
343 self
344 }
345
346 pub fn set_fraction<T: Into<f64>>(mut self, v: T) -> Self {
348 self.0.request.fraction = v.into();
349 self
350 }
351 }
352
353 #[doc(hidden)]
354 impl crate::RequestBuilder for SplitReadStream {
355 fn request_options(&mut self) -> &mut crate::RequestOptions {
356 &mut self.0.options
357 }
358 }
359}
360
361pub mod big_query_write {
363 use crate::Result;
364
365 #[derive(Clone, Debug)]
367 pub(crate) struct RequestBuilder<R: std::default::Default> {
368 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
369 request: R,
370 options: crate::RequestOptions,
371 }
372
373 impl<R> RequestBuilder<R>
374 where
375 R: std::default::Default,
376 {
377 pub(crate) fn new(
378 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
379 ) -> Self {
380 Self {
381 stub,
382 request: R::default(),
383 options: crate::RequestOptions::default(),
384 }
385 }
386 }
387
388 #[derive(Clone, Debug)]
390 pub(crate) struct BidiStreamBuilder {
391 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
392 options: crate::RequestOptions,
393 }
394
395 impl BidiStreamBuilder {
396 pub(crate) fn new(
397 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
398 ) -> Self {
399 Self {
400 stub,
401 options: crate::RequestOptions::default(),
402 }
403 }
404 }
405
406 #[derive(Clone, Debug)]
408 pub(crate) struct CreateWriteStream(
409 RequestBuilder<crate::write::generated::gapic_storage::model::CreateWriteStreamRequest>,
410 );
411
412 impl CreateWriteStream {
413 pub(crate) fn new(
414 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
415 ) -> Self {
416 Self(RequestBuilder::new(stub))
417 }
418
419 pub fn with_request<
421 V: Into<crate::write::generated::gapic_storage::model::CreateWriteStreamRequest>,
422 >(
423 mut self,
424 v: V,
425 ) -> Self {
426 self.0.request = v.into();
427 self
428 }
429
430 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
432 self.0.options = v.into();
433 self
434 }
435
436 pub async fn send(
438 self,
439 ) -> Result<crate::write::generated::gapic_storage::model::WriteStream> {
440 (*self.0.stub)
441 .create_write_stream(self.0.request, self.0.options)
442 .await
443 .map(crate::Response::into_body)
444 }
445
446 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
450 self.0.request.parent = v.into();
451 self
452 }
453
454 pub fn set_write_stream<T>(mut self, v: T) -> Self
458 where
459 T: std::convert::Into<crate::write::generated::gapic_storage::model::WriteStream>,
460 {
461 self.0.request.write_stream = std::option::Option::Some(v.into());
462 self
463 }
464
465 pub fn set_or_clear_write_stream<T>(mut self, v: std::option::Option<T>) -> Self
469 where
470 T: std::convert::Into<crate::write::generated::gapic_storage::model::WriteStream>,
471 {
472 self.0.request.write_stream = v.map(|x| x.into());
473 self
474 }
475 }
476
477 #[doc(hidden)]
478 impl crate::RequestBuilder for CreateWriteStream {
479 fn request_options(&mut self) -> &mut crate::RequestOptions {
480 &mut self.0.options
481 }
482 }
483
484 #[derive(Clone, Debug)]
486 pub(crate) struct AppendRows(BidiStreamBuilder);
487
488 impl AppendRows {
489 pub(crate) fn new(
490 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
491 ) -> Self {
492 Self(BidiStreamBuilder::new(stub))
493 }
494
495 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
497 self.0.options = v.into();
498 self
499 }
500
501 pub fn build(
503 self,
504 ) -> (
505 google_cloud_gax::streaming::RequestSender<
506 crate::write::generated::gapic_storage::model::AppendRowsRequest,
507 >,
508 google_cloud_gax::streaming::ResponseStream<
509 crate::write::generated::gapic_storage::model::AppendRowsResponse,
510 >,
511 ) {
512 (*self.0.stub).append_rows(self.0.options)
513 }
514 }
515
516 #[doc(hidden)]
517 impl crate::RequestBuilder for AppendRows {
518 fn request_options(&mut self) -> &mut crate::RequestOptions {
519 &mut self.0.options
520 }
521 }
522
523 #[derive(Clone, Debug)]
525 pub(crate) struct GetWriteStream(
526 RequestBuilder<crate::write::generated::gapic_storage::model::GetWriteStreamRequest>,
527 );
528
529 impl GetWriteStream {
530 pub(crate) fn new(
531 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
532 ) -> Self {
533 Self(RequestBuilder::new(stub))
534 }
535
536 pub fn with_request<
538 V: Into<crate::write::generated::gapic_storage::model::GetWriteStreamRequest>,
539 >(
540 mut self,
541 v: V,
542 ) -> Self {
543 self.0.request = v.into();
544 self
545 }
546
547 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
549 self.0.options = v.into();
550 self
551 }
552
553 pub async fn send(
555 self,
556 ) -> Result<crate::write::generated::gapic_storage::model::WriteStream> {
557 (*self.0.stub)
558 .get_write_stream(self.0.request, self.0.options)
559 .await
560 .map(crate::Response::into_body)
561 }
562
563 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
567 self.0.request.name = v.into();
568 self
569 }
570
571 pub fn set_view<T: Into<crate::write::generated::gapic_storage::model::WriteStreamView>>(
573 mut self,
574 v: T,
575 ) -> Self {
576 self.0.request.view = v.into();
577 self
578 }
579 }
580
581 #[doc(hidden)]
582 impl crate::RequestBuilder for GetWriteStream {
583 fn request_options(&mut self) -> &mut crate::RequestOptions {
584 &mut self.0.options
585 }
586 }
587
588 #[derive(Clone, Debug)]
590 pub(crate) struct FinalizeWriteStream(
591 RequestBuilder<crate::write::generated::gapic_storage::model::FinalizeWriteStreamRequest>,
592 );
593
594 impl FinalizeWriteStream {
595 pub(crate) fn new(
596 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
597 ) -> Self {
598 Self(RequestBuilder::new(stub))
599 }
600
601 pub fn with_request<
603 V: Into<crate::write::generated::gapic_storage::model::FinalizeWriteStreamRequest>,
604 >(
605 mut self,
606 v: V,
607 ) -> Self {
608 self.0.request = v.into();
609 self
610 }
611
612 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
614 self.0.options = v.into();
615 self
616 }
617
618 pub async fn send(
620 self,
621 ) -> Result<crate::write::generated::gapic_storage::model::FinalizeWriteStreamResponse>
622 {
623 (*self.0.stub)
624 .finalize_write_stream(self.0.request, self.0.options)
625 .await
626 .map(crate::Response::into_body)
627 }
628
629 pub fn set_name<T: Into<std::string::String>>(mut self, v: T) -> Self {
633 self.0.request.name = v.into();
634 self
635 }
636 }
637
638 #[doc(hidden)]
639 impl crate::RequestBuilder for FinalizeWriteStream {
640 fn request_options(&mut self) -> &mut crate::RequestOptions {
641 &mut self.0.options
642 }
643 }
644
645 #[derive(Clone, Debug)]
647 pub(crate) struct BatchCommitWriteStreams(
648 RequestBuilder<
649 crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsRequest,
650 >,
651 );
652
653 impl BatchCommitWriteStreams {
654 pub(crate) fn new(
655 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
656 ) -> Self {
657 Self(RequestBuilder::new(stub))
658 }
659
660 pub fn with_request<
662 V: Into<crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsRequest>,
663 >(
664 mut self,
665 v: V,
666 ) -> Self {
667 self.0.request = v.into();
668 self
669 }
670
671 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
673 self.0.options = v.into();
674 self
675 }
676
677 pub async fn send(
679 self,
680 ) -> Result<crate::write::generated::gapic_storage::model::BatchCommitWriteStreamsResponse>
681 {
682 (*self.0.stub)
683 .batch_commit_write_streams(self.0.request, self.0.options)
684 .await
685 .map(crate::Response::into_body)
686 }
687
688 pub fn set_parent<T: Into<std::string::String>>(mut self, v: T) -> Self {
692 self.0.request.parent = v.into();
693 self
694 }
695
696 pub fn set_write_streams<T, V>(mut self, v: T) -> Self
700 where
701 T: std::iter::IntoIterator<Item = V>,
702 V: std::convert::Into<std::string::String>,
703 {
704 use std::iter::Iterator;
705 self.0.request.write_streams = v.into_iter().map(|i| i.into()).collect();
706 self
707 }
708 }
709
710 #[doc(hidden)]
711 impl crate::RequestBuilder for BatchCommitWriteStreams {
712 fn request_options(&mut self) -> &mut crate::RequestOptions {
713 &mut self.0.options
714 }
715 }
716
717 #[derive(Clone, Debug)]
719 pub(crate) struct FlushRows(
720 RequestBuilder<crate::write::generated::gapic_storage::model::FlushRowsRequest>,
721 );
722
723 impl FlushRows {
724 pub(crate) fn new(
725 stub: std::sync::Arc<dyn super::super::stub::dynamic::BigQueryWrite>,
726 ) -> Self {
727 Self(RequestBuilder::new(stub))
728 }
729
730 pub fn with_request<
732 V: Into<crate::write::generated::gapic_storage::model::FlushRowsRequest>,
733 >(
734 mut self,
735 v: V,
736 ) -> Self {
737 self.0.request = v.into();
738 self
739 }
740
741 pub fn with_options<V: Into<crate::RequestOptions>>(mut self, v: V) -> Self {
743 self.0.options = v.into();
744 self
745 }
746
747 pub async fn send(
749 self,
750 ) -> Result<crate::write::generated::gapic_storage::model::FlushRowsResponse> {
751 (*self.0.stub)
752 .flush_rows(self.0.request, self.0.options)
753 .await
754 .map(crate::Response::into_body)
755 }
756
757 pub fn set_write_stream<T: Into<std::string::String>>(mut self, v: T) -> Self {
761 self.0.request.write_stream = v.into();
762 self
763 }
764
765 pub fn set_offset<T>(mut self, v: T) -> Self
767 where
768 T: std::convert::Into<wkt::Int64Value>,
769 {
770 self.0.request.offset = std::option::Option::Some(v.into());
771 self
772 }
773
774 pub fn set_or_clear_offset<T>(mut self, v: std::option::Option<T>) -> Self
776 where
777 T: std::convert::Into<wkt::Int64Value>,
778 {
779 self.0.request.offset = v.map(|x| x.into());
780 self
781 }
782 }
783
784 #[doc(hidden)]
785 impl crate::RequestBuilder for FlushRows {
786 fn request_options(&mut self) -> &mut crate::RequestOptions {
787 &mut self.0.options
788 }
789 }
790}