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