google_cloud_pubsub/generated/gapic/model.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#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19
20mod debug;
21mod deserialize;
22mod serialize;
23
24/// A policy constraining the storage of messages published to the topic.
25#[derive(Clone, Default, PartialEq)]
26#[non_exhaustive]
27pub struct MessageStoragePolicy {
28 /// Optional. A list of IDs of Google Cloud regions where messages that are
29 /// published to the topic may be persisted in storage. Messages published by
30 /// publishers running in non-allowed Google Cloud regions (or running outside
31 /// of Google Cloud altogether) are routed for storage in one of the allowed
32 /// regions. An empty list means that no regions are allowed, and is not a
33 /// valid configuration.
34 pub allowed_persistence_regions: std::vec::Vec<std::string::String>,
35
36 /// Optional. If true, `allowed_persistence_regions` is also used to enforce
37 /// in-transit guarantees for messages. That is, Pub/Sub will fail
38 /// Publish operations on this topic and subscribe operations
39 /// on any subscription attached to this topic in any region that is
40 /// not in `allowed_persistence_regions`.
41 pub enforce_in_transit: bool,
42
43 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
44}
45
46impl MessageStoragePolicy {
47 /// Creates a new default instance.
48 pub fn new() -> Self {
49 std::default::Default::default()
50 }
51
52 /// Sets the value of [allowed_persistence_regions][crate::model::MessageStoragePolicy::allowed_persistence_regions].
53 ///
54 /// # Example
55 /// ```ignore,no_run
56 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
57 /// let x = MessageStoragePolicy::new().set_allowed_persistence_regions(["a", "b", "c"]);
58 /// ```
59 pub fn set_allowed_persistence_regions<T, V>(mut self, v: T) -> Self
60 where
61 T: std::iter::IntoIterator<Item = V>,
62 V: std::convert::Into<std::string::String>,
63 {
64 use std::iter::Iterator;
65 self.allowed_persistence_regions = v.into_iter().map(|i| i.into()).collect();
66 self
67 }
68
69 /// Sets the value of [enforce_in_transit][crate::model::MessageStoragePolicy::enforce_in_transit].
70 ///
71 /// # Example
72 /// ```ignore,no_run
73 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
74 /// let x = MessageStoragePolicy::new().set_enforce_in_transit(true);
75 /// ```
76 pub fn set_enforce_in_transit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
77 self.enforce_in_transit = v.into();
78 self
79 }
80}
81
82impl wkt::message::Message for MessageStoragePolicy {
83 fn typename() -> &'static str {
84 "type.googleapis.com/google.pubsub.v1.MessageStoragePolicy"
85 }
86}
87
88/// Settings for validating messages published against a schema.
89#[derive(Clone, Default, PartialEq)]
90#[non_exhaustive]
91pub struct SchemaSettings {
92 /// Required. The name of the schema that messages published should be
93 /// validated against. Format is `projects/{project}/schemas/{schema}`. The
94 /// value of this field will be `_deleted-schema_` if the schema has been
95 /// deleted.
96 pub schema: std::string::String,
97
98 /// Optional. The encoding of messages validated against `schema`.
99 pub encoding: crate::model::Encoding,
100
101 /// Optional. The minimum (inclusive) revision allowed for validating messages.
102 /// If empty or not present, allow any revision to be validated against
103 /// last_revision or any revision created before.
104 pub first_revision_id: std::string::String,
105
106 /// Optional. The maximum (inclusive) revision allowed for validating messages.
107 /// If empty or not present, allow any revision to be validated against
108 /// first_revision or any revision created after.
109 pub last_revision_id: std::string::String,
110
111 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
112}
113
114impl SchemaSettings {
115 /// Creates a new default instance.
116 pub fn new() -> Self {
117 std::default::Default::default()
118 }
119
120 /// Sets the value of [schema][crate::model::SchemaSettings::schema].
121 ///
122 /// # Example
123 /// ```ignore,no_run
124 /// # use google_cloud_pubsub::model::SchemaSettings;
125 /// let x = SchemaSettings::new().set_schema("example");
126 /// ```
127 pub fn set_schema<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
128 self.schema = v.into();
129 self
130 }
131
132 /// Sets the value of [encoding][crate::model::SchemaSettings::encoding].
133 ///
134 /// # Example
135 /// ```ignore,no_run
136 /// # use google_cloud_pubsub::model::SchemaSettings;
137 /// use google_cloud_pubsub::model::Encoding;
138 /// let x0 = SchemaSettings::new().set_encoding(Encoding::Json);
139 /// let x1 = SchemaSettings::new().set_encoding(Encoding::Binary);
140 /// ```
141 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
142 self.encoding = v.into();
143 self
144 }
145
146 /// Sets the value of [first_revision_id][crate::model::SchemaSettings::first_revision_id].
147 ///
148 /// # Example
149 /// ```ignore,no_run
150 /// # use google_cloud_pubsub::model::SchemaSettings;
151 /// let x = SchemaSettings::new().set_first_revision_id("example");
152 /// ```
153 pub fn set_first_revision_id<T: std::convert::Into<std::string::String>>(
154 mut self,
155 v: T,
156 ) -> Self {
157 self.first_revision_id = v.into();
158 self
159 }
160
161 /// Sets the value of [last_revision_id][crate::model::SchemaSettings::last_revision_id].
162 ///
163 /// # Example
164 /// ```ignore,no_run
165 /// # use google_cloud_pubsub::model::SchemaSettings;
166 /// let x = SchemaSettings::new().set_last_revision_id("example");
167 /// ```
168 pub fn set_last_revision_id<T: std::convert::Into<std::string::String>>(
169 mut self,
170 v: T,
171 ) -> Self {
172 self.last_revision_id = v.into();
173 self
174 }
175}
176
177impl wkt::message::Message for SchemaSettings {
178 fn typename() -> &'static str {
179 "type.googleapis.com/google.pubsub.v1.SchemaSettings"
180 }
181}
182
183/// Settings for an ingestion data source on a topic.
184#[derive(Clone, Default, PartialEq)]
185#[non_exhaustive]
186pub struct IngestionDataSourceSettings {
187 /// Optional. Platform Logs settings. If unset, no Platform Logs will be
188 /// generated.
189 pub platform_logs_settings: std::option::Option<crate::model::PlatformLogsSettings>,
190
191 /// Only one source type can have settings set.
192 pub source: std::option::Option<crate::model::ingestion_data_source_settings::Source>,
193
194 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
195}
196
197impl IngestionDataSourceSettings {
198 /// Creates a new default instance.
199 pub fn new() -> Self {
200 std::default::Default::default()
201 }
202
203 /// Sets the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
204 ///
205 /// # Example
206 /// ```ignore,no_run
207 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
208 /// use google_cloud_pubsub::model::PlatformLogsSettings;
209 /// let x = IngestionDataSourceSettings::new().set_platform_logs_settings(PlatformLogsSettings::default()/* use setters */);
210 /// ```
211 pub fn set_platform_logs_settings<T>(mut self, v: T) -> Self
212 where
213 T: std::convert::Into<crate::model::PlatformLogsSettings>,
214 {
215 self.platform_logs_settings = std::option::Option::Some(v.into());
216 self
217 }
218
219 /// Sets or clears the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
220 ///
221 /// # Example
222 /// ```ignore,no_run
223 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
224 /// use google_cloud_pubsub::model::PlatformLogsSettings;
225 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(Some(PlatformLogsSettings::default()/* use setters */));
226 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(None::<PlatformLogsSettings>);
227 /// ```
228 pub fn set_or_clear_platform_logs_settings<T>(mut self, v: std::option::Option<T>) -> Self
229 where
230 T: std::convert::Into<crate::model::PlatformLogsSettings>,
231 {
232 self.platform_logs_settings = v.map(|x| x.into());
233 self
234 }
235
236 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source].
237 ///
238 /// Note that all the setters affecting `source` are mutually
239 /// exclusive.
240 ///
241 /// # Example
242 /// ```ignore,no_run
243 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
244 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
245 /// let x = IngestionDataSourceSettings::new().set_source(Some(
246 /// google_cloud_pubsub::model::ingestion_data_source_settings::Source::AwsKinesis(AwsKinesis::default().into())));
247 /// ```
248 pub fn set_source<
249 T: std::convert::Into<
250 std::option::Option<crate::model::ingestion_data_source_settings::Source>,
251 >,
252 >(
253 mut self,
254 v: T,
255 ) -> Self {
256 self.source = v.into();
257 self
258 }
259
260 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
261 /// if it holds a `AwsKinesis`, `None` if the field is not set or
262 /// holds a different branch.
263 pub fn aws_kinesis(
264 &self,
265 ) -> std::option::Option<
266 &std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
267 > {
268 #[allow(unreachable_patterns)]
269 self.source.as_ref().and_then(|v| match v {
270 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v) => {
271 std::option::Option::Some(v)
272 }
273 _ => std::option::Option::None,
274 })
275 }
276
277 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
278 /// to hold a `AwsKinesis`.
279 ///
280 /// Note that all the setters affecting `source` are
281 /// mutually exclusive.
282 ///
283 /// # Example
284 /// ```ignore,no_run
285 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
286 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
287 /// let x = IngestionDataSourceSettings::new().set_aws_kinesis(AwsKinesis::default()/* use setters */);
288 /// assert!(x.aws_kinesis().is_some());
289 /// assert!(x.cloud_storage().is_none());
290 /// assert!(x.azure_event_hubs().is_none());
291 /// assert!(x.aws_msk().is_none());
292 /// assert!(x.confluent_cloud().is_none());
293 /// ```
294 pub fn set_aws_kinesis<
295 T: std::convert::Into<
296 std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
297 >,
298 >(
299 mut self,
300 v: T,
301 ) -> Self {
302 self.source = std::option::Option::Some(
303 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v.into()),
304 );
305 self
306 }
307
308 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
309 /// if it holds a `CloudStorage`, `None` if the field is not set or
310 /// holds a different branch.
311 pub fn cloud_storage(
312 &self,
313 ) -> std::option::Option<
314 &std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
315 > {
316 #[allow(unreachable_patterns)]
317 self.source.as_ref().and_then(|v| match v {
318 crate::model::ingestion_data_source_settings::Source::CloudStorage(v) => {
319 std::option::Option::Some(v)
320 }
321 _ => std::option::Option::None,
322 })
323 }
324
325 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
326 /// to hold a `CloudStorage`.
327 ///
328 /// Note that all the setters affecting `source` are
329 /// mutually exclusive.
330 ///
331 /// # Example
332 /// ```ignore,no_run
333 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
334 /// use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
335 /// let x = IngestionDataSourceSettings::new().set_cloud_storage(CloudStorage::default()/* use setters */);
336 /// assert!(x.cloud_storage().is_some());
337 /// assert!(x.aws_kinesis().is_none());
338 /// assert!(x.azure_event_hubs().is_none());
339 /// assert!(x.aws_msk().is_none());
340 /// assert!(x.confluent_cloud().is_none());
341 /// ```
342 pub fn set_cloud_storage<
343 T: std::convert::Into<
344 std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
345 >,
346 >(
347 mut self,
348 v: T,
349 ) -> Self {
350 self.source = std::option::Option::Some(
351 crate::model::ingestion_data_source_settings::Source::CloudStorage(v.into()),
352 );
353 self
354 }
355
356 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
357 /// if it holds a `AzureEventHubs`, `None` if the field is not set or
358 /// holds a different branch.
359 pub fn azure_event_hubs(
360 &self,
361 ) -> std::option::Option<
362 &std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
363 > {
364 #[allow(unreachable_patterns)]
365 self.source.as_ref().and_then(|v| match v {
366 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v) => {
367 std::option::Option::Some(v)
368 }
369 _ => std::option::Option::None,
370 })
371 }
372
373 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
374 /// to hold a `AzureEventHubs`.
375 ///
376 /// Note that all the setters affecting `source` are
377 /// mutually exclusive.
378 ///
379 /// # Example
380 /// ```ignore,no_run
381 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
382 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
383 /// let x = IngestionDataSourceSettings::new().set_azure_event_hubs(AzureEventHubs::default()/* use setters */);
384 /// assert!(x.azure_event_hubs().is_some());
385 /// assert!(x.aws_kinesis().is_none());
386 /// assert!(x.cloud_storage().is_none());
387 /// assert!(x.aws_msk().is_none());
388 /// assert!(x.confluent_cloud().is_none());
389 /// ```
390 pub fn set_azure_event_hubs<
391 T: std::convert::Into<
392 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
393 >,
394 >(
395 mut self,
396 v: T,
397 ) -> Self {
398 self.source = std::option::Option::Some(
399 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v.into()),
400 );
401 self
402 }
403
404 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
405 /// if it holds a `AwsMsk`, `None` if the field is not set or
406 /// holds a different branch.
407 pub fn aws_msk(
408 &self,
409 ) -> std::option::Option<&std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>
410 {
411 #[allow(unreachable_patterns)]
412 self.source.as_ref().and_then(|v| match v {
413 crate::model::ingestion_data_source_settings::Source::AwsMsk(v) => {
414 std::option::Option::Some(v)
415 }
416 _ => std::option::Option::None,
417 })
418 }
419
420 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
421 /// to hold a `AwsMsk`.
422 ///
423 /// Note that all the setters affecting `source` are
424 /// mutually exclusive.
425 ///
426 /// # Example
427 /// ```ignore,no_run
428 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
429 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
430 /// let x = IngestionDataSourceSettings::new().set_aws_msk(AwsMsk::default()/* use setters */);
431 /// assert!(x.aws_msk().is_some());
432 /// assert!(x.aws_kinesis().is_none());
433 /// assert!(x.cloud_storage().is_none());
434 /// assert!(x.azure_event_hubs().is_none());
435 /// assert!(x.confluent_cloud().is_none());
436 /// ```
437 pub fn set_aws_msk<
438 T: std::convert::Into<std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>,
439 >(
440 mut self,
441 v: T,
442 ) -> Self {
443 self.source = std::option::Option::Some(
444 crate::model::ingestion_data_source_settings::Source::AwsMsk(v.into()),
445 );
446 self
447 }
448
449 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
450 /// if it holds a `ConfluentCloud`, `None` if the field is not set or
451 /// holds a different branch.
452 pub fn confluent_cloud(
453 &self,
454 ) -> std::option::Option<
455 &std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
456 > {
457 #[allow(unreachable_patterns)]
458 self.source.as_ref().and_then(|v| match v {
459 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v) => {
460 std::option::Option::Some(v)
461 }
462 _ => std::option::Option::None,
463 })
464 }
465
466 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
467 /// to hold a `ConfluentCloud`.
468 ///
469 /// Note that all the setters affecting `source` are
470 /// mutually exclusive.
471 ///
472 /// # Example
473 /// ```ignore,no_run
474 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
475 /// use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
476 /// let x = IngestionDataSourceSettings::new().set_confluent_cloud(ConfluentCloud::default()/* use setters */);
477 /// assert!(x.confluent_cloud().is_some());
478 /// assert!(x.aws_kinesis().is_none());
479 /// assert!(x.cloud_storage().is_none());
480 /// assert!(x.azure_event_hubs().is_none());
481 /// assert!(x.aws_msk().is_none());
482 /// ```
483 pub fn set_confluent_cloud<
484 T: std::convert::Into<
485 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
486 >,
487 >(
488 mut self,
489 v: T,
490 ) -> Self {
491 self.source = std::option::Option::Some(
492 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v.into()),
493 );
494 self
495 }
496}
497
498impl wkt::message::Message for IngestionDataSourceSettings {
499 fn typename() -> &'static str {
500 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings"
501 }
502}
503
504/// Defines additional types related to [IngestionDataSourceSettings].
505pub mod ingestion_data_source_settings {
506 #[allow(unused_imports)]
507 use super::*;
508
509 /// Ingestion settings for Amazon Kinesis Data Streams.
510 #[derive(Clone, Default, PartialEq)]
511 #[non_exhaustive]
512 pub struct AwsKinesis {
513 /// Output only. An output-only field that indicates the state of the Kinesis
514 /// ingestion source.
515 pub state: crate::model::ingestion_data_source_settings::aws_kinesis::State,
516
517 /// Required. The Kinesis stream ARN to ingest data from.
518 pub stream_arn: std::string::String,
519
520 /// Required. The Kinesis consumer ARN to used for ingestion in Enhanced
521 /// Fan-Out mode. The consumer must be already created and ready to be used.
522 pub consumer_arn: std::string::String,
523
524 /// Required. AWS role ARN to be used for Federated Identity authentication
525 /// with Kinesis. Check the Pub/Sub docs for how to set up this role and the
526 /// required permissions that need to be attached to it.
527 pub aws_role_arn: std::string::String,
528
529 /// Required. The GCP service account to be used for Federated Identity
530 /// authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for
531 /// the provided role). The `aws_role_arn` must be set up with
532 /// `accounts.google.com:sub` equals to this service account number.
533 pub gcp_service_account: std::string::String,
534
535 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
536 }
537
538 impl AwsKinesis {
539 /// Creates a new default instance.
540 pub fn new() -> Self {
541 std::default::Default::default()
542 }
543
544 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsKinesis::state].
545 ///
546 /// # Example
547 /// ```ignore,no_run
548 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
549 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_kinesis::State;
550 /// let x0 = AwsKinesis::new().set_state(State::Active);
551 /// let x1 = AwsKinesis::new().set_state(State::KinesisPermissionDenied);
552 /// let x2 = AwsKinesis::new().set_state(State::PublishPermissionDenied);
553 /// ```
554 pub fn set_state<
555 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_kinesis::State>,
556 >(
557 mut self,
558 v: T,
559 ) -> Self {
560 self.state = v.into();
561 self
562 }
563
564 /// Sets the value of [stream_arn][crate::model::ingestion_data_source_settings::AwsKinesis::stream_arn].
565 ///
566 /// # Example
567 /// ```ignore,no_run
568 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
569 /// let x = AwsKinesis::new().set_stream_arn("example");
570 /// ```
571 pub fn set_stream_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
572 self.stream_arn = v.into();
573 self
574 }
575
576 /// Sets the value of [consumer_arn][crate::model::ingestion_data_source_settings::AwsKinesis::consumer_arn].
577 ///
578 /// # Example
579 /// ```ignore,no_run
580 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
581 /// let x = AwsKinesis::new().set_consumer_arn("example");
582 /// ```
583 pub fn set_consumer_arn<T: std::convert::Into<std::string::String>>(
584 mut self,
585 v: T,
586 ) -> Self {
587 self.consumer_arn = v.into();
588 self
589 }
590
591 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsKinesis::aws_role_arn].
592 ///
593 /// # Example
594 /// ```ignore,no_run
595 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
596 /// let x = AwsKinesis::new().set_aws_role_arn("example");
597 /// ```
598 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
599 mut self,
600 v: T,
601 ) -> Self {
602 self.aws_role_arn = v.into();
603 self
604 }
605
606 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsKinesis::gcp_service_account].
607 ///
608 /// # Example
609 /// ```ignore,no_run
610 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
611 /// let x = AwsKinesis::new().set_gcp_service_account("example");
612 /// ```
613 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
614 mut self,
615 v: T,
616 ) -> Self {
617 self.gcp_service_account = v.into();
618 self
619 }
620 }
621
622 impl wkt::message::Message for AwsKinesis {
623 fn typename() -> &'static str {
624 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis"
625 }
626 }
627
628 /// Defines additional types related to [AwsKinesis].
629 pub mod aws_kinesis {
630 #[allow(unused_imports)]
631 use super::*;
632
633 /// Possible states for ingestion from Amazon Kinesis Data Streams.
634 ///
635 /// # Working with unknown values
636 ///
637 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
638 /// additional enum variants at any time. Adding new variants is not considered
639 /// a breaking change. Applications should write their code in anticipation of:
640 ///
641 /// - New values appearing in future releases of the client library, **and**
642 /// - New values received dynamically, without application changes.
643 ///
644 /// Please consult the [Working with enums] section in the user guide for some
645 /// guidelines.
646 ///
647 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
648 #[derive(Clone, Debug, PartialEq)]
649 #[non_exhaustive]
650 pub enum State {
651 /// Default value. This value is unused.
652 Unspecified,
653 /// Ingestion is active.
654 Active,
655 /// Permission denied encountered while consuming data from Kinesis.
656 /// This can happen if:
657 ///
658 /// - The provided `aws_role_arn` does not exist or does not have the
659 /// appropriate permissions attached.
660 /// - The provided `aws_role_arn` is not set up properly for Identity
661 /// Federation using `gcp_service_account`.
662 /// - The Pub/Sub SA is not granted the
663 /// `iam.serviceAccounts.getOpenIdToken` permission on
664 /// `gcp_service_account`.
665 KinesisPermissionDenied,
666 /// Permission denied encountered while publishing to the topic. This can
667 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
668 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
669 PublishPermissionDenied,
670 /// The Kinesis stream does not exist.
671 StreamNotFound,
672 /// The Kinesis consumer does not exist.
673 ConsumerNotFound,
674 /// If set, the enum was initialized with an unknown value.
675 ///
676 /// Applications can examine the value using [State::value] or
677 /// [State::name].
678 UnknownValue(state::UnknownValue),
679 }
680
681 #[doc(hidden)]
682 pub mod state {
683 #[allow(unused_imports)]
684 use super::*;
685 #[derive(Clone, Debug, PartialEq)]
686 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
687 }
688
689 impl State {
690 /// Gets the enum value.
691 ///
692 /// Returns `None` if the enum contains an unknown value deserialized from
693 /// the string representation of enums.
694 pub fn value(&self) -> std::option::Option<i32> {
695 match self {
696 Self::Unspecified => std::option::Option::Some(0),
697 Self::Active => std::option::Option::Some(1),
698 Self::KinesisPermissionDenied => std::option::Option::Some(2),
699 Self::PublishPermissionDenied => std::option::Option::Some(3),
700 Self::StreamNotFound => std::option::Option::Some(4),
701 Self::ConsumerNotFound => std::option::Option::Some(5),
702 Self::UnknownValue(u) => u.0.value(),
703 }
704 }
705
706 /// Gets the enum value as a string.
707 ///
708 /// Returns `None` if the enum contains an unknown value deserialized from
709 /// the integer representation of enums.
710 pub fn name(&self) -> std::option::Option<&str> {
711 match self {
712 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
713 Self::Active => std::option::Option::Some("ACTIVE"),
714 Self::KinesisPermissionDenied => {
715 std::option::Option::Some("KINESIS_PERMISSION_DENIED")
716 }
717 Self::PublishPermissionDenied => {
718 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
719 }
720 Self::StreamNotFound => std::option::Option::Some("STREAM_NOT_FOUND"),
721 Self::ConsumerNotFound => std::option::Option::Some("CONSUMER_NOT_FOUND"),
722 Self::UnknownValue(u) => u.0.name(),
723 }
724 }
725 }
726
727 impl std::default::Default for State {
728 fn default() -> Self {
729 use std::convert::From;
730 Self::from(0)
731 }
732 }
733
734 impl std::fmt::Display for State {
735 fn fmt(
736 &self,
737 f: &mut std::fmt::Formatter<'_>,
738 ) -> std::result::Result<(), std::fmt::Error> {
739 wkt::internal::display_enum(f, self.name(), self.value())
740 }
741 }
742
743 impl std::convert::From<i32> for State {
744 fn from(value: i32) -> Self {
745 match value {
746 0 => Self::Unspecified,
747 1 => Self::Active,
748 2 => Self::KinesisPermissionDenied,
749 3 => Self::PublishPermissionDenied,
750 4 => Self::StreamNotFound,
751 5 => Self::ConsumerNotFound,
752 _ => Self::UnknownValue(state::UnknownValue(
753 wkt::internal::UnknownEnumValue::Integer(value),
754 )),
755 }
756 }
757 }
758
759 impl std::convert::From<&str> for State {
760 fn from(value: &str) -> Self {
761 use std::string::ToString;
762 match value {
763 "STATE_UNSPECIFIED" => Self::Unspecified,
764 "ACTIVE" => Self::Active,
765 "KINESIS_PERMISSION_DENIED" => Self::KinesisPermissionDenied,
766 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
767 "STREAM_NOT_FOUND" => Self::StreamNotFound,
768 "CONSUMER_NOT_FOUND" => Self::ConsumerNotFound,
769 _ => Self::UnknownValue(state::UnknownValue(
770 wkt::internal::UnknownEnumValue::String(value.to_string()),
771 )),
772 }
773 }
774 }
775
776 impl serde::ser::Serialize for State {
777 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
778 where
779 S: serde::Serializer,
780 {
781 match self {
782 Self::Unspecified => serializer.serialize_i32(0),
783 Self::Active => serializer.serialize_i32(1),
784 Self::KinesisPermissionDenied => serializer.serialize_i32(2),
785 Self::PublishPermissionDenied => serializer.serialize_i32(3),
786 Self::StreamNotFound => serializer.serialize_i32(4),
787 Self::ConsumerNotFound => serializer.serialize_i32(5),
788 Self::UnknownValue(u) => u.0.serialize(serializer),
789 }
790 }
791 }
792
793 impl<'de> serde::de::Deserialize<'de> for State {
794 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
795 where
796 D: serde::Deserializer<'de>,
797 {
798 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
799 ".google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State",
800 ))
801 }
802 }
803 }
804
805 /// Ingestion settings for Cloud Storage.
806 #[derive(Clone, Default, PartialEq)]
807 #[non_exhaustive]
808 pub struct CloudStorage {
809 /// Output only. An output-only field that indicates the state of the Cloud
810 /// Storage ingestion source.
811 pub state: crate::model::ingestion_data_source_settings::cloud_storage::State,
812
813 /// Optional. Cloud Storage bucket. The bucket name must be without any
814 /// prefix like "gs://". See the [bucket naming requirements]
815 /// (<https://cloud.google.com/storage/docs/buckets#naming>).
816 pub bucket: std::string::String,
817
818 /// Optional. Only objects with a larger or equal creation timestamp will be
819 /// ingested.
820 pub minimum_object_create_time: std::option::Option<wkt::Timestamp>,
821
822 /// Optional. Glob pattern used to match objects that will be ingested. If
823 /// unset, all objects will be ingested. See the [supported
824 /// patterns](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob).
825 pub match_glob: std::string::String,
826
827 /// Defaults to text format.
828 pub input_format: std::option::Option<
829 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
830 >,
831
832 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
833 }
834
835 impl CloudStorage {
836 /// Creates a new default instance.
837 pub fn new() -> Self {
838 std::default::Default::default()
839 }
840
841 /// Sets the value of [state][crate::model::ingestion_data_source_settings::CloudStorage::state].
842 ///
843 /// # Example
844 /// ```ignore,no_run
845 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
846 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::State;
847 /// let x0 = CloudStorage::new().set_state(State::Active);
848 /// let x1 = CloudStorage::new().set_state(State::CloudStoragePermissionDenied);
849 /// let x2 = CloudStorage::new().set_state(State::PublishPermissionDenied);
850 /// ```
851 pub fn set_state<
852 T: std::convert::Into<crate::model::ingestion_data_source_settings::cloud_storage::State>,
853 >(
854 mut self,
855 v: T,
856 ) -> Self {
857 self.state = v.into();
858 self
859 }
860
861 /// Sets the value of [bucket][crate::model::ingestion_data_source_settings::CloudStorage::bucket].
862 ///
863 /// # Example
864 /// ```ignore,no_run
865 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
866 /// let x = CloudStorage::new().set_bucket("example");
867 /// ```
868 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
869 self.bucket = v.into();
870 self
871 }
872
873 /// Sets the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
874 ///
875 /// # Example
876 /// ```ignore,no_run
877 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
878 /// use wkt::Timestamp;
879 /// let x = CloudStorage::new().set_minimum_object_create_time(Timestamp::default()/* use setters */);
880 /// ```
881 pub fn set_minimum_object_create_time<T>(mut self, v: T) -> Self
882 where
883 T: std::convert::Into<wkt::Timestamp>,
884 {
885 self.minimum_object_create_time = std::option::Option::Some(v.into());
886 self
887 }
888
889 /// Sets or clears the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
890 ///
891 /// # Example
892 /// ```ignore,no_run
893 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
894 /// use wkt::Timestamp;
895 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(Some(Timestamp::default()/* use setters */));
896 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(None::<Timestamp>);
897 /// ```
898 pub fn set_or_clear_minimum_object_create_time<T>(
899 mut self,
900 v: std::option::Option<T>,
901 ) -> Self
902 where
903 T: std::convert::Into<wkt::Timestamp>,
904 {
905 self.minimum_object_create_time = v.map(|x| x.into());
906 self
907 }
908
909 /// Sets the value of [match_glob][crate::model::ingestion_data_source_settings::CloudStorage::match_glob].
910 ///
911 /// # Example
912 /// ```ignore,no_run
913 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
914 /// let x = CloudStorage::new().set_match_glob("example");
915 /// ```
916 pub fn set_match_glob<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
917 self.match_glob = v.into();
918 self
919 }
920
921 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format].
922 ///
923 /// Note that all the setters affecting `input_format` are mutually
924 /// exclusive.
925 ///
926 /// # Example
927 /// ```ignore,no_run
928 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
929 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
930 /// let x = CloudStorage::new().set_input_format(Some(
931 /// google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(TextFormat::default().into())));
932 /// ```
933 pub fn set_input_format<
934 T: std::convert::Into<
935 std::option::Option<
936 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
937 >,
938 >,
939 >(
940 mut self,
941 v: T,
942 ) -> Self {
943 self.input_format = v.into();
944 self
945 }
946
947 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
948 /// if it holds a `TextFormat`, `None` if the field is not set or
949 /// holds a different branch.
950 pub fn text_format(
951 &self,
952 ) -> std::option::Option<
953 &std::boxed::Box<
954 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
955 >,
956 > {
957 #[allow(unreachable_patterns)]
958 self.input_format.as_ref().and_then(|v| match v {
959 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(v) => std::option::Option::Some(v),
960 _ => std::option::Option::None,
961 })
962 }
963
964 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
965 /// to hold a `TextFormat`.
966 ///
967 /// Note that all the setters affecting `input_format` are
968 /// mutually exclusive.
969 ///
970 /// # Example
971 /// ```ignore,no_run
972 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
973 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
974 /// let x = CloudStorage::new().set_text_format(TextFormat::default()/* use setters */);
975 /// assert!(x.text_format().is_some());
976 /// assert!(x.avro_format().is_none());
977 /// assert!(x.pubsub_avro_format().is_none());
978 /// ```
979 pub fn set_text_format<
980 T: std::convert::Into<
981 std::boxed::Box<
982 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
983 >,
984 >,
985 >(
986 mut self,
987 v: T,
988 ) -> Self {
989 self.input_format = std::option::Option::Some(
990 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(
991 v.into()
992 )
993 );
994 self
995 }
996
997 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
998 /// if it holds a `AvroFormat`, `None` if the field is not set or
999 /// holds a different branch.
1000 pub fn avro_format(
1001 &self,
1002 ) -> std::option::Option<
1003 &std::boxed::Box<
1004 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1005 >,
1006 > {
1007 #[allow(unreachable_patterns)]
1008 self.input_format.as_ref().and_then(|v| match v {
1009 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(v) => std::option::Option::Some(v),
1010 _ => std::option::Option::None,
1011 })
1012 }
1013
1014 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1015 /// to hold a `AvroFormat`.
1016 ///
1017 /// Note that all the setters affecting `input_format` are
1018 /// mutually exclusive.
1019 ///
1020 /// # Example
1021 /// ```ignore,no_run
1022 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1023 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::AvroFormat;
1024 /// let x = CloudStorage::new().set_avro_format(AvroFormat::default()/* use setters */);
1025 /// assert!(x.avro_format().is_some());
1026 /// assert!(x.text_format().is_none());
1027 /// assert!(x.pubsub_avro_format().is_none());
1028 /// ```
1029 pub fn set_avro_format<
1030 T: std::convert::Into<
1031 std::boxed::Box<
1032 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1033 >,
1034 >,
1035 >(
1036 mut self,
1037 v: T,
1038 ) -> Self {
1039 self.input_format = std::option::Option::Some(
1040 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(
1041 v.into()
1042 )
1043 );
1044 self
1045 }
1046
1047 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1048 /// if it holds a `PubsubAvroFormat`, `None` if the field is not set or
1049 /// holds a different branch.
1050 pub fn pubsub_avro_format(
1051 &self,
1052 ) -> std::option::Option<
1053 &std::boxed::Box<
1054 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1055 >,
1056 > {
1057 #[allow(unreachable_patterns)]
1058 self.input_format.as_ref().and_then(|v| match v {
1059 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(v) => std::option::Option::Some(v),
1060 _ => std::option::Option::None,
1061 })
1062 }
1063
1064 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1065 /// to hold a `PubsubAvroFormat`.
1066 ///
1067 /// Note that all the setters affecting `input_format` are
1068 /// mutually exclusive.
1069 ///
1070 /// # Example
1071 /// ```ignore,no_run
1072 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1073 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat;
1074 /// let x = CloudStorage::new().set_pubsub_avro_format(PubSubAvroFormat::default()/* use setters */);
1075 /// assert!(x.pubsub_avro_format().is_some());
1076 /// assert!(x.text_format().is_none());
1077 /// assert!(x.avro_format().is_none());
1078 /// ```
1079 pub fn set_pubsub_avro_format<T: std::convert::Into<std::boxed::Box<crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat>>>(mut self, v: T) -> Self{
1080 self.input_format = std::option::Option::Some(
1081 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(
1082 v.into()
1083 )
1084 );
1085 self
1086 }
1087 }
1088
1089 impl wkt::message::Message for CloudStorage {
1090 fn typename() -> &'static str {
1091 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage"
1092 }
1093 }
1094
1095 /// Defines additional types related to [CloudStorage].
1096 pub mod cloud_storage {
1097 #[allow(unused_imports)]
1098 use super::*;
1099
1100 /// Configuration for reading Cloud Storage data in text format. Each line of
1101 /// text as specified by the delimiter will be set to the `data` field of a
1102 /// Pub/Sub message.
1103 #[derive(Clone, Default, PartialEq)]
1104 #[non_exhaustive]
1105 pub struct TextFormat {
1106 /// Optional. When unset, '\n' is used.
1107 pub delimiter: std::option::Option<std::string::String>,
1108
1109 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1110 }
1111
1112 impl TextFormat {
1113 /// Creates a new default instance.
1114 pub fn new() -> Self {
1115 std::default::Default::default()
1116 }
1117
1118 /// Sets the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1119 ///
1120 /// # Example
1121 /// ```ignore,no_run
1122 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1123 /// let x = TextFormat::new().set_delimiter("example");
1124 /// ```
1125 pub fn set_delimiter<T>(mut self, v: T) -> Self
1126 where
1127 T: std::convert::Into<std::string::String>,
1128 {
1129 self.delimiter = std::option::Option::Some(v.into());
1130 self
1131 }
1132
1133 /// Sets or clears the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1134 ///
1135 /// # Example
1136 /// ```ignore,no_run
1137 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1138 /// let x = TextFormat::new().set_or_clear_delimiter(Some("example"));
1139 /// let x = TextFormat::new().set_or_clear_delimiter(None::<String>);
1140 /// ```
1141 pub fn set_or_clear_delimiter<T>(mut self, v: std::option::Option<T>) -> Self
1142 where
1143 T: std::convert::Into<std::string::String>,
1144 {
1145 self.delimiter = v.map(|x| x.into());
1146 self
1147 }
1148 }
1149
1150 impl wkt::message::Message for TextFormat {
1151 fn typename() -> &'static str {
1152 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.TextFormat"
1153 }
1154 }
1155
1156 /// Configuration for reading Cloud Storage data in Avro binary format. The
1157 /// bytes of each object will be set to the `data` field of a Pub/Sub
1158 /// message.
1159 #[derive(Clone, Default, PartialEq)]
1160 #[non_exhaustive]
1161 pub struct AvroFormat {
1162 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1163 }
1164
1165 impl AvroFormat {
1166 /// Creates a new default instance.
1167 pub fn new() -> Self {
1168 std::default::Default::default()
1169 }
1170 }
1171
1172 impl wkt::message::Message for AvroFormat {
1173 fn typename() -> &'static str {
1174 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.AvroFormat"
1175 }
1176 }
1177
1178 /// Configuration for reading Cloud Storage data written via [Cloud Storage
1179 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage). The
1180 /// data and attributes fields of the originally exported Pub/Sub message
1181 /// will be restored when publishing.
1182 #[derive(Clone, Default, PartialEq)]
1183 #[non_exhaustive]
1184 pub struct PubSubAvroFormat {
1185 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1186 }
1187
1188 impl PubSubAvroFormat {
1189 /// Creates a new default instance.
1190 pub fn new() -> Self {
1191 std::default::Default::default()
1192 }
1193 }
1194
1195 impl wkt::message::Message for PubSubAvroFormat {
1196 fn typename() -> &'static str {
1197 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat"
1198 }
1199 }
1200
1201 /// Possible states for ingestion from Cloud Storage.
1202 ///
1203 /// # Working with unknown values
1204 ///
1205 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1206 /// additional enum variants at any time. Adding new variants is not considered
1207 /// a breaking change. Applications should write their code in anticipation of:
1208 ///
1209 /// - New values appearing in future releases of the client library, **and**
1210 /// - New values received dynamically, without application changes.
1211 ///
1212 /// Please consult the [Working with enums] section in the user guide for some
1213 /// guidelines.
1214 ///
1215 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1216 #[derive(Clone, Debug, PartialEq)]
1217 #[non_exhaustive]
1218 pub enum State {
1219 /// Default value. This value is unused.
1220 Unspecified,
1221 /// Ingestion is active.
1222 Active,
1223 /// Permission denied encountered while calling the Cloud Storage API. This
1224 /// can happen if the Pub/Sub SA has not been granted the
1225 /// [appropriate
1226 /// permissions](https://cloud.google.com/storage/docs/access-control/iam-permissions):
1227 ///
1228 /// - storage.objects.list: to list the objects in a bucket.
1229 /// - storage.objects.get: to read the objects in a bucket.
1230 /// - storage.buckets.get: to verify the bucket exists.
1231 CloudStoragePermissionDenied,
1232 /// Permission denied encountered while publishing to the topic. This can
1233 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
1234 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
1235 PublishPermissionDenied,
1236 /// The provided Cloud Storage bucket doesn't exist.
1237 BucketNotFound,
1238 /// The Cloud Storage bucket has too many objects, ingestion will be
1239 /// paused.
1240 TooManyObjects,
1241 /// If set, the enum was initialized with an unknown value.
1242 ///
1243 /// Applications can examine the value using [State::value] or
1244 /// [State::name].
1245 UnknownValue(state::UnknownValue),
1246 }
1247
1248 #[doc(hidden)]
1249 pub mod state {
1250 #[allow(unused_imports)]
1251 use super::*;
1252 #[derive(Clone, Debug, PartialEq)]
1253 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1254 }
1255
1256 impl State {
1257 /// Gets the enum value.
1258 ///
1259 /// Returns `None` if the enum contains an unknown value deserialized from
1260 /// the string representation of enums.
1261 pub fn value(&self) -> std::option::Option<i32> {
1262 match self {
1263 Self::Unspecified => std::option::Option::Some(0),
1264 Self::Active => std::option::Option::Some(1),
1265 Self::CloudStoragePermissionDenied => std::option::Option::Some(2),
1266 Self::PublishPermissionDenied => std::option::Option::Some(3),
1267 Self::BucketNotFound => std::option::Option::Some(4),
1268 Self::TooManyObjects => std::option::Option::Some(5),
1269 Self::UnknownValue(u) => u.0.value(),
1270 }
1271 }
1272
1273 /// Gets the enum value as a string.
1274 ///
1275 /// Returns `None` if the enum contains an unknown value deserialized from
1276 /// the integer representation of enums.
1277 pub fn name(&self) -> std::option::Option<&str> {
1278 match self {
1279 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1280 Self::Active => std::option::Option::Some("ACTIVE"),
1281 Self::CloudStoragePermissionDenied => {
1282 std::option::Option::Some("CLOUD_STORAGE_PERMISSION_DENIED")
1283 }
1284 Self::PublishPermissionDenied => {
1285 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1286 }
1287 Self::BucketNotFound => std::option::Option::Some("BUCKET_NOT_FOUND"),
1288 Self::TooManyObjects => std::option::Option::Some("TOO_MANY_OBJECTS"),
1289 Self::UnknownValue(u) => u.0.name(),
1290 }
1291 }
1292 }
1293
1294 impl std::default::Default for State {
1295 fn default() -> Self {
1296 use std::convert::From;
1297 Self::from(0)
1298 }
1299 }
1300
1301 impl std::fmt::Display for State {
1302 fn fmt(
1303 &self,
1304 f: &mut std::fmt::Formatter<'_>,
1305 ) -> std::result::Result<(), std::fmt::Error> {
1306 wkt::internal::display_enum(f, self.name(), self.value())
1307 }
1308 }
1309
1310 impl std::convert::From<i32> for State {
1311 fn from(value: i32) -> Self {
1312 match value {
1313 0 => Self::Unspecified,
1314 1 => Self::Active,
1315 2 => Self::CloudStoragePermissionDenied,
1316 3 => Self::PublishPermissionDenied,
1317 4 => Self::BucketNotFound,
1318 5 => Self::TooManyObjects,
1319 _ => Self::UnknownValue(state::UnknownValue(
1320 wkt::internal::UnknownEnumValue::Integer(value),
1321 )),
1322 }
1323 }
1324 }
1325
1326 impl std::convert::From<&str> for State {
1327 fn from(value: &str) -> Self {
1328 use std::string::ToString;
1329 match value {
1330 "STATE_UNSPECIFIED" => Self::Unspecified,
1331 "ACTIVE" => Self::Active,
1332 "CLOUD_STORAGE_PERMISSION_DENIED" => Self::CloudStoragePermissionDenied,
1333 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1334 "BUCKET_NOT_FOUND" => Self::BucketNotFound,
1335 "TOO_MANY_OBJECTS" => Self::TooManyObjects,
1336 _ => Self::UnknownValue(state::UnknownValue(
1337 wkt::internal::UnknownEnumValue::String(value.to_string()),
1338 )),
1339 }
1340 }
1341 }
1342
1343 impl serde::ser::Serialize for State {
1344 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1345 where
1346 S: serde::Serializer,
1347 {
1348 match self {
1349 Self::Unspecified => serializer.serialize_i32(0),
1350 Self::Active => serializer.serialize_i32(1),
1351 Self::CloudStoragePermissionDenied => serializer.serialize_i32(2),
1352 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1353 Self::BucketNotFound => serializer.serialize_i32(4),
1354 Self::TooManyObjects => serializer.serialize_i32(5),
1355 Self::UnknownValue(u) => u.0.serialize(serializer),
1356 }
1357 }
1358 }
1359
1360 impl<'de> serde::de::Deserialize<'de> for State {
1361 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1362 where
1363 D: serde::Deserializer<'de>,
1364 {
1365 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1366 ".google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.State",
1367 ))
1368 }
1369 }
1370
1371 /// Defaults to text format.
1372 #[derive(Clone, Debug, PartialEq)]
1373 #[non_exhaustive]
1374 pub enum InputFormat {
1375 /// Optional. Data from Cloud Storage will be interpreted as text.
1376 TextFormat(
1377 std::boxed::Box<
1378 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
1379 >,
1380 ),
1381 /// Optional. Data from Cloud Storage will be interpreted in Avro format.
1382 AvroFormat(
1383 std::boxed::Box<
1384 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1385 >,
1386 ),
1387 /// Optional. It will be assumed data from Cloud Storage was written via
1388 /// [Cloud Storage
1389 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage).
1390 PubsubAvroFormat(
1391 std::boxed::Box<
1392 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1393 >,
1394 ),
1395 }
1396 }
1397
1398 /// Ingestion settings for Azure Event Hubs.
1399 #[derive(Clone, Default, PartialEq)]
1400 #[non_exhaustive]
1401 pub struct AzureEventHubs {
1402 /// Output only. An output-only field that indicates the state of the Event
1403 /// Hubs ingestion source.
1404 pub state: crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1405
1406 /// Optional. Name of the resource group within the azure subscription.
1407 pub resource_group: std::string::String,
1408
1409 /// Optional. The name of the Event Hubs namespace.
1410 pub namespace: std::string::String,
1411
1412 /// Optional. The name of the Event Hub.
1413 pub event_hub: std::string::String,
1414
1415 /// Optional. The client id of the Azure application that is being used to
1416 /// authenticate Pub/Sub.
1417 pub client_id: std::string::String,
1418
1419 /// Optional. The tenant id of the Azure application that is being used to
1420 /// authenticate Pub/Sub.
1421 pub tenant_id: std::string::String,
1422
1423 /// Optional. The Azure subscription id.
1424 pub subscription_id: std::string::String,
1425
1426 /// Optional. The GCP service account to be used for Federated Identity
1427 /// authentication.
1428 pub gcp_service_account: std::string::String,
1429
1430 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1431 }
1432
1433 impl AzureEventHubs {
1434 /// Creates a new default instance.
1435 pub fn new() -> Self {
1436 std::default::Default::default()
1437 }
1438
1439 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AzureEventHubs::state].
1440 ///
1441 /// # Example
1442 /// ```ignore,no_run
1443 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1444 /// use google_cloud_pubsub::model::ingestion_data_source_settings::azure_event_hubs::State;
1445 /// let x0 = AzureEventHubs::new().set_state(State::Active);
1446 /// let x1 = AzureEventHubs::new().set_state(State::EventHubsPermissionDenied);
1447 /// let x2 = AzureEventHubs::new().set_state(State::PublishPermissionDenied);
1448 /// ```
1449 pub fn set_state<
1450 T: std::convert::Into<
1451 crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1452 >,
1453 >(
1454 mut self,
1455 v: T,
1456 ) -> Self {
1457 self.state = v.into();
1458 self
1459 }
1460
1461 /// Sets the value of [resource_group][crate::model::ingestion_data_source_settings::AzureEventHubs::resource_group].
1462 ///
1463 /// # Example
1464 /// ```ignore,no_run
1465 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1466 /// let x = AzureEventHubs::new().set_resource_group("example");
1467 /// ```
1468 pub fn set_resource_group<T: std::convert::Into<std::string::String>>(
1469 mut self,
1470 v: T,
1471 ) -> Self {
1472 self.resource_group = v.into();
1473 self
1474 }
1475
1476 /// Sets the value of [namespace][crate::model::ingestion_data_source_settings::AzureEventHubs::namespace].
1477 ///
1478 /// # Example
1479 /// ```ignore,no_run
1480 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1481 /// let x = AzureEventHubs::new().set_namespace("example");
1482 /// ```
1483 pub fn set_namespace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1484 self.namespace = v.into();
1485 self
1486 }
1487
1488 /// Sets the value of [event_hub][crate::model::ingestion_data_source_settings::AzureEventHubs::event_hub].
1489 ///
1490 /// # Example
1491 /// ```ignore,no_run
1492 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1493 /// let x = AzureEventHubs::new().set_event_hub("example");
1494 /// ```
1495 pub fn set_event_hub<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1496 self.event_hub = v.into();
1497 self
1498 }
1499
1500 /// Sets the value of [client_id][crate::model::ingestion_data_source_settings::AzureEventHubs::client_id].
1501 ///
1502 /// # Example
1503 /// ```ignore,no_run
1504 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1505 /// let x = AzureEventHubs::new().set_client_id("example");
1506 /// ```
1507 pub fn set_client_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1508 self.client_id = v.into();
1509 self
1510 }
1511
1512 /// Sets the value of [tenant_id][crate::model::ingestion_data_source_settings::AzureEventHubs::tenant_id].
1513 ///
1514 /// # Example
1515 /// ```ignore,no_run
1516 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1517 /// let x = AzureEventHubs::new().set_tenant_id("example");
1518 /// ```
1519 pub fn set_tenant_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1520 self.tenant_id = v.into();
1521 self
1522 }
1523
1524 /// Sets the value of [subscription_id][crate::model::ingestion_data_source_settings::AzureEventHubs::subscription_id].
1525 ///
1526 /// # Example
1527 /// ```ignore,no_run
1528 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1529 /// let x = AzureEventHubs::new().set_subscription_id("example");
1530 /// ```
1531 pub fn set_subscription_id<T: std::convert::Into<std::string::String>>(
1532 mut self,
1533 v: T,
1534 ) -> Self {
1535 self.subscription_id = v.into();
1536 self
1537 }
1538
1539 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AzureEventHubs::gcp_service_account].
1540 ///
1541 /// # Example
1542 /// ```ignore,no_run
1543 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1544 /// let x = AzureEventHubs::new().set_gcp_service_account("example");
1545 /// ```
1546 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1547 mut self,
1548 v: T,
1549 ) -> Self {
1550 self.gcp_service_account = v.into();
1551 self
1552 }
1553 }
1554
1555 impl wkt::message::Message for AzureEventHubs {
1556 fn typename() -> &'static str {
1557 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs"
1558 }
1559 }
1560
1561 /// Defines additional types related to [AzureEventHubs].
1562 pub mod azure_event_hubs {
1563 #[allow(unused_imports)]
1564 use super::*;
1565
1566 /// Possible states for managed ingestion from Event Hubs.
1567 ///
1568 /// # Working with unknown values
1569 ///
1570 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1571 /// additional enum variants at any time. Adding new variants is not considered
1572 /// a breaking change. Applications should write their code in anticipation of:
1573 ///
1574 /// - New values appearing in future releases of the client library, **and**
1575 /// - New values received dynamically, without application changes.
1576 ///
1577 /// Please consult the [Working with enums] section in the user guide for some
1578 /// guidelines.
1579 ///
1580 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1581 #[derive(Clone, Debug, PartialEq)]
1582 #[non_exhaustive]
1583 pub enum State {
1584 /// Default value. This value is unused.
1585 Unspecified,
1586 /// Ingestion is active.
1587 Active,
1588 /// Permission denied encountered while consuming data from Event Hubs.
1589 /// This can happen when `client_id`, or `tenant_id` are invalid. Or the
1590 /// right permissions haven't been granted.
1591 EventHubsPermissionDenied,
1592 /// Permission denied encountered while publishing to the topic.
1593 PublishPermissionDenied,
1594 /// The provided Event Hubs namespace couldn't be found.
1595 NamespaceNotFound,
1596 /// The provided Event Hub couldn't be found.
1597 EventHubNotFound,
1598 /// The provided Event Hubs subscription couldn't be found.
1599 SubscriptionNotFound,
1600 /// The provided Event Hubs resource group couldn't be found.
1601 ResourceGroupNotFound,
1602 /// If set, the enum was initialized with an unknown value.
1603 ///
1604 /// Applications can examine the value using [State::value] or
1605 /// [State::name].
1606 UnknownValue(state::UnknownValue),
1607 }
1608
1609 #[doc(hidden)]
1610 pub mod state {
1611 #[allow(unused_imports)]
1612 use super::*;
1613 #[derive(Clone, Debug, PartialEq)]
1614 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1615 }
1616
1617 impl State {
1618 /// Gets the enum value.
1619 ///
1620 /// Returns `None` if the enum contains an unknown value deserialized from
1621 /// the string representation of enums.
1622 pub fn value(&self) -> std::option::Option<i32> {
1623 match self {
1624 Self::Unspecified => std::option::Option::Some(0),
1625 Self::Active => std::option::Option::Some(1),
1626 Self::EventHubsPermissionDenied => std::option::Option::Some(2),
1627 Self::PublishPermissionDenied => std::option::Option::Some(3),
1628 Self::NamespaceNotFound => std::option::Option::Some(4),
1629 Self::EventHubNotFound => std::option::Option::Some(5),
1630 Self::SubscriptionNotFound => std::option::Option::Some(6),
1631 Self::ResourceGroupNotFound => std::option::Option::Some(7),
1632 Self::UnknownValue(u) => u.0.value(),
1633 }
1634 }
1635
1636 /// Gets the enum value as a string.
1637 ///
1638 /// Returns `None` if the enum contains an unknown value deserialized from
1639 /// the integer representation of enums.
1640 pub fn name(&self) -> std::option::Option<&str> {
1641 match self {
1642 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1643 Self::Active => std::option::Option::Some("ACTIVE"),
1644 Self::EventHubsPermissionDenied => {
1645 std::option::Option::Some("EVENT_HUBS_PERMISSION_DENIED")
1646 }
1647 Self::PublishPermissionDenied => {
1648 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1649 }
1650 Self::NamespaceNotFound => std::option::Option::Some("NAMESPACE_NOT_FOUND"),
1651 Self::EventHubNotFound => std::option::Option::Some("EVENT_HUB_NOT_FOUND"),
1652 Self::SubscriptionNotFound => {
1653 std::option::Option::Some("SUBSCRIPTION_NOT_FOUND")
1654 }
1655 Self::ResourceGroupNotFound => {
1656 std::option::Option::Some("RESOURCE_GROUP_NOT_FOUND")
1657 }
1658 Self::UnknownValue(u) => u.0.name(),
1659 }
1660 }
1661 }
1662
1663 impl std::default::Default for State {
1664 fn default() -> Self {
1665 use std::convert::From;
1666 Self::from(0)
1667 }
1668 }
1669
1670 impl std::fmt::Display for State {
1671 fn fmt(
1672 &self,
1673 f: &mut std::fmt::Formatter<'_>,
1674 ) -> std::result::Result<(), std::fmt::Error> {
1675 wkt::internal::display_enum(f, self.name(), self.value())
1676 }
1677 }
1678
1679 impl std::convert::From<i32> for State {
1680 fn from(value: i32) -> Self {
1681 match value {
1682 0 => Self::Unspecified,
1683 1 => Self::Active,
1684 2 => Self::EventHubsPermissionDenied,
1685 3 => Self::PublishPermissionDenied,
1686 4 => Self::NamespaceNotFound,
1687 5 => Self::EventHubNotFound,
1688 6 => Self::SubscriptionNotFound,
1689 7 => Self::ResourceGroupNotFound,
1690 _ => Self::UnknownValue(state::UnknownValue(
1691 wkt::internal::UnknownEnumValue::Integer(value),
1692 )),
1693 }
1694 }
1695 }
1696
1697 impl std::convert::From<&str> for State {
1698 fn from(value: &str) -> Self {
1699 use std::string::ToString;
1700 match value {
1701 "STATE_UNSPECIFIED" => Self::Unspecified,
1702 "ACTIVE" => Self::Active,
1703 "EVENT_HUBS_PERMISSION_DENIED" => Self::EventHubsPermissionDenied,
1704 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1705 "NAMESPACE_NOT_FOUND" => Self::NamespaceNotFound,
1706 "EVENT_HUB_NOT_FOUND" => Self::EventHubNotFound,
1707 "SUBSCRIPTION_NOT_FOUND" => Self::SubscriptionNotFound,
1708 "RESOURCE_GROUP_NOT_FOUND" => Self::ResourceGroupNotFound,
1709 _ => Self::UnknownValue(state::UnknownValue(
1710 wkt::internal::UnknownEnumValue::String(value.to_string()),
1711 )),
1712 }
1713 }
1714 }
1715
1716 impl serde::ser::Serialize for State {
1717 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1718 where
1719 S: serde::Serializer,
1720 {
1721 match self {
1722 Self::Unspecified => serializer.serialize_i32(0),
1723 Self::Active => serializer.serialize_i32(1),
1724 Self::EventHubsPermissionDenied => serializer.serialize_i32(2),
1725 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1726 Self::NamespaceNotFound => serializer.serialize_i32(4),
1727 Self::EventHubNotFound => serializer.serialize_i32(5),
1728 Self::SubscriptionNotFound => serializer.serialize_i32(6),
1729 Self::ResourceGroupNotFound => serializer.serialize_i32(7),
1730 Self::UnknownValue(u) => u.0.serialize(serializer),
1731 }
1732 }
1733 }
1734
1735 impl<'de> serde::de::Deserialize<'de> for State {
1736 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1737 where
1738 D: serde::Deserializer<'de>,
1739 {
1740 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1741 ".google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs.State",
1742 ))
1743 }
1744 }
1745 }
1746
1747 /// Ingestion settings for Amazon MSK.
1748 #[derive(Clone, Default, PartialEq)]
1749 #[non_exhaustive]
1750 pub struct AwsMsk {
1751 /// Output only. An output-only field that indicates the state of the Amazon
1752 /// MSK ingestion source.
1753 pub state: crate::model::ingestion_data_source_settings::aws_msk::State,
1754
1755 /// Required. The Amazon Resource Name (ARN) that uniquely identifies the
1756 /// cluster.
1757 pub cluster_arn: std::string::String,
1758
1759 /// Required. The name of the topic in the Amazon MSK cluster that Pub/Sub
1760 /// will import from.
1761 pub topic: std::string::String,
1762
1763 /// Required. AWS role ARN to be used for Federated Identity authentication
1764 /// with Amazon MSK. Check the Pub/Sub docs for how to set up this role and
1765 /// the required permissions that need to be attached to it.
1766 pub aws_role_arn: std::string::String,
1767
1768 /// Required. The GCP service account to be used for Federated Identity
1769 /// authentication with Amazon MSK (via a `AssumeRoleWithWebIdentity` call
1770 /// for the provided role). The `aws_role_arn` must be set up with
1771 /// `accounts.google.com:sub` equals to this service account number.
1772 pub gcp_service_account: std::string::String,
1773
1774 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1775 }
1776
1777 impl AwsMsk {
1778 /// Creates a new default instance.
1779 pub fn new() -> Self {
1780 std::default::Default::default()
1781 }
1782
1783 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsMsk::state].
1784 ///
1785 /// # Example
1786 /// ```ignore,no_run
1787 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1788 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_msk::State;
1789 /// let x0 = AwsMsk::new().set_state(State::Active);
1790 /// let x1 = AwsMsk::new().set_state(State::MskPermissionDenied);
1791 /// let x2 = AwsMsk::new().set_state(State::PublishPermissionDenied);
1792 /// ```
1793 pub fn set_state<
1794 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_msk::State>,
1795 >(
1796 mut self,
1797 v: T,
1798 ) -> Self {
1799 self.state = v.into();
1800 self
1801 }
1802
1803 /// Sets the value of [cluster_arn][crate::model::ingestion_data_source_settings::AwsMsk::cluster_arn].
1804 ///
1805 /// # Example
1806 /// ```ignore,no_run
1807 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1808 /// let x = AwsMsk::new().set_cluster_arn("example");
1809 /// ```
1810 pub fn set_cluster_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1811 self.cluster_arn = v.into();
1812 self
1813 }
1814
1815 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::AwsMsk::topic].
1816 ///
1817 /// # Example
1818 /// ```ignore,no_run
1819 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1820 /// let x = AwsMsk::new().set_topic("example");
1821 /// ```
1822 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1823 self.topic = v.into();
1824 self
1825 }
1826
1827 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsMsk::aws_role_arn].
1828 ///
1829 /// # Example
1830 /// ```ignore,no_run
1831 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1832 /// let x = AwsMsk::new().set_aws_role_arn("example");
1833 /// ```
1834 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
1835 mut self,
1836 v: T,
1837 ) -> Self {
1838 self.aws_role_arn = v.into();
1839 self
1840 }
1841
1842 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsMsk::gcp_service_account].
1843 ///
1844 /// # Example
1845 /// ```ignore,no_run
1846 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1847 /// let x = AwsMsk::new().set_gcp_service_account("example");
1848 /// ```
1849 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1850 mut self,
1851 v: T,
1852 ) -> Self {
1853 self.gcp_service_account = v.into();
1854 self
1855 }
1856 }
1857
1858 impl wkt::message::Message for AwsMsk {
1859 fn typename() -> &'static str {
1860 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsMsk"
1861 }
1862 }
1863
1864 /// Defines additional types related to [AwsMsk].
1865 pub mod aws_msk {
1866 #[allow(unused_imports)]
1867 use super::*;
1868
1869 /// Possible states for managed ingestion from Amazon MSK.
1870 ///
1871 /// # Working with unknown values
1872 ///
1873 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1874 /// additional enum variants at any time. Adding new variants is not considered
1875 /// a breaking change. Applications should write their code in anticipation of:
1876 ///
1877 /// - New values appearing in future releases of the client library, **and**
1878 /// - New values received dynamically, without application changes.
1879 ///
1880 /// Please consult the [Working with enums] section in the user guide for some
1881 /// guidelines.
1882 ///
1883 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1884 #[derive(Clone, Debug, PartialEq)]
1885 #[non_exhaustive]
1886 pub enum State {
1887 /// Default value. This value is unused.
1888 Unspecified,
1889 /// Ingestion is active.
1890 Active,
1891 /// Permission denied encountered while consuming data from Amazon MSK.
1892 MskPermissionDenied,
1893 /// Permission denied encountered while publishing to the topic.
1894 PublishPermissionDenied,
1895 /// The provided MSK cluster wasn't found.
1896 ClusterNotFound,
1897 /// The provided topic wasn't found.
1898 TopicNotFound,
1899 /// If set, the enum was initialized with an unknown value.
1900 ///
1901 /// Applications can examine the value using [State::value] or
1902 /// [State::name].
1903 UnknownValue(state::UnknownValue),
1904 }
1905
1906 #[doc(hidden)]
1907 pub mod state {
1908 #[allow(unused_imports)]
1909 use super::*;
1910 #[derive(Clone, Debug, PartialEq)]
1911 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1912 }
1913
1914 impl State {
1915 /// Gets the enum value.
1916 ///
1917 /// Returns `None` if the enum contains an unknown value deserialized from
1918 /// the string representation of enums.
1919 pub fn value(&self) -> std::option::Option<i32> {
1920 match self {
1921 Self::Unspecified => std::option::Option::Some(0),
1922 Self::Active => std::option::Option::Some(1),
1923 Self::MskPermissionDenied => std::option::Option::Some(2),
1924 Self::PublishPermissionDenied => std::option::Option::Some(3),
1925 Self::ClusterNotFound => std::option::Option::Some(4),
1926 Self::TopicNotFound => std::option::Option::Some(5),
1927 Self::UnknownValue(u) => u.0.value(),
1928 }
1929 }
1930
1931 /// Gets the enum value as a string.
1932 ///
1933 /// Returns `None` if the enum contains an unknown value deserialized from
1934 /// the integer representation of enums.
1935 pub fn name(&self) -> std::option::Option<&str> {
1936 match self {
1937 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1938 Self::Active => std::option::Option::Some("ACTIVE"),
1939 Self::MskPermissionDenied => std::option::Option::Some("MSK_PERMISSION_DENIED"),
1940 Self::PublishPermissionDenied => {
1941 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1942 }
1943 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
1944 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
1945 Self::UnknownValue(u) => u.0.name(),
1946 }
1947 }
1948 }
1949
1950 impl std::default::Default for State {
1951 fn default() -> Self {
1952 use std::convert::From;
1953 Self::from(0)
1954 }
1955 }
1956
1957 impl std::fmt::Display for State {
1958 fn fmt(
1959 &self,
1960 f: &mut std::fmt::Formatter<'_>,
1961 ) -> std::result::Result<(), std::fmt::Error> {
1962 wkt::internal::display_enum(f, self.name(), self.value())
1963 }
1964 }
1965
1966 impl std::convert::From<i32> for State {
1967 fn from(value: i32) -> Self {
1968 match value {
1969 0 => Self::Unspecified,
1970 1 => Self::Active,
1971 2 => Self::MskPermissionDenied,
1972 3 => Self::PublishPermissionDenied,
1973 4 => Self::ClusterNotFound,
1974 5 => Self::TopicNotFound,
1975 _ => Self::UnknownValue(state::UnknownValue(
1976 wkt::internal::UnknownEnumValue::Integer(value),
1977 )),
1978 }
1979 }
1980 }
1981
1982 impl std::convert::From<&str> for State {
1983 fn from(value: &str) -> Self {
1984 use std::string::ToString;
1985 match value {
1986 "STATE_UNSPECIFIED" => Self::Unspecified,
1987 "ACTIVE" => Self::Active,
1988 "MSK_PERMISSION_DENIED" => Self::MskPermissionDenied,
1989 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1990 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
1991 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
1992 _ => Self::UnknownValue(state::UnknownValue(
1993 wkt::internal::UnknownEnumValue::String(value.to_string()),
1994 )),
1995 }
1996 }
1997 }
1998
1999 impl serde::ser::Serialize for State {
2000 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2001 where
2002 S: serde::Serializer,
2003 {
2004 match self {
2005 Self::Unspecified => serializer.serialize_i32(0),
2006 Self::Active => serializer.serialize_i32(1),
2007 Self::MskPermissionDenied => serializer.serialize_i32(2),
2008 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2009 Self::ClusterNotFound => serializer.serialize_i32(4),
2010 Self::TopicNotFound => serializer.serialize_i32(5),
2011 Self::UnknownValue(u) => u.0.serialize(serializer),
2012 }
2013 }
2014 }
2015
2016 impl<'de> serde::de::Deserialize<'de> for State {
2017 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2018 where
2019 D: serde::Deserializer<'de>,
2020 {
2021 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2022 ".google.pubsub.v1.IngestionDataSourceSettings.AwsMsk.State",
2023 ))
2024 }
2025 }
2026 }
2027
2028 /// Ingestion settings for Confluent Cloud.
2029 #[derive(Clone, Default, PartialEq)]
2030 #[non_exhaustive]
2031 pub struct ConfluentCloud {
2032 /// Output only. An output-only field that indicates the state of the
2033 /// Confluent Cloud ingestion source.
2034 pub state: crate::model::ingestion_data_source_settings::confluent_cloud::State,
2035
2036 /// Required. The address of the bootstrap server. The format is url:port.
2037 pub bootstrap_server: std::string::String,
2038
2039 /// Required. The id of the cluster.
2040 pub cluster_id: std::string::String,
2041
2042 /// Required. The name of the topic in the Confluent Cloud cluster that
2043 /// Pub/Sub will import from.
2044 pub topic: std::string::String,
2045
2046 /// Required. The id of the identity pool to be used for Federated Identity
2047 /// authentication with Confluent Cloud. See
2048 /// <https://docs.confluent.io/cloud/current/security/authenticate/workload-identities/identity-providers/oauth/identity-pools.html#add-oauth-identity-pools>.
2049 pub identity_pool_id: std::string::String,
2050
2051 /// Required. The GCP service account to be used for Federated Identity
2052 /// authentication with `identity_pool_id`.
2053 pub gcp_service_account: std::string::String,
2054
2055 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2056 }
2057
2058 impl ConfluentCloud {
2059 /// Creates a new default instance.
2060 pub fn new() -> Self {
2061 std::default::Default::default()
2062 }
2063
2064 /// Sets the value of [state][crate::model::ingestion_data_source_settings::ConfluentCloud::state].
2065 ///
2066 /// # Example
2067 /// ```ignore,no_run
2068 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2069 /// use google_cloud_pubsub::model::ingestion_data_source_settings::confluent_cloud::State;
2070 /// let x0 = ConfluentCloud::new().set_state(State::Active);
2071 /// let x1 = ConfluentCloud::new().set_state(State::ConfluentCloudPermissionDenied);
2072 /// let x2 = ConfluentCloud::new().set_state(State::PublishPermissionDenied);
2073 /// ```
2074 pub fn set_state<
2075 T: std::convert::Into<
2076 crate::model::ingestion_data_source_settings::confluent_cloud::State,
2077 >,
2078 >(
2079 mut self,
2080 v: T,
2081 ) -> Self {
2082 self.state = v.into();
2083 self
2084 }
2085
2086 /// Sets the value of [bootstrap_server][crate::model::ingestion_data_source_settings::ConfluentCloud::bootstrap_server].
2087 ///
2088 /// # Example
2089 /// ```ignore,no_run
2090 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2091 /// let x = ConfluentCloud::new().set_bootstrap_server("example");
2092 /// ```
2093 pub fn set_bootstrap_server<T: std::convert::Into<std::string::String>>(
2094 mut self,
2095 v: T,
2096 ) -> Self {
2097 self.bootstrap_server = v.into();
2098 self
2099 }
2100
2101 /// Sets the value of [cluster_id][crate::model::ingestion_data_source_settings::ConfluentCloud::cluster_id].
2102 ///
2103 /// # Example
2104 /// ```ignore,no_run
2105 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2106 /// let x = ConfluentCloud::new().set_cluster_id("example");
2107 /// ```
2108 pub fn set_cluster_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2109 self.cluster_id = v.into();
2110 self
2111 }
2112
2113 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::ConfluentCloud::topic].
2114 ///
2115 /// # Example
2116 /// ```ignore,no_run
2117 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2118 /// let x = ConfluentCloud::new().set_topic("example");
2119 /// ```
2120 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2121 self.topic = v.into();
2122 self
2123 }
2124
2125 /// Sets the value of [identity_pool_id][crate::model::ingestion_data_source_settings::ConfluentCloud::identity_pool_id].
2126 ///
2127 /// # Example
2128 /// ```ignore,no_run
2129 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2130 /// let x = ConfluentCloud::new().set_identity_pool_id("example");
2131 /// ```
2132 pub fn set_identity_pool_id<T: std::convert::Into<std::string::String>>(
2133 mut self,
2134 v: T,
2135 ) -> Self {
2136 self.identity_pool_id = v.into();
2137 self
2138 }
2139
2140 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::ConfluentCloud::gcp_service_account].
2141 ///
2142 /// # Example
2143 /// ```ignore,no_run
2144 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2145 /// let x = ConfluentCloud::new().set_gcp_service_account("example");
2146 /// ```
2147 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
2148 mut self,
2149 v: T,
2150 ) -> Self {
2151 self.gcp_service_account = v.into();
2152 self
2153 }
2154 }
2155
2156 impl wkt::message::Message for ConfluentCloud {
2157 fn typename() -> &'static str {
2158 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud"
2159 }
2160 }
2161
2162 /// Defines additional types related to [ConfluentCloud].
2163 pub mod confluent_cloud {
2164 #[allow(unused_imports)]
2165 use super::*;
2166
2167 /// Possible states for managed ingestion from Confluent Cloud.
2168 ///
2169 /// # Working with unknown values
2170 ///
2171 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2172 /// additional enum variants at any time. Adding new variants is not considered
2173 /// a breaking change. Applications should write their code in anticipation of:
2174 ///
2175 /// - New values appearing in future releases of the client library, **and**
2176 /// - New values received dynamically, without application changes.
2177 ///
2178 /// Please consult the [Working with enums] section in the user guide for some
2179 /// guidelines.
2180 ///
2181 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2182 #[derive(Clone, Debug, PartialEq)]
2183 #[non_exhaustive]
2184 pub enum State {
2185 /// Default value. This value is unused.
2186 Unspecified,
2187 /// Ingestion is active.
2188 Active,
2189 /// Permission denied encountered while consuming data from Confluent
2190 /// Cloud.
2191 ConfluentCloudPermissionDenied,
2192 /// Permission denied encountered while publishing to the topic.
2193 PublishPermissionDenied,
2194 /// The provided bootstrap server address is unreachable.
2195 UnreachableBootstrapServer,
2196 /// The provided cluster wasn't found.
2197 ClusterNotFound,
2198 /// The provided topic wasn't found.
2199 TopicNotFound,
2200 /// If set, the enum was initialized with an unknown value.
2201 ///
2202 /// Applications can examine the value using [State::value] or
2203 /// [State::name].
2204 UnknownValue(state::UnknownValue),
2205 }
2206
2207 #[doc(hidden)]
2208 pub mod state {
2209 #[allow(unused_imports)]
2210 use super::*;
2211 #[derive(Clone, Debug, PartialEq)]
2212 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2213 }
2214
2215 impl State {
2216 /// Gets the enum value.
2217 ///
2218 /// Returns `None` if the enum contains an unknown value deserialized from
2219 /// the string representation of enums.
2220 pub fn value(&self) -> std::option::Option<i32> {
2221 match self {
2222 Self::Unspecified => std::option::Option::Some(0),
2223 Self::Active => std::option::Option::Some(1),
2224 Self::ConfluentCloudPermissionDenied => std::option::Option::Some(2),
2225 Self::PublishPermissionDenied => std::option::Option::Some(3),
2226 Self::UnreachableBootstrapServer => std::option::Option::Some(4),
2227 Self::ClusterNotFound => std::option::Option::Some(5),
2228 Self::TopicNotFound => std::option::Option::Some(6),
2229 Self::UnknownValue(u) => u.0.value(),
2230 }
2231 }
2232
2233 /// Gets the enum value as a string.
2234 ///
2235 /// Returns `None` if the enum contains an unknown value deserialized from
2236 /// the integer representation of enums.
2237 pub fn name(&self) -> std::option::Option<&str> {
2238 match self {
2239 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
2240 Self::Active => std::option::Option::Some("ACTIVE"),
2241 Self::ConfluentCloudPermissionDenied => {
2242 std::option::Option::Some("CONFLUENT_CLOUD_PERMISSION_DENIED")
2243 }
2244 Self::PublishPermissionDenied => {
2245 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
2246 }
2247 Self::UnreachableBootstrapServer => {
2248 std::option::Option::Some("UNREACHABLE_BOOTSTRAP_SERVER")
2249 }
2250 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
2251 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
2252 Self::UnknownValue(u) => u.0.name(),
2253 }
2254 }
2255 }
2256
2257 impl std::default::Default for State {
2258 fn default() -> Self {
2259 use std::convert::From;
2260 Self::from(0)
2261 }
2262 }
2263
2264 impl std::fmt::Display for State {
2265 fn fmt(
2266 &self,
2267 f: &mut std::fmt::Formatter<'_>,
2268 ) -> std::result::Result<(), std::fmt::Error> {
2269 wkt::internal::display_enum(f, self.name(), self.value())
2270 }
2271 }
2272
2273 impl std::convert::From<i32> for State {
2274 fn from(value: i32) -> Self {
2275 match value {
2276 0 => Self::Unspecified,
2277 1 => Self::Active,
2278 2 => Self::ConfluentCloudPermissionDenied,
2279 3 => Self::PublishPermissionDenied,
2280 4 => Self::UnreachableBootstrapServer,
2281 5 => Self::ClusterNotFound,
2282 6 => Self::TopicNotFound,
2283 _ => Self::UnknownValue(state::UnknownValue(
2284 wkt::internal::UnknownEnumValue::Integer(value),
2285 )),
2286 }
2287 }
2288 }
2289
2290 impl std::convert::From<&str> for State {
2291 fn from(value: &str) -> Self {
2292 use std::string::ToString;
2293 match value {
2294 "STATE_UNSPECIFIED" => Self::Unspecified,
2295 "ACTIVE" => Self::Active,
2296 "CONFLUENT_CLOUD_PERMISSION_DENIED" => Self::ConfluentCloudPermissionDenied,
2297 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
2298 "UNREACHABLE_BOOTSTRAP_SERVER" => Self::UnreachableBootstrapServer,
2299 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
2300 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
2301 _ => Self::UnknownValue(state::UnknownValue(
2302 wkt::internal::UnknownEnumValue::String(value.to_string()),
2303 )),
2304 }
2305 }
2306 }
2307
2308 impl serde::ser::Serialize for State {
2309 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2310 where
2311 S: serde::Serializer,
2312 {
2313 match self {
2314 Self::Unspecified => serializer.serialize_i32(0),
2315 Self::Active => serializer.serialize_i32(1),
2316 Self::ConfluentCloudPermissionDenied => serializer.serialize_i32(2),
2317 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2318 Self::UnreachableBootstrapServer => serializer.serialize_i32(4),
2319 Self::ClusterNotFound => serializer.serialize_i32(5),
2320 Self::TopicNotFound => serializer.serialize_i32(6),
2321 Self::UnknownValue(u) => u.0.serialize(serializer),
2322 }
2323 }
2324 }
2325
2326 impl<'de> serde::de::Deserialize<'de> for State {
2327 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2328 where
2329 D: serde::Deserializer<'de>,
2330 {
2331 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2332 ".google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud.State",
2333 ))
2334 }
2335 }
2336 }
2337
2338 /// Only one source type can have settings set.
2339 #[derive(Clone, Debug, PartialEq)]
2340 #[non_exhaustive]
2341 pub enum Source {
2342 /// Optional. Amazon Kinesis Data Streams.
2343 AwsKinesis(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>),
2344 /// Optional. Cloud Storage.
2345 CloudStorage(std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>),
2346 /// Optional. Azure Event Hubs.
2347 AzureEventHubs(
2348 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
2349 ),
2350 /// Optional. Amazon MSK.
2351 AwsMsk(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>),
2352 /// Optional. Confluent Cloud.
2353 ConfluentCloud(
2354 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
2355 ),
2356 }
2357}
2358
2359/// Settings for Platform Logs produced by Pub/Sub.
2360#[derive(Clone, Default, PartialEq)]
2361#[non_exhaustive]
2362pub struct PlatformLogsSettings {
2363 /// Optional. The minimum severity level of Platform Logs that will be written.
2364 pub severity: crate::model::platform_logs_settings::Severity,
2365
2366 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2367}
2368
2369impl PlatformLogsSettings {
2370 /// Creates a new default instance.
2371 pub fn new() -> Self {
2372 std::default::Default::default()
2373 }
2374
2375 /// Sets the value of [severity][crate::model::PlatformLogsSettings::severity].
2376 ///
2377 /// # Example
2378 /// ```ignore,no_run
2379 /// # use google_cloud_pubsub::model::PlatformLogsSettings;
2380 /// use google_cloud_pubsub::model::platform_logs_settings::Severity;
2381 /// let x0 = PlatformLogsSettings::new().set_severity(Severity::Disabled);
2382 /// let x1 = PlatformLogsSettings::new().set_severity(Severity::Debug);
2383 /// let x2 = PlatformLogsSettings::new().set_severity(Severity::Info);
2384 /// ```
2385 pub fn set_severity<T: std::convert::Into<crate::model::platform_logs_settings::Severity>>(
2386 mut self,
2387 v: T,
2388 ) -> Self {
2389 self.severity = v.into();
2390 self
2391 }
2392}
2393
2394impl wkt::message::Message for PlatformLogsSettings {
2395 fn typename() -> &'static str {
2396 "type.googleapis.com/google.pubsub.v1.PlatformLogsSettings"
2397 }
2398}
2399
2400/// Defines additional types related to [PlatformLogsSettings].
2401pub mod platform_logs_settings {
2402 #[allow(unused_imports)]
2403 use super::*;
2404
2405 /// Severity levels of Platform Logs.
2406 ///
2407 /// # Working with unknown values
2408 ///
2409 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2410 /// additional enum variants at any time. Adding new variants is not considered
2411 /// a breaking change. Applications should write their code in anticipation of:
2412 ///
2413 /// - New values appearing in future releases of the client library, **and**
2414 /// - New values received dynamically, without application changes.
2415 ///
2416 /// Please consult the [Working with enums] section in the user guide for some
2417 /// guidelines.
2418 ///
2419 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2420 #[derive(Clone, Debug, PartialEq)]
2421 #[non_exhaustive]
2422 pub enum Severity {
2423 /// Default value. Logs level is unspecified. Logs will be disabled.
2424 Unspecified,
2425 /// Logs will be disabled.
2426 Disabled,
2427 /// Debug logs and higher-severity logs will be written.
2428 Debug,
2429 /// Info logs and higher-severity logs will be written.
2430 Info,
2431 /// Warning logs and higher-severity logs will be written.
2432 Warning,
2433 /// Only error logs will be written.
2434 Error,
2435 /// If set, the enum was initialized with an unknown value.
2436 ///
2437 /// Applications can examine the value using [Severity::value] or
2438 /// [Severity::name].
2439 UnknownValue(severity::UnknownValue),
2440 }
2441
2442 #[doc(hidden)]
2443 pub mod severity {
2444 #[allow(unused_imports)]
2445 use super::*;
2446 #[derive(Clone, Debug, PartialEq)]
2447 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2448 }
2449
2450 impl Severity {
2451 /// Gets the enum value.
2452 ///
2453 /// Returns `None` if the enum contains an unknown value deserialized from
2454 /// the string representation of enums.
2455 pub fn value(&self) -> std::option::Option<i32> {
2456 match self {
2457 Self::Unspecified => std::option::Option::Some(0),
2458 Self::Disabled => std::option::Option::Some(1),
2459 Self::Debug => std::option::Option::Some(2),
2460 Self::Info => std::option::Option::Some(3),
2461 Self::Warning => std::option::Option::Some(4),
2462 Self::Error => std::option::Option::Some(5),
2463 Self::UnknownValue(u) => u.0.value(),
2464 }
2465 }
2466
2467 /// Gets the enum value as a string.
2468 ///
2469 /// Returns `None` if the enum contains an unknown value deserialized from
2470 /// the integer representation of enums.
2471 pub fn name(&self) -> std::option::Option<&str> {
2472 match self {
2473 Self::Unspecified => std::option::Option::Some("SEVERITY_UNSPECIFIED"),
2474 Self::Disabled => std::option::Option::Some("DISABLED"),
2475 Self::Debug => std::option::Option::Some("DEBUG"),
2476 Self::Info => std::option::Option::Some("INFO"),
2477 Self::Warning => std::option::Option::Some("WARNING"),
2478 Self::Error => std::option::Option::Some("ERROR"),
2479 Self::UnknownValue(u) => u.0.name(),
2480 }
2481 }
2482 }
2483
2484 impl std::default::Default for Severity {
2485 fn default() -> Self {
2486 use std::convert::From;
2487 Self::from(0)
2488 }
2489 }
2490
2491 impl std::fmt::Display for Severity {
2492 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2493 wkt::internal::display_enum(f, self.name(), self.value())
2494 }
2495 }
2496
2497 impl std::convert::From<i32> for Severity {
2498 fn from(value: i32) -> Self {
2499 match value {
2500 0 => Self::Unspecified,
2501 1 => Self::Disabled,
2502 2 => Self::Debug,
2503 3 => Self::Info,
2504 4 => Self::Warning,
2505 5 => Self::Error,
2506 _ => Self::UnknownValue(severity::UnknownValue(
2507 wkt::internal::UnknownEnumValue::Integer(value),
2508 )),
2509 }
2510 }
2511 }
2512
2513 impl std::convert::From<&str> for Severity {
2514 fn from(value: &str) -> Self {
2515 use std::string::ToString;
2516 match value {
2517 "SEVERITY_UNSPECIFIED" => Self::Unspecified,
2518 "DISABLED" => Self::Disabled,
2519 "DEBUG" => Self::Debug,
2520 "INFO" => Self::Info,
2521 "WARNING" => Self::Warning,
2522 "ERROR" => Self::Error,
2523 _ => Self::UnknownValue(severity::UnknownValue(
2524 wkt::internal::UnknownEnumValue::String(value.to_string()),
2525 )),
2526 }
2527 }
2528 }
2529
2530 impl serde::ser::Serialize for Severity {
2531 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2532 where
2533 S: serde::Serializer,
2534 {
2535 match self {
2536 Self::Unspecified => serializer.serialize_i32(0),
2537 Self::Disabled => serializer.serialize_i32(1),
2538 Self::Debug => serializer.serialize_i32(2),
2539 Self::Info => serializer.serialize_i32(3),
2540 Self::Warning => serializer.serialize_i32(4),
2541 Self::Error => serializer.serialize_i32(5),
2542 Self::UnknownValue(u) => u.0.serialize(serializer),
2543 }
2544 }
2545 }
2546
2547 impl<'de> serde::de::Deserialize<'de> for Severity {
2548 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2549 where
2550 D: serde::Deserializer<'de>,
2551 {
2552 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Severity>::new(
2553 ".google.pubsub.v1.PlatformLogsSettings.Severity",
2554 ))
2555 }
2556 }
2557}
2558
2559/// User-defined JavaScript function that can transform or filter a Pub/Sub
2560/// message.
2561#[derive(Clone, Default, PartialEq)]
2562#[non_exhaustive]
2563pub struct JavaScriptUDF {
2564 /// Required. Name of the JavasScript function that should applied to Pub/Sub
2565 /// messages.
2566 pub function_name: std::string::String,
2567
2568 /// Required. JavaScript code that contains a function `function_name` with the
2569 /// below signature:
2570 ///
2571 /// ```norust
2572 /// /**
2573 /// * Transforms a Pub/Sub message.
2574 ///
2575 /// * @return {(Object<string, (string | Object<string, string>)>|null)} - To
2576 /// * filter a message, return `null`. To transform a message return a map
2577 /// * with the following keys:
2578 /// * - (required) 'data' : {string}
2579 /// * - (optional) 'attributes' : {Object<string, string>}
2580 /// * Returning empty `attributes` will remove all attributes from the
2581 /// * message.
2582 /// *
2583 /// * @param {(Object<string, (string | Object<string, string>)>} Pub/Sub
2584 /// * message. Keys:
2585 /// * - (required) 'data' : {string}
2586 /// * - (required) 'attributes' : {Object<string, string>}
2587 /// *
2588 /// * @param {Object<string, any>} metadata - Pub/Sub message metadata.
2589 /// * Keys:
2590 /// * - (optional) 'message_id' : {string}
2591 /// * - (optional) 'publish_time': {string} YYYY-MM-DDTHH:MM:SSZ format
2592 /// * - (optional) 'ordering_key': {string}
2593 /// */
2594 ///
2595 /// function <function_name>(message, metadata) {
2596 /// }
2597 /// ```
2598 pub code: std::string::String,
2599
2600 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2601}
2602
2603impl JavaScriptUDF {
2604 /// Creates a new default instance.
2605 pub fn new() -> Self {
2606 std::default::Default::default()
2607 }
2608
2609 /// Sets the value of [function_name][crate::model::JavaScriptUDF::function_name].
2610 ///
2611 /// # Example
2612 /// ```ignore,no_run
2613 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2614 /// let x = JavaScriptUDF::new().set_function_name("example");
2615 /// ```
2616 pub fn set_function_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2617 self.function_name = v.into();
2618 self
2619 }
2620
2621 /// Sets the value of [code][crate::model::JavaScriptUDF::code].
2622 ///
2623 /// # Example
2624 /// ```ignore,no_run
2625 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2626 /// let x = JavaScriptUDF::new().set_code("example");
2627 /// ```
2628 pub fn set_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2629 self.code = v.into();
2630 self
2631 }
2632}
2633
2634impl wkt::message::Message for JavaScriptUDF {
2635 fn typename() -> &'static str {
2636 "type.googleapis.com/google.pubsub.v1.JavaScriptUDF"
2637 }
2638}
2639
2640/// Configuration for making inference requests against Vertex AI models.
2641#[derive(Clone, Default, PartialEq)]
2642#[non_exhaustive]
2643pub struct AIInference {
2644 /// Required. An endpoint to a Vertex AI model of the form
2645 /// `projects/{project}/locations/{location}/endpoints/{endpoint}` or
2646 /// `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`.
2647 /// Vertex AI API requests will be sent to this endpoint.
2648 pub endpoint: std::string::String,
2649
2650 /// Optional. The service account to use to make prediction requests against
2651 /// endpoints. The resource creator or updater that specifies this field must
2652 /// have `iam.serviceAccounts.actAs` permission on the service account. If not
2653 /// specified, the Pub/Sub [service
2654 /// agent](https://cloud.google.com/iam/docs/service-agents),
2655 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
2656 pub service_account_email: std::string::String,
2657
2658 /// The format of inference requests made to the endpoint.
2659 pub inference_mode: std::option::Option<crate::model::ai_inference::InferenceMode>,
2660
2661 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2662}
2663
2664impl AIInference {
2665 /// Creates a new default instance.
2666 pub fn new() -> Self {
2667 std::default::Default::default()
2668 }
2669
2670 /// Sets the value of [endpoint][crate::model::AIInference::endpoint].
2671 ///
2672 /// # Example
2673 /// ```ignore,no_run
2674 /// # use google_cloud_pubsub::model::AIInference;
2675 /// let x = AIInference::new().set_endpoint("example");
2676 /// ```
2677 pub fn set_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2678 self.endpoint = v.into();
2679 self
2680 }
2681
2682 /// Sets the value of [service_account_email][crate::model::AIInference::service_account_email].
2683 ///
2684 /// # Example
2685 /// ```ignore,no_run
2686 /// # use google_cloud_pubsub::model::AIInference;
2687 /// let x = AIInference::new().set_service_account_email("example");
2688 /// ```
2689 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
2690 mut self,
2691 v: T,
2692 ) -> Self {
2693 self.service_account_email = v.into();
2694 self
2695 }
2696
2697 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode].
2698 ///
2699 /// Note that all the setters affecting `inference_mode` are mutually
2700 /// exclusive.
2701 ///
2702 /// # Example
2703 /// ```ignore,no_run
2704 /// # use google_cloud_pubsub::model::AIInference;
2705 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2706 /// let x = AIInference::new().set_inference_mode(Some(
2707 /// google_cloud_pubsub::model::ai_inference::InferenceMode::UnstructuredInference(UnstructuredInference::default().into())));
2708 /// ```
2709 pub fn set_inference_mode<
2710 T: std::convert::Into<std::option::Option<crate::model::ai_inference::InferenceMode>>,
2711 >(
2712 mut self,
2713 v: T,
2714 ) -> Self {
2715 self.inference_mode = v.into();
2716 self
2717 }
2718
2719 /// The value of [inference_mode][crate::model::AIInference::inference_mode]
2720 /// if it holds a `UnstructuredInference`, `None` if the field is not set or
2721 /// holds a different branch.
2722 pub fn unstructured_inference(
2723 &self,
2724 ) -> std::option::Option<&std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>
2725 {
2726 #[allow(unreachable_patterns)]
2727 self.inference_mode.as_ref().and_then(|v| match v {
2728 crate::model::ai_inference::InferenceMode::UnstructuredInference(v) => {
2729 std::option::Option::Some(v)
2730 }
2731 _ => std::option::Option::None,
2732 })
2733 }
2734
2735 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode]
2736 /// to hold a `UnstructuredInference`.
2737 ///
2738 /// Note that all the setters affecting `inference_mode` are
2739 /// mutually exclusive.
2740 ///
2741 /// # Example
2742 /// ```ignore,no_run
2743 /// # use google_cloud_pubsub::model::AIInference;
2744 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2745 /// let x = AIInference::new().set_unstructured_inference(UnstructuredInference::default()/* use setters */);
2746 /// assert!(x.unstructured_inference().is_some());
2747 /// ```
2748 pub fn set_unstructured_inference<
2749 T: std::convert::Into<std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>,
2750 >(
2751 mut self,
2752 v: T,
2753 ) -> Self {
2754 self.inference_mode = std::option::Option::Some(
2755 crate::model::ai_inference::InferenceMode::UnstructuredInference(v.into()),
2756 );
2757 self
2758 }
2759}
2760
2761impl wkt::message::Message for AIInference {
2762 fn typename() -> &'static str {
2763 "type.googleapis.com/google.pubsub.v1.AIInference"
2764 }
2765}
2766
2767/// Defines additional types related to [AIInference].
2768pub mod ai_inference {
2769 #[allow(unused_imports)]
2770 use super::*;
2771
2772 /// Configuration for making inferences using arbitrary JSON payloads.
2773 #[derive(Clone, Default, PartialEq)]
2774 #[non_exhaustive]
2775 pub struct UnstructuredInference {
2776 /// Optional. A parameters object to be included in each inference request.
2777 /// The parameters object is combined with the data field of the Pub/Sub
2778 /// message to form the inference request.
2779 pub parameters: std::option::Option<wkt::Struct>,
2780
2781 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2782 }
2783
2784 impl UnstructuredInference {
2785 /// Creates a new default instance.
2786 pub fn new() -> Self {
2787 std::default::Default::default()
2788 }
2789
2790 /// Sets the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
2791 ///
2792 /// # Example
2793 /// ```ignore,no_run
2794 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2795 /// use wkt::Struct;
2796 /// let x = UnstructuredInference::new().set_parameters(Struct::default()/* use setters */);
2797 /// ```
2798 pub fn set_parameters<T>(mut self, v: T) -> Self
2799 where
2800 T: std::convert::Into<wkt::Struct>,
2801 {
2802 self.parameters = std::option::Option::Some(v.into());
2803 self
2804 }
2805
2806 /// Sets or clears the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
2807 ///
2808 /// # Example
2809 /// ```ignore,no_run
2810 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2811 /// use wkt::Struct;
2812 /// let x = UnstructuredInference::new().set_or_clear_parameters(Some(Struct::default()/* use setters */));
2813 /// let x = UnstructuredInference::new().set_or_clear_parameters(None::<Struct>);
2814 /// ```
2815 pub fn set_or_clear_parameters<T>(mut self, v: std::option::Option<T>) -> Self
2816 where
2817 T: std::convert::Into<wkt::Struct>,
2818 {
2819 self.parameters = v.map(|x| x.into());
2820 self
2821 }
2822 }
2823
2824 impl wkt::message::Message for UnstructuredInference {
2825 fn typename() -> &'static str {
2826 "type.googleapis.com/google.pubsub.v1.AIInference.UnstructuredInference"
2827 }
2828 }
2829
2830 /// The format of inference requests made to the endpoint.
2831 #[derive(Clone, Debug, PartialEq)]
2832 #[non_exhaustive]
2833 pub enum InferenceMode {
2834 /// Optional. Requests and responses can be any arbitrary JSON object.
2835 UnstructuredInference(std::boxed::Box<crate::model::ai_inference::UnstructuredInference>),
2836 }
2837}
2838
2839/// All supported message transforms types.
2840#[derive(Clone, Default, PartialEq)]
2841#[non_exhaustive]
2842pub struct MessageTransform {
2843 /// Optional. This field is deprecated, use the `disabled` field to disable
2844 /// transforms.
2845 #[deprecated]
2846 pub enabled: bool,
2847
2848 /// Optional. If true, the transform is disabled and will not be applied to
2849 /// messages. Defaults to `false`.
2850 pub disabled: bool,
2851
2852 /// The type of transform to apply to messages.
2853 pub transform: std::option::Option<crate::model::message_transform::Transform>,
2854
2855 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2856}
2857
2858impl MessageTransform {
2859 /// Creates a new default instance.
2860 pub fn new() -> Self {
2861 std::default::Default::default()
2862 }
2863
2864 /// Sets the value of [enabled][crate::model::MessageTransform::enabled].
2865 ///
2866 /// # Example
2867 /// ```ignore,no_run
2868 /// # use google_cloud_pubsub::model::MessageTransform;
2869 /// let x = MessageTransform::new().set_enabled(true);
2870 /// ```
2871 #[deprecated]
2872 pub fn set_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2873 self.enabled = v.into();
2874 self
2875 }
2876
2877 /// Sets the value of [disabled][crate::model::MessageTransform::disabled].
2878 ///
2879 /// # Example
2880 /// ```ignore,no_run
2881 /// # use google_cloud_pubsub::model::MessageTransform;
2882 /// let x = MessageTransform::new().set_disabled(true);
2883 /// ```
2884 pub fn set_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2885 self.disabled = v.into();
2886 self
2887 }
2888
2889 /// Sets the value of [transform][crate::model::MessageTransform::transform].
2890 ///
2891 /// Note that all the setters affecting `transform` are mutually
2892 /// exclusive.
2893 ///
2894 /// # Example
2895 /// ```ignore,no_run
2896 /// # use google_cloud_pubsub::model::MessageTransform;
2897 /// use google_cloud_pubsub::model::JavaScriptUDF;
2898 /// let x = MessageTransform::new().set_transform(Some(
2899 /// google_cloud_pubsub::model::message_transform::Transform::JavascriptUdf(JavaScriptUDF::default().into())));
2900 /// ```
2901 pub fn set_transform<
2902 T: std::convert::Into<std::option::Option<crate::model::message_transform::Transform>>,
2903 >(
2904 mut self,
2905 v: T,
2906 ) -> Self {
2907 self.transform = v.into();
2908 self
2909 }
2910
2911 /// The value of [transform][crate::model::MessageTransform::transform]
2912 /// if it holds a `JavascriptUdf`, `None` if the field is not set or
2913 /// holds a different branch.
2914 pub fn javascript_udf(
2915 &self,
2916 ) -> std::option::Option<&std::boxed::Box<crate::model::JavaScriptUDF>> {
2917 #[allow(unreachable_patterns)]
2918 self.transform.as_ref().and_then(|v| match v {
2919 crate::model::message_transform::Transform::JavascriptUdf(v) => {
2920 std::option::Option::Some(v)
2921 }
2922 _ => std::option::Option::None,
2923 })
2924 }
2925
2926 /// Sets the value of [transform][crate::model::MessageTransform::transform]
2927 /// to hold a `JavascriptUdf`.
2928 ///
2929 /// Note that all the setters affecting `transform` are
2930 /// mutually exclusive.
2931 ///
2932 /// # Example
2933 /// ```ignore,no_run
2934 /// # use google_cloud_pubsub::model::MessageTransform;
2935 /// use google_cloud_pubsub::model::JavaScriptUDF;
2936 /// let x = MessageTransform::new().set_javascript_udf(JavaScriptUDF::default()/* use setters */);
2937 /// assert!(x.javascript_udf().is_some());
2938 /// assert!(x.ai_inference().is_none());
2939 /// ```
2940 pub fn set_javascript_udf<
2941 T: std::convert::Into<std::boxed::Box<crate::model::JavaScriptUDF>>,
2942 >(
2943 mut self,
2944 v: T,
2945 ) -> Self {
2946 self.transform = std::option::Option::Some(
2947 crate::model::message_transform::Transform::JavascriptUdf(v.into()),
2948 );
2949 self
2950 }
2951
2952 /// The value of [transform][crate::model::MessageTransform::transform]
2953 /// if it holds a `AiInference`, `None` if the field is not set or
2954 /// holds a different branch.
2955 pub fn ai_inference(&self) -> std::option::Option<&std::boxed::Box<crate::model::AIInference>> {
2956 #[allow(unreachable_patterns)]
2957 self.transform.as_ref().and_then(|v| match v {
2958 crate::model::message_transform::Transform::AiInference(v) => {
2959 std::option::Option::Some(v)
2960 }
2961 _ => std::option::Option::None,
2962 })
2963 }
2964
2965 /// Sets the value of [transform][crate::model::MessageTransform::transform]
2966 /// to hold a `AiInference`.
2967 ///
2968 /// Note that all the setters affecting `transform` are
2969 /// mutually exclusive.
2970 ///
2971 /// # Example
2972 /// ```ignore,no_run
2973 /// # use google_cloud_pubsub::model::MessageTransform;
2974 /// use google_cloud_pubsub::model::AIInference;
2975 /// let x = MessageTransform::new().set_ai_inference(AIInference::default()/* use setters */);
2976 /// assert!(x.ai_inference().is_some());
2977 /// assert!(x.javascript_udf().is_none());
2978 /// ```
2979 pub fn set_ai_inference<T: std::convert::Into<std::boxed::Box<crate::model::AIInference>>>(
2980 mut self,
2981 v: T,
2982 ) -> Self {
2983 self.transform = std::option::Option::Some(
2984 crate::model::message_transform::Transform::AiInference(v.into()),
2985 );
2986 self
2987 }
2988}
2989
2990impl wkt::message::Message for MessageTransform {
2991 fn typename() -> &'static str {
2992 "type.googleapis.com/google.pubsub.v1.MessageTransform"
2993 }
2994}
2995
2996/// Defines additional types related to [MessageTransform].
2997pub mod message_transform {
2998 #[allow(unused_imports)]
2999 use super::*;
3000
3001 /// The type of transform to apply to messages.
3002 #[derive(Clone, Debug, PartialEq)]
3003 #[non_exhaustive]
3004 pub enum Transform {
3005 /// Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's
3006 /// are specified on a resource, each must have a unique `function_name`.
3007 JavascriptUdf(std::boxed::Box<crate::model::JavaScriptUDF>),
3008 /// Optional. AI Inference. Specifies the Vertex AI endpoint that inference
3009 /// requests built from the Pub/Sub message data and provided parameters will
3010 /// be sent to.
3011 AiInference(std::boxed::Box<crate::model::AIInference>),
3012 }
3013}
3014
3015/// A topic resource.
3016#[derive(Clone, Default, PartialEq)]
3017#[non_exhaustive]
3018pub struct Topic {
3019 /// Required. Identifier. The name of the topic. It must have the format
3020 /// `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
3021 /// and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
3022 /// underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
3023 /// signs (`%`). It must be between 3 and 255 characters in length, and it
3024 /// must not start with `"goog"`.
3025 pub name: std::string::String,
3026
3027 /// Optional. See [Creating and managing labels]
3028 /// (<https://cloud.google.com/pubsub/docs/labels>).
3029 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
3030
3031 /// Optional. Policy constraining the set of Google Cloud Platform regions
3032 /// where messages published to the topic may be stored. If not present, then
3033 /// no constraints are in effect.
3034 pub message_storage_policy: std::option::Option<crate::model::MessageStoragePolicy>,
3035
3036 /// Optional. The resource name of the Cloud KMS CryptoKey to be used to
3037 /// protect access to messages published on this topic.
3038 ///
3039 /// The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
3040 pub kms_key_name: std::string::String,
3041
3042 /// Optional. Settings for validating messages published against a schema.
3043 pub schema_settings: std::option::Option<crate::model::SchemaSettings>,
3044
3045 /// Optional. Reserved for future use. This field is set only in responses from
3046 /// the server; it is ignored if it is set in any requests.
3047 pub satisfies_pzs: bool,
3048
3049 /// Optional. Indicates the minimum duration to retain a message after it is
3050 /// published to the topic. If this field is set, messages published to the
3051 /// topic in the last `message_retention_duration` are always available to
3052 /// subscribers. For instance, it allows any attached subscription to [seek to
3053 /// a
3054 /// timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
3055 /// that is up to `message_retention_duration` in the past. If this field is
3056 /// not set, message retention is controlled by settings on individual
3057 /// subscriptions. Cannot be more than 31 days or less than 10 minutes.
3058 pub message_retention_duration: std::option::Option<wkt::Duration>,
3059
3060 /// Output only. An output-only field indicating the state of the topic.
3061 pub state: crate::model::topic::State,
3062
3063 /// Optional. Settings for ingestion from a data source into this topic.
3064 pub ingestion_data_source_settings:
3065 std::option::Option<crate::model::IngestionDataSourceSettings>,
3066
3067 /// Optional. Transforms to be applied to messages published to the topic.
3068 /// Transforms are applied in the order specified.
3069 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
3070
3071 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
3072 /// resource. For example:
3073 /// "123/environment": "production",
3074 /// "123/costCenter": "marketing"
3075 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
3076 /// using tags with Pub/Sub resources.
3077 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
3078
3079 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3080}
3081
3082impl Topic {
3083 /// Creates a new default instance.
3084 pub fn new() -> Self {
3085 std::default::Default::default()
3086 }
3087
3088 /// Sets the value of [name][crate::model::Topic::name].
3089 ///
3090 /// # Example
3091 /// ```ignore,no_run
3092 /// # use google_cloud_pubsub::model::Topic;
3093 /// let x = Topic::new().set_name("example");
3094 /// ```
3095 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3096 self.name = v.into();
3097 self
3098 }
3099
3100 /// Sets the value of [labels][crate::model::Topic::labels].
3101 ///
3102 /// # Example
3103 /// ```ignore,no_run
3104 /// # use google_cloud_pubsub::model::Topic;
3105 /// let x = Topic::new().set_labels([
3106 /// ("key0", "abc"),
3107 /// ("key1", "xyz"),
3108 /// ]);
3109 /// ```
3110 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
3111 where
3112 T: std::iter::IntoIterator<Item = (K, V)>,
3113 K: std::convert::Into<std::string::String>,
3114 V: std::convert::Into<std::string::String>,
3115 {
3116 use std::iter::Iterator;
3117 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3118 self
3119 }
3120
3121 /// Sets the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3122 ///
3123 /// # Example
3124 /// ```ignore,no_run
3125 /// # use google_cloud_pubsub::model::Topic;
3126 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3127 /// let x = Topic::new().set_message_storage_policy(MessageStoragePolicy::default()/* use setters */);
3128 /// ```
3129 pub fn set_message_storage_policy<T>(mut self, v: T) -> Self
3130 where
3131 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3132 {
3133 self.message_storage_policy = std::option::Option::Some(v.into());
3134 self
3135 }
3136
3137 /// Sets or clears the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3138 ///
3139 /// # Example
3140 /// ```ignore,no_run
3141 /// # use google_cloud_pubsub::model::Topic;
3142 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3143 /// let x = Topic::new().set_or_clear_message_storage_policy(Some(MessageStoragePolicy::default()/* use setters */));
3144 /// let x = Topic::new().set_or_clear_message_storage_policy(None::<MessageStoragePolicy>);
3145 /// ```
3146 pub fn set_or_clear_message_storage_policy<T>(mut self, v: std::option::Option<T>) -> Self
3147 where
3148 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3149 {
3150 self.message_storage_policy = v.map(|x| x.into());
3151 self
3152 }
3153
3154 /// Sets the value of [kms_key_name][crate::model::Topic::kms_key_name].
3155 ///
3156 /// # Example
3157 /// ```ignore,no_run
3158 /// # use google_cloud_pubsub::model::Topic;
3159 /// let x = Topic::new().set_kms_key_name("example");
3160 /// ```
3161 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3162 self.kms_key_name = v.into();
3163 self
3164 }
3165
3166 /// Sets the value of [schema_settings][crate::model::Topic::schema_settings].
3167 ///
3168 /// # Example
3169 /// ```ignore,no_run
3170 /// # use google_cloud_pubsub::model::Topic;
3171 /// use google_cloud_pubsub::model::SchemaSettings;
3172 /// let x = Topic::new().set_schema_settings(SchemaSettings::default()/* use setters */);
3173 /// ```
3174 pub fn set_schema_settings<T>(mut self, v: T) -> Self
3175 where
3176 T: std::convert::Into<crate::model::SchemaSettings>,
3177 {
3178 self.schema_settings = std::option::Option::Some(v.into());
3179 self
3180 }
3181
3182 /// Sets or clears the value of [schema_settings][crate::model::Topic::schema_settings].
3183 ///
3184 /// # Example
3185 /// ```ignore,no_run
3186 /// # use google_cloud_pubsub::model::Topic;
3187 /// use google_cloud_pubsub::model::SchemaSettings;
3188 /// let x = Topic::new().set_or_clear_schema_settings(Some(SchemaSettings::default()/* use setters */));
3189 /// let x = Topic::new().set_or_clear_schema_settings(None::<SchemaSettings>);
3190 /// ```
3191 pub fn set_or_clear_schema_settings<T>(mut self, v: std::option::Option<T>) -> Self
3192 where
3193 T: std::convert::Into<crate::model::SchemaSettings>,
3194 {
3195 self.schema_settings = v.map(|x| x.into());
3196 self
3197 }
3198
3199 /// Sets the value of [satisfies_pzs][crate::model::Topic::satisfies_pzs].
3200 ///
3201 /// # Example
3202 /// ```ignore,no_run
3203 /// # use google_cloud_pubsub::model::Topic;
3204 /// let x = Topic::new().set_satisfies_pzs(true);
3205 /// ```
3206 pub fn set_satisfies_pzs<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3207 self.satisfies_pzs = v.into();
3208 self
3209 }
3210
3211 /// Sets the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3212 ///
3213 /// # Example
3214 /// ```ignore,no_run
3215 /// # use google_cloud_pubsub::model::Topic;
3216 /// use wkt::Duration;
3217 /// let x = Topic::new().set_message_retention_duration(Duration::default()/* use setters */);
3218 /// ```
3219 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
3220 where
3221 T: std::convert::Into<wkt::Duration>,
3222 {
3223 self.message_retention_duration = std::option::Option::Some(v.into());
3224 self
3225 }
3226
3227 /// Sets or clears the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3228 ///
3229 /// # Example
3230 /// ```ignore,no_run
3231 /// # use google_cloud_pubsub::model::Topic;
3232 /// use wkt::Duration;
3233 /// let x = Topic::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
3234 /// let x = Topic::new().set_or_clear_message_retention_duration(None::<Duration>);
3235 /// ```
3236 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
3237 where
3238 T: std::convert::Into<wkt::Duration>,
3239 {
3240 self.message_retention_duration = v.map(|x| x.into());
3241 self
3242 }
3243
3244 /// Sets the value of [state][crate::model::Topic::state].
3245 ///
3246 /// # Example
3247 /// ```ignore,no_run
3248 /// # use google_cloud_pubsub::model::Topic;
3249 /// use google_cloud_pubsub::model::topic::State;
3250 /// let x0 = Topic::new().set_state(State::Active);
3251 /// let x1 = Topic::new().set_state(State::IngestionResourceError);
3252 /// ```
3253 pub fn set_state<T: std::convert::Into<crate::model::topic::State>>(mut self, v: T) -> Self {
3254 self.state = v.into();
3255 self
3256 }
3257
3258 /// Sets the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3259 ///
3260 /// # Example
3261 /// ```ignore,no_run
3262 /// # use google_cloud_pubsub::model::Topic;
3263 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3264 /// let x = Topic::new().set_ingestion_data_source_settings(IngestionDataSourceSettings::default()/* use setters */);
3265 /// ```
3266 pub fn set_ingestion_data_source_settings<T>(mut self, v: T) -> Self
3267 where
3268 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3269 {
3270 self.ingestion_data_source_settings = std::option::Option::Some(v.into());
3271 self
3272 }
3273
3274 /// Sets or clears the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3275 ///
3276 /// # Example
3277 /// ```ignore,no_run
3278 /// # use google_cloud_pubsub::model::Topic;
3279 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3280 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(Some(IngestionDataSourceSettings::default()/* use setters */));
3281 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(None::<IngestionDataSourceSettings>);
3282 /// ```
3283 pub fn set_or_clear_ingestion_data_source_settings<T>(
3284 mut self,
3285 v: std::option::Option<T>,
3286 ) -> Self
3287 where
3288 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3289 {
3290 self.ingestion_data_source_settings = v.map(|x| x.into());
3291 self
3292 }
3293
3294 /// Sets the value of [message_transforms][crate::model::Topic::message_transforms].
3295 ///
3296 /// # Example
3297 /// ```ignore,no_run
3298 /// # use google_cloud_pubsub::model::Topic;
3299 /// use google_cloud_pubsub::model::MessageTransform;
3300 /// let x = Topic::new()
3301 /// .set_message_transforms([
3302 /// MessageTransform::default()/* use setters */,
3303 /// MessageTransform::default()/* use (different) setters */,
3304 /// ]);
3305 /// ```
3306 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
3307 where
3308 T: std::iter::IntoIterator<Item = V>,
3309 V: std::convert::Into<crate::model::MessageTransform>,
3310 {
3311 use std::iter::Iterator;
3312 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
3313 self
3314 }
3315
3316 /// Sets the value of [tags][crate::model::Topic::tags].
3317 ///
3318 /// # Example
3319 /// ```ignore,no_run
3320 /// # use google_cloud_pubsub::model::Topic;
3321 /// let x = Topic::new().set_tags([
3322 /// ("key0", "abc"),
3323 /// ("key1", "xyz"),
3324 /// ]);
3325 /// ```
3326 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
3327 where
3328 T: std::iter::IntoIterator<Item = (K, V)>,
3329 K: std::convert::Into<std::string::String>,
3330 V: std::convert::Into<std::string::String>,
3331 {
3332 use std::iter::Iterator;
3333 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3334 self
3335 }
3336}
3337
3338impl wkt::message::Message for Topic {
3339 fn typename() -> &'static str {
3340 "type.googleapis.com/google.pubsub.v1.Topic"
3341 }
3342}
3343
3344/// Defines additional types related to [Topic].
3345pub mod topic {
3346 #[allow(unused_imports)]
3347 use super::*;
3348
3349 /// The state of the topic.
3350 ///
3351 /// # Working with unknown values
3352 ///
3353 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3354 /// additional enum variants at any time. Adding new variants is not considered
3355 /// a breaking change. Applications should write their code in anticipation of:
3356 ///
3357 /// - New values appearing in future releases of the client library, **and**
3358 /// - New values received dynamically, without application changes.
3359 ///
3360 /// Please consult the [Working with enums] section in the user guide for some
3361 /// guidelines.
3362 ///
3363 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3364 #[derive(Clone, Debug, PartialEq)]
3365 #[non_exhaustive]
3366 pub enum State {
3367 /// Default value. This value is unused.
3368 Unspecified,
3369 /// The topic does not have any persistent errors.
3370 Active,
3371 /// Ingestion from the data source has encountered a permanent error.
3372 /// See the more detailed error state in the corresponding ingestion
3373 /// source configuration.
3374 IngestionResourceError,
3375 /// If set, the enum was initialized with an unknown value.
3376 ///
3377 /// Applications can examine the value using [State::value] or
3378 /// [State::name].
3379 UnknownValue(state::UnknownValue),
3380 }
3381
3382 #[doc(hidden)]
3383 pub mod state {
3384 #[allow(unused_imports)]
3385 use super::*;
3386 #[derive(Clone, Debug, PartialEq)]
3387 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3388 }
3389
3390 impl State {
3391 /// Gets the enum value.
3392 ///
3393 /// Returns `None` if the enum contains an unknown value deserialized from
3394 /// the string representation of enums.
3395 pub fn value(&self) -> std::option::Option<i32> {
3396 match self {
3397 Self::Unspecified => std::option::Option::Some(0),
3398 Self::Active => std::option::Option::Some(1),
3399 Self::IngestionResourceError => std::option::Option::Some(2),
3400 Self::UnknownValue(u) => u.0.value(),
3401 }
3402 }
3403
3404 /// Gets the enum value as a string.
3405 ///
3406 /// Returns `None` if the enum contains an unknown value deserialized from
3407 /// the integer representation of enums.
3408 pub fn name(&self) -> std::option::Option<&str> {
3409 match self {
3410 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
3411 Self::Active => std::option::Option::Some("ACTIVE"),
3412 Self::IngestionResourceError => {
3413 std::option::Option::Some("INGESTION_RESOURCE_ERROR")
3414 }
3415 Self::UnknownValue(u) => u.0.name(),
3416 }
3417 }
3418 }
3419
3420 impl std::default::Default for State {
3421 fn default() -> Self {
3422 use std::convert::From;
3423 Self::from(0)
3424 }
3425 }
3426
3427 impl std::fmt::Display for State {
3428 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3429 wkt::internal::display_enum(f, self.name(), self.value())
3430 }
3431 }
3432
3433 impl std::convert::From<i32> for State {
3434 fn from(value: i32) -> Self {
3435 match value {
3436 0 => Self::Unspecified,
3437 1 => Self::Active,
3438 2 => Self::IngestionResourceError,
3439 _ => Self::UnknownValue(state::UnknownValue(
3440 wkt::internal::UnknownEnumValue::Integer(value),
3441 )),
3442 }
3443 }
3444 }
3445
3446 impl std::convert::From<&str> for State {
3447 fn from(value: &str) -> Self {
3448 use std::string::ToString;
3449 match value {
3450 "STATE_UNSPECIFIED" => Self::Unspecified,
3451 "ACTIVE" => Self::Active,
3452 "INGESTION_RESOURCE_ERROR" => Self::IngestionResourceError,
3453 _ => Self::UnknownValue(state::UnknownValue(
3454 wkt::internal::UnknownEnumValue::String(value.to_string()),
3455 )),
3456 }
3457 }
3458 }
3459
3460 impl serde::ser::Serialize for State {
3461 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3462 where
3463 S: serde::Serializer,
3464 {
3465 match self {
3466 Self::Unspecified => serializer.serialize_i32(0),
3467 Self::Active => serializer.serialize_i32(1),
3468 Self::IngestionResourceError => serializer.serialize_i32(2),
3469 Self::UnknownValue(u) => u.0.serialize(serializer),
3470 }
3471 }
3472 }
3473
3474 impl<'de> serde::de::Deserialize<'de> for State {
3475 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3476 where
3477 D: serde::Deserializer<'de>,
3478 {
3479 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
3480 ".google.pubsub.v1.Topic.State",
3481 ))
3482 }
3483 }
3484}
3485
3486/// Request for the GetTopic method.
3487#[derive(Clone, Default, PartialEq)]
3488#[non_exhaustive]
3489pub struct GetTopicRequest {
3490 /// Required. The name of the topic to get.
3491 /// Format is `projects/{project}/topics/{topic}`.
3492 pub topic: std::string::String,
3493
3494 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3495}
3496
3497impl GetTopicRequest {
3498 /// Creates a new default instance.
3499 pub fn new() -> Self {
3500 std::default::Default::default()
3501 }
3502
3503 /// Sets the value of [topic][crate::model::GetTopicRequest::topic].
3504 ///
3505 /// # Example
3506 /// ```ignore,no_run
3507 /// # use google_cloud_pubsub::model::GetTopicRequest;
3508 /// let x = GetTopicRequest::new().set_topic("example");
3509 /// ```
3510 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3511 self.topic = v.into();
3512 self
3513 }
3514}
3515
3516impl wkt::message::Message for GetTopicRequest {
3517 fn typename() -> &'static str {
3518 "type.googleapis.com/google.pubsub.v1.GetTopicRequest"
3519 }
3520}
3521
3522/// Request for the UpdateTopic method.
3523#[derive(Clone, Default, PartialEq)]
3524#[non_exhaustive]
3525pub struct UpdateTopicRequest {
3526 /// Required. The updated topic object.
3527 pub topic: std::option::Option<crate::model::Topic>,
3528
3529 /// Required. Indicates which fields in the provided topic to update. Must be
3530 /// specified and non-empty. Note that if `update_mask` contains
3531 /// "message_storage_policy" but the `message_storage_policy` is not set in
3532 /// the `topic` provided above, then the updated value is determined by the
3533 /// policy configured at the project or organization level.
3534 pub update_mask: std::option::Option<wkt::FieldMask>,
3535
3536 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3537}
3538
3539impl UpdateTopicRequest {
3540 /// Creates a new default instance.
3541 pub fn new() -> Self {
3542 std::default::Default::default()
3543 }
3544
3545 /// Sets the value of [topic][crate::model::UpdateTopicRequest::topic].
3546 ///
3547 /// # Example
3548 /// ```ignore,no_run
3549 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3550 /// use google_cloud_pubsub::model::Topic;
3551 /// let x = UpdateTopicRequest::new().set_topic(Topic::default()/* use setters */);
3552 /// ```
3553 pub fn set_topic<T>(mut self, v: T) -> Self
3554 where
3555 T: std::convert::Into<crate::model::Topic>,
3556 {
3557 self.topic = std::option::Option::Some(v.into());
3558 self
3559 }
3560
3561 /// Sets or clears the value of [topic][crate::model::UpdateTopicRequest::topic].
3562 ///
3563 /// # Example
3564 /// ```ignore,no_run
3565 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3566 /// use google_cloud_pubsub::model::Topic;
3567 /// let x = UpdateTopicRequest::new().set_or_clear_topic(Some(Topic::default()/* use setters */));
3568 /// let x = UpdateTopicRequest::new().set_or_clear_topic(None::<Topic>);
3569 /// ```
3570 pub fn set_or_clear_topic<T>(mut self, v: std::option::Option<T>) -> Self
3571 where
3572 T: std::convert::Into<crate::model::Topic>,
3573 {
3574 self.topic = v.map(|x| x.into());
3575 self
3576 }
3577
3578 /// Sets the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
3579 ///
3580 /// # Example
3581 /// ```ignore,no_run
3582 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3583 /// use wkt::FieldMask;
3584 /// let x = UpdateTopicRequest::new().set_update_mask(FieldMask::default()/* use setters */);
3585 /// ```
3586 pub fn set_update_mask<T>(mut self, v: T) -> Self
3587 where
3588 T: std::convert::Into<wkt::FieldMask>,
3589 {
3590 self.update_mask = std::option::Option::Some(v.into());
3591 self
3592 }
3593
3594 /// Sets or clears the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
3595 ///
3596 /// # Example
3597 /// ```ignore,no_run
3598 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3599 /// use wkt::FieldMask;
3600 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
3601 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(None::<FieldMask>);
3602 /// ```
3603 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
3604 where
3605 T: std::convert::Into<wkt::FieldMask>,
3606 {
3607 self.update_mask = v.map(|x| x.into());
3608 self
3609 }
3610}
3611
3612impl wkt::message::Message for UpdateTopicRequest {
3613 fn typename() -> &'static str {
3614 "type.googleapis.com/google.pubsub.v1.UpdateTopicRequest"
3615 }
3616}
3617
3618/// Request for the `ListTopics` method.
3619#[derive(Clone, Default, PartialEq)]
3620#[non_exhaustive]
3621pub struct ListTopicsRequest {
3622 /// Required. The name of the project in which to list topics.
3623 /// Format is `projects/{project-id}`.
3624 pub project: std::string::String,
3625
3626 /// Optional. Maximum number of topics to return.
3627 pub page_size: i32,
3628
3629 /// Optional. The value returned by the last `ListTopicsResponse`; indicates
3630 /// that this is a continuation of a prior `ListTopics` call, and that the
3631 /// system should return the next page of data.
3632 pub page_token: std::string::String,
3633
3634 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3635}
3636
3637impl ListTopicsRequest {
3638 /// Creates a new default instance.
3639 pub fn new() -> Self {
3640 std::default::Default::default()
3641 }
3642
3643 /// Sets the value of [project][crate::model::ListTopicsRequest::project].
3644 ///
3645 /// # Example
3646 /// ```ignore,no_run
3647 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3648 /// let x = ListTopicsRequest::new().set_project("example");
3649 /// ```
3650 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3651 self.project = v.into();
3652 self
3653 }
3654
3655 /// Sets the value of [page_size][crate::model::ListTopicsRequest::page_size].
3656 ///
3657 /// # Example
3658 /// ```ignore,no_run
3659 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3660 /// let x = ListTopicsRequest::new().set_page_size(42);
3661 /// ```
3662 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3663 self.page_size = v.into();
3664 self
3665 }
3666
3667 /// Sets the value of [page_token][crate::model::ListTopicsRequest::page_token].
3668 ///
3669 /// # Example
3670 /// ```ignore,no_run
3671 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3672 /// let x = ListTopicsRequest::new().set_page_token("example");
3673 /// ```
3674 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3675 self.page_token = v.into();
3676 self
3677 }
3678}
3679
3680impl wkt::message::Message for ListTopicsRequest {
3681 fn typename() -> &'static str {
3682 "type.googleapis.com/google.pubsub.v1.ListTopicsRequest"
3683 }
3684}
3685
3686/// Response for the `ListTopics` method.
3687#[derive(Clone, Default, PartialEq)]
3688#[non_exhaustive]
3689pub struct ListTopicsResponse {
3690 /// Optional. The resulting topics.
3691 pub topics: std::vec::Vec<crate::model::Topic>,
3692
3693 /// Optional. If not empty, indicates that there may be more topics that match
3694 /// the request; this value should be passed in a new `ListTopicsRequest`.
3695 pub next_page_token: std::string::String,
3696
3697 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3698}
3699
3700impl ListTopicsResponse {
3701 /// Creates a new default instance.
3702 pub fn new() -> Self {
3703 std::default::Default::default()
3704 }
3705
3706 /// Sets the value of [topics][crate::model::ListTopicsResponse::topics].
3707 ///
3708 /// # Example
3709 /// ```ignore,no_run
3710 /// # use google_cloud_pubsub::model::ListTopicsResponse;
3711 /// use google_cloud_pubsub::model::Topic;
3712 /// let x = ListTopicsResponse::new()
3713 /// .set_topics([
3714 /// Topic::default()/* use setters */,
3715 /// Topic::default()/* use (different) setters */,
3716 /// ]);
3717 /// ```
3718 pub fn set_topics<T, V>(mut self, v: T) -> Self
3719 where
3720 T: std::iter::IntoIterator<Item = V>,
3721 V: std::convert::Into<crate::model::Topic>,
3722 {
3723 use std::iter::Iterator;
3724 self.topics = v.into_iter().map(|i| i.into()).collect();
3725 self
3726 }
3727
3728 /// Sets the value of [next_page_token][crate::model::ListTopicsResponse::next_page_token].
3729 ///
3730 /// # Example
3731 /// ```ignore,no_run
3732 /// # use google_cloud_pubsub::model::ListTopicsResponse;
3733 /// let x = ListTopicsResponse::new().set_next_page_token("example");
3734 /// ```
3735 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3736 self.next_page_token = v.into();
3737 self
3738 }
3739}
3740
3741impl wkt::message::Message for ListTopicsResponse {
3742 fn typename() -> &'static str {
3743 "type.googleapis.com/google.pubsub.v1.ListTopicsResponse"
3744 }
3745}
3746
3747#[doc(hidden)]
3748impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicsResponse {
3749 type PageItem = crate::model::Topic;
3750
3751 fn items(self) -> std::vec::Vec<Self::PageItem> {
3752 self.topics
3753 }
3754
3755 fn next_page_token(&self) -> std::string::String {
3756 use std::clone::Clone;
3757 self.next_page_token.clone()
3758 }
3759}
3760
3761/// Request for the `ListTopicSubscriptions` method.
3762#[derive(Clone, Default, PartialEq)]
3763#[non_exhaustive]
3764pub struct ListTopicSubscriptionsRequest {
3765 /// Required. The name of the topic that subscriptions are attached to.
3766 /// Format is `projects/{project}/topics/{topic}`.
3767 pub topic: std::string::String,
3768
3769 /// Optional. Maximum number of subscription names to return.
3770 pub page_size: i32,
3771
3772 /// Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
3773 /// indicates that this is a continuation of a prior `ListTopicSubscriptions`
3774 /// call, and that the system should return the next page of data.
3775 pub page_token: std::string::String,
3776
3777 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3778}
3779
3780impl ListTopicSubscriptionsRequest {
3781 /// Creates a new default instance.
3782 pub fn new() -> Self {
3783 std::default::Default::default()
3784 }
3785
3786 /// Sets the value of [topic][crate::model::ListTopicSubscriptionsRequest::topic].
3787 ///
3788 /// # Example
3789 /// ```ignore,no_run
3790 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3791 /// let x = ListTopicSubscriptionsRequest::new().set_topic("example");
3792 /// ```
3793 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3794 self.topic = v.into();
3795 self
3796 }
3797
3798 /// Sets the value of [page_size][crate::model::ListTopicSubscriptionsRequest::page_size].
3799 ///
3800 /// # Example
3801 /// ```ignore,no_run
3802 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3803 /// let x = ListTopicSubscriptionsRequest::new().set_page_size(42);
3804 /// ```
3805 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3806 self.page_size = v.into();
3807 self
3808 }
3809
3810 /// Sets the value of [page_token][crate::model::ListTopicSubscriptionsRequest::page_token].
3811 ///
3812 /// # Example
3813 /// ```ignore,no_run
3814 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3815 /// let x = ListTopicSubscriptionsRequest::new().set_page_token("example");
3816 /// ```
3817 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3818 self.page_token = v.into();
3819 self
3820 }
3821}
3822
3823impl wkt::message::Message for ListTopicSubscriptionsRequest {
3824 fn typename() -> &'static str {
3825 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsRequest"
3826 }
3827}
3828
3829/// Response for the `ListTopicSubscriptions` method.
3830#[derive(Clone, Default, PartialEq)]
3831#[non_exhaustive]
3832pub struct ListTopicSubscriptionsResponse {
3833 /// Optional. The names of subscriptions attached to the topic specified in the
3834 /// request.
3835 pub subscriptions: std::vec::Vec<std::string::String>,
3836
3837 /// Optional. If not empty, indicates that there may be more subscriptions that
3838 /// match the request; this value should be passed in a new
3839 /// `ListTopicSubscriptionsRequest` to get more subscriptions.
3840 pub next_page_token: std::string::String,
3841
3842 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3843}
3844
3845impl ListTopicSubscriptionsResponse {
3846 /// Creates a new default instance.
3847 pub fn new() -> Self {
3848 std::default::Default::default()
3849 }
3850
3851 /// Sets the value of [subscriptions][crate::model::ListTopicSubscriptionsResponse::subscriptions].
3852 ///
3853 /// # Example
3854 /// ```ignore,no_run
3855 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
3856 /// let x = ListTopicSubscriptionsResponse::new().set_subscriptions(["a", "b", "c"]);
3857 /// ```
3858 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
3859 where
3860 T: std::iter::IntoIterator<Item = V>,
3861 V: std::convert::Into<std::string::String>,
3862 {
3863 use std::iter::Iterator;
3864 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
3865 self
3866 }
3867
3868 /// Sets the value of [next_page_token][crate::model::ListTopicSubscriptionsResponse::next_page_token].
3869 ///
3870 /// # Example
3871 /// ```ignore,no_run
3872 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
3873 /// let x = ListTopicSubscriptionsResponse::new().set_next_page_token("example");
3874 /// ```
3875 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3876 self.next_page_token = v.into();
3877 self
3878 }
3879}
3880
3881impl wkt::message::Message for ListTopicSubscriptionsResponse {
3882 fn typename() -> &'static str {
3883 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsResponse"
3884 }
3885}
3886
3887#[doc(hidden)]
3888impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicSubscriptionsResponse {
3889 type PageItem = std::string::String;
3890
3891 fn items(self) -> std::vec::Vec<Self::PageItem> {
3892 self.subscriptions
3893 }
3894
3895 fn next_page_token(&self) -> std::string::String {
3896 use std::clone::Clone;
3897 self.next_page_token.clone()
3898 }
3899}
3900
3901/// Request for the `ListTopicSnapshots` method.
3902#[derive(Clone, Default, PartialEq)]
3903#[non_exhaustive]
3904pub struct ListTopicSnapshotsRequest {
3905 /// Required. The name of the topic that snapshots are attached to.
3906 /// Format is `projects/{project}/topics/{topic}`.
3907 pub topic: std::string::String,
3908
3909 /// Optional. Maximum number of snapshot names to return.
3910 pub page_size: i32,
3911
3912 /// Optional. The value returned by the last `ListTopicSnapshotsResponse`;
3913 /// indicates that this is a continuation of a prior `ListTopicSnapshots` call,
3914 /// and that the system should return the next page of data.
3915 pub page_token: std::string::String,
3916
3917 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3918}
3919
3920impl ListTopicSnapshotsRequest {
3921 /// Creates a new default instance.
3922 pub fn new() -> Self {
3923 std::default::Default::default()
3924 }
3925
3926 /// Sets the value of [topic][crate::model::ListTopicSnapshotsRequest::topic].
3927 ///
3928 /// # Example
3929 /// ```ignore,no_run
3930 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3931 /// let x = ListTopicSnapshotsRequest::new().set_topic("example");
3932 /// ```
3933 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3934 self.topic = v.into();
3935 self
3936 }
3937
3938 /// Sets the value of [page_size][crate::model::ListTopicSnapshotsRequest::page_size].
3939 ///
3940 /// # Example
3941 /// ```ignore,no_run
3942 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3943 /// let x = ListTopicSnapshotsRequest::new().set_page_size(42);
3944 /// ```
3945 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3946 self.page_size = v.into();
3947 self
3948 }
3949
3950 /// Sets the value of [page_token][crate::model::ListTopicSnapshotsRequest::page_token].
3951 ///
3952 /// # Example
3953 /// ```ignore,no_run
3954 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3955 /// let x = ListTopicSnapshotsRequest::new().set_page_token("example");
3956 /// ```
3957 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3958 self.page_token = v.into();
3959 self
3960 }
3961}
3962
3963impl wkt::message::Message for ListTopicSnapshotsRequest {
3964 fn typename() -> &'static str {
3965 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsRequest"
3966 }
3967}
3968
3969/// Response for the `ListTopicSnapshots` method.
3970#[derive(Clone, Default, PartialEq)]
3971#[non_exhaustive]
3972pub struct ListTopicSnapshotsResponse {
3973 /// Optional. The names of the snapshots that match the request.
3974 pub snapshots: std::vec::Vec<std::string::String>,
3975
3976 /// Optional. If not empty, indicates that there may be more snapshots that
3977 /// match the request; this value should be passed in a new
3978 /// `ListTopicSnapshotsRequest` to get more snapshots.
3979 pub next_page_token: std::string::String,
3980
3981 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3982}
3983
3984impl ListTopicSnapshotsResponse {
3985 /// Creates a new default instance.
3986 pub fn new() -> Self {
3987 std::default::Default::default()
3988 }
3989
3990 /// Sets the value of [snapshots][crate::model::ListTopicSnapshotsResponse::snapshots].
3991 ///
3992 /// # Example
3993 /// ```ignore,no_run
3994 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
3995 /// let x = ListTopicSnapshotsResponse::new().set_snapshots(["a", "b", "c"]);
3996 /// ```
3997 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
3998 where
3999 T: std::iter::IntoIterator<Item = V>,
4000 V: std::convert::Into<std::string::String>,
4001 {
4002 use std::iter::Iterator;
4003 self.snapshots = v.into_iter().map(|i| i.into()).collect();
4004 self
4005 }
4006
4007 /// Sets the value of [next_page_token][crate::model::ListTopicSnapshotsResponse::next_page_token].
4008 ///
4009 /// # Example
4010 /// ```ignore,no_run
4011 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
4012 /// let x = ListTopicSnapshotsResponse::new().set_next_page_token("example");
4013 /// ```
4014 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4015 self.next_page_token = v.into();
4016 self
4017 }
4018}
4019
4020impl wkt::message::Message for ListTopicSnapshotsResponse {
4021 fn typename() -> &'static str {
4022 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsResponse"
4023 }
4024}
4025
4026/// Request for the `DeleteTopic` method.
4027#[derive(Clone, Default, PartialEq)]
4028#[non_exhaustive]
4029pub struct DeleteTopicRequest {
4030 /// Required. Name of the topic to delete.
4031 /// Format is `projects/{project}/topics/{topic}`.
4032 pub topic: std::string::String,
4033
4034 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4035}
4036
4037impl DeleteTopicRequest {
4038 /// Creates a new default instance.
4039 pub fn new() -> Self {
4040 std::default::Default::default()
4041 }
4042
4043 /// Sets the value of [topic][crate::model::DeleteTopicRequest::topic].
4044 ///
4045 /// # Example
4046 /// ```ignore,no_run
4047 /// # use google_cloud_pubsub::model::DeleteTopicRequest;
4048 /// let x = DeleteTopicRequest::new().set_topic("example");
4049 /// ```
4050 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4051 self.topic = v.into();
4052 self
4053 }
4054}
4055
4056impl wkt::message::Message for DeleteTopicRequest {
4057 fn typename() -> &'static str {
4058 "type.googleapis.com/google.pubsub.v1.DeleteTopicRequest"
4059 }
4060}
4061
4062/// Request for the DetachSubscription method.
4063#[derive(Clone, Default, PartialEq)]
4064#[non_exhaustive]
4065pub struct DetachSubscriptionRequest {
4066 /// Required. The subscription to detach.
4067 /// Format is `projects/{project}/subscriptions/{subscription}`.
4068 pub subscription: std::string::String,
4069
4070 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4071}
4072
4073impl DetachSubscriptionRequest {
4074 /// Creates a new default instance.
4075 pub fn new() -> Self {
4076 std::default::Default::default()
4077 }
4078
4079 /// Sets the value of [subscription][crate::model::DetachSubscriptionRequest::subscription].
4080 ///
4081 /// # Example
4082 /// ```ignore,no_run
4083 /// # use google_cloud_pubsub::model::DetachSubscriptionRequest;
4084 /// let x = DetachSubscriptionRequest::new().set_subscription("example");
4085 /// ```
4086 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4087 self.subscription = v.into();
4088 self
4089 }
4090}
4091
4092impl wkt::message::Message for DetachSubscriptionRequest {
4093 fn typename() -> &'static str {
4094 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionRequest"
4095 }
4096}
4097
4098/// Response for the DetachSubscription method.
4099/// Reserved for future use.
4100#[derive(Clone, Default, PartialEq)]
4101#[non_exhaustive]
4102pub struct DetachSubscriptionResponse {
4103 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4104}
4105
4106impl DetachSubscriptionResponse {
4107 /// Creates a new default instance.
4108 pub fn new() -> Self {
4109 std::default::Default::default()
4110 }
4111}
4112
4113impl wkt::message::Message for DetachSubscriptionResponse {
4114 fn typename() -> &'static str {
4115 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionResponse"
4116 }
4117}
4118
4119/// A subscription resource. If none of `push_config`, `bigquery_config`, or
4120/// `cloud_storage_config` is set, then the subscriber will pull and ack messages
4121/// using API methods. At most one of these fields may be set.
4122#[derive(Clone, Default, PartialEq)]
4123#[non_exhaustive]
4124pub struct Subscription {
4125 /// Required. Identifier. The name of the subscription. It must have the format
4126 /// `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
4127 /// start with a letter, and contain only letters (`[A-Za-z]`), numbers
4128 /// (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
4129 /// plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
4130 /// in length, and it must not start with `"goog"`.
4131 pub name: std::string::String,
4132
4133 /// Required. The name of the topic from which this subscription is receiving
4134 /// messages. Format is `projects/{project}/topics/{topic}`. The value of this
4135 /// field will be `_deleted-topic_` if the topic has been deleted.
4136 pub topic: std::string::String,
4137
4138 /// Optional. If push delivery is used with this subscription, this field is
4139 /// used to configure it.
4140 pub push_config: std::option::Option<crate::model::PushConfig>,
4141
4142 /// Optional. If delivery to BigQuery is used with this subscription, this
4143 /// field is used to configure it.
4144 pub bigquery_config: std::option::Option<crate::model::BigQueryConfig>,
4145
4146 /// Optional. If delivery to Google Cloud Storage is used with this
4147 /// subscription, this field is used to configure it.
4148 pub cloud_storage_config: std::option::Option<crate::model::CloudStorageConfig>,
4149
4150 /// Optional. If delivery to Bigtable is used with this subscription, this
4151 /// field is used to configure it.
4152 pub bigtable_config: std::option::Option<crate::model::BigtableConfig>,
4153
4154 /// Optional. The approximate amount of time (on a best-effort basis) Pub/Sub
4155 /// waits for the subscriber to acknowledge receipt before resending the
4156 /// message. In the interval after the message is delivered and before it is
4157 /// acknowledged, it is considered to be _outstanding_. During that time
4158 /// period, the message will not be redelivered (on a best-effort basis).
4159 ///
4160 /// For pull subscriptions, this value is used as the initial value for the ack
4161 /// deadline. To override this value for a given message, call
4162 /// `ModifyAckDeadline` with the corresponding `ack_id` if using
4163 /// non-streaming pull or send the `ack_id` in a
4164 /// `StreamingModifyAckDeadlineRequest` if using streaming pull.
4165 /// The minimum custom deadline you can specify is 10 seconds.
4166 /// The maximum custom deadline you can specify is 600 seconds (10 minutes).
4167 /// If this parameter is 0, a default value of 10 seconds is used.
4168 ///
4169 /// For push delivery, this value is also used to set the request timeout for
4170 /// the call to the push endpoint.
4171 ///
4172 /// If the subscriber never acknowledges the message, the Pub/Sub
4173 /// system will eventually redeliver the message.
4174 pub ack_deadline_seconds: i32,
4175
4176 /// Optional. Indicates whether to retain acknowledged messages. If true, then
4177 /// messages are not expunged from the subscription's backlog, even if they are
4178 /// acknowledged, until they fall out of the `message_retention_duration`
4179 /// window. This must be true if you would like to [`Seek` to a timestamp]
4180 /// (<https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time>) in
4181 /// the past to replay previously-acknowledged messages.
4182 pub retain_acked_messages: bool,
4183
4184 /// Optional. How long to retain unacknowledged messages in the subscription's
4185 /// backlog, from the moment a message is published. If `retain_acked_messages`
4186 /// is true, then this also configures the retention of acknowledged messages,
4187 /// and thus configures how far back in time a `Seek` can be done. Defaults to
4188 /// 7 days. Cannot be more than 31 days or less than 10 minutes.
4189 pub message_retention_duration: std::option::Option<wkt::Duration>,
4190
4191 /// Optional. See [Creating and managing
4192 /// labels](https://cloud.google.com/pubsub/docs/labels).
4193 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
4194
4195 /// Optional. If true, messages published with the same `ordering_key` in
4196 /// `PubsubMessage` will be delivered to the subscribers in the order in which
4197 /// they are received by the Pub/Sub system. Otherwise, they may be delivered
4198 /// in any order.
4199 pub enable_message_ordering: bool,
4200
4201 /// Optional. A policy that specifies the conditions for this subscription's
4202 /// expiration. A subscription is considered active as long as any connected
4203 /// subscriber is successfully consuming messages from the subscription or is
4204 /// issuing operations on the subscription. If `expiration_policy` is not set,
4205 /// a *default policy* with `ttl` of 31 days will be used. The minimum allowed
4206 /// value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set,
4207 /// but `expiration_policy.ttl` is not set, the subscription never expires.
4208 pub expiration_policy: std::option::Option<crate::model::ExpirationPolicy>,
4209
4210 /// Optional. An expression written in the Pub/Sub [filter
4211 /// language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
4212 /// then only `PubsubMessage`s whose `attributes` field matches the filter are
4213 /// delivered on this subscription. If empty, then no messages are filtered
4214 /// out.
4215 pub filter: std::string::String,
4216
4217 /// Optional. A policy that specifies the conditions for dead lettering
4218 /// messages in this subscription. If dead_letter_policy is not set, dead
4219 /// lettering is disabled.
4220 ///
4221 /// The Pub/Sub service account associated with this subscriptions's
4222 /// parent project (i.e.,
4223 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
4224 /// permission to Acknowledge() messages on this subscription.
4225 pub dead_letter_policy: std::option::Option<crate::model::DeadLetterPolicy>,
4226
4227 /// Optional. A policy that specifies how Pub/Sub retries message delivery for
4228 /// this subscription.
4229 ///
4230 /// If not set, the default retry policy is applied. This generally implies
4231 /// that messages will be retried as soon as possible for healthy subscribers.
4232 /// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
4233 /// events for a given message.
4234 pub retry_policy: std::option::Option<crate::model::RetryPolicy>,
4235
4236 /// Optional. Indicates whether the subscription is detached from its topic.
4237 /// Detached subscriptions don't receive messages from their topic and don't
4238 /// retain any backlog. `Pull` and `StreamingPull` requests will return
4239 /// FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
4240 /// the endpoint will not be made.
4241 pub detached: bool,
4242
4243 /// Optional. If true, Pub/Sub provides the following guarantees for the
4244 /// delivery of a message with a given value of `message_id` on this
4245 /// subscription:
4246 ///
4247 /// * The message sent to a subscriber is guaranteed not to be resent
4248 /// before the message's acknowledgment deadline expires.
4249 /// * An acknowledged message will not be resent to a subscriber.
4250 ///
4251 /// Note that subscribers may still receive multiple copies of a message
4252 /// when `enable_exactly_once_delivery` is true if the message was published
4253 /// multiple times by a publisher client. These copies are considered distinct
4254 /// by Pub/Sub and have distinct `message_id` values.
4255 pub enable_exactly_once_delivery: bool,
4256
4257 /// Output only. Indicates the minimum duration for which a message is retained
4258 /// after it is published to the subscription's topic. If this field is set,
4259 /// messages published to the subscription's topic in the last
4260 /// `topic_message_retention_duration` are always available to subscribers. See
4261 /// the `message_retention_duration` field in `Topic`. This field is set only
4262 /// in responses from the server; it is ignored if it is set in any requests.
4263 pub topic_message_retention_duration: std::option::Option<wkt::Duration>,
4264
4265 /// Output only. An output-only field indicating whether or not the
4266 /// subscription can receive messages.
4267 pub state: crate::model::subscription::State,
4268
4269 /// Output only. Information about the associated Analytics Hub subscription.
4270 /// Only set if the subscription is created by Analytics Hub.
4271 pub analytics_hub_subscription_info:
4272 std::option::Option<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4273
4274 /// Optional. Transforms to be applied to messages before they are delivered to
4275 /// subscribers. Transforms are applied in the order specified.
4276 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
4277
4278 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
4279 /// resource. For example:
4280 /// "123/environment": "production",
4281 /// "123/costCenter": "marketing"
4282 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
4283 /// using tags with Pub/Sub resources.
4284 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
4285
4286 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4287}
4288
4289impl Subscription {
4290 /// Creates a new default instance.
4291 pub fn new() -> Self {
4292 std::default::Default::default()
4293 }
4294
4295 /// Sets the value of [name][crate::model::Subscription::name].
4296 ///
4297 /// # Example
4298 /// ```ignore,no_run
4299 /// # use google_cloud_pubsub::model::Subscription;
4300 /// let x = Subscription::new().set_name("example");
4301 /// ```
4302 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4303 self.name = v.into();
4304 self
4305 }
4306
4307 /// Sets the value of [topic][crate::model::Subscription::topic].
4308 ///
4309 /// # Example
4310 /// ```ignore,no_run
4311 /// # use google_cloud_pubsub::model::Subscription;
4312 /// let x = Subscription::new().set_topic("example");
4313 /// ```
4314 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4315 self.topic = v.into();
4316 self
4317 }
4318
4319 /// Sets the value of [push_config][crate::model::Subscription::push_config].
4320 ///
4321 /// # Example
4322 /// ```ignore,no_run
4323 /// # use google_cloud_pubsub::model::Subscription;
4324 /// use google_cloud_pubsub::model::PushConfig;
4325 /// let x = Subscription::new().set_push_config(PushConfig::default()/* use setters */);
4326 /// ```
4327 pub fn set_push_config<T>(mut self, v: T) -> Self
4328 where
4329 T: std::convert::Into<crate::model::PushConfig>,
4330 {
4331 self.push_config = std::option::Option::Some(v.into());
4332 self
4333 }
4334
4335 /// Sets or clears the value of [push_config][crate::model::Subscription::push_config].
4336 ///
4337 /// # Example
4338 /// ```ignore,no_run
4339 /// # use google_cloud_pubsub::model::Subscription;
4340 /// use google_cloud_pubsub::model::PushConfig;
4341 /// let x = Subscription::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
4342 /// let x = Subscription::new().set_or_clear_push_config(None::<PushConfig>);
4343 /// ```
4344 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
4345 where
4346 T: std::convert::Into<crate::model::PushConfig>,
4347 {
4348 self.push_config = v.map(|x| x.into());
4349 self
4350 }
4351
4352 /// Sets the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4353 ///
4354 /// # Example
4355 /// ```ignore,no_run
4356 /// # use google_cloud_pubsub::model::Subscription;
4357 /// use google_cloud_pubsub::model::BigQueryConfig;
4358 /// let x = Subscription::new().set_bigquery_config(BigQueryConfig::default()/* use setters */);
4359 /// ```
4360 pub fn set_bigquery_config<T>(mut self, v: T) -> Self
4361 where
4362 T: std::convert::Into<crate::model::BigQueryConfig>,
4363 {
4364 self.bigquery_config = std::option::Option::Some(v.into());
4365 self
4366 }
4367
4368 /// Sets or clears the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4369 ///
4370 /// # Example
4371 /// ```ignore,no_run
4372 /// # use google_cloud_pubsub::model::Subscription;
4373 /// use google_cloud_pubsub::model::BigQueryConfig;
4374 /// let x = Subscription::new().set_or_clear_bigquery_config(Some(BigQueryConfig::default()/* use setters */));
4375 /// let x = Subscription::new().set_or_clear_bigquery_config(None::<BigQueryConfig>);
4376 /// ```
4377 pub fn set_or_clear_bigquery_config<T>(mut self, v: std::option::Option<T>) -> Self
4378 where
4379 T: std::convert::Into<crate::model::BigQueryConfig>,
4380 {
4381 self.bigquery_config = v.map(|x| x.into());
4382 self
4383 }
4384
4385 /// Sets the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4386 ///
4387 /// # Example
4388 /// ```ignore,no_run
4389 /// # use google_cloud_pubsub::model::Subscription;
4390 /// use google_cloud_pubsub::model::CloudStorageConfig;
4391 /// let x = Subscription::new().set_cloud_storage_config(CloudStorageConfig::default()/* use setters */);
4392 /// ```
4393 pub fn set_cloud_storage_config<T>(mut self, v: T) -> Self
4394 where
4395 T: std::convert::Into<crate::model::CloudStorageConfig>,
4396 {
4397 self.cloud_storage_config = std::option::Option::Some(v.into());
4398 self
4399 }
4400
4401 /// Sets or clears the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4402 ///
4403 /// # Example
4404 /// ```ignore,no_run
4405 /// # use google_cloud_pubsub::model::Subscription;
4406 /// use google_cloud_pubsub::model::CloudStorageConfig;
4407 /// let x = Subscription::new().set_or_clear_cloud_storage_config(Some(CloudStorageConfig::default()/* use setters */));
4408 /// let x = Subscription::new().set_or_clear_cloud_storage_config(None::<CloudStorageConfig>);
4409 /// ```
4410 pub fn set_or_clear_cloud_storage_config<T>(mut self, v: std::option::Option<T>) -> Self
4411 where
4412 T: std::convert::Into<crate::model::CloudStorageConfig>,
4413 {
4414 self.cloud_storage_config = v.map(|x| x.into());
4415 self
4416 }
4417
4418 /// Sets the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4419 ///
4420 /// # Example
4421 /// ```ignore,no_run
4422 /// # use google_cloud_pubsub::model::Subscription;
4423 /// use google_cloud_pubsub::model::BigtableConfig;
4424 /// let x = Subscription::new().set_bigtable_config(BigtableConfig::default()/* use setters */);
4425 /// ```
4426 pub fn set_bigtable_config<T>(mut self, v: T) -> Self
4427 where
4428 T: std::convert::Into<crate::model::BigtableConfig>,
4429 {
4430 self.bigtable_config = std::option::Option::Some(v.into());
4431 self
4432 }
4433
4434 /// Sets or clears the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4435 ///
4436 /// # Example
4437 /// ```ignore,no_run
4438 /// # use google_cloud_pubsub::model::Subscription;
4439 /// use google_cloud_pubsub::model::BigtableConfig;
4440 /// let x = Subscription::new().set_or_clear_bigtable_config(Some(BigtableConfig::default()/* use setters */));
4441 /// let x = Subscription::new().set_or_clear_bigtable_config(None::<BigtableConfig>);
4442 /// ```
4443 pub fn set_or_clear_bigtable_config<T>(mut self, v: std::option::Option<T>) -> Self
4444 where
4445 T: std::convert::Into<crate::model::BigtableConfig>,
4446 {
4447 self.bigtable_config = v.map(|x| x.into());
4448 self
4449 }
4450
4451 /// Sets the value of [ack_deadline_seconds][crate::model::Subscription::ack_deadline_seconds].
4452 ///
4453 /// # Example
4454 /// ```ignore,no_run
4455 /// # use google_cloud_pubsub::model::Subscription;
4456 /// let x = Subscription::new().set_ack_deadline_seconds(42);
4457 /// ```
4458 pub fn set_ack_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4459 self.ack_deadline_seconds = v.into();
4460 self
4461 }
4462
4463 /// Sets the value of [retain_acked_messages][crate::model::Subscription::retain_acked_messages].
4464 ///
4465 /// # Example
4466 /// ```ignore,no_run
4467 /// # use google_cloud_pubsub::model::Subscription;
4468 /// let x = Subscription::new().set_retain_acked_messages(true);
4469 /// ```
4470 pub fn set_retain_acked_messages<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4471 self.retain_acked_messages = v.into();
4472 self
4473 }
4474
4475 /// Sets the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4476 ///
4477 /// # Example
4478 /// ```ignore,no_run
4479 /// # use google_cloud_pubsub::model::Subscription;
4480 /// use wkt::Duration;
4481 /// let x = Subscription::new().set_message_retention_duration(Duration::default()/* use setters */);
4482 /// ```
4483 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
4484 where
4485 T: std::convert::Into<wkt::Duration>,
4486 {
4487 self.message_retention_duration = std::option::Option::Some(v.into());
4488 self
4489 }
4490
4491 /// Sets or clears the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4492 ///
4493 /// # Example
4494 /// ```ignore,no_run
4495 /// # use google_cloud_pubsub::model::Subscription;
4496 /// use wkt::Duration;
4497 /// let x = Subscription::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
4498 /// let x = Subscription::new().set_or_clear_message_retention_duration(None::<Duration>);
4499 /// ```
4500 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
4501 where
4502 T: std::convert::Into<wkt::Duration>,
4503 {
4504 self.message_retention_duration = v.map(|x| x.into());
4505 self
4506 }
4507
4508 /// Sets the value of [labels][crate::model::Subscription::labels].
4509 ///
4510 /// # Example
4511 /// ```ignore,no_run
4512 /// # use google_cloud_pubsub::model::Subscription;
4513 /// let x = Subscription::new().set_labels([
4514 /// ("key0", "abc"),
4515 /// ("key1", "xyz"),
4516 /// ]);
4517 /// ```
4518 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
4519 where
4520 T: std::iter::IntoIterator<Item = (K, V)>,
4521 K: std::convert::Into<std::string::String>,
4522 V: std::convert::Into<std::string::String>,
4523 {
4524 use std::iter::Iterator;
4525 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4526 self
4527 }
4528
4529 /// Sets the value of [enable_message_ordering][crate::model::Subscription::enable_message_ordering].
4530 ///
4531 /// # Example
4532 /// ```ignore,no_run
4533 /// # use google_cloud_pubsub::model::Subscription;
4534 /// let x = Subscription::new().set_enable_message_ordering(true);
4535 /// ```
4536 pub fn set_enable_message_ordering<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4537 self.enable_message_ordering = v.into();
4538 self
4539 }
4540
4541 /// Sets the value of [expiration_policy][crate::model::Subscription::expiration_policy].
4542 ///
4543 /// # Example
4544 /// ```ignore,no_run
4545 /// # use google_cloud_pubsub::model::Subscription;
4546 /// use google_cloud_pubsub::model::ExpirationPolicy;
4547 /// let x = Subscription::new().set_expiration_policy(ExpirationPolicy::default()/* use setters */);
4548 /// ```
4549 pub fn set_expiration_policy<T>(mut self, v: T) -> Self
4550 where
4551 T: std::convert::Into<crate::model::ExpirationPolicy>,
4552 {
4553 self.expiration_policy = std::option::Option::Some(v.into());
4554 self
4555 }
4556
4557 /// Sets or clears the value of [expiration_policy][crate::model::Subscription::expiration_policy].
4558 ///
4559 /// # Example
4560 /// ```ignore,no_run
4561 /// # use google_cloud_pubsub::model::Subscription;
4562 /// use google_cloud_pubsub::model::ExpirationPolicy;
4563 /// let x = Subscription::new().set_or_clear_expiration_policy(Some(ExpirationPolicy::default()/* use setters */));
4564 /// let x = Subscription::new().set_or_clear_expiration_policy(None::<ExpirationPolicy>);
4565 /// ```
4566 pub fn set_or_clear_expiration_policy<T>(mut self, v: std::option::Option<T>) -> Self
4567 where
4568 T: std::convert::Into<crate::model::ExpirationPolicy>,
4569 {
4570 self.expiration_policy = v.map(|x| x.into());
4571 self
4572 }
4573
4574 /// Sets the value of [filter][crate::model::Subscription::filter].
4575 ///
4576 /// # Example
4577 /// ```ignore,no_run
4578 /// # use google_cloud_pubsub::model::Subscription;
4579 /// let x = Subscription::new().set_filter("example");
4580 /// ```
4581 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4582 self.filter = v.into();
4583 self
4584 }
4585
4586 /// Sets the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
4587 ///
4588 /// # Example
4589 /// ```ignore,no_run
4590 /// # use google_cloud_pubsub::model::Subscription;
4591 /// use google_cloud_pubsub::model::DeadLetterPolicy;
4592 /// let x = Subscription::new().set_dead_letter_policy(DeadLetterPolicy::default()/* use setters */);
4593 /// ```
4594 pub fn set_dead_letter_policy<T>(mut self, v: T) -> Self
4595 where
4596 T: std::convert::Into<crate::model::DeadLetterPolicy>,
4597 {
4598 self.dead_letter_policy = std::option::Option::Some(v.into());
4599 self
4600 }
4601
4602 /// Sets or clears the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
4603 ///
4604 /// # Example
4605 /// ```ignore,no_run
4606 /// # use google_cloud_pubsub::model::Subscription;
4607 /// use google_cloud_pubsub::model::DeadLetterPolicy;
4608 /// let x = Subscription::new().set_or_clear_dead_letter_policy(Some(DeadLetterPolicy::default()/* use setters */));
4609 /// let x = Subscription::new().set_or_clear_dead_letter_policy(None::<DeadLetterPolicy>);
4610 /// ```
4611 pub fn set_or_clear_dead_letter_policy<T>(mut self, v: std::option::Option<T>) -> Self
4612 where
4613 T: std::convert::Into<crate::model::DeadLetterPolicy>,
4614 {
4615 self.dead_letter_policy = v.map(|x| x.into());
4616 self
4617 }
4618
4619 /// Sets the value of [retry_policy][crate::model::Subscription::retry_policy].
4620 ///
4621 /// # Example
4622 /// ```ignore,no_run
4623 /// # use google_cloud_pubsub::model::Subscription;
4624 /// use google_cloud_pubsub::model::RetryPolicy;
4625 /// let x = Subscription::new().set_retry_policy(RetryPolicy::default()/* use setters */);
4626 /// ```
4627 pub fn set_retry_policy<T>(mut self, v: T) -> Self
4628 where
4629 T: std::convert::Into<crate::model::RetryPolicy>,
4630 {
4631 self.retry_policy = std::option::Option::Some(v.into());
4632 self
4633 }
4634
4635 /// Sets or clears the value of [retry_policy][crate::model::Subscription::retry_policy].
4636 ///
4637 /// # Example
4638 /// ```ignore,no_run
4639 /// # use google_cloud_pubsub::model::Subscription;
4640 /// use google_cloud_pubsub::model::RetryPolicy;
4641 /// let x = Subscription::new().set_or_clear_retry_policy(Some(RetryPolicy::default()/* use setters */));
4642 /// let x = Subscription::new().set_or_clear_retry_policy(None::<RetryPolicy>);
4643 /// ```
4644 pub fn set_or_clear_retry_policy<T>(mut self, v: std::option::Option<T>) -> Self
4645 where
4646 T: std::convert::Into<crate::model::RetryPolicy>,
4647 {
4648 self.retry_policy = v.map(|x| x.into());
4649 self
4650 }
4651
4652 /// Sets the value of [detached][crate::model::Subscription::detached].
4653 ///
4654 /// # Example
4655 /// ```ignore,no_run
4656 /// # use google_cloud_pubsub::model::Subscription;
4657 /// let x = Subscription::new().set_detached(true);
4658 /// ```
4659 pub fn set_detached<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4660 self.detached = v.into();
4661 self
4662 }
4663
4664 /// Sets the value of [enable_exactly_once_delivery][crate::model::Subscription::enable_exactly_once_delivery].
4665 ///
4666 /// # Example
4667 /// ```ignore,no_run
4668 /// # use google_cloud_pubsub::model::Subscription;
4669 /// let x = Subscription::new().set_enable_exactly_once_delivery(true);
4670 /// ```
4671 pub fn set_enable_exactly_once_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4672 self.enable_exactly_once_delivery = v.into();
4673 self
4674 }
4675
4676 /// Sets the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
4677 ///
4678 /// # Example
4679 /// ```ignore,no_run
4680 /// # use google_cloud_pubsub::model::Subscription;
4681 /// use wkt::Duration;
4682 /// let x = Subscription::new().set_topic_message_retention_duration(Duration::default()/* use setters */);
4683 /// ```
4684 pub fn set_topic_message_retention_duration<T>(mut self, v: T) -> Self
4685 where
4686 T: std::convert::Into<wkt::Duration>,
4687 {
4688 self.topic_message_retention_duration = std::option::Option::Some(v.into());
4689 self
4690 }
4691
4692 /// Sets or clears the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
4693 ///
4694 /// # Example
4695 /// ```ignore,no_run
4696 /// # use google_cloud_pubsub::model::Subscription;
4697 /// use wkt::Duration;
4698 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(Some(Duration::default()/* use setters */));
4699 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(None::<Duration>);
4700 /// ```
4701 pub fn set_or_clear_topic_message_retention_duration<T>(
4702 mut self,
4703 v: std::option::Option<T>,
4704 ) -> Self
4705 where
4706 T: std::convert::Into<wkt::Duration>,
4707 {
4708 self.topic_message_retention_duration = v.map(|x| x.into());
4709 self
4710 }
4711
4712 /// Sets the value of [state][crate::model::Subscription::state].
4713 ///
4714 /// # Example
4715 /// ```ignore,no_run
4716 /// # use google_cloud_pubsub::model::Subscription;
4717 /// use google_cloud_pubsub::model::subscription::State;
4718 /// let x0 = Subscription::new().set_state(State::Active);
4719 /// let x1 = Subscription::new().set_state(State::ResourceError);
4720 /// ```
4721 pub fn set_state<T: std::convert::Into<crate::model::subscription::State>>(
4722 mut self,
4723 v: T,
4724 ) -> Self {
4725 self.state = v.into();
4726 self
4727 }
4728
4729 /// Sets the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
4730 ///
4731 /// # Example
4732 /// ```ignore,no_run
4733 /// # use google_cloud_pubsub::model::Subscription;
4734 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4735 /// let x = Subscription::new().set_analytics_hub_subscription_info(AnalyticsHubSubscriptionInfo::default()/* use setters */);
4736 /// ```
4737 pub fn set_analytics_hub_subscription_info<T>(mut self, v: T) -> Self
4738 where
4739 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4740 {
4741 self.analytics_hub_subscription_info = std::option::Option::Some(v.into());
4742 self
4743 }
4744
4745 /// Sets or clears the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
4746 ///
4747 /// # Example
4748 /// ```ignore,no_run
4749 /// # use google_cloud_pubsub::model::Subscription;
4750 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4751 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(Some(AnalyticsHubSubscriptionInfo::default()/* use setters */));
4752 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(None::<AnalyticsHubSubscriptionInfo>);
4753 /// ```
4754 pub fn set_or_clear_analytics_hub_subscription_info<T>(
4755 mut self,
4756 v: std::option::Option<T>,
4757 ) -> Self
4758 where
4759 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4760 {
4761 self.analytics_hub_subscription_info = v.map(|x| x.into());
4762 self
4763 }
4764
4765 /// Sets the value of [message_transforms][crate::model::Subscription::message_transforms].
4766 ///
4767 /// # Example
4768 /// ```ignore,no_run
4769 /// # use google_cloud_pubsub::model::Subscription;
4770 /// use google_cloud_pubsub::model::MessageTransform;
4771 /// let x = Subscription::new()
4772 /// .set_message_transforms([
4773 /// MessageTransform::default()/* use setters */,
4774 /// MessageTransform::default()/* use (different) setters */,
4775 /// ]);
4776 /// ```
4777 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
4778 where
4779 T: std::iter::IntoIterator<Item = V>,
4780 V: std::convert::Into<crate::model::MessageTransform>,
4781 {
4782 use std::iter::Iterator;
4783 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
4784 self
4785 }
4786
4787 /// Sets the value of [tags][crate::model::Subscription::tags].
4788 ///
4789 /// # Example
4790 /// ```ignore,no_run
4791 /// # use google_cloud_pubsub::model::Subscription;
4792 /// let x = Subscription::new().set_tags([
4793 /// ("key0", "abc"),
4794 /// ("key1", "xyz"),
4795 /// ]);
4796 /// ```
4797 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
4798 where
4799 T: std::iter::IntoIterator<Item = (K, V)>,
4800 K: std::convert::Into<std::string::String>,
4801 V: std::convert::Into<std::string::String>,
4802 {
4803 use std::iter::Iterator;
4804 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4805 self
4806 }
4807}
4808
4809impl wkt::message::Message for Subscription {
4810 fn typename() -> &'static str {
4811 "type.googleapis.com/google.pubsub.v1.Subscription"
4812 }
4813}
4814
4815/// Defines additional types related to [Subscription].
4816pub mod subscription {
4817 #[allow(unused_imports)]
4818 use super::*;
4819
4820 /// Information about an associated [Analytics Hub
4821 /// subscription](https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
4822 #[derive(Clone, Default, PartialEq)]
4823 #[non_exhaustive]
4824 pub struct AnalyticsHubSubscriptionInfo {
4825 /// Optional. The name of the associated Analytics Hub listing resource.
4826 /// Pattern:
4827 /// "projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}"
4828 pub listing: std::string::String,
4829
4830 /// Optional. The name of the associated Analytics Hub subscription resource.
4831 /// Pattern:
4832 /// "projects/{project}/locations/{location}/subscriptions/{subscription}"
4833 pub subscription: std::string::String,
4834
4835 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4836 }
4837
4838 impl AnalyticsHubSubscriptionInfo {
4839 /// Creates a new default instance.
4840 pub fn new() -> Self {
4841 std::default::Default::default()
4842 }
4843
4844 /// Sets the value of [listing][crate::model::subscription::AnalyticsHubSubscriptionInfo::listing].
4845 ///
4846 /// # Example
4847 /// ```ignore,no_run
4848 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4849 /// let x = AnalyticsHubSubscriptionInfo::new().set_listing("example");
4850 /// ```
4851 pub fn set_listing<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4852 self.listing = v.into();
4853 self
4854 }
4855
4856 /// Sets the value of [subscription][crate::model::subscription::AnalyticsHubSubscriptionInfo::subscription].
4857 ///
4858 /// # Example
4859 /// ```ignore,no_run
4860 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4861 /// let x = AnalyticsHubSubscriptionInfo::new().set_subscription("example");
4862 /// ```
4863 pub fn set_subscription<T: std::convert::Into<std::string::String>>(
4864 mut self,
4865 v: T,
4866 ) -> Self {
4867 self.subscription = v.into();
4868 self
4869 }
4870 }
4871
4872 impl wkt::message::Message for AnalyticsHubSubscriptionInfo {
4873 fn typename() -> &'static str {
4874 "type.googleapis.com/google.pubsub.v1.Subscription.AnalyticsHubSubscriptionInfo"
4875 }
4876 }
4877
4878 /// Possible states for a subscription.
4879 ///
4880 /// # Working with unknown values
4881 ///
4882 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4883 /// additional enum variants at any time. Adding new variants is not considered
4884 /// a breaking change. Applications should write their code in anticipation of:
4885 ///
4886 /// - New values appearing in future releases of the client library, **and**
4887 /// - New values received dynamically, without application changes.
4888 ///
4889 /// Please consult the [Working with enums] section in the user guide for some
4890 /// guidelines.
4891 ///
4892 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4893 #[derive(Clone, Debug, PartialEq)]
4894 #[non_exhaustive]
4895 pub enum State {
4896 /// Default value. This value is unused.
4897 Unspecified,
4898 /// The subscription can actively receive messages
4899 Active,
4900 /// The subscription cannot receive messages because of an error with the
4901 /// resource to which it pushes messages. See the more detailed error state
4902 /// in the corresponding configuration.
4903 ResourceError,
4904 /// If set, the enum was initialized with an unknown value.
4905 ///
4906 /// Applications can examine the value using [State::value] or
4907 /// [State::name].
4908 UnknownValue(state::UnknownValue),
4909 }
4910
4911 #[doc(hidden)]
4912 pub mod state {
4913 #[allow(unused_imports)]
4914 use super::*;
4915 #[derive(Clone, Debug, PartialEq)]
4916 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4917 }
4918
4919 impl State {
4920 /// Gets the enum value.
4921 ///
4922 /// Returns `None` if the enum contains an unknown value deserialized from
4923 /// the string representation of enums.
4924 pub fn value(&self) -> std::option::Option<i32> {
4925 match self {
4926 Self::Unspecified => std::option::Option::Some(0),
4927 Self::Active => std::option::Option::Some(1),
4928 Self::ResourceError => std::option::Option::Some(2),
4929 Self::UnknownValue(u) => u.0.value(),
4930 }
4931 }
4932
4933 /// Gets the enum value as a string.
4934 ///
4935 /// Returns `None` if the enum contains an unknown value deserialized from
4936 /// the integer representation of enums.
4937 pub fn name(&self) -> std::option::Option<&str> {
4938 match self {
4939 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
4940 Self::Active => std::option::Option::Some("ACTIVE"),
4941 Self::ResourceError => std::option::Option::Some("RESOURCE_ERROR"),
4942 Self::UnknownValue(u) => u.0.name(),
4943 }
4944 }
4945 }
4946
4947 impl std::default::Default for State {
4948 fn default() -> Self {
4949 use std::convert::From;
4950 Self::from(0)
4951 }
4952 }
4953
4954 impl std::fmt::Display for State {
4955 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4956 wkt::internal::display_enum(f, self.name(), self.value())
4957 }
4958 }
4959
4960 impl std::convert::From<i32> for State {
4961 fn from(value: i32) -> Self {
4962 match value {
4963 0 => Self::Unspecified,
4964 1 => Self::Active,
4965 2 => Self::ResourceError,
4966 _ => Self::UnknownValue(state::UnknownValue(
4967 wkt::internal::UnknownEnumValue::Integer(value),
4968 )),
4969 }
4970 }
4971 }
4972
4973 impl std::convert::From<&str> for State {
4974 fn from(value: &str) -> Self {
4975 use std::string::ToString;
4976 match value {
4977 "STATE_UNSPECIFIED" => Self::Unspecified,
4978 "ACTIVE" => Self::Active,
4979 "RESOURCE_ERROR" => Self::ResourceError,
4980 _ => Self::UnknownValue(state::UnknownValue(
4981 wkt::internal::UnknownEnumValue::String(value.to_string()),
4982 )),
4983 }
4984 }
4985 }
4986
4987 impl serde::ser::Serialize for State {
4988 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4989 where
4990 S: serde::Serializer,
4991 {
4992 match self {
4993 Self::Unspecified => serializer.serialize_i32(0),
4994 Self::Active => serializer.serialize_i32(1),
4995 Self::ResourceError => serializer.serialize_i32(2),
4996 Self::UnknownValue(u) => u.0.serialize(serializer),
4997 }
4998 }
4999 }
5000
5001 impl<'de> serde::de::Deserialize<'de> for State {
5002 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5003 where
5004 D: serde::Deserializer<'de>,
5005 {
5006 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
5007 ".google.pubsub.v1.Subscription.State",
5008 ))
5009 }
5010 }
5011}
5012
5013/// A policy that specifies how Pub/Sub retries message delivery.
5014///
5015/// Retry delay will be exponential based on provided minimum and maximum
5016/// backoffs. <https://en.wikipedia.org/wiki/Exponential_backoff>.
5017///
5018/// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
5019/// events for a given message.
5020///
5021/// Retry Policy is implemented on a best effort basis. At times, the delay
5022/// between consecutive deliveries may not match the configuration. That is,
5023/// delay can be more or less than configured backoff.
5024#[derive(Clone, Default, PartialEq)]
5025#[non_exhaustive]
5026pub struct RetryPolicy {
5027 /// Optional. The minimum delay between consecutive deliveries of a given
5028 /// message. Value should be between 0 and 600 seconds. Defaults to 10 seconds.
5029 pub minimum_backoff: std::option::Option<wkt::Duration>,
5030
5031 /// Optional. The maximum delay between consecutive deliveries of a given
5032 /// message. Value should be between 0 and 600 seconds. Defaults to 600
5033 /// seconds.
5034 pub maximum_backoff: std::option::Option<wkt::Duration>,
5035
5036 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5037}
5038
5039impl RetryPolicy {
5040 /// Creates a new default instance.
5041 pub fn new() -> Self {
5042 std::default::Default::default()
5043 }
5044
5045 /// Sets the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5046 ///
5047 /// # Example
5048 /// ```ignore,no_run
5049 /// # use google_cloud_pubsub::model::RetryPolicy;
5050 /// use wkt::Duration;
5051 /// let x = RetryPolicy::new().set_minimum_backoff(Duration::default()/* use setters */);
5052 /// ```
5053 pub fn set_minimum_backoff<T>(mut self, v: T) -> Self
5054 where
5055 T: std::convert::Into<wkt::Duration>,
5056 {
5057 self.minimum_backoff = std::option::Option::Some(v.into());
5058 self
5059 }
5060
5061 /// Sets or clears the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5062 ///
5063 /// # Example
5064 /// ```ignore,no_run
5065 /// # use google_cloud_pubsub::model::RetryPolicy;
5066 /// use wkt::Duration;
5067 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(Some(Duration::default()/* use setters */));
5068 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(None::<Duration>);
5069 /// ```
5070 pub fn set_or_clear_minimum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5071 where
5072 T: std::convert::Into<wkt::Duration>,
5073 {
5074 self.minimum_backoff = v.map(|x| x.into());
5075 self
5076 }
5077
5078 /// Sets the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5079 ///
5080 /// # Example
5081 /// ```ignore,no_run
5082 /// # use google_cloud_pubsub::model::RetryPolicy;
5083 /// use wkt::Duration;
5084 /// let x = RetryPolicy::new().set_maximum_backoff(Duration::default()/* use setters */);
5085 /// ```
5086 pub fn set_maximum_backoff<T>(mut self, v: T) -> Self
5087 where
5088 T: std::convert::Into<wkt::Duration>,
5089 {
5090 self.maximum_backoff = std::option::Option::Some(v.into());
5091 self
5092 }
5093
5094 /// Sets or clears the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5095 ///
5096 /// # Example
5097 /// ```ignore,no_run
5098 /// # use google_cloud_pubsub::model::RetryPolicy;
5099 /// use wkt::Duration;
5100 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(Some(Duration::default()/* use setters */));
5101 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(None::<Duration>);
5102 /// ```
5103 pub fn set_or_clear_maximum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5104 where
5105 T: std::convert::Into<wkt::Duration>,
5106 {
5107 self.maximum_backoff = v.map(|x| x.into());
5108 self
5109 }
5110}
5111
5112impl wkt::message::Message for RetryPolicy {
5113 fn typename() -> &'static str {
5114 "type.googleapis.com/google.pubsub.v1.RetryPolicy"
5115 }
5116}
5117
5118/// Dead lettering is done on a best effort basis. The same message might be
5119/// dead lettered multiple times.
5120///
5121/// If validation on any of the fields fails at subscription creation/updation,
5122/// the create/update subscription request will fail.
5123#[derive(Clone, Default, PartialEq)]
5124#[non_exhaustive]
5125pub struct DeadLetterPolicy {
5126 /// Optional. The name of the topic to which dead letter messages should be
5127 /// published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub
5128 /// service account associated with the enclosing subscription's parent project
5129 /// (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must
5130 /// have permission to Publish() to this topic.
5131 ///
5132 /// The operation will fail if the topic does not exist.
5133 /// Users should ensure that there is a subscription attached to this topic
5134 /// since messages published to a topic with no subscriptions are lost.
5135 pub dead_letter_topic: std::string::String,
5136
5137 /// Optional. The maximum number of delivery attempts for any message. The
5138 /// value must be between 5 and 100.
5139 ///
5140 /// The number of delivery attempts is defined as 1 + (the sum of number of
5141 /// NACKs and number of times the acknowledgment deadline has been exceeded
5142 /// for the message).
5143 ///
5144 /// A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
5145 /// client libraries may automatically extend ack_deadlines.
5146 ///
5147 /// This field will be honored on a best effort basis.
5148 ///
5149 /// If this parameter is 0, a default value of 5 is used.
5150 pub max_delivery_attempts: i32,
5151
5152 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5153}
5154
5155impl DeadLetterPolicy {
5156 /// Creates a new default instance.
5157 pub fn new() -> Self {
5158 std::default::Default::default()
5159 }
5160
5161 /// Sets the value of [dead_letter_topic][crate::model::DeadLetterPolicy::dead_letter_topic].
5162 ///
5163 /// # Example
5164 /// ```ignore,no_run
5165 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5166 /// let x = DeadLetterPolicy::new().set_dead_letter_topic("example");
5167 /// ```
5168 pub fn set_dead_letter_topic<T: std::convert::Into<std::string::String>>(
5169 mut self,
5170 v: T,
5171 ) -> Self {
5172 self.dead_letter_topic = v.into();
5173 self
5174 }
5175
5176 /// Sets the value of [max_delivery_attempts][crate::model::DeadLetterPolicy::max_delivery_attempts].
5177 ///
5178 /// # Example
5179 /// ```ignore,no_run
5180 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5181 /// let x = DeadLetterPolicy::new().set_max_delivery_attempts(42);
5182 /// ```
5183 pub fn set_max_delivery_attempts<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5184 self.max_delivery_attempts = v.into();
5185 self
5186 }
5187}
5188
5189impl wkt::message::Message for DeadLetterPolicy {
5190 fn typename() -> &'static str {
5191 "type.googleapis.com/google.pubsub.v1.DeadLetterPolicy"
5192 }
5193}
5194
5195/// A policy that specifies the conditions for resource expiration (i.e.,
5196/// automatic resource deletion).
5197#[derive(Clone, Default, PartialEq)]
5198#[non_exhaustive]
5199pub struct ExpirationPolicy {
5200 /// Optional. Specifies the "time-to-live" duration for an associated resource.
5201 /// The resource expires if it is not active for a period of `ttl`. The
5202 /// definition of "activity" depends on the type of the associated resource.
5203 /// The minimum and maximum allowed values for `ttl` depend on the type of the
5204 /// associated resource, as well. If `ttl` is not set, the associated resource
5205 /// never expires.
5206 pub ttl: std::option::Option<wkt::Duration>,
5207
5208 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5209}
5210
5211impl ExpirationPolicy {
5212 /// Creates a new default instance.
5213 pub fn new() -> Self {
5214 std::default::Default::default()
5215 }
5216
5217 /// Sets the value of [ttl][crate::model::ExpirationPolicy::ttl].
5218 ///
5219 /// # Example
5220 /// ```ignore,no_run
5221 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5222 /// use wkt::Duration;
5223 /// let x = ExpirationPolicy::new().set_ttl(Duration::default()/* use setters */);
5224 /// ```
5225 pub fn set_ttl<T>(mut self, v: T) -> Self
5226 where
5227 T: std::convert::Into<wkt::Duration>,
5228 {
5229 self.ttl = std::option::Option::Some(v.into());
5230 self
5231 }
5232
5233 /// Sets or clears the value of [ttl][crate::model::ExpirationPolicy::ttl].
5234 ///
5235 /// # Example
5236 /// ```ignore,no_run
5237 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5238 /// use wkt::Duration;
5239 /// let x = ExpirationPolicy::new().set_or_clear_ttl(Some(Duration::default()/* use setters */));
5240 /// let x = ExpirationPolicy::new().set_or_clear_ttl(None::<Duration>);
5241 /// ```
5242 pub fn set_or_clear_ttl<T>(mut self, v: std::option::Option<T>) -> Self
5243 where
5244 T: std::convert::Into<wkt::Duration>,
5245 {
5246 self.ttl = v.map(|x| x.into());
5247 self
5248 }
5249}
5250
5251impl wkt::message::Message for ExpirationPolicy {
5252 fn typename() -> &'static str {
5253 "type.googleapis.com/google.pubsub.v1.ExpirationPolicy"
5254 }
5255}
5256
5257/// Configuration for a push delivery endpoint.
5258#[derive(Clone, Default, PartialEq)]
5259#[non_exhaustive]
5260pub struct PushConfig {
5261 /// Optional. A URL locating the endpoint to which messages should be pushed.
5262 /// For example, a Webhook endpoint might use `<https://example.com/push>`.
5263 pub push_endpoint: std::string::String,
5264
5265 /// Optional. Endpoint configuration attributes that can be used to control
5266 /// different aspects of the message delivery.
5267 ///
5268 /// The only currently supported attribute is `x-goog-version`, which you can
5269 /// use to change the format of the pushed message. This attribute
5270 /// indicates the version of the data expected by the endpoint. This
5271 /// controls the shape of the pushed message (i.e., its fields and metadata).
5272 ///
5273 /// If not present during the `CreateSubscription` call, it will default to
5274 /// the version of the Pub/Sub API used to make such call. If not present in a
5275 /// `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
5276 /// calls will always return a valid version, even if the subscription was
5277 /// created without this attribute.
5278 ///
5279 /// The only supported values for the `x-goog-version` attribute are:
5280 ///
5281 /// * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
5282 /// * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
5283 ///
5284 /// For example:
5285 /// `attributes { "x-goog-version": "v1" }`
5286 pub attributes: std::collections::HashMap<std::string::String, std::string::String>,
5287
5288 /// An authentication method used by push endpoints to verify the source of
5289 /// push requests. This can be used with push endpoints that are private by
5290 /// default to allow requests only from the Pub/Sub system, for example.
5291 /// This field is optional and should be set only by users interested in
5292 /// authenticated push.
5293 pub authentication_method: std::option::Option<crate::model::push_config::AuthenticationMethod>,
5294
5295 /// The format of the delivered message to the push endpoint is defined by
5296 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
5297 pub wrapper: std::option::Option<crate::model::push_config::Wrapper>,
5298
5299 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5300}
5301
5302impl PushConfig {
5303 /// Creates a new default instance.
5304 pub fn new() -> Self {
5305 std::default::Default::default()
5306 }
5307
5308 /// Sets the value of [push_endpoint][crate::model::PushConfig::push_endpoint].
5309 ///
5310 /// # Example
5311 /// ```ignore,no_run
5312 /// # use google_cloud_pubsub::model::PushConfig;
5313 /// let x = PushConfig::new().set_push_endpoint("example");
5314 /// ```
5315 pub fn set_push_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5316 self.push_endpoint = v.into();
5317 self
5318 }
5319
5320 /// Sets the value of [attributes][crate::model::PushConfig::attributes].
5321 ///
5322 /// # Example
5323 /// ```ignore,no_run
5324 /// # use google_cloud_pubsub::model::PushConfig;
5325 /// let x = PushConfig::new().set_attributes([
5326 /// ("key0", "abc"),
5327 /// ("key1", "xyz"),
5328 /// ]);
5329 /// ```
5330 pub fn set_attributes<T, K, V>(mut self, v: T) -> Self
5331 where
5332 T: std::iter::IntoIterator<Item = (K, V)>,
5333 K: std::convert::Into<std::string::String>,
5334 V: std::convert::Into<std::string::String>,
5335 {
5336 use std::iter::Iterator;
5337 self.attributes = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5338 self
5339 }
5340
5341 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method].
5342 ///
5343 /// Note that all the setters affecting `authentication_method` are mutually
5344 /// exclusive.
5345 ///
5346 /// # Example
5347 /// ```ignore,no_run
5348 /// # use google_cloud_pubsub::model::PushConfig;
5349 /// use google_cloud_pubsub::model::push_config::OidcToken;
5350 /// let x = PushConfig::new().set_authentication_method(Some(
5351 /// google_cloud_pubsub::model::push_config::AuthenticationMethod::OidcToken(OidcToken::default().into())));
5352 /// ```
5353 pub fn set_authentication_method<
5354 T: std::convert::Into<std::option::Option<crate::model::push_config::AuthenticationMethod>>,
5355 >(
5356 mut self,
5357 v: T,
5358 ) -> Self {
5359 self.authentication_method = v.into();
5360 self
5361 }
5362
5363 /// The value of [authentication_method][crate::model::PushConfig::authentication_method]
5364 /// if it holds a `OidcToken`, `None` if the field is not set or
5365 /// holds a different branch.
5366 pub fn oidc_token(
5367 &self,
5368 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::OidcToken>> {
5369 #[allow(unreachable_patterns)]
5370 self.authentication_method.as_ref().and_then(|v| match v {
5371 crate::model::push_config::AuthenticationMethod::OidcToken(v) => {
5372 std::option::Option::Some(v)
5373 }
5374 _ => std::option::Option::None,
5375 })
5376 }
5377
5378 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method]
5379 /// to hold a `OidcToken`.
5380 ///
5381 /// Note that all the setters affecting `authentication_method` are
5382 /// mutually exclusive.
5383 ///
5384 /// # Example
5385 /// ```ignore,no_run
5386 /// # use google_cloud_pubsub::model::PushConfig;
5387 /// use google_cloud_pubsub::model::push_config::OidcToken;
5388 /// let x = PushConfig::new().set_oidc_token(OidcToken::default()/* use setters */);
5389 /// assert!(x.oidc_token().is_some());
5390 /// ```
5391 pub fn set_oidc_token<
5392 T: std::convert::Into<std::boxed::Box<crate::model::push_config::OidcToken>>,
5393 >(
5394 mut self,
5395 v: T,
5396 ) -> Self {
5397 self.authentication_method = std::option::Option::Some(
5398 crate::model::push_config::AuthenticationMethod::OidcToken(v.into()),
5399 );
5400 self
5401 }
5402
5403 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper].
5404 ///
5405 /// Note that all the setters affecting `wrapper` are mutually
5406 /// exclusive.
5407 ///
5408 /// # Example
5409 /// ```ignore,no_run
5410 /// # use google_cloud_pubsub::model::PushConfig;
5411 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5412 /// let x = PushConfig::new().set_wrapper(Some(
5413 /// google_cloud_pubsub::model::push_config::Wrapper::PubsubWrapper(PubsubWrapper::default().into())));
5414 /// ```
5415 pub fn set_wrapper<
5416 T: std::convert::Into<std::option::Option<crate::model::push_config::Wrapper>>,
5417 >(
5418 mut self,
5419 v: T,
5420 ) -> Self {
5421 self.wrapper = v.into();
5422 self
5423 }
5424
5425 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5426 /// if it holds a `PubsubWrapper`, `None` if the field is not set or
5427 /// holds a different branch.
5428 pub fn pubsub_wrapper(
5429 &self,
5430 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::PubsubWrapper>> {
5431 #[allow(unreachable_patterns)]
5432 self.wrapper.as_ref().and_then(|v| match v {
5433 crate::model::push_config::Wrapper::PubsubWrapper(v) => std::option::Option::Some(v),
5434 _ => std::option::Option::None,
5435 })
5436 }
5437
5438 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5439 /// to hold a `PubsubWrapper`.
5440 ///
5441 /// Note that all the setters affecting `wrapper` are
5442 /// mutually exclusive.
5443 ///
5444 /// # Example
5445 /// ```ignore,no_run
5446 /// # use google_cloud_pubsub::model::PushConfig;
5447 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5448 /// let x = PushConfig::new().set_pubsub_wrapper(PubsubWrapper::default()/* use setters */);
5449 /// assert!(x.pubsub_wrapper().is_some());
5450 /// assert!(x.no_wrapper().is_none());
5451 /// ```
5452 pub fn set_pubsub_wrapper<
5453 T: std::convert::Into<std::boxed::Box<crate::model::push_config::PubsubWrapper>>,
5454 >(
5455 mut self,
5456 v: T,
5457 ) -> Self {
5458 self.wrapper =
5459 std::option::Option::Some(crate::model::push_config::Wrapper::PubsubWrapper(v.into()));
5460 self
5461 }
5462
5463 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5464 /// if it holds a `NoWrapper`, `None` if the field is not set or
5465 /// holds a different branch.
5466 pub fn no_wrapper(
5467 &self,
5468 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::NoWrapper>> {
5469 #[allow(unreachable_patterns)]
5470 self.wrapper.as_ref().and_then(|v| match v {
5471 crate::model::push_config::Wrapper::NoWrapper(v) => std::option::Option::Some(v),
5472 _ => std::option::Option::None,
5473 })
5474 }
5475
5476 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5477 /// to hold a `NoWrapper`.
5478 ///
5479 /// Note that all the setters affecting `wrapper` are
5480 /// mutually exclusive.
5481 ///
5482 /// # Example
5483 /// ```ignore,no_run
5484 /// # use google_cloud_pubsub::model::PushConfig;
5485 /// use google_cloud_pubsub::model::push_config::NoWrapper;
5486 /// let x = PushConfig::new().set_no_wrapper(NoWrapper::default()/* use setters */);
5487 /// assert!(x.no_wrapper().is_some());
5488 /// assert!(x.pubsub_wrapper().is_none());
5489 /// ```
5490 pub fn set_no_wrapper<
5491 T: std::convert::Into<std::boxed::Box<crate::model::push_config::NoWrapper>>,
5492 >(
5493 mut self,
5494 v: T,
5495 ) -> Self {
5496 self.wrapper =
5497 std::option::Option::Some(crate::model::push_config::Wrapper::NoWrapper(v.into()));
5498 self
5499 }
5500}
5501
5502impl wkt::message::Message for PushConfig {
5503 fn typename() -> &'static str {
5504 "type.googleapis.com/google.pubsub.v1.PushConfig"
5505 }
5506}
5507
5508/// Defines additional types related to [PushConfig].
5509pub mod push_config {
5510 #[allow(unused_imports)]
5511 use super::*;
5512
5513 /// Contains information needed for generating an
5514 /// [OpenID Connect
5515 /// token](https://developers.google.com/identity/protocols/OpenIDConnect).
5516 #[derive(Clone, Default, PartialEq)]
5517 #[non_exhaustive]
5518 pub struct OidcToken {
5519 /// Optional. [Service account
5520 /// email](https://cloud.google.com/iam/docs/service-accounts)
5521 /// used for generating the OIDC token. For more information
5522 /// on setting up authentication, see
5523 /// [Push subscriptions](https://cloud.google.com/pubsub/docs/push).
5524 pub service_account_email: std::string::String,
5525
5526 /// Optional. Audience to be used when generating OIDC token. The audience
5527 /// claim identifies the recipients that the JWT is intended for. The
5528 /// audience value is a single case-sensitive string. Having multiple values
5529 /// (array) for the audience field is not supported. More info about the OIDC
5530 /// JWT token audience here:
5531 /// <https://tools.ietf.org/html/rfc7519#section-4.1.3> Note: if not specified,
5532 /// the Push endpoint URL will be used.
5533 pub audience: std::string::String,
5534
5535 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5536 }
5537
5538 impl OidcToken {
5539 /// Creates a new default instance.
5540 pub fn new() -> Self {
5541 std::default::Default::default()
5542 }
5543
5544 /// Sets the value of [service_account_email][crate::model::push_config::OidcToken::service_account_email].
5545 ///
5546 /// # Example
5547 /// ```ignore,no_run
5548 /// # use google_cloud_pubsub::model::push_config::OidcToken;
5549 /// let x = OidcToken::new().set_service_account_email("example");
5550 /// ```
5551 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
5552 mut self,
5553 v: T,
5554 ) -> Self {
5555 self.service_account_email = v.into();
5556 self
5557 }
5558
5559 /// Sets the value of [audience][crate::model::push_config::OidcToken::audience].
5560 ///
5561 /// # Example
5562 /// ```ignore,no_run
5563 /// # use google_cloud_pubsub::model::push_config::OidcToken;
5564 /// let x = OidcToken::new().set_audience("example");
5565 /// ```
5566 pub fn set_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5567 self.audience = v.into();
5568 self
5569 }
5570 }
5571
5572 impl wkt::message::Message for OidcToken {
5573 fn typename() -> &'static str {
5574 "type.googleapis.com/google.pubsub.v1.PushConfig.OidcToken"
5575 }
5576 }
5577
5578 /// The payload to the push endpoint is in the form of the JSON representation
5579 /// of a PubsubMessage
5580 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
5581 #[derive(Clone, Default, PartialEq)]
5582 #[non_exhaustive]
5583 pub struct PubsubWrapper {
5584 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5585 }
5586
5587 impl PubsubWrapper {
5588 /// Creates a new default instance.
5589 pub fn new() -> Self {
5590 std::default::Default::default()
5591 }
5592 }
5593
5594 impl wkt::message::Message for PubsubWrapper {
5595 fn typename() -> &'static str {
5596 "type.googleapis.com/google.pubsub.v1.PushConfig.PubsubWrapper"
5597 }
5598 }
5599
5600 /// Sets the `data` field as the HTTP body for delivery.
5601 #[derive(Clone, Default, PartialEq)]
5602 #[non_exhaustive]
5603 pub struct NoWrapper {
5604 /// Optional. When true, writes the Pub/Sub message metadata to
5605 /// `x-goog-pubsub-<KEY>:<VAL>` headers of the HTTP request. Writes the
5606 /// Pub/Sub message attributes to `<KEY>:<VAL>` headers of the HTTP request.
5607 pub write_metadata: bool,
5608
5609 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5610 }
5611
5612 impl NoWrapper {
5613 /// Creates a new default instance.
5614 pub fn new() -> Self {
5615 std::default::Default::default()
5616 }
5617
5618 /// Sets the value of [write_metadata][crate::model::push_config::NoWrapper::write_metadata].
5619 ///
5620 /// # Example
5621 /// ```ignore,no_run
5622 /// # use google_cloud_pubsub::model::push_config::NoWrapper;
5623 /// let x = NoWrapper::new().set_write_metadata(true);
5624 /// ```
5625 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5626 self.write_metadata = v.into();
5627 self
5628 }
5629 }
5630
5631 impl wkt::message::Message for NoWrapper {
5632 fn typename() -> &'static str {
5633 "type.googleapis.com/google.pubsub.v1.PushConfig.NoWrapper"
5634 }
5635 }
5636
5637 /// An authentication method used by push endpoints to verify the source of
5638 /// push requests. This can be used with push endpoints that are private by
5639 /// default to allow requests only from the Pub/Sub system, for example.
5640 /// This field is optional and should be set only by users interested in
5641 /// authenticated push.
5642 #[derive(Clone, Debug, PartialEq)]
5643 #[non_exhaustive]
5644 pub enum AuthenticationMethod {
5645 /// Optional. If specified, Pub/Sub will generate and attach an OIDC JWT
5646 /// token as an `Authorization` header in the HTTP request for every pushed
5647 /// message.
5648 OidcToken(std::boxed::Box<crate::model::push_config::OidcToken>),
5649 }
5650
5651 /// The format of the delivered message to the push endpoint is defined by
5652 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
5653 #[derive(Clone, Debug, PartialEq)]
5654 #[non_exhaustive]
5655 pub enum Wrapper {
5656 /// Optional. When set, the payload to the push endpoint is in the form of
5657 /// the JSON representation of a PubsubMessage
5658 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
5659 PubsubWrapper(std::boxed::Box<crate::model::push_config::PubsubWrapper>),
5660 /// Optional. When set, the payload to the push endpoint is not wrapped.
5661 NoWrapper(std::boxed::Box<crate::model::push_config::NoWrapper>),
5662 }
5663}
5664
5665/// Configuration for a BigQuery subscription.
5666#[derive(Clone, Default, PartialEq)]
5667#[non_exhaustive]
5668pub struct BigQueryConfig {
5669 /// Optional. The name of the table to which to write data, of the form
5670 /// {projectId}.{datasetId}.{tableId}
5671 pub table: std::string::String,
5672
5673 /// Optional. When true, use the topic's schema as the columns to write to in
5674 /// BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be
5675 /// enabled at the same time.
5676 pub use_topic_schema: bool,
5677
5678 /// Optional. When true, write the subscription name, message_id, publish_time,
5679 /// attributes, and ordering_key to additional columns in the table. The
5680 /// subscription name, message_id, and publish_time fields are put in their own
5681 /// columns while all other message properties (other than data) are written to
5682 /// a JSON object in the attributes column.
5683 pub write_metadata: bool,
5684
5685 /// Optional. When true and use_topic_schema is true, any fields that are a
5686 /// part of the topic schema that are not part of the BigQuery table schema are
5687 /// dropped when writing to BigQuery. Otherwise, the schemas must be kept in
5688 /// sync and any messages with extra fields are not written and remain in the
5689 /// subscription's backlog.
5690 pub drop_unknown_fields: bool,
5691
5692 /// Output only. An output-only field that indicates whether or not the
5693 /// subscription can receive messages.
5694 pub state: crate::model::big_query_config::State,
5695
5696 /// Optional. When true, use the BigQuery table's schema as the columns to
5697 /// write to in BigQuery. `use_table_schema` and `use_topic_schema` cannot be
5698 /// enabled at the same time.
5699 pub use_table_schema: bool,
5700
5701 /// Optional. The service account to use to write to BigQuery. The subscription
5702 /// creator or updater that specifies this field must have
5703 /// `iam.serviceAccounts.actAs` permission on the service account. If not
5704 /// specified, the Pub/Sub [service
5705 /// agent](https://cloud.google.com/iam/docs/service-agents),
5706 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
5707 pub service_account_email: std::string::String,
5708
5709 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5710}
5711
5712impl BigQueryConfig {
5713 /// Creates a new default instance.
5714 pub fn new() -> Self {
5715 std::default::Default::default()
5716 }
5717
5718 /// Sets the value of [table][crate::model::BigQueryConfig::table].
5719 ///
5720 /// # Example
5721 /// ```ignore,no_run
5722 /// # use google_cloud_pubsub::model::BigQueryConfig;
5723 /// let x = BigQueryConfig::new().set_table("example");
5724 /// ```
5725 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5726 self.table = v.into();
5727 self
5728 }
5729
5730 /// Sets the value of [use_topic_schema][crate::model::BigQueryConfig::use_topic_schema].
5731 ///
5732 /// # Example
5733 /// ```ignore,no_run
5734 /// # use google_cloud_pubsub::model::BigQueryConfig;
5735 /// let x = BigQueryConfig::new().set_use_topic_schema(true);
5736 /// ```
5737 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5738 self.use_topic_schema = v.into();
5739 self
5740 }
5741
5742 /// Sets the value of [write_metadata][crate::model::BigQueryConfig::write_metadata].
5743 ///
5744 /// # Example
5745 /// ```ignore,no_run
5746 /// # use google_cloud_pubsub::model::BigQueryConfig;
5747 /// let x = BigQueryConfig::new().set_write_metadata(true);
5748 /// ```
5749 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5750 self.write_metadata = v.into();
5751 self
5752 }
5753
5754 /// Sets the value of [drop_unknown_fields][crate::model::BigQueryConfig::drop_unknown_fields].
5755 ///
5756 /// # Example
5757 /// ```ignore,no_run
5758 /// # use google_cloud_pubsub::model::BigQueryConfig;
5759 /// let x = BigQueryConfig::new().set_drop_unknown_fields(true);
5760 /// ```
5761 pub fn set_drop_unknown_fields<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5762 self.drop_unknown_fields = v.into();
5763 self
5764 }
5765
5766 /// Sets the value of [state][crate::model::BigQueryConfig::state].
5767 ///
5768 /// # Example
5769 /// ```ignore,no_run
5770 /// # use google_cloud_pubsub::model::BigQueryConfig;
5771 /// use google_cloud_pubsub::model::big_query_config::State;
5772 /// let x0 = BigQueryConfig::new().set_state(State::Active);
5773 /// let x1 = BigQueryConfig::new().set_state(State::PermissionDenied);
5774 /// let x2 = BigQueryConfig::new().set_state(State::NotFound);
5775 /// ```
5776 pub fn set_state<T: std::convert::Into<crate::model::big_query_config::State>>(
5777 mut self,
5778 v: T,
5779 ) -> Self {
5780 self.state = v.into();
5781 self
5782 }
5783
5784 /// Sets the value of [use_table_schema][crate::model::BigQueryConfig::use_table_schema].
5785 ///
5786 /// # Example
5787 /// ```ignore,no_run
5788 /// # use google_cloud_pubsub::model::BigQueryConfig;
5789 /// let x = BigQueryConfig::new().set_use_table_schema(true);
5790 /// ```
5791 pub fn set_use_table_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5792 self.use_table_schema = v.into();
5793 self
5794 }
5795
5796 /// Sets the value of [service_account_email][crate::model::BigQueryConfig::service_account_email].
5797 ///
5798 /// # Example
5799 /// ```ignore,no_run
5800 /// # use google_cloud_pubsub::model::BigQueryConfig;
5801 /// let x = BigQueryConfig::new().set_service_account_email("example");
5802 /// ```
5803 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
5804 mut self,
5805 v: T,
5806 ) -> Self {
5807 self.service_account_email = v.into();
5808 self
5809 }
5810}
5811
5812impl wkt::message::Message for BigQueryConfig {
5813 fn typename() -> &'static str {
5814 "type.googleapis.com/google.pubsub.v1.BigQueryConfig"
5815 }
5816}
5817
5818/// Defines additional types related to [BigQueryConfig].
5819pub mod big_query_config {
5820 #[allow(unused_imports)]
5821 use super::*;
5822
5823 /// Possible states for a BigQuery subscription.
5824 ///
5825 /// # Working with unknown values
5826 ///
5827 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5828 /// additional enum variants at any time. Adding new variants is not considered
5829 /// a breaking change. Applications should write their code in anticipation of:
5830 ///
5831 /// - New values appearing in future releases of the client library, **and**
5832 /// - New values received dynamically, without application changes.
5833 ///
5834 /// Please consult the [Working with enums] section in the user guide for some
5835 /// guidelines.
5836 ///
5837 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5838 #[derive(Clone, Debug, PartialEq)]
5839 #[non_exhaustive]
5840 pub enum State {
5841 /// Default value. This value is unused.
5842 Unspecified,
5843 /// The subscription can actively send messages to BigQuery
5844 Active,
5845 /// Cannot write to the BigQuery table because of permission denied errors.
5846 /// This can happen if
5847 ///
5848 /// - Pub/Sub SA has not been granted the [appropriate BigQuery IAM
5849 /// permissions](https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account)
5850 /// - bigquery.googleapis.com API is not enabled for the project
5851 /// ([instructions](https://cloud.google.com/service-usage/docs/enable-disable))
5852 PermissionDenied,
5853 /// Cannot write to the BigQuery table because it does not exist.
5854 NotFound,
5855 /// Cannot write to the BigQuery table due to a schema mismatch.
5856 SchemaMismatch,
5857 /// Cannot write to the destination because enforce_in_transit is set to true
5858 /// and the destination locations are not in the allowed regions.
5859 InTransitLocationRestriction,
5860 /// Cannot write to the BigQuery table because the table is not in the same
5861 /// location as where Vertex AI models used in `message_transform`s are
5862 /// deployed.
5863 VertexAiLocationRestriction,
5864 /// If set, the enum was initialized with an unknown value.
5865 ///
5866 /// Applications can examine the value using [State::value] or
5867 /// [State::name].
5868 UnknownValue(state::UnknownValue),
5869 }
5870
5871 #[doc(hidden)]
5872 pub mod state {
5873 #[allow(unused_imports)]
5874 use super::*;
5875 #[derive(Clone, Debug, PartialEq)]
5876 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5877 }
5878
5879 impl State {
5880 /// Gets the enum value.
5881 ///
5882 /// Returns `None` if the enum contains an unknown value deserialized from
5883 /// the string representation of enums.
5884 pub fn value(&self) -> std::option::Option<i32> {
5885 match self {
5886 Self::Unspecified => std::option::Option::Some(0),
5887 Self::Active => std::option::Option::Some(1),
5888 Self::PermissionDenied => std::option::Option::Some(2),
5889 Self::NotFound => std::option::Option::Some(3),
5890 Self::SchemaMismatch => std::option::Option::Some(4),
5891 Self::InTransitLocationRestriction => std::option::Option::Some(5),
5892 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
5893 Self::UnknownValue(u) => u.0.value(),
5894 }
5895 }
5896
5897 /// Gets the enum value as a string.
5898 ///
5899 /// Returns `None` if the enum contains an unknown value deserialized from
5900 /// the integer representation of enums.
5901 pub fn name(&self) -> std::option::Option<&str> {
5902 match self {
5903 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
5904 Self::Active => std::option::Option::Some("ACTIVE"),
5905 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
5906 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
5907 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
5908 Self::InTransitLocationRestriction => {
5909 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
5910 }
5911 Self::VertexAiLocationRestriction => {
5912 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
5913 }
5914 Self::UnknownValue(u) => u.0.name(),
5915 }
5916 }
5917 }
5918
5919 impl std::default::Default for State {
5920 fn default() -> Self {
5921 use std::convert::From;
5922 Self::from(0)
5923 }
5924 }
5925
5926 impl std::fmt::Display for State {
5927 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5928 wkt::internal::display_enum(f, self.name(), self.value())
5929 }
5930 }
5931
5932 impl std::convert::From<i32> for State {
5933 fn from(value: i32) -> Self {
5934 match value {
5935 0 => Self::Unspecified,
5936 1 => Self::Active,
5937 2 => Self::PermissionDenied,
5938 3 => Self::NotFound,
5939 4 => Self::SchemaMismatch,
5940 5 => Self::InTransitLocationRestriction,
5941 6 => Self::VertexAiLocationRestriction,
5942 _ => Self::UnknownValue(state::UnknownValue(
5943 wkt::internal::UnknownEnumValue::Integer(value),
5944 )),
5945 }
5946 }
5947 }
5948
5949 impl std::convert::From<&str> for State {
5950 fn from(value: &str) -> Self {
5951 use std::string::ToString;
5952 match value {
5953 "STATE_UNSPECIFIED" => Self::Unspecified,
5954 "ACTIVE" => Self::Active,
5955 "PERMISSION_DENIED" => Self::PermissionDenied,
5956 "NOT_FOUND" => Self::NotFound,
5957 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
5958 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
5959 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
5960 _ => Self::UnknownValue(state::UnknownValue(
5961 wkt::internal::UnknownEnumValue::String(value.to_string()),
5962 )),
5963 }
5964 }
5965 }
5966
5967 impl serde::ser::Serialize for State {
5968 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5969 where
5970 S: serde::Serializer,
5971 {
5972 match self {
5973 Self::Unspecified => serializer.serialize_i32(0),
5974 Self::Active => serializer.serialize_i32(1),
5975 Self::PermissionDenied => serializer.serialize_i32(2),
5976 Self::NotFound => serializer.serialize_i32(3),
5977 Self::SchemaMismatch => serializer.serialize_i32(4),
5978 Self::InTransitLocationRestriction => serializer.serialize_i32(5),
5979 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
5980 Self::UnknownValue(u) => u.0.serialize(serializer),
5981 }
5982 }
5983 }
5984
5985 impl<'de> serde::de::Deserialize<'de> for State {
5986 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5987 where
5988 D: serde::Deserializer<'de>,
5989 {
5990 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
5991 ".google.pubsub.v1.BigQueryConfig.State",
5992 ))
5993 }
5994 }
5995}
5996
5997/// Configuration for a Bigtable subscription. The Pub/Sub message will be
5998/// written to a Bigtable row as follows:
5999///
6000/// - row key: subscription name and message ID delimited by #.
6001/// - columns: message bytes written to a single column family "data" with an
6002/// empty-string column qualifier.
6003/// - cell timestamp: the message publish timestamp.
6004#[derive(Clone, Default, PartialEq)]
6005#[non_exhaustive]
6006pub struct BigtableConfig {
6007 /// Optional. The unique name of the table to write messages to.
6008 ///
6009 /// Values are of the form
6010 /// `projects/<project>/instances/<instance>/tables/<table>`.
6011 pub table: std::string::String,
6012
6013 /// Optional. The app profile to use for the Bigtable writes. If not specified,
6014 /// the "default" application profile will be used. The app profile must use
6015 /// single-cluster routing.
6016 pub app_profile_id: std::string::String,
6017
6018 /// Optional. The service account to use to write to Bigtable. The subscription
6019 /// creator or updater that specifies this field must have
6020 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6021 /// specified, the Pub/Sub [service
6022 /// agent](https://cloud.google.com/iam/docs/service-agents),
6023 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6024 pub service_account_email: std::string::String,
6025
6026 /// Optional. When true, write the subscription name, message_id, publish_time,
6027 /// attributes, and ordering_key to additional columns in the table under the
6028 /// pubsub_metadata column family. The subscription name, message_id, and
6029 /// publish_time fields are put in their own columns while all other message
6030 /// properties (other than data) are written to a JSON object in the attributes
6031 /// column.
6032 pub write_metadata: bool,
6033
6034 /// Output only. An output-only field that indicates whether or not the
6035 /// subscription can receive messages.
6036 pub state: crate::model::bigtable_config::State,
6037
6038 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6039}
6040
6041impl BigtableConfig {
6042 /// Creates a new default instance.
6043 pub fn new() -> Self {
6044 std::default::Default::default()
6045 }
6046
6047 /// Sets the value of [table][crate::model::BigtableConfig::table].
6048 ///
6049 /// # Example
6050 /// ```ignore,no_run
6051 /// # use google_cloud_pubsub::model::BigtableConfig;
6052 /// let x = BigtableConfig::new().set_table("example");
6053 /// ```
6054 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6055 self.table = v.into();
6056 self
6057 }
6058
6059 /// Sets the value of [app_profile_id][crate::model::BigtableConfig::app_profile_id].
6060 ///
6061 /// # Example
6062 /// ```ignore,no_run
6063 /// # use google_cloud_pubsub::model::BigtableConfig;
6064 /// let x = BigtableConfig::new().set_app_profile_id("example");
6065 /// ```
6066 pub fn set_app_profile_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6067 self.app_profile_id = v.into();
6068 self
6069 }
6070
6071 /// Sets the value of [service_account_email][crate::model::BigtableConfig::service_account_email].
6072 ///
6073 /// # Example
6074 /// ```ignore,no_run
6075 /// # use google_cloud_pubsub::model::BigtableConfig;
6076 /// let x = BigtableConfig::new().set_service_account_email("example");
6077 /// ```
6078 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6079 mut self,
6080 v: T,
6081 ) -> Self {
6082 self.service_account_email = v.into();
6083 self
6084 }
6085
6086 /// Sets the value of [write_metadata][crate::model::BigtableConfig::write_metadata].
6087 ///
6088 /// # Example
6089 /// ```ignore,no_run
6090 /// # use google_cloud_pubsub::model::BigtableConfig;
6091 /// let x = BigtableConfig::new().set_write_metadata(true);
6092 /// ```
6093 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6094 self.write_metadata = v.into();
6095 self
6096 }
6097
6098 /// Sets the value of [state][crate::model::BigtableConfig::state].
6099 ///
6100 /// # Example
6101 /// ```ignore,no_run
6102 /// # use google_cloud_pubsub::model::BigtableConfig;
6103 /// use google_cloud_pubsub::model::bigtable_config::State;
6104 /// let x0 = BigtableConfig::new().set_state(State::Active);
6105 /// let x1 = BigtableConfig::new().set_state(State::NotFound);
6106 /// let x2 = BigtableConfig::new().set_state(State::AppProfileMisconfigured);
6107 /// ```
6108 pub fn set_state<T: std::convert::Into<crate::model::bigtable_config::State>>(
6109 mut self,
6110 v: T,
6111 ) -> Self {
6112 self.state = v.into();
6113 self
6114 }
6115}
6116
6117impl wkt::message::Message for BigtableConfig {
6118 fn typename() -> &'static str {
6119 "type.googleapis.com/google.pubsub.v1.BigtableConfig"
6120 }
6121}
6122
6123/// Defines additional types related to [BigtableConfig].
6124pub mod bigtable_config {
6125 #[allow(unused_imports)]
6126 use super::*;
6127
6128 /// Possible states for a Bigtable subscription.
6129 /// Note: more states could be added in the future. Please code accordingly.
6130 ///
6131 /// # Working with unknown values
6132 ///
6133 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6134 /// additional enum variants at any time. Adding new variants is not considered
6135 /// a breaking change. Applications should write their code in anticipation of:
6136 ///
6137 /// - New values appearing in future releases of the client library, **and**
6138 /// - New values received dynamically, without application changes.
6139 ///
6140 /// Please consult the [Working with enums] section in the user guide for some
6141 /// guidelines.
6142 ///
6143 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6144 #[derive(Clone, Debug, PartialEq)]
6145 #[non_exhaustive]
6146 pub enum State {
6147 /// Default value. This value is unused.
6148 Unspecified,
6149 /// The subscription can actively send messages to Bigtable.
6150 Active,
6151 /// Cannot write to Bigtable because the instance, table, or app profile
6152 /// does not exist.
6153 NotFound,
6154 /// Cannot write to Bigtable because the app profile is not configured for
6155 /// single-cluster routing.
6156 AppProfileMisconfigured,
6157 /// Cannot write to Bigtable because of permission denied errors.
6158 /// This can happen if:
6159 ///
6160 /// - The Pub/Sub service agent has not been granted the
6161 /// [appropriate Bigtable IAM permission
6162 /// bigtable.tables.mutateRows]({$universe.dns_names.final_documentation_domain}/bigtable/docs/access-control#permissions)
6163 /// - The bigtable.googleapis.com API is not enabled for the project
6164 /// ([instructions]({$universe.dns_names.final_documentation_domain}/service-usage/docs/enable-disable))
6165 PermissionDenied,
6166 /// Cannot write to Bigtable because of a missing column family ("data") or
6167 /// if there is no structured row key for the subscription name + message ID.
6168 SchemaMismatch,
6169 /// Cannot write to the destination because enforce_in_transit is set to true
6170 /// and the destination locations are not in the allowed regions.
6171 InTransitLocationRestriction,
6172 /// Cannot write to Bigtable because the table is not in the same location as
6173 /// where Vertex AI models used in `message_transform`s are deployed.
6174 VertexAiLocationRestriction,
6175 /// If set, the enum was initialized with an unknown value.
6176 ///
6177 /// Applications can examine the value using [State::value] or
6178 /// [State::name].
6179 UnknownValue(state::UnknownValue),
6180 }
6181
6182 #[doc(hidden)]
6183 pub mod state {
6184 #[allow(unused_imports)]
6185 use super::*;
6186 #[derive(Clone, Debug, PartialEq)]
6187 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6188 }
6189
6190 impl State {
6191 /// Gets the enum value.
6192 ///
6193 /// Returns `None` if the enum contains an unknown value deserialized from
6194 /// the string representation of enums.
6195 pub fn value(&self) -> std::option::Option<i32> {
6196 match self {
6197 Self::Unspecified => std::option::Option::Some(0),
6198 Self::Active => std::option::Option::Some(1),
6199 Self::NotFound => std::option::Option::Some(2),
6200 Self::AppProfileMisconfigured => std::option::Option::Some(3),
6201 Self::PermissionDenied => std::option::Option::Some(4),
6202 Self::SchemaMismatch => std::option::Option::Some(5),
6203 Self::InTransitLocationRestriction => std::option::Option::Some(6),
6204 Self::VertexAiLocationRestriction => std::option::Option::Some(7),
6205 Self::UnknownValue(u) => u.0.value(),
6206 }
6207 }
6208
6209 /// Gets the enum value as a string.
6210 ///
6211 /// Returns `None` if the enum contains an unknown value deserialized from
6212 /// the integer representation of enums.
6213 pub fn name(&self) -> std::option::Option<&str> {
6214 match self {
6215 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6216 Self::Active => std::option::Option::Some("ACTIVE"),
6217 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6218 Self::AppProfileMisconfigured => {
6219 std::option::Option::Some("APP_PROFILE_MISCONFIGURED")
6220 }
6221 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6222 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6223 Self::InTransitLocationRestriction => {
6224 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6225 }
6226 Self::VertexAiLocationRestriction => {
6227 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6228 }
6229 Self::UnknownValue(u) => u.0.name(),
6230 }
6231 }
6232 }
6233
6234 impl std::default::Default for State {
6235 fn default() -> Self {
6236 use std::convert::From;
6237 Self::from(0)
6238 }
6239 }
6240
6241 impl std::fmt::Display for State {
6242 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6243 wkt::internal::display_enum(f, self.name(), self.value())
6244 }
6245 }
6246
6247 impl std::convert::From<i32> for State {
6248 fn from(value: i32) -> Self {
6249 match value {
6250 0 => Self::Unspecified,
6251 1 => Self::Active,
6252 2 => Self::NotFound,
6253 3 => Self::AppProfileMisconfigured,
6254 4 => Self::PermissionDenied,
6255 5 => Self::SchemaMismatch,
6256 6 => Self::InTransitLocationRestriction,
6257 7 => Self::VertexAiLocationRestriction,
6258 _ => Self::UnknownValue(state::UnknownValue(
6259 wkt::internal::UnknownEnumValue::Integer(value),
6260 )),
6261 }
6262 }
6263 }
6264
6265 impl std::convert::From<&str> for State {
6266 fn from(value: &str) -> Self {
6267 use std::string::ToString;
6268 match value {
6269 "STATE_UNSPECIFIED" => Self::Unspecified,
6270 "ACTIVE" => Self::Active,
6271 "NOT_FOUND" => Self::NotFound,
6272 "APP_PROFILE_MISCONFIGURED" => Self::AppProfileMisconfigured,
6273 "PERMISSION_DENIED" => Self::PermissionDenied,
6274 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6275 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6276 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6277 _ => Self::UnknownValue(state::UnknownValue(
6278 wkt::internal::UnknownEnumValue::String(value.to_string()),
6279 )),
6280 }
6281 }
6282 }
6283
6284 impl serde::ser::Serialize for State {
6285 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6286 where
6287 S: serde::Serializer,
6288 {
6289 match self {
6290 Self::Unspecified => serializer.serialize_i32(0),
6291 Self::Active => serializer.serialize_i32(1),
6292 Self::NotFound => serializer.serialize_i32(2),
6293 Self::AppProfileMisconfigured => serializer.serialize_i32(3),
6294 Self::PermissionDenied => serializer.serialize_i32(4),
6295 Self::SchemaMismatch => serializer.serialize_i32(5),
6296 Self::InTransitLocationRestriction => serializer.serialize_i32(6),
6297 Self::VertexAiLocationRestriction => serializer.serialize_i32(7),
6298 Self::UnknownValue(u) => u.0.serialize(serializer),
6299 }
6300 }
6301 }
6302
6303 impl<'de> serde::de::Deserialize<'de> for State {
6304 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6305 where
6306 D: serde::Deserializer<'de>,
6307 {
6308 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6309 ".google.pubsub.v1.BigtableConfig.State",
6310 ))
6311 }
6312 }
6313}
6314
6315/// Configuration for a Cloud Storage subscription.
6316#[derive(Clone, Default, PartialEq)]
6317#[non_exhaustive]
6318pub struct CloudStorageConfig {
6319 /// Required. User-provided name for the Cloud Storage bucket.
6320 /// The bucket must be created by the user. The bucket name must be without
6321 /// any prefix like "gs://". See the [bucket naming
6322 /// requirements] (<https://cloud.google.com/storage/docs/buckets#naming>).
6323 pub bucket: std::string::String,
6324
6325 /// Optional. User-provided prefix for Cloud Storage filename. See the [object
6326 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6327 pub filename_prefix: std::string::String,
6328
6329 /// Optional. User-provided suffix for Cloud Storage filename. See the [object
6330 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6331 /// Must not end in "/".
6332 pub filename_suffix: std::string::String,
6333
6334 /// Optional. User-provided format string specifying how to represent datetimes
6335 /// in Cloud Storage filenames. See the [datetime format
6336 /// guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
6337 pub filename_datetime_format: std::string::String,
6338
6339 /// Optional. The maximum duration that can elapse before a new Cloud Storage
6340 /// file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not
6341 /// exceed the subscription's acknowledgment deadline.
6342 pub max_duration: std::option::Option<wkt::Duration>,
6343
6344 /// Optional. The maximum bytes that can be written to a Cloud Storage file
6345 /// before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may
6346 /// be exceeded in cases where messages are larger than the limit.
6347 pub max_bytes: i64,
6348
6349 /// Optional. The maximum number of messages that can be written to a Cloud
6350 /// Storage file before a new file is created. Min 1000 messages.
6351 pub max_messages: i64,
6352
6353 /// Output only. An output-only field that indicates whether or not the
6354 /// subscription can receive messages.
6355 pub state: crate::model::cloud_storage_config::State,
6356
6357 /// Optional. The service account to use to write to Cloud Storage. The
6358 /// subscription creator or updater that specifies this field must have
6359 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6360 /// specified, the Pub/Sub
6361 /// [service agent](https://cloud.google.com/iam/docs/service-agents),
6362 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6363 pub service_account_email: std::string::String,
6364
6365 /// Defaults to text format.
6366 pub output_format: std::option::Option<crate::model::cloud_storage_config::OutputFormat>,
6367
6368 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6369}
6370
6371impl CloudStorageConfig {
6372 /// Creates a new default instance.
6373 pub fn new() -> Self {
6374 std::default::Default::default()
6375 }
6376
6377 /// Sets the value of [bucket][crate::model::CloudStorageConfig::bucket].
6378 ///
6379 /// # Example
6380 /// ```ignore,no_run
6381 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6382 /// let x = CloudStorageConfig::new().set_bucket("example");
6383 /// ```
6384 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6385 self.bucket = v.into();
6386 self
6387 }
6388
6389 /// Sets the value of [filename_prefix][crate::model::CloudStorageConfig::filename_prefix].
6390 ///
6391 /// # Example
6392 /// ```ignore,no_run
6393 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6394 /// let x = CloudStorageConfig::new().set_filename_prefix("example");
6395 /// ```
6396 pub fn set_filename_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6397 self.filename_prefix = v.into();
6398 self
6399 }
6400
6401 /// Sets the value of [filename_suffix][crate::model::CloudStorageConfig::filename_suffix].
6402 ///
6403 /// # Example
6404 /// ```ignore,no_run
6405 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6406 /// let x = CloudStorageConfig::new().set_filename_suffix("example");
6407 /// ```
6408 pub fn set_filename_suffix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6409 self.filename_suffix = v.into();
6410 self
6411 }
6412
6413 /// Sets the value of [filename_datetime_format][crate::model::CloudStorageConfig::filename_datetime_format].
6414 ///
6415 /// # Example
6416 /// ```ignore,no_run
6417 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6418 /// let x = CloudStorageConfig::new().set_filename_datetime_format("example");
6419 /// ```
6420 pub fn set_filename_datetime_format<T: std::convert::Into<std::string::String>>(
6421 mut self,
6422 v: T,
6423 ) -> Self {
6424 self.filename_datetime_format = v.into();
6425 self
6426 }
6427
6428 /// Sets the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6429 ///
6430 /// # Example
6431 /// ```ignore,no_run
6432 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6433 /// use wkt::Duration;
6434 /// let x = CloudStorageConfig::new().set_max_duration(Duration::default()/* use setters */);
6435 /// ```
6436 pub fn set_max_duration<T>(mut self, v: T) -> Self
6437 where
6438 T: std::convert::Into<wkt::Duration>,
6439 {
6440 self.max_duration = std::option::Option::Some(v.into());
6441 self
6442 }
6443
6444 /// Sets or clears the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6445 ///
6446 /// # Example
6447 /// ```ignore,no_run
6448 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6449 /// use wkt::Duration;
6450 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6451 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(None::<Duration>);
6452 /// ```
6453 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6454 where
6455 T: std::convert::Into<wkt::Duration>,
6456 {
6457 self.max_duration = v.map(|x| x.into());
6458 self
6459 }
6460
6461 /// Sets the value of [max_bytes][crate::model::CloudStorageConfig::max_bytes].
6462 ///
6463 /// # Example
6464 /// ```ignore,no_run
6465 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6466 /// let x = CloudStorageConfig::new().set_max_bytes(42);
6467 /// ```
6468 pub fn set_max_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6469 self.max_bytes = v.into();
6470 self
6471 }
6472
6473 /// Sets the value of [max_messages][crate::model::CloudStorageConfig::max_messages].
6474 ///
6475 /// # Example
6476 /// ```ignore,no_run
6477 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6478 /// let x = CloudStorageConfig::new().set_max_messages(42);
6479 /// ```
6480 pub fn set_max_messages<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6481 self.max_messages = v.into();
6482 self
6483 }
6484
6485 /// Sets the value of [state][crate::model::CloudStorageConfig::state].
6486 ///
6487 /// # Example
6488 /// ```ignore,no_run
6489 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6490 /// use google_cloud_pubsub::model::cloud_storage_config::State;
6491 /// let x0 = CloudStorageConfig::new().set_state(State::Active);
6492 /// let x1 = CloudStorageConfig::new().set_state(State::PermissionDenied);
6493 /// let x2 = CloudStorageConfig::new().set_state(State::NotFound);
6494 /// ```
6495 pub fn set_state<T: std::convert::Into<crate::model::cloud_storage_config::State>>(
6496 mut self,
6497 v: T,
6498 ) -> Self {
6499 self.state = v.into();
6500 self
6501 }
6502
6503 /// Sets the value of [service_account_email][crate::model::CloudStorageConfig::service_account_email].
6504 ///
6505 /// # Example
6506 /// ```ignore,no_run
6507 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6508 /// let x = CloudStorageConfig::new().set_service_account_email("example");
6509 /// ```
6510 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6511 mut self,
6512 v: T,
6513 ) -> Self {
6514 self.service_account_email = v.into();
6515 self
6516 }
6517
6518 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format].
6519 ///
6520 /// Note that all the setters affecting `output_format` are mutually
6521 /// exclusive.
6522 ///
6523 /// # Example
6524 /// ```ignore,no_run
6525 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6526 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
6527 /// let x = CloudStorageConfig::new().set_output_format(Some(
6528 /// google_cloud_pubsub::model::cloud_storage_config::OutputFormat::TextConfig(TextConfig::default().into())));
6529 /// ```
6530 pub fn set_output_format<
6531 T: std::convert::Into<std::option::Option<crate::model::cloud_storage_config::OutputFormat>>,
6532 >(
6533 mut self,
6534 v: T,
6535 ) -> Self {
6536 self.output_format = v.into();
6537 self
6538 }
6539
6540 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
6541 /// if it holds a `TextConfig`, `None` if the field is not set or
6542 /// holds a different branch.
6543 pub fn text_config(
6544 &self,
6545 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::TextConfig>> {
6546 #[allow(unreachable_patterns)]
6547 self.output_format.as_ref().and_then(|v| match v {
6548 crate::model::cloud_storage_config::OutputFormat::TextConfig(v) => {
6549 std::option::Option::Some(v)
6550 }
6551 _ => std::option::Option::None,
6552 })
6553 }
6554
6555 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
6556 /// to hold a `TextConfig`.
6557 ///
6558 /// Note that all the setters affecting `output_format` are
6559 /// mutually exclusive.
6560 ///
6561 /// # Example
6562 /// ```ignore,no_run
6563 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6564 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
6565 /// let x = CloudStorageConfig::new().set_text_config(TextConfig::default()/* use setters */);
6566 /// assert!(x.text_config().is_some());
6567 /// assert!(x.avro_config().is_none());
6568 /// ```
6569 pub fn set_text_config<
6570 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::TextConfig>>,
6571 >(
6572 mut self,
6573 v: T,
6574 ) -> Self {
6575 self.output_format = std::option::Option::Some(
6576 crate::model::cloud_storage_config::OutputFormat::TextConfig(v.into()),
6577 );
6578 self
6579 }
6580
6581 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
6582 /// if it holds a `AvroConfig`, `None` if the field is not set or
6583 /// holds a different branch.
6584 pub fn avro_config(
6585 &self,
6586 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>> {
6587 #[allow(unreachable_patterns)]
6588 self.output_format.as_ref().and_then(|v| match v {
6589 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v) => {
6590 std::option::Option::Some(v)
6591 }
6592 _ => std::option::Option::None,
6593 })
6594 }
6595
6596 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
6597 /// to hold a `AvroConfig`.
6598 ///
6599 /// Note that all the setters affecting `output_format` are
6600 /// mutually exclusive.
6601 ///
6602 /// # Example
6603 /// ```ignore,no_run
6604 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6605 /// use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6606 /// let x = CloudStorageConfig::new().set_avro_config(AvroConfig::default()/* use setters */);
6607 /// assert!(x.avro_config().is_some());
6608 /// assert!(x.text_config().is_none());
6609 /// ```
6610 pub fn set_avro_config<
6611 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>>,
6612 >(
6613 mut self,
6614 v: T,
6615 ) -> Self {
6616 self.output_format = std::option::Option::Some(
6617 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v.into()),
6618 );
6619 self
6620 }
6621}
6622
6623impl wkt::message::Message for CloudStorageConfig {
6624 fn typename() -> &'static str {
6625 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig"
6626 }
6627}
6628
6629/// Defines additional types related to [CloudStorageConfig].
6630pub mod cloud_storage_config {
6631 #[allow(unused_imports)]
6632 use super::*;
6633
6634 /// Configuration for writing message data in text format.
6635 /// Message payloads will be written to files as raw text, separated by a
6636 /// newline.
6637 #[derive(Clone, Default, PartialEq)]
6638 #[non_exhaustive]
6639 pub struct TextConfig {
6640 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6641 }
6642
6643 impl TextConfig {
6644 /// Creates a new default instance.
6645 pub fn new() -> Self {
6646 std::default::Default::default()
6647 }
6648 }
6649
6650 impl wkt::message::Message for TextConfig {
6651 fn typename() -> &'static str {
6652 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.TextConfig"
6653 }
6654 }
6655
6656 /// Configuration for writing message data in Avro format.
6657 /// Message payloads and metadata will be written to files as an Avro binary.
6658 #[derive(Clone, Default, PartialEq)]
6659 #[non_exhaustive]
6660 pub struct AvroConfig {
6661 /// Optional. When true, write the subscription name, message_id,
6662 /// publish_time, attributes, and ordering_key as additional fields in the
6663 /// output. The subscription name, message_id, and publish_time fields are
6664 /// put in their own fields while all other message properties other than
6665 /// data (for example, an ordering_key, if present) are added as entries in
6666 /// the attributes map.
6667 pub write_metadata: bool,
6668
6669 /// Optional. When true, the output Cloud Storage file will be serialized
6670 /// using the topic schema, if it exists.
6671 pub use_topic_schema: bool,
6672
6673 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6674 }
6675
6676 impl AvroConfig {
6677 /// Creates a new default instance.
6678 pub fn new() -> Self {
6679 std::default::Default::default()
6680 }
6681
6682 /// Sets the value of [write_metadata][crate::model::cloud_storage_config::AvroConfig::write_metadata].
6683 ///
6684 /// # Example
6685 /// ```ignore,no_run
6686 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6687 /// let x = AvroConfig::new().set_write_metadata(true);
6688 /// ```
6689 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6690 self.write_metadata = v.into();
6691 self
6692 }
6693
6694 /// Sets the value of [use_topic_schema][crate::model::cloud_storage_config::AvroConfig::use_topic_schema].
6695 ///
6696 /// # Example
6697 /// ```ignore,no_run
6698 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6699 /// let x = AvroConfig::new().set_use_topic_schema(true);
6700 /// ```
6701 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6702 self.use_topic_schema = v.into();
6703 self
6704 }
6705 }
6706
6707 impl wkt::message::Message for AvroConfig {
6708 fn typename() -> &'static str {
6709 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.AvroConfig"
6710 }
6711 }
6712
6713 /// Possible states for a Cloud Storage subscription.
6714 ///
6715 /// # Working with unknown values
6716 ///
6717 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6718 /// additional enum variants at any time. Adding new variants is not considered
6719 /// a breaking change. Applications should write their code in anticipation of:
6720 ///
6721 /// - New values appearing in future releases of the client library, **and**
6722 /// - New values received dynamically, without application changes.
6723 ///
6724 /// Please consult the [Working with enums] section in the user guide for some
6725 /// guidelines.
6726 ///
6727 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6728 #[derive(Clone, Debug, PartialEq)]
6729 #[non_exhaustive]
6730 pub enum State {
6731 /// Default value. This value is unused.
6732 Unspecified,
6733 /// The subscription can actively send messages to Cloud Storage.
6734 Active,
6735 /// Cannot write to the Cloud Storage bucket because of permission denied
6736 /// errors.
6737 PermissionDenied,
6738 /// Cannot write to the Cloud Storage bucket because it does not exist.
6739 NotFound,
6740 /// Cannot write to the destination because enforce_in_transit is set to true
6741 /// and the destination locations are not in the allowed regions.
6742 InTransitLocationRestriction,
6743 /// Cannot write to the Cloud Storage bucket due to an incompatibility
6744 /// between the topic schema and subscription settings.
6745 SchemaMismatch,
6746 /// Cannot write to the Cloud Storage bucket because the bucket is not in the
6747 /// same location as where Vertex AI models used in `message_transform`s are
6748 /// deployed.
6749 VertexAiLocationRestriction,
6750 /// If set, the enum was initialized with an unknown value.
6751 ///
6752 /// Applications can examine the value using [State::value] or
6753 /// [State::name].
6754 UnknownValue(state::UnknownValue),
6755 }
6756
6757 #[doc(hidden)]
6758 pub mod state {
6759 #[allow(unused_imports)]
6760 use super::*;
6761 #[derive(Clone, Debug, PartialEq)]
6762 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6763 }
6764
6765 impl State {
6766 /// Gets the enum value.
6767 ///
6768 /// Returns `None` if the enum contains an unknown value deserialized from
6769 /// the string representation of enums.
6770 pub fn value(&self) -> std::option::Option<i32> {
6771 match self {
6772 Self::Unspecified => std::option::Option::Some(0),
6773 Self::Active => std::option::Option::Some(1),
6774 Self::PermissionDenied => std::option::Option::Some(2),
6775 Self::NotFound => std::option::Option::Some(3),
6776 Self::InTransitLocationRestriction => std::option::Option::Some(4),
6777 Self::SchemaMismatch => std::option::Option::Some(5),
6778 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
6779 Self::UnknownValue(u) => u.0.value(),
6780 }
6781 }
6782
6783 /// Gets the enum value as a string.
6784 ///
6785 /// Returns `None` if the enum contains an unknown value deserialized from
6786 /// the integer representation of enums.
6787 pub fn name(&self) -> std::option::Option<&str> {
6788 match self {
6789 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6790 Self::Active => std::option::Option::Some("ACTIVE"),
6791 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6792 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6793 Self::InTransitLocationRestriction => {
6794 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6795 }
6796 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6797 Self::VertexAiLocationRestriction => {
6798 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6799 }
6800 Self::UnknownValue(u) => u.0.name(),
6801 }
6802 }
6803 }
6804
6805 impl std::default::Default for State {
6806 fn default() -> Self {
6807 use std::convert::From;
6808 Self::from(0)
6809 }
6810 }
6811
6812 impl std::fmt::Display for State {
6813 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6814 wkt::internal::display_enum(f, self.name(), self.value())
6815 }
6816 }
6817
6818 impl std::convert::From<i32> for State {
6819 fn from(value: i32) -> Self {
6820 match value {
6821 0 => Self::Unspecified,
6822 1 => Self::Active,
6823 2 => Self::PermissionDenied,
6824 3 => Self::NotFound,
6825 4 => Self::InTransitLocationRestriction,
6826 5 => Self::SchemaMismatch,
6827 6 => Self::VertexAiLocationRestriction,
6828 _ => Self::UnknownValue(state::UnknownValue(
6829 wkt::internal::UnknownEnumValue::Integer(value),
6830 )),
6831 }
6832 }
6833 }
6834
6835 impl std::convert::From<&str> for State {
6836 fn from(value: &str) -> Self {
6837 use std::string::ToString;
6838 match value {
6839 "STATE_UNSPECIFIED" => Self::Unspecified,
6840 "ACTIVE" => Self::Active,
6841 "PERMISSION_DENIED" => Self::PermissionDenied,
6842 "NOT_FOUND" => Self::NotFound,
6843 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6844 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6845 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6846 _ => Self::UnknownValue(state::UnknownValue(
6847 wkt::internal::UnknownEnumValue::String(value.to_string()),
6848 )),
6849 }
6850 }
6851 }
6852
6853 impl serde::ser::Serialize for State {
6854 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6855 where
6856 S: serde::Serializer,
6857 {
6858 match self {
6859 Self::Unspecified => serializer.serialize_i32(0),
6860 Self::Active => serializer.serialize_i32(1),
6861 Self::PermissionDenied => serializer.serialize_i32(2),
6862 Self::NotFound => serializer.serialize_i32(3),
6863 Self::InTransitLocationRestriction => serializer.serialize_i32(4),
6864 Self::SchemaMismatch => serializer.serialize_i32(5),
6865 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
6866 Self::UnknownValue(u) => u.0.serialize(serializer),
6867 }
6868 }
6869 }
6870
6871 impl<'de> serde::de::Deserialize<'de> for State {
6872 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6873 where
6874 D: serde::Deserializer<'de>,
6875 {
6876 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6877 ".google.pubsub.v1.CloudStorageConfig.State",
6878 ))
6879 }
6880 }
6881
6882 /// Defaults to text format.
6883 #[derive(Clone, Debug, PartialEq)]
6884 #[non_exhaustive]
6885 pub enum OutputFormat {
6886 /// Optional. If set, message data will be written to Cloud Storage in text
6887 /// format.
6888 TextConfig(std::boxed::Box<crate::model::cloud_storage_config::TextConfig>),
6889 /// Optional. If set, message data will be written to Cloud Storage in Avro
6890 /// format.
6891 AvroConfig(std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>),
6892 }
6893}
6894
6895/// Request for the GetSubscription method.
6896#[derive(Clone, Default, PartialEq)]
6897#[non_exhaustive]
6898pub struct GetSubscriptionRequest {
6899 /// Required. The name of the subscription to get.
6900 /// Format is `projects/{project}/subscriptions/{sub}`.
6901 pub subscription: std::string::String,
6902
6903 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6904}
6905
6906impl GetSubscriptionRequest {
6907 /// Creates a new default instance.
6908 pub fn new() -> Self {
6909 std::default::Default::default()
6910 }
6911
6912 /// Sets the value of [subscription][crate::model::GetSubscriptionRequest::subscription].
6913 ///
6914 /// # Example
6915 /// ```ignore,no_run
6916 /// # use google_cloud_pubsub::model::GetSubscriptionRequest;
6917 /// let x = GetSubscriptionRequest::new().set_subscription("example");
6918 /// ```
6919 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6920 self.subscription = v.into();
6921 self
6922 }
6923}
6924
6925impl wkt::message::Message for GetSubscriptionRequest {
6926 fn typename() -> &'static str {
6927 "type.googleapis.com/google.pubsub.v1.GetSubscriptionRequest"
6928 }
6929}
6930
6931/// Request for the UpdateSubscription method.
6932#[derive(Clone, Default, PartialEq)]
6933#[non_exhaustive]
6934pub struct UpdateSubscriptionRequest {
6935 /// Required. The updated subscription object.
6936 pub subscription: std::option::Option<crate::model::Subscription>,
6937
6938 /// Required. Indicates which fields in the provided subscription to update.
6939 /// Must be specified and non-empty.
6940 pub update_mask: std::option::Option<wkt::FieldMask>,
6941
6942 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6943}
6944
6945impl UpdateSubscriptionRequest {
6946 /// Creates a new default instance.
6947 pub fn new() -> Self {
6948 std::default::Default::default()
6949 }
6950
6951 /// Sets the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
6952 ///
6953 /// # Example
6954 /// ```ignore,no_run
6955 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
6956 /// use google_cloud_pubsub::model::Subscription;
6957 /// let x = UpdateSubscriptionRequest::new().set_subscription(Subscription::default()/* use setters */);
6958 /// ```
6959 pub fn set_subscription<T>(mut self, v: T) -> Self
6960 where
6961 T: std::convert::Into<crate::model::Subscription>,
6962 {
6963 self.subscription = std::option::Option::Some(v.into());
6964 self
6965 }
6966
6967 /// Sets or clears the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
6968 ///
6969 /// # Example
6970 /// ```ignore,no_run
6971 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
6972 /// use google_cloud_pubsub::model::Subscription;
6973 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(Some(Subscription::default()/* use setters */));
6974 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(None::<Subscription>);
6975 /// ```
6976 pub fn set_or_clear_subscription<T>(mut self, v: std::option::Option<T>) -> Self
6977 where
6978 T: std::convert::Into<crate::model::Subscription>,
6979 {
6980 self.subscription = v.map(|x| x.into());
6981 self
6982 }
6983
6984 /// Sets the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
6985 ///
6986 /// # Example
6987 /// ```ignore,no_run
6988 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
6989 /// use wkt::FieldMask;
6990 /// let x = UpdateSubscriptionRequest::new().set_update_mask(FieldMask::default()/* use setters */);
6991 /// ```
6992 pub fn set_update_mask<T>(mut self, v: T) -> Self
6993 where
6994 T: std::convert::Into<wkt::FieldMask>,
6995 {
6996 self.update_mask = std::option::Option::Some(v.into());
6997 self
6998 }
6999
7000 /// Sets or clears the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
7001 ///
7002 /// # Example
7003 /// ```ignore,no_run
7004 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7005 /// use wkt::FieldMask;
7006 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7007 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7008 /// ```
7009 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7010 where
7011 T: std::convert::Into<wkt::FieldMask>,
7012 {
7013 self.update_mask = v.map(|x| x.into());
7014 self
7015 }
7016}
7017
7018impl wkt::message::Message for UpdateSubscriptionRequest {
7019 fn typename() -> &'static str {
7020 "type.googleapis.com/google.pubsub.v1.UpdateSubscriptionRequest"
7021 }
7022}
7023
7024/// Request for the `ListSubscriptions` method.
7025#[derive(Clone, Default, PartialEq)]
7026#[non_exhaustive]
7027pub struct ListSubscriptionsRequest {
7028 /// Required. The name of the project in which to list subscriptions.
7029 /// Format is `projects/{project-id}`.
7030 pub project: std::string::String,
7031
7032 /// Optional. Maximum number of subscriptions to return.
7033 pub page_size: i32,
7034
7035 /// Optional. The value returned by the last `ListSubscriptionsResponse`;
7036 /// indicates that this is a continuation of a prior `ListSubscriptions` call,
7037 /// and that the system should return the next page of data.
7038 pub page_token: std::string::String,
7039
7040 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7041}
7042
7043impl ListSubscriptionsRequest {
7044 /// Creates a new default instance.
7045 pub fn new() -> Self {
7046 std::default::Default::default()
7047 }
7048
7049 /// Sets the value of [project][crate::model::ListSubscriptionsRequest::project].
7050 ///
7051 /// # Example
7052 /// ```ignore,no_run
7053 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7054 /// let x = ListSubscriptionsRequest::new().set_project("example");
7055 /// ```
7056 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7057 self.project = v.into();
7058 self
7059 }
7060
7061 /// Sets the value of [page_size][crate::model::ListSubscriptionsRequest::page_size].
7062 ///
7063 /// # Example
7064 /// ```ignore,no_run
7065 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7066 /// let x = ListSubscriptionsRequest::new().set_page_size(42);
7067 /// ```
7068 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7069 self.page_size = v.into();
7070 self
7071 }
7072
7073 /// Sets the value of [page_token][crate::model::ListSubscriptionsRequest::page_token].
7074 ///
7075 /// # Example
7076 /// ```ignore,no_run
7077 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7078 /// let x = ListSubscriptionsRequest::new().set_page_token("example");
7079 /// ```
7080 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7081 self.page_token = v.into();
7082 self
7083 }
7084}
7085
7086impl wkt::message::Message for ListSubscriptionsRequest {
7087 fn typename() -> &'static str {
7088 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsRequest"
7089 }
7090}
7091
7092/// Response for the `ListSubscriptions` method.
7093#[derive(Clone, Default, PartialEq)]
7094#[non_exhaustive]
7095pub struct ListSubscriptionsResponse {
7096 /// Optional. The subscriptions that match the request.
7097 pub subscriptions: std::vec::Vec<crate::model::Subscription>,
7098
7099 /// Optional. If not empty, indicates that there may be more subscriptions that
7100 /// match the request; this value should be passed in a new
7101 /// `ListSubscriptionsRequest` to get more subscriptions.
7102 pub next_page_token: std::string::String,
7103
7104 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7105}
7106
7107impl ListSubscriptionsResponse {
7108 /// Creates a new default instance.
7109 pub fn new() -> Self {
7110 std::default::Default::default()
7111 }
7112
7113 /// Sets the value of [subscriptions][crate::model::ListSubscriptionsResponse::subscriptions].
7114 ///
7115 /// # Example
7116 /// ```ignore,no_run
7117 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7118 /// use google_cloud_pubsub::model::Subscription;
7119 /// let x = ListSubscriptionsResponse::new()
7120 /// .set_subscriptions([
7121 /// Subscription::default()/* use setters */,
7122 /// Subscription::default()/* use (different) setters */,
7123 /// ]);
7124 /// ```
7125 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
7126 where
7127 T: std::iter::IntoIterator<Item = V>,
7128 V: std::convert::Into<crate::model::Subscription>,
7129 {
7130 use std::iter::Iterator;
7131 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
7132 self
7133 }
7134
7135 /// Sets the value of [next_page_token][crate::model::ListSubscriptionsResponse::next_page_token].
7136 ///
7137 /// # Example
7138 /// ```ignore,no_run
7139 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7140 /// let x = ListSubscriptionsResponse::new().set_next_page_token("example");
7141 /// ```
7142 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7143 self.next_page_token = v.into();
7144 self
7145 }
7146}
7147
7148impl wkt::message::Message for ListSubscriptionsResponse {
7149 fn typename() -> &'static str {
7150 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsResponse"
7151 }
7152}
7153
7154#[doc(hidden)]
7155impl google_cloud_gax::paginator::internal::PageableResponse for ListSubscriptionsResponse {
7156 type PageItem = crate::model::Subscription;
7157
7158 fn items(self) -> std::vec::Vec<Self::PageItem> {
7159 self.subscriptions
7160 }
7161
7162 fn next_page_token(&self) -> std::string::String {
7163 use std::clone::Clone;
7164 self.next_page_token.clone()
7165 }
7166}
7167
7168/// Request for the DeleteSubscription method.
7169#[derive(Clone, Default, PartialEq)]
7170#[non_exhaustive]
7171pub struct DeleteSubscriptionRequest {
7172 /// Required. The subscription to delete.
7173 /// Format is `projects/{project}/subscriptions/{sub}`.
7174 pub subscription: std::string::String,
7175
7176 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7177}
7178
7179impl DeleteSubscriptionRequest {
7180 /// Creates a new default instance.
7181 pub fn new() -> Self {
7182 std::default::Default::default()
7183 }
7184
7185 /// Sets the value of [subscription][crate::model::DeleteSubscriptionRequest::subscription].
7186 ///
7187 /// # Example
7188 /// ```ignore,no_run
7189 /// # use google_cloud_pubsub::model::DeleteSubscriptionRequest;
7190 /// let x = DeleteSubscriptionRequest::new().set_subscription("example");
7191 /// ```
7192 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7193 self.subscription = v.into();
7194 self
7195 }
7196}
7197
7198impl wkt::message::Message for DeleteSubscriptionRequest {
7199 fn typename() -> &'static str {
7200 "type.googleapis.com/google.pubsub.v1.DeleteSubscriptionRequest"
7201 }
7202}
7203
7204/// Request for the ModifyPushConfig method.
7205#[derive(Clone, Default, PartialEq)]
7206#[non_exhaustive]
7207pub struct ModifyPushConfigRequest {
7208 /// Required. The name of the subscription.
7209 /// Format is `projects/{project}/subscriptions/{sub}`.
7210 pub subscription: std::string::String,
7211
7212 /// Required. The push configuration for future deliveries.
7213 ///
7214 /// An empty `pushConfig` indicates that the Pub/Sub system should
7215 /// stop pushing messages from the given subscription and allow
7216 /// messages to be pulled and acknowledged - effectively pausing
7217 /// the subscription if `Pull` or `StreamingPull` is not called.
7218 pub push_config: std::option::Option<crate::model::PushConfig>,
7219
7220 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7221}
7222
7223impl ModifyPushConfigRequest {
7224 /// Creates a new default instance.
7225 pub fn new() -> Self {
7226 std::default::Default::default()
7227 }
7228
7229 /// Sets the value of [subscription][crate::model::ModifyPushConfigRequest::subscription].
7230 ///
7231 /// # Example
7232 /// ```ignore,no_run
7233 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7234 /// let x = ModifyPushConfigRequest::new().set_subscription("example");
7235 /// ```
7236 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7237 self.subscription = v.into();
7238 self
7239 }
7240
7241 /// Sets the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7242 ///
7243 /// # Example
7244 /// ```ignore,no_run
7245 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7246 /// use google_cloud_pubsub::model::PushConfig;
7247 /// let x = ModifyPushConfigRequest::new().set_push_config(PushConfig::default()/* use setters */);
7248 /// ```
7249 pub fn set_push_config<T>(mut self, v: T) -> Self
7250 where
7251 T: std::convert::Into<crate::model::PushConfig>,
7252 {
7253 self.push_config = std::option::Option::Some(v.into());
7254 self
7255 }
7256
7257 /// Sets or clears the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7258 ///
7259 /// # Example
7260 /// ```ignore,no_run
7261 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7262 /// use google_cloud_pubsub::model::PushConfig;
7263 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
7264 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(None::<PushConfig>);
7265 /// ```
7266 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
7267 where
7268 T: std::convert::Into<crate::model::PushConfig>,
7269 {
7270 self.push_config = v.map(|x| x.into());
7271 self
7272 }
7273}
7274
7275impl wkt::message::Message for ModifyPushConfigRequest {
7276 fn typename() -> &'static str {
7277 "type.googleapis.com/google.pubsub.v1.ModifyPushConfigRequest"
7278 }
7279}
7280
7281/// Request for the `CreateSnapshot` method.
7282#[derive(Clone, Default, PartialEq)]
7283#[non_exhaustive]
7284pub struct CreateSnapshotRequest {
7285 /// Required. User-provided name for this snapshot. If the name is not provided
7286 /// in the request, the server will assign a random name for this snapshot on
7287 /// the same project as the subscription. Note that for REST API requests, you
7288 /// must specify a name. See the [resource name
7289 /// rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
7290 /// Format is `projects/{project}/snapshots/{snap}`.
7291 pub name: std::string::String,
7292
7293 /// Required. The subscription whose backlog the snapshot retains.
7294 /// Specifically, the created snapshot is guaranteed to retain:
7295 /// (a) The existing backlog on the subscription. More precisely, this is
7296 /// defined as the messages in the subscription's backlog that are
7297 /// unacknowledged upon the successful completion of the
7298 /// `CreateSnapshot` request; as well as:
7299 /// (b) Any messages published to the subscription's topic following the
7300 /// successful completion of the CreateSnapshot request.
7301 /// Format is `projects/{project}/subscriptions/{sub}`.
7302 pub subscription: std::string::String,
7303
7304 /// Optional. See [Creating and managing
7305 /// labels](https://cloud.google.com/pubsub/docs/labels).
7306 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7307
7308 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
7309 /// resource. For example:
7310 /// "123/environment": "production",
7311 /// "123/costCenter": "marketing"
7312 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
7313 /// using tags with Pub/Sub resources.
7314 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
7315
7316 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7317}
7318
7319impl CreateSnapshotRequest {
7320 /// Creates a new default instance.
7321 pub fn new() -> Self {
7322 std::default::Default::default()
7323 }
7324
7325 /// Sets the value of [name][crate::model::CreateSnapshotRequest::name].
7326 ///
7327 /// # Example
7328 /// ```ignore,no_run
7329 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7330 /// let x = CreateSnapshotRequest::new().set_name("example");
7331 /// ```
7332 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7333 self.name = v.into();
7334 self
7335 }
7336
7337 /// Sets the value of [subscription][crate::model::CreateSnapshotRequest::subscription].
7338 ///
7339 /// # Example
7340 /// ```ignore,no_run
7341 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7342 /// let x = CreateSnapshotRequest::new().set_subscription("example");
7343 /// ```
7344 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7345 self.subscription = v.into();
7346 self
7347 }
7348
7349 /// Sets the value of [labels][crate::model::CreateSnapshotRequest::labels].
7350 ///
7351 /// # Example
7352 /// ```ignore,no_run
7353 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7354 /// let x = CreateSnapshotRequest::new().set_labels([
7355 /// ("key0", "abc"),
7356 /// ("key1", "xyz"),
7357 /// ]);
7358 /// ```
7359 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
7360 where
7361 T: std::iter::IntoIterator<Item = (K, V)>,
7362 K: std::convert::Into<std::string::String>,
7363 V: std::convert::Into<std::string::String>,
7364 {
7365 use std::iter::Iterator;
7366 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7367 self
7368 }
7369
7370 /// Sets the value of [tags][crate::model::CreateSnapshotRequest::tags].
7371 ///
7372 /// # Example
7373 /// ```ignore,no_run
7374 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7375 /// let x = CreateSnapshotRequest::new().set_tags([
7376 /// ("key0", "abc"),
7377 /// ("key1", "xyz"),
7378 /// ]);
7379 /// ```
7380 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
7381 where
7382 T: std::iter::IntoIterator<Item = (K, V)>,
7383 K: std::convert::Into<std::string::String>,
7384 V: std::convert::Into<std::string::String>,
7385 {
7386 use std::iter::Iterator;
7387 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7388 self
7389 }
7390}
7391
7392impl wkt::message::Message for CreateSnapshotRequest {
7393 fn typename() -> &'static str {
7394 "type.googleapis.com/google.pubsub.v1.CreateSnapshotRequest"
7395 }
7396}
7397
7398/// Request for the UpdateSnapshot method.
7399#[derive(Clone, Default, PartialEq)]
7400#[non_exhaustive]
7401pub struct UpdateSnapshotRequest {
7402 /// Required. The updated snapshot object.
7403 pub snapshot: std::option::Option<crate::model::Snapshot>,
7404
7405 /// Required. Indicates which fields in the provided snapshot to update.
7406 /// Must be specified and non-empty.
7407 pub update_mask: std::option::Option<wkt::FieldMask>,
7408
7409 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7410}
7411
7412impl UpdateSnapshotRequest {
7413 /// Creates a new default instance.
7414 pub fn new() -> Self {
7415 std::default::Default::default()
7416 }
7417
7418 /// Sets the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7419 ///
7420 /// # Example
7421 /// ```ignore,no_run
7422 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7423 /// use google_cloud_pubsub::model::Snapshot;
7424 /// let x = UpdateSnapshotRequest::new().set_snapshot(Snapshot::default()/* use setters */);
7425 /// ```
7426 pub fn set_snapshot<T>(mut self, v: T) -> Self
7427 where
7428 T: std::convert::Into<crate::model::Snapshot>,
7429 {
7430 self.snapshot = std::option::Option::Some(v.into());
7431 self
7432 }
7433
7434 /// Sets or clears the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7435 ///
7436 /// # Example
7437 /// ```ignore,no_run
7438 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7439 /// use google_cloud_pubsub::model::Snapshot;
7440 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(Some(Snapshot::default()/* use setters */));
7441 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(None::<Snapshot>);
7442 /// ```
7443 pub fn set_or_clear_snapshot<T>(mut self, v: std::option::Option<T>) -> Self
7444 where
7445 T: std::convert::Into<crate::model::Snapshot>,
7446 {
7447 self.snapshot = v.map(|x| x.into());
7448 self
7449 }
7450
7451 /// Sets the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7452 ///
7453 /// # Example
7454 /// ```ignore,no_run
7455 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7456 /// use wkt::FieldMask;
7457 /// let x = UpdateSnapshotRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7458 /// ```
7459 pub fn set_update_mask<T>(mut self, v: T) -> Self
7460 where
7461 T: std::convert::Into<wkt::FieldMask>,
7462 {
7463 self.update_mask = std::option::Option::Some(v.into());
7464 self
7465 }
7466
7467 /// Sets or clears the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7468 ///
7469 /// # Example
7470 /// ```ignore,no_run
7471 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7472 /// use wkt::FieldMask;
7473 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7474 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7475 /// ```
7476 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7477 where
7478 T: std::convert::Into<wkt::FieldMask>,
7479 {
7480 self.update_mask = v.map(|x| x.into());
7481 self
7482 }
7483}
7484
7485impl wkt::message::Message for UpdateSnapshotRequest {
7486 fn typename() -> &'static str {
7487 "type.googleapis.com/google.pubsub.v1.UpdateSnapshotRequest"
7488 }
7489}
7490
7491/// A snapshot resource. Snapshots are used in
7492/// [Seek](https://cloud.google.com/pubsub/docs/replay-overview)
7493/// operations, which allow you to manage message acknowledgments in bulk. That
7494/// is, you can set the acknowledgment state of messages in an existing
7495/// subscription to the state captured by a snapshot.
7496#[derive(Clone, Default, PartialEq)]
7497#[non_exhaustive]
7498pub struct Snapshot {
7499 /// Optional. The name of the snapshot.
7500 pub name: std::string::String,
7501
7502 /// Optional. The name of the topic from which this snapshot is retaining
7503 /// messages.
7504 pub topic: std::string::String,
7505
7506 /// Optional. The snapshot is guaranteed to exist up until this time.
7507 /// A newly-created snapshot expires no later than 7 days from the time of its
7508 /// creation. Its exact lifetime is determined at creation by the existing
7509 /// backlog in the source subscription. Specifically, the lifetime of the
7510 /// snapshot is `7 days - (age of oldest unacked message in the subscription)`.
7511 /// For example, consider a subscription whose oldest unacked message is 3 days
7512 /// old. If a snapshot is created from this subscription, the snapshot -- which
7513 /// will always capture this 3-day-old backlog as long as the snapshot
7514 /// exists -- will expire in 4 days. The service will refuse to create a
7515 /// snapshot that would expire in less than 1 hour after creation.
7516 pub expire_time: std::option::Option<wkt::Timestamp>,
7517
7518 /// Optional. See [Creating and managing labels]
7519 /// (<https://cloud.google.com/pubsub/docs/labels>).
7520 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7521
7522 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7523}
7524
7525impl Snapshot {
7526 /// Creates a new default instance.
7527 pub fn new() -> Self {
7528 std::default::Default::default()
7529 }
7530
7531 /// Sets the value of [name][crate::model::Snapshot::name].
7532 ///
7533 /// # Example
7534 /// ```ignore,no_run
7535 /// # use google_cloud_pubsub::model::Snapshot;
7536 /// let x = Snapshot::new().set_name("example");
7537 /// ```
7538 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7539 self.name = v.into();
7540 self
7541 }
7542
7543 /// Sets the value of [topic][crate::model::Snapshot::topic].
7544 ///
7545 /// # Example
7546 /// ```ignore,no_run
7547 /// # use google_cloud_pubsub::model::Snapshot;
7548 /// let x = Snapshot::new().set_topic("example");
7549 /// ```
7550 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7551 self.topic = v.into();
7552 self
7553 }
7554
7555 /// Sets the value of [expire_time][crate::model::Snapshot::expire_time].
7556 ///
7557 /// # Example
7558 /// ```ignore,no_run
7559 /// # use google_cloud_pubsub::model::Snapshot;
7560 /// use wkt::Timestamp;
7561 /// let x = Snapshot::new().set_expire_time(Timestamp::default()/* use setters */);
7562 /// ```
7563 pub fn set_expire_time<T>(mut self, v: T) -> Self
7564 where
7565 T: std::convert::Into<wkt::Timestamp>,
7566 {
7567 self.expire_time = std::option::Option::Some(v.into());
7568 self
7569 }
7570
7571 /// Sets or clears the value of [expire_time][crate::model::Snapshot::expire_time].
7572 ///
7573 /// # Example
7574 /// ```ignore,no_run
7575 /// # use google_cloud_pubsub::model::Snapshot;
7576 /// use wkt::Timestamp;
7577 /// let x = Snapshot::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
7578 /// let x = Snapshot::new().set_or_clear_expire_time(None::<Timestamp>);
7579 /// ```
7580 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
7581 where
7582 T: std::convert::Into<wkt::Timestamp>,
7583 {
7584 self.expire_time = v.map(|x| x.into());
7585 self
7586 }
7587
7588 /// Sets the value of [labels][crate::model::Snapshot::labels].
7589 ///
7590 /// # Example
7591 /// ```ignore,no_run
7592 /// # use google_cloud_pubsub::model::Snapshot;
7593 /// let x = Snapshot::new().set_labels([
7594 /// ("key0", "abc"),
7595 /// ("key1", "xyz"),
7596 /// ]);
7597 /// ```
7598 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
7599 where
7600 T: std::iter::IntoIterator<Item = (K, V)>,
7601 K: std::convert::Into<std::string::String>,
7602 V: std::convert::Into<std::string::String>,
7603 {
7604 use std::iter::Iterator;
7605 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7606 self
7607 }
7608}
7609
7610impl wkt::message::Message for Snapshot {
7611 fn typename() -> &'static str {
7612 "type.googleapis.com/google.pubsub.v1.Snapshot"
7613 }
7614}
7615
7616/// Request for the GetSnapshot method.
7617#[derive(Clone, Default, PartialEq)]
7618#[non_exhaustive]
7619pub struct GetSnapshotRequest {
7620 /// Required. The name of the snapshot to get.
7621 /// Format is `projects/{project}/snapshots/{snap}`.
7622 pub snapshot: std::string::String,
7623
7624 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7625}
7626
7627impl GetSnapshotRequest {
7628 /// Creates a new default instance.
7629 pub fn new() -> Self {
7630 std::default::Default::default()
7631 }
7632
7633 /// Sets the value of [snapshot][crate::model::GetSnapshotRequest::snapshot].
7634 ///
7635 /// # Example
7636 /// ```ignore,no_run
7637 /// # use google_cloud_pubsub::model::GetSnapshotRequest;
7638 /// let x = GetSnapshotRequest::new().set_snapshot("example");
7639 /// ```
7640 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7641 self.snapshot = v.into();
7642 self
7643 }
7644}
7645
7646impl wkt::message::Message for GetSnapshotRequest {
7647 fn typename() -> &'static str {
7648 "type.googleapis.com/google.pubsub.v1.GetSnapshotRequest"
7649 }
7650}
7651
7652/// Request for the `ListSnapshots` method.
7653#[derive(Clone, Default, PartialEq)]
7654#[non_exhaustive]
7655pub struct ListSnapshotsRequest {
7656 /// Required. The name of the project in which to list snapshots.
7657 /// Format is `projects/{project-id}`.
7658 pub project: std::string::String,
7659
7660 /// Optional. Maximum number of snapshots to return.
7661 pub page_size: i32,
7662
7663 /// Optional. The value returned by the last `ListSnapshotsResponse`; indicates
7664 /// that this is a continuation of a prior `ListSnapshots` call, and that the
7665 /// system should return the next page of data.
7666 pub page_token: std::string::String,
7667
7668 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7669}
7670
7671impl ListSnapshotsRequest {
7672 /// Creates a new default instance.
7673 pub fn new() -> Self {
7674 std::default::Default::default()
7675 }
7676
7677 /// Sets the value of [project][crate::model::ListSnapshotsRequest::project].
7678 ///
7679 /// # Example
7680 /// ```ignore,no_run
7681 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7682 /// let x = ListSnapshotsRequest::new().set_project("example");
7683 /// ```
7684 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7685 self.project = v.into();
7686 self
7687 }
7688
7689 /// Sets the value of [page_size][crate::model::ListSnapshotsRequest::page_size].
7690 ///
7691 /// # Example
7692 /// ```ignore,no_run
7693 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7694 /// let x = ListSnapshotsRequest::new().set_page_size(42);
7695 /// ```
7696 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7697 self.page_size = v.into();
7698 self
7699 }
7700
7701 /// Sets the value of [page_token][crate::model::ListSnapshotsRequest::page_token].
7702 ///
7703 /// # Example
7704 /// ```ignore,no_run
7705 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7706 /// let x = ListSnapshotsRequest::new().set_page_token("example");
7707 /// ```
7708 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7709 self.page_token = v.into();
7710 self
7711 }
7712}
7713
7714impl wkt::message::Message for ListSnapshotsRequest {
7715 fn typename() -> &'static str {
7716 "type.googleapis.com/google.pubsub.v1.ListSnapshotsRequest"
7717 }
7718}
7719
7720/// Response for the `ListSnapshots` method.
7721#[derive(Clone, Default, PartialEq)]
7722#[non_exhaustive]
7723pub struct ListSnapshotsResponse {
7724 /// Optional. The resulting snapshots.
7725 pub snapshots: std::vec::Vec<crate::model::Snapshot>,
7726
7727 /// Optional. If not empty, indicates that there may be more snapshot that
7728 /// match the request; this value should be passed in a new
7729 /// `ListSnapshotsRequest`.
7730 pub next_page_token: std::string::String,
7731
7732 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7733}
7734
7735impl ListSnapshotsResponse {
7736 /// Creates a new default instance.
7737 pub fn new() -> Self {
7738 std::default::Default::default()
7739 }
7740
7741 /// Sets the value of [snapshots][crate::model::ListSnapshotsResponse::snapshots].
7742 ///
7743 /// # Example
7744 /// ```ignore,no_run
7745 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
7746 /// use google_cloud_pubsub::model::Snapshot;
7747 /// let x = ListSnapshotsResponse::new()
7748 /// .set_snapshots([
7749 /// Snapshot::default()/* use setters */,
7750 /// Snapshot::default()/* use (different) setters */,
7751 /// ]);
7752 /// ```
7753 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
7754 where
7755 T: std::iter::IntoIterator<Item = V>,
7756 V: std::convert::Into<crate::model::Snapshot>,
7757 {
7758 use std::iter::Iterator;
7759 self.snapshots = v.into_iter().map(|i| i.into()).collect();
7760 self
7761 }
7762
7763 /// Sets the value of [next_page_token][crate::model::ListSnapshotsResponse::next_page_token].
7764 ///
7765 /// # Example
7766 /// ```ignore,no_run
7767 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
7768 /// let x = ListSnapshotsResponse::new().set_next_page_token("example");
7769 /// ```
7770 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7771 self.next_page_token = v.into();
7772 self
7773 }
7774}
7775
7776impl wkt::message::Message for ListSnapshotsResponse {
7777 fn typename() -> &'static str {
7778 "type.googleapis.com/google.pubsub.v1.ListSnapshotsResponse"
7779 }
7780}
7781
7782#[doc(hidden)]
7783impl google_cloud_gax::paginator::internal::PageableResponse for ListSnapshotsResponse {
7784 type PageItem = crate::model::Snapshot;
7785
7786 fn items(self) -> std::vec::Vec<Self::PageItem> {
7787 self.snapshots
7788 }
7789
7790 fn next_page_token(&self) -> std::string::String {
7791 use std::clone::Clone;
7792 self.next_page_token.clone()
7793 }
7794}
7795
7796/// Request for the `DeleteSnapshot` method.
7797#[derive(Clone, Default, PartialEq)]
7798#[non_exhaustive]
7799pub struct DeleteSnapshotRequest {
7800 /// Required. The name of the snapshot to delete.
7801 /// Format is `projects/{project}/snapshots/{snap}`.
7802 pub snapshot: std::string::String,
7803
7804 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7805}
7806
7807impl DeleteSnapshotRequest {
7808 /// Creates a new default instance.
7809 pub fn new() -> Self {
7810 std::default::Default::default()
7811 }
7812
7813 /// Sets the value of [snapshot][crate::model::DeleteSnapshotRequest::snapshot].
7814 ///
7815 /// # Example
7816 /// ```ignore,no_run
7817 /// # use google_cloud_pubsub::model::DeleteSnapshotRequest;
7818 /// let x = DeleteSnapshotRequest::new().set_snapshot("example");
7819 /// ```
7820 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7821 self.snapshot = v.into();
7822 self
7823 }
7824}
7825
7826impl wkt::message::Message for DeleteSnapshotRequest {
7827 fn typename() -> &'static str {
7828 "type.googleapis.com/google.pubsub.v1.DeleteSnapshotRequest"
7829 }
7830}
7831
7832/// Request for the `Seek` method.
7833#[derive(Clone, Default, PartialEq)]
7834#[non_exhaustive]
7835pub struct SeekRequest {
7836 /// Required. The subscription to affect.
7837 pub subscription: std::string::String,
7838
7839 #[allow(missing_docs)]
7840 pub target: std::option::Option<crate::model::seek_request::Target>,
7841
7842 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7843}
7844
7845impl SeekRequest {
7846 /// Creates a new default instance.
7847 pub fn new() -> Self {
7848 std::default::Default::default()
7849 }
7850
7851 /// Sets the value of [subscription][crate::model::SeekRequest::subscription].
7852 ///
7853 /// # Example
7854 /// ```ignore,no_run
7855 /// # use google_cloud_pubsub::model::SeekRequest;
7856 /// let x = SeekRequest::new().set_subscription("example");
7857 /// ```
7858 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7859 self.subscription = v.into();
7860 self
7861 }
7862
7863 /// Sets the value of [target][crate::model::SeekRequest::target].
7864 ///
7865 /// Note that all the setters affecting `target` are mutually
7866 /// exclusive.
7867 ///
7868 /// # Example
7869 /// ```ignore,no_run
7870 /// # use google_cloud_pubsub::model::SeekRequest;
7871 /// use google_cloud_pubsub::model::seek_request::Target;
7872 /// let x = SeekRequest::new().set_target(Some(Target::Snapshot("example".to_string())));
7873 /// ```
7874 pub fn set_target<
7875 T: std::convert::Into<std::option::Option<crate::model::seek_request::Target>>,
7876 >(
7877 mut self,
7878 v: T,
7879 ) -> Self {
7880 self.target = v.into();
7881 self
7882 }
7883
7884 /// The value of [target][crate::model::SeekRequest::target]
7885 /// if it holds a `Time`, `None` if the field is not set or
7886 /// holds a different branch.
7887 pub fn time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
7888 #[allow(unreachable_patterns)]
7889 self.target.as_ref().and_then(|v| match v {
7890 crate::model::seek_request::Target::Time(v) => std::option::Option::Some(v),
7891 _ => std::option::Option::None,
7892 })
7893 }
7894
7895 /// Sets the value of [target][crate::model::SeekRequest::target]
7896 /// to hold a `Time`.
7897 ///
7898 /// Note that all the setters affecting `target` are
7899 /// mutually exclusive.
7900 ///
7901 /// # Example
7902 /// ```ignore,no_run
7903 /// # use google_cloud_pubsub::model::SeekRequest;
7904 /// use wkt::Timestamp;
7905 /// let x = SeekRequest::new().set_time(Timestamp::default()/* use setters */);
7906 /// assert!(x.time().is_some());
7907 /// assert!(x.snapshot().is_none());
7908 /// ```
7909 pub fn set_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
7910 mut self,
7911 v: T,
7912 ) -> Self {
7913 self.target = std::option::Option::Some(crate::model::seek_request::Target::Time(v.into()));
7914 self
7915 }
7916
7917 /// The value of [target][crate::model::SeekRequest::target]
7918 /// if it holds a `Snapshot`, `None` if the field is not set or
7919 /// holds a different branch.
7920 pub fn snapshot(&self) -> std::option::Option<&std::string::String> {
7921 #[allow(unreachable_patterns)]
7922 self.target.as_ref().and_then(|v| match v {
7923 crate::model::seek_request::Target::Snapshot(v) => std::option::Option::Some(v),
7924 _ => std::option::Option::None,
7925 })
7926 }
7927
7928 /// Sets the value of [target][crate::model::SeekRequest::target]
7929 /// to hold a `Snapshot`.
7930 ///
7931 /// Note that all the setters affecting `target` are
7932 /// mutually exclusive.
7933 ///
7934 /// # Example
7935 /// ```ignore,no_run
7936 /// # use google_cloud_pubsub::model::SeekRequest;
7937 /// let x = SeekRequest::new().set_snapshot("example");
7938 /// assert!(x.snapshot().is_some());
7939 /// assert!(x.time().is_none());
7940 /// ```
7941 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7942 self.target =
7943 std::option::Option::Some(crate::model::seek_request::Target::Snapshot(v.into()));
7944 self
7945 }
7946}
7947
7948impl wkt::message::Message for SeekRequest {
7949 fn typename() -> &'static str {
7950 "type.googleapis.com/google.pubsub.v1.SeekRequest"
7951 }
7952}
7953
7954/// Defines additional types related to [SeekRequest].
7955pub mod seek_request {
7956 #[allow(unused_imports)]
7957 use super::*;
7958
7959 #[allow(missing_docs)]
7960 #[derive(Clone, Debug, PartialEq)]
7961 #[non_exhaustive]
7962 pub enum Target {
7963 /// Optional. The time to seek to.
7964 /// Messages retained in the subscription that were published before this
7965 /// time are marked as acknowledged, and messages retained in the
7966 /// subscription that were published after this time are marked as
7967 /// unacknowledged. Note that this operation affects only those messages
7968 /// retained in the subscription (configured by the combination of
7969 /// `message_retention_duration` and `retain_acked_messages`). For example,
7970 /// if `time` corresponds to a point before the message retention
7971 /// window (or to a point before the system's notion of the subscription
7972 /// creation time), only retained messages will be marked as unacknowledged,
7973 /// and already-expunged messages will not be restored.
7974 Time(std::boxed::Box<wkt::Timestamp>),
7975 /// Optional. The snapshot to seek to. The snapshot's topic must be the same
7976 /// as that of the provided subscription. Format is
7977 /// `projects/{project}/snapshots/{snap}`.
7978 Snapshot(std::string::String),
7979 }
7980}
7981
7982/// Response for the `Seek` method (this response is empty).
7983#[derive(Clone, Default, PartialEq)]
7984#[non_exhaustive]
7985pub struct SeekResponse {
7986 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7987}
7988
7989impl SeekResponse {
7990 /// Creates a new default instance.
7991 pub fn new() -> Self {
7992 std::default::Default::default()
7993 }
7994}
7995
7996impl wkt::message::Message for SeekResponse {
7997 fn typename() -> &'static str {
7998 "type.googleapis.com/google.pubsub.v1.SeekResponse"
7999 }
8000}
8001
8002/// A schema resource.
8003#[derive(Clone, Default, PartialEq)]
8004#[non_exhaustive]
8005pub struct Schema {
8006 /// Required. Name of the schema.
8007 /// Format is `projects/{project}/schemas/{schema}`.
8008 pub name: std::string::String,
8009
8010 /// The type of the schema definition.
8011 pub r#type: crate::model::schema::Type,
8012
8013 /// The definition of the schema. This should contain a string representing
8014 /// the full definition of the schema that is a valid schema definition of
8015 /// the type specified in `type`.
8016 pub definition: std::string::String,
8017
8018 /// Output only. Immutable. The revision ID of the schema.
8019 pub revision_id: std::string::String,
8020
8021 /// Output only. The timestamp that the revision was created.
8022 pub revision_create_time: std::option::Option<wkt::Timestamp>,
8023
8024 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8025}
8026
8027impl Schema {
8028 /// Creates a new default instance.
8029 pub fn new() -> Self {
8030 std::default::Default::default()
8031 }
8032
8033 /// Sets the value of [name][crate::model::Schema::name].
8034 ///
8035 /// # Example
8036 /// ```ignore,no_run
8037 /// # use google_cloud_pubsub::model::Schema;
8038 /// let x = Schema::new().set_name("example");
8039 /// ```
8040 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8041 self.name = v.into();
8042 self
8043 }
8044
8045 /// Sets the value of [r#type][crate::model::Schema::type].
8046 ///
8047 /// # Example
8048 /// ```ignore,no_run
8049 /// # use google_cloud_pubsub::model::Schema;
8050 /// use google_cloud_pubsub::model::schema::Type;
8051 /// let x0 = Schema::new().set_type(Type::ProtocolBuffer);
8052 /// let x1 = Schema::new().set_type(Type::Avro);
8053 /// ```
8054 pub fn set_type<T: std::convert::Into<crate::model::schema::Type>>(mut self, v: T) -> Self {
8055 self.r#type = v.into();
8056 self
8057 }
8058
8059 /// Sets the value of [definition][crate::model::Schema::definition].
8060 ///
8061 /// # Example
8062 /// ```ignore,no_run
8063 /// # use google_cloud_pubsub::model::Schema;
8064 /// let x = Schema::new().set_definition("example");
8065 /// ```
8066 pub fn set_definition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8067 self.definition = v.into();
8068 self
8069 }
8070
8071 /// Sets the value of [revision_id][crate::model::Schema::revision_id].
8072 ///
8073 /// # Example
8074 /// ```ignore,no_run
8075 /// # use google_cloud_pubsub::model::Schema;
8076 /// let x = Schema::new().set_revision_id("example");
8077 /// ```
8078 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8079 self.revision_id = v.into();
8080 self
8081 }
8082
8083 /// Sets the value of [revision_create_time][crate::model::Schema::revision_create_time].
8084 ///
8085 /// # Example
8086 /// ```ignore,no_run
8087 /// # use google_cloud_pubsub::model::Schema;
8088 /// use wkt::Timestamp;
8089 /// let x = Schema::new().set_revision_create_time(Timestamp::default()/* use setters */);
8090 /// ```
8091 pub fn set_revision_create_time<T>(mut self, v: T) -> Self
8092 where
8093 T: std::convert::Into<wkt::Timestamp>,
8094 {
8095 self.revision_create_time = std::option::Option::Some(v.into());
8096 self
8097 }
8098
8099 /// Sets or clears the value of [revision_create_time][crate::model::Schema::revision_create_time].
8100 ///
8101 /// # Example
8102 /// ```ignore,no_run
8103 /// # use google_cloud_pubsub::model::Schema;
8104 /// use wkt::Timestamp;
8105 /// let x = Schema::new().set_or_clear_revision_create_time(Some(Timestamp::default()/* use setters */));
8106 /// let x = Schema::new().set_or_clear_revision_create_time(None::<Timestamp>);
8107 /// ```
8108 pub fn set_or_clear_revision_create_time<T>(mut self, v: std::option::Option<T>) -> Self
8109 where
8110 T: std::convert::Into<wkt::Timestamp>,
8111 {
8112 self.revision_create_time = v.map(|x| x.into());
8113 self
8114 }
8115}
8116
8117impl wkt::message::Message for Schema {
8118 fn typename() -> &'static str {
8119 "type.googleapis.com/google.pubsub.v1.Schema"
8120 }
8121}
8122
8123/// Defines additional types related to [Schema].
8124pub mod schema {
8125 #[allow(unused_imports)]
8126 use super::*;
8127
8128 /// Possible schema definition types.
8129 ///
8130 /// # Working with unknown values
8131 ///
8132 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8133 /// additional enum variants at any time. Adding new variants is not considered
8134 /// a breaking change. Applications should write their code in anticipation of:
8135 ///
8136 /// - New values appearing in future releases of the client library, **and**
8137 /// - New values received dynamically, without application changes.
8138 ///
8139 /// Please consult the [Working with enums] section in the user guide for some
8140 /// guidelines.
8141 ///
8142 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8143 #[derive(Clone, Debug, PartialEq)]
8144 #[non_exhaustive]
8145 pub enum Type {
8146 /// Default value. This value is unused.
8147 Unspecified,
8148 /// A Protocol Buffer schema definition.
8149 ProtocolBuffer,
8150 /// An Avro schema definition.
8151 Avro,
8152 /// If set, the enum was initialized with an unknown value.
8153 ///
8154 /// Applications can examine the value using [Type::value] or
8155 /// [Type::name].
8156 UnknownValue(r#type::UnknownValue),
8157 }
8158
8159 #[doc(hidden)]
8160 pub mod r#type {
8161 #[allow(unused_imports)]
8162 use super::*;
8163 #[derive(Clone, Debug, PartialEq)]
8164 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8165 }
8166
8167 impl Type {
8168 /// Gets the enum value.
8169 ///
8170 /// Returns `None` if the enum contains an unknown value deserialized from
8171 /// the string representation of enums.
8172 pub fn value(&self) -> std::option::Option<i32> {
8173 match self {
8174 Self::Unspecified => std::option::Option::Some(0),
8175 Self::ProtocolBuffer => std::option::Option::Some(1),
8176 Self::Avro => std::option::Option::Some(2),
8177 Self::UnknownValue(u) => u.0.value(),
8178 }
8179 }
8180
8181 /// Gets the enum value as a string.
8182 ///
8183 /// Returns `None` if the enum contains an unknown value deserialized from
8184 /// the integer representation of enums.
8185 pub fn name(&self) -> std::option::Option<&str> {
8186 match self {
8187 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
8188 Self::ProtocolBuffer => std::option::Option::Some("PROTOCOL_BUFFER"),
8189 Self::Avro => std::option::Option::Some("AVRO"),
8190 Self::UnknownValue(u) => u.0.name(),
8191 }
8192 }
8193 }
8194
8195 impl std::default::Default for Type {
8196 fn default() -> Self {
8197 use std::convert::From;
8198 Self::from(0)
8199 }
8200 }
8201
8202 impl std::fmt::Display for Type {
8203 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8204 wkt::internal::display_enum(f, self.name(), self.value())
8205 }
8206 }
8207
8208 impl std::convert::From<i32> for Type {
8209 fn from(value: i32) -> Self {
8210 match value {
8211 0 => Self::Unspecified,
8212 1 => Self::ProtocolBuffer,
8213 2 => Self::Avro,
8214 _ => Self::UnknownValue(r#type::UnknownValue(
8215 wkt::internal::UnknownEnumValue::Integer(value),
8216 )),
8217 }
8218 }
8219 }
8220
8221 impl std::convert::From<&str> for Type {
8222 fn from(value: &str) -> Self {
8223 use std::string::ToString;
8224 match value {
8225 "TYPE_UNSPECIFIED" => Self::Unspecified,
8226 "PROTOCOL_BUFFER" => Self::ProtocolBuffer,
8227 "AVRO" => Self::Avro,
8228 _ => Self::UnknownValue(r#type::UnknownValue(
8229 wkt::internal::UnknownEnumValue::String(value.to_string()),
8230 )),
8231 }
8232 }
8233 }
8234
8235 impl serde::ser::Serialize for Type {
8236 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8237 where
8238 S: serde::Serializer,
8239 {
8240 match self {
8241 Self::Unspecified => serializer.serialize_i32(0),
8242 Self::ProtocolBuffer => serializer.serialize_i32(1),
8243 Self::Avro => serializer.serialize_i32(2),
8244 Self::UnknownValue(u) => u.0.serialize(serializer),
8245 }
8246 }
8247 }
8248
8249 impl<'de> serde::de::Deserialize<'de> for Type {
8250 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8251 where
8252 D: serde::Deserializer<'de>,
8253 {
8254 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
8255 ".google.pubsub.v1.Schema.Type",
8256 ))
8257 }
8258 }
8259}
8260
8261/// Request for the CreateSchema method.
8262#[derive(Clone, Default, PartialEq)]
8263#[non_exhaustive]
8264pub struct CreateSchemaRequest {
8265 /// Required. The name of the project in which to create the schema.
8266 /// Format is `projects/{project-id}`.
8267 pub parent: std::string::String,
8268
8269 /// Required. The schema object to create.
8270 ///
8271 /// This schema's `name` parameter is ignored. The schema object returned
8272 /// by CreateSchema will have a `name` made using the given `parent` and
8273 /// `schema_id`.
8274 pub schema: std::option::Option<crate::model::Schema>,
8275
8276 /// The ID to use for the schema, which will become the final component of
8277 /// the schema's resource name.
8278 ///
8279 /// See <https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names> for
8280 /// resource name constraints.
8281 pub schema_id: std::string::String,
8282
8283 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8284}
8285
8286impl CreateSchemaRequest {
8287 /// Creates a new default instance.
8288 pub fn new() -> Self {
8289 std::default::Default::default()
8290 }
8291
8292 /// Sets the value of [parent][crate::model::CreateSchemaRequest::parent].
8293 ///
8294 /// # Example
8295 /// ```ignore,no_run
8296 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8297 /// let x = CreateSchemaRequest::new().set_parent("example");
8298 /// ```
8299 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8300 self.parent = v.into();
8301 self
8302 }
8303
8304 /// Sets the value of [schema][crate::model::CreateSchemaRequest::schema].
8305 ///
8306 /// # Example
8307 /// ```ignore,no_run
8308 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8309 /// use google_cloud_pubsub::model::Schema;
8310 /// let x = CreateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8311 /// ```
8312 pub fn set_schema<T>(mut self, v: T) -> Self
8313 where
8314 T: std::convert::Into<crate::model::Schema>,
8315 {
8316 self.schema = std::option::Option::Some(v.into());
8317 self
8318 }
8319
8320 /// Sets or clears the value of [schema][crate::model::CreateSchemaRequest::schema].
8321 ///
8322 /// # Example
8323 /// ```ignore,no_run
8324 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8325 /// use google_cloud_pubsub::model::Schema;
8326 /// let x = CreateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
8327 /// let x = CreateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
8328 /// ```
8329 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
8330 where
8331 T: std::convert::Into<crate::model::Schema>,
8332 {
8333 self.schema = v.map(|x| x.into());
8334 self
8335 }
8336
8337 /// Sets the value of [schema_id][crate::model::CreateSchemaRequest::schema_id].
8338 ///
8339 /// # Example
8340 /// ```ignore,no_run
8341 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8342 /// let x = CreateSchemaRequest::new().set_schema_id("example");
8343 /// ```
8344 pub fn set_schema_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8345 self.schema_id = v.into();
8346 self
8347 }
8348}
8349
8350impl wkt::message::Message for CreateSchemaRequest {
8351 fn typename() -> &'static str {
8352 "type.googleapis.com/google.pubsub.v1.CreateSchemaRequest"
8353 }
8354}
8355
8356/// Request for the GetSchema method.
8357#[derive(Clone, Default, PartialEq)]
8358#[non_exhaustive]
8359pub struct GetSchemaRequest {
8360 /// Required. The name of the schema to get.
8361 /// Format is `projects/{project}/schemas/{schema}`.
8362 pub name: std::string::String,
8363
8364 /// The set of fields to return in the response. If not set, returns a Schema
8365 /// with all fields filled out. Set to `BASIC` to omit the `definition`.
8366 pub view: crate::model::SchemaView,
8367
8368 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8369}
8370
8371impl GetSchemaRequest {
8372 /// Creates a new default instance.
8373 pub fn new() -> Self {
8374 std::default::Default::default()
8375 }
8376
8377 /// Sets the value of [name][crate::model::GetSchemaRequest::name].
8378 ///
8379 /// # Example
8380 /// ```ignore,no_run
8381 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8382 /// let x = GetSchemaRequest::new().set_name("example");
8383 /// ```
8384 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8385 self.name = v.into();
8386 self
8387 }
8388
8389 /// Sets the value of [view][crate::model::GetSchemaRequest::view].
8390 ///
8391 /// # Example
8392 /// ```ignore,no_run
8393 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8394 /// use google_cloud_pubsub::model::SchemaView;
8395 /// let x0 = GetSchemaRequest::new().set_view(SchemaView::Basic);
8396 /// let x1 = GetSchemaRequest::new().set_view(SchemaView::Full);
8397 /// ```
8398 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8399 self.view = v.into();
8400 self
8401 }
8402}
8403
8404impl wkt::message::Message for GetSchemaRequest {
8405 fn typename() -> &'static str {
8406 "type.googleapis.com/google.pubsub.v1.GetSchemaRequest"
8407 }
8408}
8409
8410/// Request for the `ListSchemas` method.
8411#[derive(Clone, Default, PartialEq)]
8412#[non_exhaustive]
8413pub struct ListSchemasRequest {
8414 /// Required. The name of the project in which to list schemas.
8415 /// Format is `projects/{project-id}`.
8416 pub parent: std::string::String,
8417
8418 /// The set of Schema fields to return in the response. If not set, returns
8419 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
8420 /// retrieve all fields.
8421 pub view: crate::model::SchemaView,
8422
8423 /// Maximum number of schemas to return.
8424 pub page_size: i32,
8425
8426 /// The value returned by the last `ListSchemasResponse`; indicates that
8427 /// this is a continuation of a prior `ListSchemas` call, and that the
8428 /// system should return the next page of data.
8429 pub page_token: std::string::String,
8430
8431 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8432}
8433
8434impl ListSchemasRequest {
8435 /// Creates a new default instance.
8436 pub fn new() -> Self {
8437 std::default::Default::default()
8438 }
8439
8440 /// Sets the value of [parent][crate::model::ListSchemasRequest::parent].
8441 ///
8442 /// # Example
8443 /// ```ignore,no_run
8444 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8445 /// let x = ListSchemasRequest::new().set_parent("example");
8446 /// ```
8447 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8448 self.parent = v.into();
8449 self
8450 }
8451
8452 /// Sets the value of [view][crate::model::ListSchemasRequest::view].
8453 ///
8454 /// # Example
8455 /// ```ignore,no_run
8456 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8457 /// use google_cloud_pubsub::model::SchemaView;
8458 /// let x0 = ListSchemasRequest::new().set_view(SchemaView::Basic);
8459 /// let x1 = ListSchemasRequest::new().set_view(SchemaView::Full);
8460 /// ```
8461 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8462 self.view = v.into();
8463 self
8464 }
8465
8466 /// Sets the value of [page_size][crate::model::ListSchemasRequest::page_size].
8467 ///
8468 /// # Example
8469 /// ```ignore,no_run
8470 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8471 /// let x = ListSchemasRequest::new().set_page_size(42);
8472 /// ```
8473 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8474 self.page_size = v.into();
8475 self
8476 }
8477
8478 /// Sets the value of [page_token][crate::model::ListSchemasRequest::page_token].
8479 ///
8480 /// # Example
8481 /// ```ignore,no_run
8482 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8483 /// let x = ListSchemasRequest::new().set_page_token("example");
8484 /// ```
8485 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8486 self.page_token = v.into();
8487 self
8488 }
8489}
8490
8491impl wkt::message::Message for ListSchemasRequest {
8492 fn typename() -> &'static str {
8493 "type.googleapis.com/google.pubsub.v1.ListSchemasRequest"
8494 }
8495}
8496
8497/// Response for the `ListSchemas` method.
8498#[derive(Clone, Default, PartialEq)]
8499#[non_exhaustive]
8500pub struct ListSchemasResponse {
8501 /// The resulting schemas.
8502 pub schemas: std::vec::Vec<crate::model::Schema>,
8503
8504 /// If not empty, indicates that there may be more schemas that match the
8505 /// request; this value should be passed in a new `ListSchemasRequest`.
8506 pub next_page_token: std::string::String,
8507
8508 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8509}
8510
8511impl ListSchemasResponse {
8512 /// Creates a new default instance.
8513 pub fn new() -> Self {
8514 std::default::Default::default()
8515 }
8516
8517 /// Sets the value of [schemas][crate::model::ListSchemasResponse::schemas].
8518 ///
8519 /// # Example
8520 /// ```ignore,no_run
8521 /// # use google_cloud_pubsub::model::ListSchemasResponse;
8522 /// use google_cloud_pubsub::model::Schema;
8523 /// let x = ListSchemasResponse::new()
8524 /// .set_schemas([
8525 /// Schema::default()/* use setters */,
8526 /// Schema::default()/* use (different) setters */,
8527 /// ]);
8528 /// ```
8529 pub fn set_schemas<T, V>(mut self, v: T) -> Self
8530 where
8531 T: std::iter::IntoIterator<Item = V>,
8532 V: std::convert::Into<crate::model::Schema>,
8533 {
8534 use std::iter::Iterator;
8535 self.schemas = v.into_iter().map(|i| i.into()).collect();
8536 self
8537 }
8538
8539 /// Sets the value of [next_page_token][crate::model::ListSchemasResponse::next_page_token].
8540 ///
8541 /// # Example
8542 /// ```ignore,no_run
8543 /// # use google_cloud_pubsub::model::ListSchemasResponse;
8544 /// let x = ListSchemasResponse::new().set_next_page_token("example");
8545 /// ```
8546 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8547 self.next_page_token = v.into();
8548 self
8549 }
8550}
8551
8552impl wkt::message::Message for ListSchemasResponse {
8553 fn typename() -> &'static str {
8554 "type.googleapis.com/google.pubsub.v1.ListSchemasResponse"
8555 }
8556}
8557
8558#[doc(hidden)]
8559impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemasResponse {
8560 type PageItem = crate::model::Schema;
8561
8562 fn items(self) -> std::vec::Vec<Self::PageItem> {
8563 self.schemas
8564 }
8565
8566 fn next_page_token(&self) -> std::string::String {
8567 use std::clone::Clone;
8568 self.next_page_token.clone()
8569 }
8570}
8571
8572/// Request for the `ListSchemaRevisions` method.
8573#[derive(Clone, Default, PartialEq)]
8574#[non_exhaustive]
8575pub struct ListSchemaRevisionsRequest {
8576 /// Required. The name of the schema to list revisions for.
8577 pub name: std::string::String,
8578
8579 /// The set of Schema fields to return in the response. If not set, returns
8580 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
8581 /// retrieve all fields.
8582 pub view: crate::model::SchemaView,
8583
8584 /// The maximum number of revisions to return per page.
8585 pub page_size: i32,
8586
8587 /// The page token, received from a previous ListSchemaRevisions call.
8588 /// Provide this to retrieve the subsequent page.
8589 pub page_token: std::string::String,
8590
8591 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8592}
8593
8594impl ListSchemaRevisionsRequest {
8595 /// Creates a new default instance.
8596 pub fn new() -> Self {
8597 std::default::Default::default()
8598 }
8599
8600 /// Sets the value of [name][crate::model::ListSchemaRevisionsRequest::name].
8601 ///
8602 /// # Example
8603 /// ```ignore,no_run
8604 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8605 /// let x = ListSchemaRevisionsRequest::new().set_name("example");
8606 /// ```
8607 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8608 self.name = v.into();
8609 self
8610 }
8611
8612 /// Sets the value of [view][crate::model::ListSchemaRevisionsRequest::view].
8613 ///
8614 /// # Example
8615 /// ```ignore,no_run
8616 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8617 /// use google_cloud_pubsub::model::SchemaView;
8618 /// let x0 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Basic);
8619 /// let x1 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Full);
8620 /// ```
8621 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8622 self.view = v.into();
8623 self
8624 }
8625
8626 /// Sets the value of [page_size][crate::model::ListSchemaRevisionsRequest::page_size].
8627 ///
8628 /// # Example
8629 /// ```ignore,no_run
8630 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8631 /// let x = ListSchemaRevisionsRequest::new().set_page_size(42);
8632 /// ```
8633 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8634 self.page_size = v.into();
8635 self
8636 }
8637
8638 /// Sets the value of [page_token][crate::model::ListSchemaRevisionsRequest::page_token].
8639 ///
8640 /// # Example
8641 /// ```ignore,no_run
8642 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8643 /// let x = ListSchemaRevisionsRequest::new().set_page_token("example");
8644 /// ```
8645 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8646 self.page_token = v.into();
8647 self
8648 }
8649}
8650
8651impl wkt::message::Message for ListSchemaRevisionsRequest {
8652 fn typename() -> &'static str {
8653 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsRequest"
8654 }
8655}
8656
8657/// Response for the `ListSchemaRevisions` method.
8658#[derive(Clone, Default, PartialEq)]
8659#[non_exhaustive]
8660pub struct ListSchemaRevisionsResponse {
8661 /// The revisions of the schema.
8662 pub schemas: std::vec::Vec<crate::model::Schema>,
8663
8664 /// A token that can be sent as `page_token` to retrieve the next page.
8665 /// If this field is empty, there are no subsequent pages.
8666 pub next_page_token: std::string::String,
8667
8668 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8669}
8670
8671impl ListSchemaRevisionsResponse {
8672 /// Creates a new default instance.
8673 pub fn new() -> Self {
8674 std::default::Default::default()
8675 }
8676
8677 /// Sets the value of [schemas][crate::model::ListSchemaRevisionsResponse::schemas].
8678 ///
8679 /// # Example
8680 /// ```ignore,no_run
8681 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
8682 /// use google_cloud_pubsub::model::Schema;
8683 /// let x = ListSchemaRevisionsResponse::new()
8684 /// .set_schemas([
8685 /// Schema::default()/* use setters */,
8686 /// Schema::default()/* use (different) setters */,
8687 /// ]);
8688 /// ```
8689 pub fn set_schemas<T, V>(mut self, v: T) -> Self
8690 where
8691 T: std::iter::IntoIterator<Item = V>,
8692 V: std::convert::Into<crate::model::Schema>,
8693 {
8694 use std::iter::Iterator;
8695 self.schemas = v.into_iter().map(|i| i.into()).collect();
8696 self
8697 }
8698
8699 /// Sets the value of [next_page_token][crate::model::ListSchemaRevisionsResponse::next_page_token].
8700 ///
8701 /// # Example
8702 /// ```ignore,no_run
8703 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
8704 /// let x = ListSchemaRevisionsResponse::new().set_next_page_token("example");
8705 /// ```
8706 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8707 self.next_page_token = v.into();
8708 self
8709 }
8710}
8711
8712impl wkt::message::Message for ListSchemaRevisionsResponse {
8713 fn typename() -> &'static str {
8714 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsResponse"
8715 }
8716}
8717
8718#[doc(hidden)]
8719impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemaRevisionsResponse {
8720 type PageItem = crate::model::Schema;
8721
8722 fn items(self) -> std::vec::Vec<Self::PageItem> {
8723 self.schemas
8724 }
8725
8726 fn next_page_token(&self) -> std::string::String {
8727 use std::clone::Clone;
8728 self.next_page_token.clone()
8729 }
8730}
8731
8732/// Request for CommitSchema method.
8733#[derive(Clone, Default, PartialEq)]
8734#[non_exhaustive]
8735pub struct CommitSchemaRequest {
8736 /// Required. The name of the schema we are revising.
8737 /// Format is `projects/{project}/schemas/{schema}`.
8738 pub name: std::string::String,
8739
8740 /// Required. The schema revision to commit.
8741 pub schema: std::option::Option<crate::model::Schema>,
8742
8743 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8744}
8745
8746impl CommitSchemaRequest {
8747 /// Creates a new default instance.
8748 pub fn new() -> Self {
8749 std::default::Default::default()
8750 }
8751
8752 /// Sets the value of [name][crate::model::CommitSchemaRequest::name].
8753 ///
8754 /// # Example
8755 /// ```ignore,no_run
8756 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8757 /// let x = CommitSchemaRequest::new().set_name("example");
8758 /// ```
8759 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8760 self.name = v.into();
8761 self
8762 }
8763
8764 /// Sets the value of [schema][crate::model::CommitSchemaRequest::schema].
8765 ///
8766 /// # Example
8767 /// ```ignore,no_run
8768 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8769 /// use google_cloud_pubsub::model::Schema;
8770 /// let x = CommitSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8771 /// ```
8772 pub fn set_schema<T>(mut self, v: T) -> Self
8773 where
8774 T: std::convert::Into<crate::model::Schema>,
8775 {
8776 self.schema = std::option::Option::Some(v.into());
8777 self
8778 }
8779
8780 /// Sets or clears the value of [schema][crate::model::CommitSchemaRequest::schema].
8781 ///
8782 /// # Example
8783 /// ```ignore,no_run
8784 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8785 /// use google_cloud_pubsub::model::Schema;
8786 /// let x = CommitSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
8787 /// let x = CommitSchemaRequest::new().set_or_clear_schema(None::<Schema>);
8788 /// ```
8789 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
8790 where
8791 T: std::convert::Into<crate::model::Schema>,
8792 {
8793 self.schema = v.map(|x| x.into());
8794 self
8795 }
8796}
8797
8798impl wkt::message::Message for CommitSchemaRequest {
8799 fn typename() -> &'static str {
8800 "type.googleapis.com/google.pubsub.v1.CommitSchemaRequest"
8801 }
8802}
8803
8804/// Request for the `RollbackSchema` method.
8805#[derive(Clone, Default, PartialEq)]
8806#[non_exhaustive]
8807pub struct RollbackSchemaRequest {
8808 /// Required. The schema being rolled back with revision id.
8809 pub name: std::string::String,
8810
8811 /// Required. The revision ID to roll back to.
8812 /// It must be a revision of the same schema.
8813 ///
8814 /// Example: c7cfa2a8
8815 pub revision_id: std::string::String,
8816
8817 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8818}
8819
8820impl RollbackSchemaRequest {
8821 /// Creates a new default instance.
8822 pub fn new() -> Self {
8823 std::default::Default::default()
8824 }
8825
8826 /// Sets the value of [name][crate::model::RollbackSchemaRequest::name].
8827 ///
8828 /// # Example
8829 /// ```ignore,no_run
8830 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
8831 /// let x = RollbackSchemaRequest::new().set_name("example");
8832 /// ```
8833 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8834 self.name = v.into();
8835 self
8836 }
8837
8838 /// Sets the value of [revision_id][crate::model::RollbackSchemaRequest::revision_id].
8839 ///
8840 /// # Example
8841 /// ```ignore,no_run
8842 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
8843 /// let x = RollbackSchemaRequest::new().set_revision_id("example");
8844 /// ```
8845 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8846 self.revision_id = v.into();
8847 self
8848 }
8849}
8850
8851impl wkt::message::Message for RollbackSchemaRequest {
8852 fn typename() -> &'static str {
8853 "type.googleapis.com/google.pubsub.v1.RollbackSchemaRequest"
8854 }
8855}
8856
8857/// Request for the `DeleteSchemaRevision` method.
8858#[derive(Clone, Default, PartialEq)]
8859#[non_exhaustive]
8860pub struct DeleteSchemaRevisionRequest {
8861 /// Required. The name of the schema revision to be deleted, with a revision ID
8862 /// explicitly included.
8863 ///
8864 /// Example: `projects/123/schemas/my-schema@c7cfa2a8`
8865 pub name: std::string::String,
8866
8867 /// Optional. This field is deprecated and should not be used for specifying
8868 /// the revision ID. The revision ID should be specified via the `name`
8869 /// parameter.
8870 #[deprecated]
8871 pub revision_id: std::string::String,
8872
8873 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8874}
8875
8876impl DeleteSchemaRevisionRequest {
8877 /// Creates a new default instance.
8878 pub fn new() -> Self {
8879 std::default::Default::default()
8880 }
8881
8882 /// Sets the value of [name][crate::model::DeleteSchemaRevisionRequest::name].
8883 ///
8884 /// # Example
8885 /// ```ignore,no_run
8886 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
8887 /// let x = DeleteSchemaRevisionRequest::new().set_name("example");
8888 /// ```
8889 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8890 self.name = v.into();
8891 self
8892 }
8893
8894 /// Sets the value of [revision_id][crate::model::DeleteSchemaRevisionRequest::revision_id].
8895 ///
8896 /// # Example
8897 /// ```ignore,no_run
8898 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
8899 /// let x = DeleteSchemaRevisionRequest::new().set_revision_id("example");
8900 /// ```
8901 #[deprecated]
8902 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8903 self.revision_id = v.into();
8904 self
8905 }
8906}
8907
8908impl wkt::message::Message for DeleteSchemaRevisionRequest {
8909 fn typename() -> &'static str {
8910 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRevisionRequest"
8911 }
8912}
8913
8914/// Request for the `DeleteSchema` method.
8915#[derive(Clone, Default, PartialEq)]
8916#[non_exhaustive]
8917pub struct DeleteSchemaRequest {
8918 /// Required. Name of the schema to delete.
8919 /// Format is `projects/{project}/schemas/{schema}`.
8920 pub name: std::string::String,
8921
8922 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8923}
8924
8925impl DeleteSchemaRequest {
8926 /// Creates a new default instance.
8927 pub fn new() -> Self {
8928 std::default::Default::default()
8929 }
8930
8931 /// Sets the value of [name][crate::model::DeleteSchemaRequest::name].
8932 ///
8933 /// # Example
8934 /// ```ignore,no_run
8935 /// # use google_cloud_pubsub::model::DeleteSchemaRequest;
8936 /// let x = DeleteSchemaRequest::new().set_name("example");
8937 /// ```
8938 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8939 self.name = v.into();
8940 self
8941 }
8942}
8943
8944impl wkt::message::Message for DeleteSchemaRequest {
8945 fn typename() -> &'static str {
8946 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRequest"
8947 }
8948}
8949
8950/// Request for the `ValidateSchema` method.
8951#[derive(Clone, Default, PartialEq)]
8952#[non_exhaustive]
8953pub struct ValidateSchemaRequest {
8954 /// Required. The name of the project in which to validate schemas.
8955 /// Format is `projects/{project-id}`.
8956 pub parent: std::string::String,
8957
8958 /// Required. The schema object to validate.
8959 pub schema: std::option::Option<crate::model::Schema>,
8960
8961 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8962}
8963
8964impl ValidateSchemaRequest {
8965 /// Creates a new default instance.
8966 pub fn new() -> Self {
8967 std::default::Default::default()
8968 }
8969
8970 /// Sets the value of [parent][crate::model::ValidateSchemaRequest::parent].
8971 ///
8972 /// # Example
8973 /// ```ignore,no_run
8974 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
8975 /// let x = ValidateSchemaRequest::new().set_parent("example");
8976 /// ```
8977 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8978 self.parent = v.into();
8979 self
8980 }
8981
8982 /// Sets the value of [schema][crate::model::ValidateSchemaRequest::schema].
8983 ///
8984 /// # Example
8985 /// ```ignore,no_run
8986 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
8987 /// use google_cloud_pubsub::model::Schema;
8988 /// let x = ValidateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8989 /// ```
8990 pub fn set_schema<T>(mut self, v: T) -> Self
8991 where
8992 T: std::convert::Into<crate::model::Schema>,
8993 {
8994 self.schema = std::option::Option::Some(v.into());
8995 self
8996 }
8997
8998 /// Sets or clears the value of [schema][crate::model::ValidateSchemaRequest::schema].
8999 ///
9000 /// # Example
9001 /// ```ignore,no_run
9002 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9003 /// use google_cloud_pubsub::model::Schema;
9004 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
9005 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
9006 /// ```
9007 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
9008 where
9009 T: std::convert::Into<crate::model::Schema>,
9010 {
9011 self.schema = v.map(|x| x.into());
9012 self
9013 }
9014}
9015
9016impl wkt::message::Message for ValidateSchemaRequest {
9017 fn typename() -> &'static str {
9018 "type.googleapis.com/google.pubsub.v1.ValidateSchemaRequest"
9019 }
9020}
9021
9022/// Response for the `ValidateSchema` method.
9023/// Empty for now.
9024#[derive(Clone, Default, PartialEq)]
9025#[non_exhaustive]
9026pub struct ValidateSchemaResponse {
9027 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9028}
9029
9030impl ValidateSchemaResponse {
9031 /// Creates a new default instance.
9032 pub fn new() -> Self {
9033 std::default::Default::default()
9034 }
9035}
9036
9037impl wkt::message::Message for ValidateSchemaResponse {
9038 fn typename() -> &'static str {
9039 "type.googleapis.com/google.pubsub.v1.ValidateSchemaResponse"
9040 }
9041}
9042
9043/// Request for the `ValidateMessage` method.
9044#[derive(Clone, Default, PartialEq)]
9045#[non_exhaustive]
9046pub struct ValidateMessageRequest {
9047 /// Required. The name of the project in which to validate schemas.
9048 /// Format is `projects/{project-id}`.
9049 pub parent: std::string::String,
9050
9051 /// Message to validate against the provided `schema_spec`.
9052 pub message: ::bytes::Bytes,
9053
9054 /// The encoding expected for messages
9055 pub encoding: crate::model::Encoding,
9056
9057 #[allow(missing_docs)]
9058 pub schema_spec: std::option::Option<crate::model::validate_message_request::SchemaSpec>,
9059
9060 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9061}
9062
9063impl ValidateMessageRequest {
9064 /// Creates a new default instance.
9065 pub fn new() -> Self {
9066 std::default::Default::default()
9067 }
9068
9069 /// Sets the value of [parent][crate::model::ValidateMessageRequest::parent].
9070 ///
9071 /// # Example
9072 /// ```ignore,no_run
9073 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9074 /// let x = ValidateMessageRequest::new().set_parent("example");
9075 /// ```
9076 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9077 self.parent = v.into();
9078 self
9079 }
9080
9081 /// Sets the value of [message][crate::model::ValidateMessageRequest::message].
9082 ///
9083 /// # Example
9084 /// ```ignore,no_run
9085 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9086 /// let x = ValidateMessageRequest::new().set_message(bytes::Bytes::from_static(b"example"));
9087 /// ```
9088 pub fn set_message<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9089 self.message = v.into();
9090 self
9091 }
9092
9093 /// Sets the value of [encoding][crate::model::ValidateMessageRequest::encoding].
9094 ///
9095 /// # Example
9096 /// ```ignore,no_run
9097 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9098 /// use google_cloud_pubsub::model::Encoding;
9099 /// let x0 = ValidateMessageRequest::new().set_encoding(Encoding::Json);
9100 /// let x1 = ValidateMessageRequest::new().set_encoding(Encoding::Binary);
9101 /// ```
9102 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
9103 self.encoding = v.into();
9104 self
9105 }
9106
9107 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec].
9108 ///
9109 /// Note that all the setters affecting `schema_spec` are mutually
9110 /// exclusive.
9111 ///
9112 /// # Example
9113 /// ```ignore,no_run
9114 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9115 /// use google_cloud_pubsub::model::validate_message_request::SchemaSpec;
9116 /// let x = ValidateMessageRequest::new().set_schema_spec(Some(SchemaSpec::Name("example".to_string())));
9117 /// ```
9118 pub fn set_schema_spec<
9119 T: std::convert::Into<std::option::Option<crate::model::validate_message_request::SchemaSpec>>,
9120 >(
9121 mut self,
9122 v: T,
9123 ) -> Self {
9124 self.schema_spec = v.into();
9125 self
9126 }
9127
9128 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9129 /// if it holds a `Name`, `None` if the field is not set or
9130 /// holds a different branch.
9131 pub fn name(&self) -> std::option::Option<&std::string::String> {
9132 #[allow(unreachable_patterns)]
9133 self.schema_spec.as_ref().and_then(|v| match v {
9134 crate::model::validate_message_request::SchemaSpec::Name(v) => {
9135 std::option::Option::Some(v)
9136 }
9137 _ => std::option::Option::None,
9138 })
9139 }
9140
9141 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9142 /// to hold a `Name`.
9143 ///
9144 /// Note that all the setters affecting `schema_spec` are
9145 /// mutually exclusive.
9146 ///
9147 /// # Example
9148 /// ```ignore,no_run
9149 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9150 /// let x = ValidateMessageRequest::new().set_name("example");
9151 /// assert!(x.name().is_some());
9152 /// assert!(x.schema().is_none());
9153 /// ```
9154 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9155 self.schema_spec = std::option::Option::Some(
9156 crate::model::validate_message_request::SchemaSpec::Name(v.into()),
9157 );
9158 self
9159 }
9160
9161 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9162 /// if it holds a `Schema`, `None` if the field is not set or
9163 /// holds a different branch.
9164 pub fn schema(&self) -> std::option::Option<&std::boxed::Box<crate::model::Schema>> {
9165 #[allow(unreachable_patterns)]
9166 self.schema_spec.as_ref().and_then(|v| match v {
9167 crate::model::validate_message_request::SchemaSpec::Schema(v) => {
9168 std::option::Option::Some(v)
9169 }
9170 _ => std::option::Option::None,
9171 })
9172 }
9173
9174 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9175 /// to hold a `Schema`.
9176 ///
9177 /// Note that all the setters affecting `schema_spec` are
9178 /// mutually exclusive.
9179 ///
9180 /// # Example
9181 /// ```ignore,no_run
9182 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9183 /// use google_cloud_pubsub::model::Schema;
9184 /// let x = ValidateMessageRequest::new().set_schema(Schema::default()/* use setters */);
9185 /// assert!(x.schema().is_some());
9186 /// assert!(x.name().is_none());
9187 /// ```
9188 pub fn set_schema<T: std::convert::Into<std::boxed::Box<crate::model::Schema>>>(
9189 mut self,
9190 v: T,
9191 ) -> Self {
9192 self.schema_spec = std::option::Option::Some(
9193 crate::model::validate_message_request::SchemaSpec::Schema(v.into()),
9194 );
9195 self
9196 }
9197}
9198
9199impl wkt::message::Message for ValidateMessageRequest {
9200 fn typename() -> &'static str {
9201 "type.googleapis.com/google.pubsub.v1.ValidateMessageRequest"
9202 }
9203}
9204
9205/// Defines additional types related to [ValidateMessageRequest].
9206pub mod validate_message_request {
9207 #[allow(unused_imports)]
9208 use super::*;
9209
9210 #[allow(missing_docs)]
9211 #[derive(Clone, Debug, PartialEq)]
9212 #[non_exhaustive]
9213 pub enum SchemaSpec {
9214 /// Name of the schema against which to validate.
9215 ///
9216 /// Format is `projects/{project}/schemas/{schema}`.
9217 Name(std::string::String),
9218 /// Ad-hoc schema against which to validate
9219 Schema(std::boxed::Box<crate::model::Schema>),
9220 }
9221}
9222
9223/// Response for the `ValidateMessage` method.
9224/// Empty for now.
9225#[derive(Clone, Default, PartialEq)]
9226#[non_exhaustive]
9227pub struct ValidateMessageResponse {
9228 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9229}
9230
9231impl ValidateMessageResponse {
9232 /// Creates a new default instance.
9233 pub fn new() -> Self {
9234 std::default::Default::default()
9235 }
9236}
9237
9238impl wkt::message::Message for ValidateMessageResponse {
9239 fn typename() -> &'static str {
9240 "type.googleapis.com/google.pubsub.v1.ValidateMessageResponse"
9241 }
9242}
9243
9244/// View of Schema object fields to be returned by GetSchema and ListSchemas.
9245///
9246/// # Working with unknown values
9247///
9248/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9249/// additional enum variants at any time. Adding new variants is not considered
9250/// a breaking change. Applications should write their code in anticipation of:
9251///
9252/// - New values appearing in future releases of the client library, **and**
9253/// - New values received dynamically, without application changes.
9254///
9255/// Please consult the [Working with enums] section in the user guide for some
9256/// guidelines.
9257///
9258/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9259#[derive(Clone, Debug, PartialEq)]
9260#[non_exhaustive]
9261pub enum SchemaView {
9262 /// The default / unset value.
9263 /// The API will default to the BASIC view.
9264 Unspecified,
9265 /// Include the name and type of the schema, but not the definition.
9266 Basic,
9267 /// Include all Schema object fields.
9268 Full,
9269 /// If set, the enum was initialized with an unknown value.
9270 ///
9271 /// Applications can examine the value using [SchemaView::value] or
9272 /// [SchemaView::name].
9273 UnknownValue(schema_view::UnknownValue),
9274}
9275
9276#[doc(hidden)]
9277pub mod schema_view {
9278 #[allow(unused_imports)]
9279 use super::*;
9280 #[derive(Clone, Debug, PartialEq)]
9281 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9282}
9283
9284impl SchemaView {
9285 /// Gets the enum value.
9286 ///
9287 /// Returns `None` if the enum contains an unknown value deserialized from
9288 /// the string representation of enums.
9289 pub fn value(&self) -> std::option::Option<i32> {
9290 match self {
9291 Self::Unspecified => std::option::Option::Some(0),
9292 Self::Basic => std::option::Option::Some(1),
9293 Self::Full => std::option::Option::Some(2),
9294 Self::UnknownValue(u) => u.0.value(),
9295 }
9296 }
9297
9298 /// Gets the enum value as a string.
9299 ///
9300 /// Returns `None` if the enum contains an unknown value deserialized from
9301 /// the integer representation of enums.
9302 pub fn name(&self) -> std::option::Option<&str> {
9303 match self {
9304 Self::Unspecified => std::option::Option::Some("SCHEMA_VIEW_UNSPECIFIED"),
9305 Self::Basic => std::option::Option::Some("BASIC"),
9306 Self::Full => std::option::Option::Some("FULL"),
9307 Self::UnknownValue(u) => u.0.name(),
9308 }
9309 }
9310}
9311
9312impl std::default::Default for SchemaView {
9313 fn default() -> Self {
9314 use std::convert::From;
9315 Self::from(0)
9316 }
9317}
9318
9319impl std::fmt::Display for SchemaView {
9320 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
9321 wkt::internal::display_enum(f, self.name(), self.value())
9322 }
9323}
9324
9325impl std::convert::From<i32> for SchemaView {
9326 fn from(value: i32) -> Self {
9327 match value {
9328 0 => Self::Unspecified,
9329 1 => Self::Basic,
9330 2 => Self::Full,
9331 _ => Self::UnknownValue(schema_view::UnknownValue(
9332 wkt::internal::UnknownEnumValue::Integer(value),
9333 )),
9334 }
9335 }
9336}
9337
9338impl std::convert::From<&str> for SchemaView {
9339 fn from(value: &str) -> Self {
9340 use std::string::ToString;
9341 match value {
9342 "SCHEMA_VIEW_UNSPECIFIED" => Self::Unspecified,
9343 "BASIC" => Self::Basic,
9344 "FULL" => Self::Full,
9345 _ => Self::UnknownValue(schema_view::UnknownValue(
9346 wkt::internal::UnknownEnumValue::String(value.to_string()),
9347 )),
9348 }
9349 }
9350}
9351
9352impl serde::ser::Serialize for SchemaView {
9353 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9354 where
9355 S: serde::Serializer,
9356 {
9357 match self {
9358 Self::Unspecified => serializer.serialize_i32(0),
9359 Self::Basic => serializer.serialize_i32(1),
9360 Self::Full => serializer.serialize_i32(2),
9361 Self::UnknownValue(u) => u.0.serialize(serializer),
9362 }
9363 }
9364}
9365
9366impl<'de> serde::de::Deserialize<'de> for SchemaView {
9367 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9368 where
9369 D: serde::Deserializer<'de>,
9370 {
9371 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SchemaView>::new(
9372 ".google.pubsub.v1.SchemaView",
9373 ))
9374 }
9375}
9376
9377/// Possible encoding types for messages.
9378///
9379/// # Working with unknown values
9380///
9381/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9382/// additional enum variants at any time. Adding new variants is not considered
9383/// a breaking change. Applications should write their code in anticipation of:
9384///
9385/// - New values appearing in future releases of the client library, **and**
9386/// - New values received dynamically, without application changes.
9387///
9388/// Please consult the [Working with enums] section in the user guide for some
9389/// guidelines.
9390///
9391/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9392#[derive(Clone, Debug, PartialEq)]
9393#[non_exhaustive]
9394pub enum Encoding {
9395 /// Unspecified
9396 Unspecified,
9397 /// JSON encoding
9398 Json,
9399 /// Binary encoding, as defined by the schema type. For some schema types,
9400 /// binary encoding may not be available.
9401 Binary,
9402 /// If set, the enum was initialized with an unknown value.
9403 ///
9404 /// Applications can examine the value using [Encoding::value] or
9405 /// [Encoding::name].
9406 UnknownValue(encoding::UnknownValue),
9407}
9408
9409#[doc(hidden)]
9410pub mod encoding {
9411 #[allow(unused_imports)]
9412 use super::*;
9413 #[derive(Clone, Debug, PartialEq)]
9414 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9415}
9416
9417impl Encoding {
9418 /// Gets the enum value.
9419 ///
9420 /// Returns `None` if the enum contains an unknown value deserialized from
9421 /// the string representation of enums.
9422 pub fn value(&self) -> std::option::Option<i32> {
9423 match self {
9424 Self::Unspecified => std::option::Option::Some(0),
9425 Self::Json => std::option::Option::Some(1),
9426 Self::Binary => std::option::Option::Some(2),
9427 Self::UnknownValue(u) => u.0.value(),
9428 }
9429 }
9430
9431 /// Gets the enum value as a string.
9432 ///
9433 /// Returns `None` if the enum contains an unknown value deserialized from
9434 /// the integer representation of enums.
9435 pub fn name(&self) -> std::option::Option<&str> {
9436 match self {
9437 Self::Unspecified => std::option::Option::Some("ENCODING_UNSPECIFIED"),
9438 Self::Json => std::option::Option::Some("JSON"),
9439 Self::Binary => std::option::Option::Some("BINARY"),
9440 Self::UnknownValue(u) => u.0.name(),
9441 }
9442 }
9443}
9444
9445impl std::default::Default for Encoding {
9446 fn default() -> Self {
9447 use std::convert::From;
9448 Self::from(0)
9449 }
9450}
9451
9452impl std::fmt::Display for Encoding {
9453 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
9454 wkt::internal::display_enum(f, self.name(), self.value())
9455 }
9456}
9457
9458impl std::convert::From<i32> for Encoding {
9459 fn from(value: i32) -> Self {
9460 match value {
9461 0 => Self::Unspecified,
9462 1 => Self::Json,
9463 2 => Self::Binary,
9464 _ => Self::UnknownValue(encoding::UnknownValue(
9465 wkt::internal::UnknownEnumValue::Integer(value),
9466 )),
9467 }
9468 }
9469}
9470
9471impl std::convert::From<&str> for Encoding {
9472 fn from(value: &str) -> Self {
9473 use std::string::ToString;
9474 match value {
9475 "ENCODING_UNSPECIFIED" => Self::Unspecified,
9476 "JSON" => Self::Json,
9477 "BINARY" => Self::Binary,
9478 _ => Self::UnknownValue(encoding::UnknownValue(
9479 wkt::internal::UnknownEnumValue::String(value.to_string()),
9480 )),
9481 }
9482 }
9483}
9484
9485impl serde::ser::Serialize for Encoding {
9486 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9487 where
9488 S: serde::Serializer,
9489 {
9490 match self {
9491 Self::Unspecified => serializer.serialize_i32(0),
9492 Self::Json => serializer.serialize_i32(1),
9493 Self::Binary => serializer.serialize_i32(2),
9494 Self::UnknownValue(u) => u.0.serialize(serializer),
9495 }
9496 }
9497}
9498
9499impl<'de> serde::de::Deserialize<'de> for Encoding {
9500 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9501 where
9502 D: serde::Deserializer<'de>,
9503 {
9504 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Encoding>::new(
9505 ".google.pubsub.v1.Encoding",
9506 ))
9507 }
9508}