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::bare_urls)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![allow(rustdoc::invalid_html_tags)]
20#![allow(rustdoc::redundant_explicit_links)]
21
22mod debug;
23mod deserialize;
24mod serialize;
25
26/// A policy constraining the storage of messages published to the topic.
27#[derive(Clone, Default, PartialEq)]
28#[non_exhaustive]
29pub struct MessageStoragePolicy {
30 /// Optional. A list of IDs of Google Cloud regions where messages that are
31 /// published to the topic may be persisted in storage. Messages published by
32 /// publishers running in non-allowed Google Cloud regions (or running outside
33 /// of Google Cloud altogether) are routed for storage in one of the allowed
34 /// regions. An empty list means that no regions are allowed, and is not a
35 /// valid configuration.
36 pub allowed_persistence_regions: std::vec::Vec<std::string::String>,
37
38 /// Optional. If true, `allowed_persistence_regions` is also used to enforce
39 /// in-transit guarantees for messages. That is, Pub/Sub will fail
40 /// Publish operations on this topic and subscribe operations
41 /// on any subscription attached to this topic in any region that is
42 /// not in `allowed_persistence_regions`.
43 pub enforce_in_transit: bool,
44
45 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
46}
47
48impl MessageStoragePolicy {
49 /// Creates a new default instance.
50 pub fn new() -> Self {
51 std::default::Default::default()
52 }
53
54 /// Sets the value of [allowed_persistence_regions][crate::model::MessageStoragePolicy::allowed_persistence_regions].
55 ///
56 /// # Example
57 /// ```ignore,no_run
58 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
59 /// let x = MessageStoragePolicy::new().set_allowed_persistence_regions(["a", "b", "c"]);
60 /// ```
61 pub fn set_allowed_persistence_regions<T, V>(mut self, v: T) -> Self
62 where
63 T: std::iter::IntoIterator<Item = V>,
64 V: std::convert::Into<std::string::String>,
65 {
66 use std::iter::Iterator;
67 self.allowed_persistence_regions = v.into_iter().map(|i| i.into()).collect();
68 self
69 }
70
71 /// Sets the value of [enforce_in_transit][crate::model::MessageStoragePolicy::enforce_in_transit].
72 ///
73 /// # Example
74 /// ```ignore,no_run
75 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
76 /// let x = MessageStoragePolicy::new().set_enforce_in_transit(true);
77 /// ```
78 pub fn set_enforce_in_transit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
79 self.enforce_in_transit = v.into();
80 self
81 }
82}
83
84impl wkt::message::Message for MessageStoragePolicy {
85 fn typename() -> &'static str {
86 "type.googleapis.com/google.pubsub.v1.MessageStoragePolicy"
87 }
88}
89
90/// Settings for validating messages published against a schema.
91#[derive(Clone, Default, PartialEq)]
92#[non_exhaustive]
93pub struct SchemaSettings {
94 /// Required. The name of the schema that messages published should be
95 /// validated against. Format is `projects/{project}/schemas/{schema}`. The
96 /// value of this field will be `_deleted-schema_` if the schema has been
97 /// deleted.
98 pub schema: std::string::String,
99
100 /// Optional. The encoding of messages validated against `schema`.
101 pub encoding: crate::model::Encoding,
102
103 /// Optional. The minimum (inclusive) revision allowed for validating messages.
104 /// If empty or not present, allow any revision to be validated against
105 /// last_revision or any revision created before.
106 pub first_revision_id: std::string::String,
107
108 /// Optional. The maximum (inclusive) revision allowed for validating messages.
109 /// If empty or not present, allow any revision to be validated against
110 /// first_revision or any revision created after.
111 pub last_revision_id: std::string::String,
112
113 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
114}
115
116impl SchemaSettings {
117 /// Creates a new default instance.
118 pub fn new() -> Self {
119 std::default::Default::default()
120 }
121
122 /// Sets the value of [schema][crate::model::SchemaSettings::schema].
123 ///
124 /// # Example
125 /// ```ignore,no_run
126 /// # use google_cloud_pubsub::model::SchemaSettings;
127 /// # let project_id = "project_id";
128 /// # let schema_id = "schema_id";
129 /// let x = SchemaSettings::new().set_schema(format!("projects/{project_id}/schemas/{schema_id}"));
130 /// ```
131 pub fn set_schema<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
132 self.schema = v.into();
133 self
134 }
135
136 /// Sets the value of [encoding][crate::model::SchemaSettings::encoding].
137 ///
138 /// # Example
139 /// ```ignore,no_run
140 /// # use google_cloud_pubsub::model::SchemaSettings;
141 /// use google_cloud_pubsub::model::Encoding;
142 /// let x0 = SchemaSettings::new().set_encoding(Encoding::Json);
143 /// let x1 = SchemaSettings::new().set_encoding(Encoding::Binary);
144 /// ```
145 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
146 self.encoding = v.into();
147 self
148 }
149
150 /// Sets the value of [first_revision_id][crate::model::SchemaSettings::first_revision_id].
151 ///
152 /// # Example
153 /// ```ignore,no_run
154 /// # use google_cloud_pubsub::model::SchemaSettings;
155 /// let x = SchemaSettings::new().set_first_revision_id("example");
156 /// ```
157 pub fn set_first_revision_id<T: std::convert::Into<std::string::String>>(
158 mut self,
159 v: T,
160 ) -> Self {
161 self.first_revision_id = v.into();
162 self
163 }
164
165 /// Sets the value of [last_revision_id][crate::model::SchemaSettings::last_revision_id].
166 ///
167 /// # Example
168 /// ```ignore,no_run
169 /// # use google_cloud_pubsub::model::SchemaSettings;
170 /// let x = SchemaSettings::new().set_last_revision_id("example");
171 /// ```
172 pub fn set_last_revision_id<T: std::convert::Into<std::string::String>>(
173 mut self,
174 v: T,
175 ) -> Self {
176 self.last_revision_id = v.into();
177 self
178 }
179}
180
181impl wkt::message::Message for SchemaSettings {
182 fn typename() -> &'static str {
183 "type.googleapis.com/google.pubsub.v1.SchemaSettings"
184 }
185}
186
187/// Settings for an ingestion data source on a topic.
188#[derive(Clone, Default, PartialEq)]
189#[non_exhaustive]
190pub struct IngestionDataSourceSettings {
191 /// Optional. Platform Logs settings. If unset, no Platform Logs will be
192 /// generated.
193 pub platform_logs_settings: std::option::Option<crate::model::PlatformLogsSettings>,
194
195 /// Only one source type can have settings set.
196 pub source: std::option::Option<crate::model::ingestion_data_source_settings::Source>,
197
198 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
199}
200
201impl IngestionDataSourceSettings {
202 /// Creates a new default instance.
203 pub fn new() -> Self {
204 std::default::Default::default()
205 }
206
207 /// Sets the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
208 ///
209 /// # Example
210 /// ```ignore,no_run
211 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
212 /// use google_cloud_pubsub::model::PlatformLogsSettings;
213 /// let x = IngestionDataSourceSettings::new().set_platform_logs_settings(PlatformLogsSettings::default()/* use setters */);
214 /// ```
215 pub fn set_platform_logs_settings<T>(mut self, v: T) -> Self
216 where
217 T: std::convert::Into<crate::model::PlatformLogsSettings>,
218 {
219 self.platform_logs_settings = std::option::Option::Some(v.into());
220 self
221 }
222
223 /// Sets or clears the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
224 ///
225 /// # Example
226 /// ```ignore,no_run
227 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
228 /// use google_cloud_pubsub::model::PlatformLogsSettings;
229 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(Some(PlatformLogsSettings::default()/* use setters */));
230 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(None::<PlatformLogsSettings>);
231 /// ```
232 pub fn set_or_clear_platform_logs_settings<T>(mut self, v: std::option::Option<T>) -> Self
233 where
234 T: std::convert::Into<crate::model::PlatformLogsSettings>,
235 {
236 self.platform_logs_settings = v.map(|x| x.into());
237 self
238 }
239
240 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source].
241 ///
242 /// Note that all the setters affecting `source` are mutually
243 /// exclusive.
244 ///
245 /// # Example
246 /// ```ignore,no_run
247 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
248 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
249 /// let x = IngestionDataSourceSettings::new().set_source(Some(
250 /// google_cloud_pubsub::model::ingestion_data_source_settings::Source::AwsKinesis(AwsKinesis::default().into())));
251 /// ```
252 pub fn set_source<
253 T: std::convert::Into<
254 std::option::Option<crate::model::ingestion_data_source_settings::Source>,
255 >,
256 >(
257 mut self,
258 v: T,
259 ) -> Self {
260 self.source = v.into();
261 self
262 }
263
264 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
265 /// if it holds a `AwsKinesis`, `None` if the field is not set or
266 /// holds a different branch.
267 pub fn aws_kinesis(
268 &self,
269 ) -> std::option::Option<
270 &std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
271 > {
272 #[allow(unreachable_patterns)]
273 self.source.as_ref().and_then(|v| match v {
274 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v) => {
275 std::option::Option::Some(v)
276 }
277 _ => std::option::Option::None,
278 })
279 }
280
281 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
282 /// to hold a `AwsKinesis`.
283 ///
284 /// Note that all the setters affecting `source` are
285 /// mutually exclusive.
286 ///
287 /// # Example
288 /// ```ignore,no_run
289 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
290 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
291 /// let x = IngestionDataSourceSettings::new().set_aws_kinesis(AwsKinesis::default()/* use setters */);
292 /// assert!(x.aws_kinesis().is_some());
293 /// assert!(x.cloud_storage().is_none());
294 /// assert!(x.azure_event_hubs().is_none());
295 /// assert!(x.aws_msk().is_none());
296 /// assert!(x.confluent_cloud().is_none());
297 /// ```
298 pub fn set_aws_kinesis<
299 T: std::convert::Into<
300 std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
301 >,
302 >(
303 mut self,
304 v: T,
305 ) -> Self {
306 self.source = std::option::Option::Some(
307 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v.into()),
308 );
309 self
310 }
311
312 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
313 /// if it holds a `CloudStorage`, `None` if the field is not set or
314 /// holds a different branch.
315 pub fn cloud_storage(
316 &self,
317 ) -> std::option::Option<
318 &std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
319 > {
320 #[allow(unreachable_patterns)]
321 self.source.as_ref().and_then(|v| match v {
322 crate::model::ingestion_data_source_settings::Source::CloudStorage(v) => {
323 std::option::Option::Some(v)
324 }
325 _ => std::option::Option::None,
326 })
327 }
328
329 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
330 /// to hold a `CloudStorage`.
331 ///
332 /// Note that all the setters affecting `source` are
333 /// mutually exclusive.
334 ///
335 /// # Example
336 /// ```ignore,no_run
337 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
338 /// use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
339 /// let x = IngestionDataSourceSettings::new().set_cloud_storage(CloudStorage::default()/* use setters */);
340 /// assert!(x.cloud_storage().is_some());
341 /// assert!(x.aws_kinesis().is_none());
342 /// assert!(x.azure_event_hubs().is_none());
343 /// assert!(x.aws_msk().is_none());
344 /// assert!(x.confluent_cloud().is_none());
345 /// ```
346 pub fn set_cloud_storage<
347 T: std::convert::Into<
348 std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
349 >,
350 >(
351 mut self,
352 v: T,
353 ) -> Self {
354 self.source = std::option::Option::Some(
355 crate::model::ingestion_data_source_settings::Source::CloudStorage(v.into()),
356 );
357 self
358 }
359
360 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
361 /// if it holds a `AzureEventHubs`, `None` if the field is not set or
362 /// holds a different branch.
363 pub fn azure_event_hubs(
364 &self,
365 ) -> std::option::Option<
366 &std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
367 > {
368 #[allow(unreachable_patterns)]
369 self.source.as_ref().and_then(|v| match v {
370 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v) => {
371 std::option::Option::Some(v)
372 }
373 _ => std::option::Option::None,
374 })
375 }
376
377 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
378 /// to hold a `AzureEventHubs`.
379 ///
380 /// Note that all the setters affecting `source` are
381 /// mutually exclusive.
382 ///
383 /// # Example
384 /// ```ignore,no_run
385 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
386 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
387 /// let x = IngestionDataSourceSettings::new().set_azure_event_hubs(AzureEventHubs::default()/* use setters */);
388 /// assert!(x.azure_event_hubs().is_some());
389 /// assert!(x.aws_kinesis().is_none());
390 /// assert!(x.cloud_storage().is_none());
391 /// assert!(x.aws_msk().is_none());
392 /// assert!(x.confluent_cloud().is_none());
393 /// ```
394 pub fn set_azure_event_hubs<
395 T: std::convert::Into<
396 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
397 >,
398 >(
399 mut self,
400 v: T,
401 ) -> Self {
402 self.source = std::option::Option::Some(
403 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v.into()),
404 );
405 self
406 }
407
408 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
409 /// if it holds a `AwsMsk`, `None` if the field is not set or
410 /// holds a different branch.
411 pub fn aws_msk(
412 &self,
413 ) -> std::option::Option<&std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>
414 {
415 #[allow(unreachable_patterns)]
416 self.source.as_ref().and_then(|v| match v {
417 crate::model::ingestion_data_source_settings::Source::AwsMsk(v) => {
418 std::option::Option::Some(v)
419 }
420 _ => std::option::Option::None,
421 })
422 }
423
424 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
425 /// to hold a `AwsMsk`.
426 ///
427 /// Note that all the setters affecting `source` are
428 /// mutually exclusive.
429 ///
430 /// # Example
431 /// ```ignore,no_run
432 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
433 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
434 /// let x = IngestionDataSourceSettings::new().set_aws_msk(AwsMsk::default()/* use setters */);
435 /// assert!(x.aws_msk().is_some());
436 /// assert!(x.aws_kinesis().is_none());
437 /// assert!(x.cloud_storage().is_none());
438 /// assert!(x.azure_event_hubs().is_none());
439 /// assert!(x.confluent_cloud().is_none());
440 /// ```
441 pub fn set_aws_msk<
442 T: std::convert::Into<std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>,
443 >(
444 mut self,
445 v: T,
446 ) -> Self {
447 self.source = std::option::Option::Some(
448 crate::model::ingestion_data_source_settings::Source::AwsMsk(v.into()),
449 );
450 self
451 }
452
453 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
454 /// if it holds a `ConfluentCloud`, `None` if the field is not set or
455 /// holds a different branch.
456 pub fn confluent_cloud(
457 &self,
458 ) -> std::option::Option<
459 &std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
460 > {
461 #[allow(unreachable_patterns)]
462 self.source.as_ref().and_then(|v| match v {
463 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v) => {
464 std::option::Option::Some(v)
465 }
466 _ => std::option::Option::None,
467 })
468 }
469
470 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
471 /// to hold a `ConfluentCloud`.
472 ///
473 /// Note that all the setters affecting `source` are
474 /// mutually exclusive.
475 ///
476 /// # Example
477 /// ```ignore,no_run
478 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
479 /// use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
480 /// let x = IngestionDataSourceSettings::new().set_confluent_cloud(ConfluentCloud::default()/* use setters */);
481 /// assert!(x.confluent_cloud().is_some());
482 /// assert!(x.aws_kinesis().is_none());
483 /// assert!(x.cloud_storage().is_none());
484 /// assert!(x.azure_event_hubs().is_none());
485 /// assert!(x.aws_msk().is_none());
486 /// ```
487 pub fn set_confluent_cloud<
488 T: std::convert::Into<
489 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
490 >,
491 >(
492 mut self,
493 v: T,
494 ) -> Self {
495 self.source = std::option::Option::Some(
496 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v.into()),
497 );
498 self
499 }
500}
501
502impl wkt::message::Message for IngestionDataSourceSettings {
503 fn typename() -> &'static str {
504 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings"
505 }
506}
507
508/// Defines additional types related to [IngestionDataSourceSettings].
509pub mod ingestion_data_source_settings {
510 #[allow(unused_imports)]
511 use super::*;
512
513 /// Ingestion settings for Amazon Kinesis Data Streams.
514 #[derive(Clone, Default, PartialEq)]
515 #[non_exhaustive]
516 pub struct AwsKinesis {
517 /// Output only. An output-only field that indicates the state of the Kinesis
518 /// ingestion source.
519 pub state: crate::model::ingestion_data_source_settings::aws_kinesis::State,
520
521 /// Required. The Kinesis stream ARN to ingest data from.
522 pub stream_arn: std::string::String,
523
524 /// Required. The Kinesis consumer ARN to used for ingestion in Enhanced
525 /// Fan-Out mode. The consumer must be already created and ready to be used.
526 pub consumer_arn: std::string::String,
527
528 /// Required. AWS role ARN to be used for Federated Identity authentication
529 /// with Kinesis. Check the Pub/Sub docs for how to set up this role and the
530 /// required permissions that need to be attached to it.
531 pub aws_role_arn: std::string::String,
532
533 /// Required. The GCP service account to be used for Federated Identity
534 /// authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for
535 /// the provided role). The `aws_role_arn` must be set up with
536 /// `accounts.google.com:sub` equals to this service account number.
537 pub gcp_service_account: std::string::String,
538
539 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
540 }
541
542 impl AwsKinesis {
543 /// Creates a new default instance.
544 pub fn new() -> Self {
545 std::default::Default::default()
546 }
547
548 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsKinesis::state].
549 ///
550 /// # Example
551 /// ```ignore,no_run
552 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
553 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_kinesis::State;
554 /// let x0 = AwsKinesis::new().set_state(State::Active);
555 /// let x1 = AwsKinesis::new().set_state(State::KinesisPermissionDenied);
556 /// let x2 = AwsKinesis::new().set_state(State::PublishPermissionDenied);
557 /// ```
558 pub fn set_state<
559 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_kinesis::State>,
560 >(
561 mut self,
562 v: T,
563 ) -> Self {
564 self.state = v.into();
565 self
566 }
567
568 /// Sets the value of [stream_arn][crate::model::ingestion_data_source_settings::AwsKinesis::stream_arn].
569 ///
570 /// # Example
571 /// ```ignore,no_run
572 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
573 /// let x = AwsKinesis::new().set_stream_arn("example");
574 /// ```
575 pub fn set_stream_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
576 self.stream_arn = v.into();
577 self
578 }
579
580 /// Sets the value of [consumer_arn][crate::model::ingestion_data_source_settings::AwsKinesis::consumer_arn].
581 ///
582 /// # Example
583 /// ```ignore,no_run
584 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
585 /// let x = AwsKinesis::new().set_consumer_arn("example");
586 /// ```
587 pub fn set_consumer_arn<T: std::convert::Into<std::string::String>>(
588 mut self,
589 v: T,
590 ) -> Self {
591 self.consumer_arn = v.into();
592 self
593 }
594
595 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsKinesis::aws_role_arn].
596 ///
597 /// # Example
598 /// ```ignore,no_run
599 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
600 /// let x = AwsKinesis::new().set_aws_role_arn("example");
601 /// ```
602 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
603 mut self,
604 v: T,
605 ) -> Self {
606 self.aws_role_arn = v.into();
607 self
608 }
609
610 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsKinesis::gcp_service_account].
611 ///
612 /// # Example
613 /// ```ignore,no_run
614 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
615 /// let x = AwsKinesis::new().set_gcp_service_account("example");
616 /// ```
617 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
618 mut self,
619 v: T,
620 ) -> Self {
621 self.gcp_service_account = v.into();
622 self
623 }
624 }
625
626 impl wkt::message::Message for AwsKinesis {
627 fn typename() -> &'static str {
628 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis"
629 }
630 }
631
632 /// Defines additional types related to [AwsKinesis].
633 pub mod aws_kinesis {
634 #[allow(unused_imports)]
635 use super::*;
636
637 /// Possible states for ingestion from Amazon Kinesis Data Streams.
638 ///
639 /// # Working with unknown values
640 ///
641 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
642 /// additional enum variants at any time. Adding new variants is not considered
643 /// a breaking change. Applications should write their code in anticipation of:
644 ///
645 /// - New values appearing in future releases of the client library, **and**
646 /// - New values received dynamically, without application changes.
647 ///
648 /// Please consult the [Working with enums] section in the user guide for some
649 /// guidelines.
650 ///
651 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
652 #[derive(Clone, Debug, PartialEq)]
653 #[non_exhaustive]
654 pub enum State {
655 /// Default value. This value is unused.
656 Unspecified,
657 /// Ingestion is active.
658 Active,
659 /// Permission denied encountered while consuming data from Kinesis.
660 /// This can happen if:
661 ///
662 /// - The provided `aws_role_arn` does not exist or does not have the
663 /// appropriate permissions attached.
664 /// - The provided `aws_role_arn` is not set up properly for Identity
665 /// Federation using `gcp_service_account`.
666 /// - The Pub/Sub SA is not granted the
667 /// `iam.serviceAccounts.getOpenIdToken` permission on
668 /// `gcp_service_account`.
669 KinesisPermissionDenied,
670 /// Permission denied encountered while publishing to the topic. This can
671 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
672 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
673 PublishPermissionDenied,
674 /// The Kinesis stream does not exist.
675 StreamNotFound,
676 /// The Kinesis consumer does not exist.
677 ConsumerNotFound,
678 /// Indicates an error state where the ingestion source cannot be
679 /// processed because the selected ingestion region is not permitted
680 /// by the Regional Access Boundary (RAB) restrictions on the project's
681 /// service account.
682 ConflictingRegionConstraints,
683 /// If set, the enum was initialized with an unknown value.
684 ///
685 /// Applications can examine the value using [State::value] or
686 /// [State::name].
687 UnknownValue(state::UnknownValue),
688 }
689
690 #[doc(hidden)]
691 pub mod state {
692 #[allow(unused_imports)]
693 use super::*;
694 #[derive(Clone, Debug, PartialEq)]
695 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
696 }
697
698 impl State {
699 /// Gets the enum value.
700 ///
701 /// Returns `None` if the enum contains an unknown value deserialized from
702 /// the string representation of enums.
703 pub fn value(&self) -> std::option::Option<i32> {
704 match self {
705 Self::Unspecified => std::option::Option::Some(0),
706 Self::Active => std::option::Option::Some(1),
707 Self::KinesisPermissionDenied => std::option::Option::Some(2),
708 Self::PublishPermissionDenied => std::option::Option::Some(3),
709 Self::StreamNotFound => std::option::Option::Some(4),
710 Self::ConsumerNotFound => std::option::Option::Some(5),
711 Self::ConflictingRegionConstraints => std::option::Option::Some(6),
712 Self::UnknownValue(u) => u.0.value(),
713 }
714 }
715
716 /// Gets the enum value as a string.
717 ///
718 /// Returns `None` if the enum contains an unknown value deserialized from
719 /// the integer representation of enums.
720 pub fn name(&self) -> std::option::Option<&str> {
721 match self {
722 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
723 Self::Active => std::option::Option::Some("ACTIVE"),
724 Self::KinesisPermissionDenied => {
725 std::option::Option::Some("KINESIS_PERMISSION_DENIED")
726 }
727 Self::PublishPermissionDenied => {
728 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
729 }
730 Self::StreamNotFound => std::option::Option::Some("STREAM_NOT_FOUND"),
731 Self::ConsumerNotFound => std::option::Option::Some("CONSUMER_NOT_FOUND"),
732 Self::ConflictingRegionConstraints => {
733 std::option::Option::Some("CONFLICTING_REGION_CONSTRAINTS")
734 }
735 Self::UnknownValue(u) => u.0.name(),
736 }
737 }
738 }
739
740 impl std::default::Default for State {
741 fn default() -> Self {
742 use std::convert::From;
743 Self::from(0)
744 }
745 }
746
747 impl std::fmt::Display for State {
748 fn fmt(
749 &self,
750 f: &mut std::fmt::Formatter<'_>,
751 ) -> std::result::Result<(), std::fmt::Error> {
752 wkt::internal::display_enum(f, self.name(), self.value())
753 }
754 }
755
756 impl std::convert::From<i32> for State {
757 fn from(value: i32) -> Self {
758 match value {
759 0 => Self::Unspecified,
760 1 => Self::Active,
761 2 => Self::KinesisPermissionDenied,
762 3 => Self::PublishPermissionDenied,
763 4 => Self::StreamNotFound,
764 5 => Self::ConsumerNotFound,
765 6 => Self::ConflictingRegionConstraints,
766 _ => Self::UnknownValue(state::UnknownValue(
767 wkt::internal::UnknownEnumValue::Integer(value),
768 )),
769 }
770 }
771 }
772
773 impl std::convert::From<&str> for State {
774 fn from(value: &str) -> Self {
775 use std::string::ToString;
776 match value {
777 "STATE_UNSPECIFIED" => Self::Unspecified,
778 "ACTIVE" => Self::Active,
779 "KINESIS_PERMISSION_DENIED" => Self::KinesisPermissionDenied,
780 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
781 "STREAM_NOT_FOUND" => Self::StreamNotFound,
782 "CONSUMER_NOT_FOUND" => Self::ConsumerNotFound,
783 "CONFLICTING_REGION_CONSTRAINTS" => Self::ConflictingRegionConstraints,
784 _ => Self::UnknownValue(state::UnknownValue(
785 wkt::internal::UnknownEnumValue::String(value.to_string()),
786 )),
787 }
788 }
789 }
790
791 impl serde::ser::Serialize for State {
792 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
793 where
794 S: serde::Serializer,
795 {
796 match self {
797 Self::Unspecified => serializer.serialize_i32(0),
798 Self::Active => serializer.serialize_i32(1),
799 Self::KinesisPermissionDenied => serializer.serialize_i32(2),
800 Self::PublishPermissionDenied => serializer.serialize_i32(3),
801 Self::StreamNotFound => serializer.serialize_i32(4),
802 Self::ConsumerNotFound => serializer.serialize_i32(5),
803 Self::ConflictingRegionConstraints => serializer.serialize_i32(6),
804 Self::UnknownValue(u) => u.0.serialize(serializer),
805 }
806 }
807 }
808
809 impl<'de> serde::de::Deserialize<'de> for State {
810 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
811 where
812 D: serde::Deserializer<'de>,
813 {
814 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
815 ".google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State",
816 ))
817 }
818 }
819 }
820
821 /// Ingestion settings for Cloud Storage.
822 #[derive(Clone, Default, PartialEq)]
823 #[non_exhaustive]
824 pub struct CloudStorage {
825 /// Output only. An output-only field that indicates the state of the Cloud
826 /// Storage ingestion source.
827 pub state: crate::model::ingestion_data_source_settings::cloud_storage::State,
828
829 /// Optional. Cloud Storage bucket. The bucket name must be without any
830 /// prefix like "gs://". See the [bucket naming requirements]
831 /// (<https://cloud.google.com/storage/docs/buckets#naming>).
832 pub bucket: std::string::String,
833
834 /// Optional. Only objects with a larger or equal creation timestamp will be
835 /// ingested.
836 pub minimum_object_create_time: std::option::Option<wkt::Timestamp>,
837
838 /// Optional. Glob pattern used to match objects that will be ingested. If
839 /// unset, all objects will be ingested. See the [supported
840 /// patterns](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob).
841 pub match_glob: std::string::String,
842
843 /// Defaults to text format.
844 pub input_format: std::option::Option<
845 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
846 >,
847
848 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
849 }
850
851 impl CloudStorage {
852 /// Creates a new default instance.
853 pub fn new() -> Self {
854 std::default::Default::default()
855 }
856
857 /// Sets the value of [state][crate::model::ingestion_data_source_settings::CloudStorage::state].
858 ///
859 /// # Example
860 /// ```ignore,no_run
861 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
862 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::State;
863 /// let x0 = CloudStorage::new().set_state(State::Active);
864 /// let x1 = CloudStorage::new().set_state(State::CloudStoragePermissionDenied);
865 /// let x2 = CloudStorage::new().set_state(State::PublishPermissionDenied);
866 /// ```
867 pub fn set_state<
868 T: std::convert::Into<crate::model::ingestion_data_source_settings::cloud_storage::State>,
869 >(
870 mut self,
871 v: T,
872 ) -> Self {
873 self.state = v.into();
874 self
875 }
876
877 /// Sets the value of [bucket][crate::model::ingestion_data_source_settings::CloudStorage::bucket].
878 ///
879 /// # Example
880 /// ```ignore,no_run
881 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
882 /// let x = CloudStorage::new().set_bucket("example");
883 /// ```
884 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
885 self.bucket = v.into();
886 self
887 }
888
889 /// Sets the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
890 ///
891 /// # Example
892 /// ```ignore,no_run
893 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
894 /// use wkt::Timestamp;
895 /// let x = CloudStorage::new().set_minimum_object_create_time(Timestamp::default()/* use setters */);
896 /// ```
897 pub fn set_minimum_object_create_time<T>(mut self, v: T) -> Self
898 where
899 T: std::convert::Into<wkt::Timestamp>,
900 {
901 self.minimum_object_create_time = std::option::Option::Some(v.into());
902 self
903 }
904
905 /// Sets or clears the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
906 ///
907 /// # Example
908 /// ```ignore,no_run
909 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
910 /// use wkt::Timestamp;
911 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(Some(Timestamp::default()/* use setters */));
912 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(None::<Timestamp>);
913 /// ```
914 pub fn set_or_clear_minimum_object_create_time<T>(
915 mut self,
916 v: std::option::Option<T>,
917 ) -> Self
918 where
919 T: std::convert::Into<wkt::Timestamp>,
920 {
921 self.minimum_object_create_time = v.map(|x| x.into());
922 self
923 }
924
925 /// Sets the value of [match_glob][crate::model::ingestion_data_source_settings::CloudStorage::match_glob].
926 ///
927 /// # Example
928 /// ```ignore,no_run
929 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
930 /// let x = CloudStorage::new().set_match_glob("example");
931 /// ```
932 pub fn set_match_glob<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
933 self.match_glob = v.into();
934 self
935 }
936
937 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format].
938 ///
939 /// Note that all the setters affecting `input_format` are mutually
940 /// exclusive.
941 ///
942 /// # Example
943 /// ```ignore,no_run
944 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
945 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
946 /// let x = CloudStorage::new().set_input_format(Some(
947 /// google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(TextFormat::default().into())));
948 /// ```
949 pub fn set_input_format<
950 T: std::convert::Into<
951 std::option::Option<
952 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
953 >,
954 >,
955 >(
956 mut self,
957 v: T,
958 ) -> Self {
959 self.input_format = v.into();
960 self
961 }
962
963 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
964 /// if it holds a `TextFormat`, `None` if the field is not set or
965 /// holds a different branch.
966 pub fn text_format(
967 &self,
968 ) -> std::option::Option<
969 &std::boxed::Box<
970 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
971 >,
972 > {
973 #[allow(unreachable_patterns)]
974 self.input_format.as_ref().and_then(|v| match v {
975 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(v) => std::option::Option::Some(v),
976 _ => std::option::Option::None,
977 })
978 }
979
980 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
981 /// to hold a `TextFormat`.
982 ///
983 /// Note that all the setters affecting `input_format` are
984 /// mutually exclusive.
985 ///
986 /// # Example
987 /// ```ignore,no_run
988 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
989 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
990 /// let x = CloudStorage::new().set_text_format(TextFormat::default()/* use setters */);
991 /// assert!(x.text_format().is_some());
992 /// assert!(x.avro_format().is_none());
993 /// assert!(x.pubsub_avro_format().is_none());
994 /// ```
995 pub fn set_text_format<
996 T: std::convert::Into<
997 std::boxed::Box<
998 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
999 >,
1000 >,
1001 >(
1002 mut self,
1003 v: T,
1004 ) -> Self {
1005 self.input_format = std::option::Option::Some(
1006 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(
1007 v.into()
1008 )
1009 );
1010 self
1011 }
1012
1013 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1014 /// if it holds a `AvroFormat`, `None` if the field is not set or
1015 /// holds a different branch.
1016 pub fn avro_format(
1017 &self,
1018 ) -> std::option::Option<
1019 &std::boxed::Box<
1020 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1021 >,
1022 > {
1023 #[allow(unreachable_patterns)]
1024 self.input_format.as_ref().and_then(|v| match v {
1025 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(v) => std::option::Option::Some(v),
1026 _ => std::option::Option::None,
1027 })
1028 }
1029
1030 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1031 /// to hold a `AvroFormat`.
1032 ///
1033 /// Note that all the setters affecting `input_format` are
1034 /// mutually exclusive.
1035 ///
1036 /// # Example
1037 /// ```ignore,no_run
1038 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1039 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::AvroFormat;
1040 /// let x = CloudStorage::new().set_avro_format(AvroFormat::default()/* use setters */);
1041 /// assert!(x.avro_format().is_some());
1042 /// assert!(x.text_format().is_none());
1043 /// assert!(x.pubsub_avro_format().is_none());
1044 /// ```
1045 pub fn set_avro_format<
1046 T: std::convert::Into<
1047 std::boxed::Box<
1048 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1049 >,
1050 >,
1051 >(
1052 mut self,
1053 v: T,
1054 ) -> Self {
1055 self.input_format = std::option::Option::Some(
1056 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(
1057 v.into()
1058 )
1059 );
1060 self
1061 }
1062
1063 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1064 /// if it holds a `PubsubAvroFormat`, `None` if the field is not set or
1065 /// holds a different branch.
1066 pub fn pubsub_avro_format(
1067 &self,
1068 ) -> std::option::Option<
1069 &std::boxed::Box<
1070 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1071 >,
1072 > {
1073 #[allow(unreachable_patterns)]
1074 self.input_format.as_ref().and_then(|v| match v {
1075 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(v) => std::option::Option::Some(v),
1076 _ => std::option::Option::None,
1077 })
1078 }
1079
1080 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1081 /// to hold a `PubsubAvroFormat`.
1082 ///
1083 /// Note that all the setters affecting `input_format` are
1084 /// mutually exclusive.
1085 ///
1086 /// # Example
1087 /// ```ignore,no_run
1088 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1089 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat;
1090 /// let x = CloudStorage::new().set_pubsub_avro_format(PubSubAvroFormat::default()/* use setters */);
1091 /// assert!(x.pubsub_avro_format().is_some());
1092 /// assert!(x.text_format().is_none());
1093 /// assert!(x.avro_format().is_none());
1094 /// ```
1095 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{
1096 self.input_format = std::option::Option::Some(
1097 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(
1098 v.into()
1099 )
1100 );
1101 self
1102 }
1103 }
1104
1105 impl wkt::message::Message for CloudStorage {
1106 fn typename() -> &'static str {
1107 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage"
1108 }
1109 }
1110
1111 /// Defines additional types related to [CloudStorage].
1112 pub mod cloud_storage {
1113 #[allow(unused_imports)]
1114 use super::*;
1115
1116 /// Configuration for reading Cloud Storage data in text format. Each line of
1117 /// text as specified by the delimiter will be set to the `data` field of a
1118 /// Pub/Sub message.
1119 #[derive(Clone, Default, PartialEq)]
1120 #[non_exhaustive]
1121 pub struct TextFormat {
1122 /// Optional. When unset, '\n' is used.
1123 pub delimiter: std::option::Option<std::string::String>,
1124
1125 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1126 }
1127
1128 impl TextFormat {
1129 /// Creates a new default instance.
1130 pub fn new() -> Self {
1131 std::default::Default::default()
1132 }
1133
1134 /// Sets the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1135 ///
1136 /// # Example
1137 /// ```ignore,no_run
1138 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1139 /// let x = TextFormat::new().set_delimiter("example");
1140 /// ```
1141 pub fn set_delimiter<T>(mut self, v: T) -> Self
1142 where
1143 T: std::convert::Into<std::string::String>,
1144 {
1145 self.delimiter = std::option::Option::Some(v.into());
1146 self
1147 }
1148
1149 /// Sets or clears the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1150 ///
1151 /// # Example
1152 /// ```ignore,no_run
1153 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1154 /// let x = TextFormat::new().set_or_clear_delimiter(Some("example"));
1155 /// let x = TextFormat::new().set_or_clear_delimiter(None::<String>);
1156 /// ```
1157 pub fn set_or_clear_delimiter<T>(mut self, v: std::option::Option<T>) -> Self
1158 where
1159 T: std::convert::Into<std::string::String>,
1160 {
1161 self.delimiter = v.map(|x| x.into());
1162 self
1163 }
1164 }
1165
1166 impl wkt::message::Message for TextFormat {
1167 fn typename() -> &'static str {
1168 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.TextFormat"
1169 }
1170 }
1171
1172 /// Configuration for reading Cloud Storage data in Avro binary format. The
1173 /// bytes of each object will be set to the `data` field of a Pub/Sub
1174 /// message.
1175 #[derive(Clone, Default, PartialEq)]
1176 #[non_exhaustive]
1177 pub struct AvroFormat {
1178 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1179 }
1180
1181 impl AvroFormat {
1182 /// Creates a new default instance.
1183 pub fn new() -> Self {
1184 std::default::Default::default()
1185 }
1186 }
1187
1188 impl wkt::message::Message for AvroFormat {
1189 fn typename() -> &'static str {
1190 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.AvroFormat"
1191 }
1192 }
1193
1194 /// Configuration for reading Cloud Storage data written via [Cloud Storage
1195 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage). The
1196 /// data and attributes fields of the originally exported Pub/Sub message
1197 /// will be restored when publishing.
1198 #[derive(Clone, Default, PartialEq)]
1199 #[non_exhaustive]
1200 pub struct PubSubAvroFormat {
1201 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1202 }
1203
1204 impl PubSubAvroFormat {
1205 /// Creates a new default instance.
1206 pub fn new() -> Self {
1207 std::default::Default::default()
1208 }
1209 }
1210
1211 impl wkt::message::Message for PubSubAvroFormat {
1212 fn typename() -> &'static str {
1213 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat"
1214 }
1215 }
1216
1217 /// Possible states for ingestion from Cloud Storage.
1218 ///
1219 /// # Working with unknown values
1220 ///
1221 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1222 /// additional enum variants at any time. Adding new variants is not considered
1223 /// a breaking change. Applications should write their code in anticipation of:
1224 ///
1225 /// - New values appearing in future releases of the client library, **and**
1226 /// - New values received dynamically, without application changes.
1227 ///
1228 /// Please consult the [Working with enums] section in the user guide for some
1229 /// guidelines.
1230 ///
1231 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1232 #[derive(Clone, Debug, PartialEq)]
1233 #[non_exhaustive]
1234 pub enum State {
1235 /// Default value. This value is unused.
1236 Unspecified,
1237 /// Ingestion is active.
1238 Active,
1239 /// Permission denied encountered while calling the Cloud Storage API. This
1240 /// can happen if the Pub/Sub SA has not been granted the
1241 /// [appropriate
1242 /// permissions](https://cloud.google.com/storage/docs/access-control/iam-permissions):
1243 ///
1244 /// - storage.objects.list: to list the objects in a bucket.
1245 /// - storage.objects.get: to read the objects in a bucket.
1246 /// - storage.buckets.get: to verify the bucket exists.
1247 CloudStoragePermissionDenied,
1248 /// Permission denied encountered while publishing to the topic. This can
1249 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
1250 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
1251 PublishPermissionDenied,
1252 /// The provided Cloud Storage bucket doesn't exist.
1253 BucketNotFound,
1254 /// The Cloud Storage bucket has too many objects, ingestion will be
1255 /// paused.
1256 TooManyObjects,
1257 /// Indicates an error state where the ingestion source cannot be
1258 /// processed because the selected ingestion region is not permitted
1259 /// by the Regional Access Boundary (RAB) restrictions on the project's
1260 /// service account.
1261 ConflictingRegionConstraints,
1262 /// If set, the enum was initialized with an unknown value.
1263 ///
1264 /// Applications can examine the value using [State::value] or
1265 /// [State::name].
1266 UnknownValue(state::UnknownValue),
1267 }
1268
1269 #[doc(hidden)]
1270 pub mod state {
1271 #[allow(unused_imports)]
1272 use super::*;
1273 #[derive(Clone, Debug, PartialEq)]
1274 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1275 }
1276
1277 impl State {
1278 /// Gets the enum value.
1279 ///
1280 /// Returns `None` if the enum contains an unknown value deserialized from
1281 /// the string representation of enums.
1282 pub fn value(&self) -> std::option::Option<i32> {
1283 match self {
1284 Self::Unspecified => std::option::Option::Some(0),
1285 Self::Active => std::option::Option::Some(1),
1286 Self::CloudStoragePermissionDenied => std::option::Option::Some(2),
1287 Self::PublishPermissionDenied => std::option::Option::Some(3),
1288 Self::BucketNotFound => std::option::Option::Some(4),
1289 Self::TooManyObjects => std::option::Option::Some(5),
1290 Self::ConflictingRegionConstraints => std::option::Option::Some(8),
1291 Self::UnknownValue(u) => u.0.value(),
1292 }
1293 }
1294
1295 /// Gets the enum value as a string.
1296 ///
1297 /// Returns `None` if the enum contains an unknown value deserialized from
1298 /// the integer representation of enums.
1299 pub fn name(&self) -> std::option::Option<&str> {
1300 match self {
1301 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1302 Self::Active => std::option::Option::Some("ACTIVE"),
1303 Self::CloudStoragePermissionDenied => {
1304 std::option::Option::Some("CLOUD_STORAGE_PERMISSION_DENIED")
1305 }
1306 Self::PublishPermissionDenied => {
1307 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1308 }
1309 Self::BucketNotFound => std::option::Option::Some("BUCKET_NOT_FOUND"),
1310 Self::TooManyObjects => std::option::Option::Some("TOO_MANY_OBJECTS"),
1311 Self::ConflictingRegionConstraints => {
1312 std::option::Option::Some("CONFLICTING_REGION_CONSTRAINTS")
1313 }
1314 Self::UnknownValue(u) => u.0.name(),
1315 }
1316 }
1317 }
1318
1319 impl std::default::Default for State {
1320 fn default() -> Self {
1321 use std::convert::From;
1322 Self::from(0)
1323 }
1324 }
1325
1326 impl std::fmt::Display for State {
1327 fn fmt(
1328 &self,
1329 f: &mut std::fmt::Formatter<'_>,
1330 ) -> std::result::Result<(), std::fmt::Error> {
1331 wkt::internal::display_enum(f, self.name(), self.value())
1332 }
1333 }
1334
1335 impl std::convert::From<i32> for State {
1336 fn from(value: i32) -> Self {
1337 match value {
1338 0 => Self::Unspecified,
1339 1 => Self::Active,
1340 2 => Self::CloudStoragePermissionDenied,
1341 3 => Self::PublishPermissionDenied,
1342 4 => Self::BucketNotFound,
1343 5 => Self::TooManyObjects,
1344 8 => Self::ConflictingRegionConstraints,
1345 _ => Self::UnknownValue(state::UnknownValue(
1346 wkt::internal::UnknownEnumValue::Integer(value),
1347 )),
1348 }
1349 }
1350 }
1351
1352 impl std::convert::From<&str> for State {
1353 fn from(value: &str) -> Self {
1354 use std::string::ToString;
1355 match value {
1356 "STATE_UNSPECIFIED" => Self::Unspecified,
1357 "ACTIVE" => Self::Active,
1358 "CLOUD_STORAGE_PERMISSION_DENIED" => Self::CloudStoragePermissionDenied,
1359 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1360 "BUCKET_NOT_FOUND" => Self::BucketNotFound,
1361 "TOO_MANY_OBJECTS" => Self::TooManyObjects,
1362 "CONFLICTING_REGION_CONSTRAINTS" => Self::ConflictingRegionConstraints,
1363 _ => Self::UnknownValue(state::UnknownValue(
1364 wkt::internal::UnknownEnumValue::String(value.to_string()),
1365 )),
1366 }
1367 }
1368 }
1369
1370 impl serde::ser::Serialize for State {
1371 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1372 where
1373 S: serde::Serializer,
1374 {
1375 match self {
1376 Self::Unspecified => serializer.serialize_i32(0),
1377 Self::Active => serializer.serialize_i32(1),
1378 Self::CloudStoragePermissionDenied => serializer.serialize_i32(2),
1379 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1380 Self::BucketNotFound => serializer.serialize_i32(4),
1381 Self::TooManyObjects => serializer.serialize_i32(5),
1382 Self::ConflictingRegionConstraints => serializer.serialize_i32(8),
1383 Self::UnknownValue(u) => u.0.serialize(serializer),
1384 }
1385 }
1386 }
1387
1388 impl<'de> serde::de::Deserialize<'de> for State {
1389 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1390 where
1391 D: serde::Deserializer<'de>,
1392 {
1393 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1394 ".google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.State",
1395 ))
1396 }
1397 }
1398
1399 /// Defaults to text format.
1400 #[derive(Clone, Debug, PartialEq)]
1401 #[non_exhaustive]
1402 pub enum InputFormat {
1403 /// Optional. Data from Cloud Storage will be interpreted as text.
1404 TextFormat(
1405 std::boxed::Box<
1406 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
1407 >,
1408 ),
1409 /// Optional. Data from Cloud Storage will be interpreted in Avro format.
1410 AvroFormat(
1411 std::boxed::Box<
1412 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1413 >,
1414 ),
1415 /// Optional. It will be assumed data from Cloud Storage was written via
1416 /// [Cloud Storage
1417 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage).
1418 PubsubAvroFormat(
1419 std::boxed::Box<
1420 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1421 >,
1422 ),
1423 }
1424 }
1425
1426 /// Ingestion settings for Azure Event Hubs.
1427 #[derive(Clone, Default, PartialEq)]
1428 #[non_exhaustive]
1429 pub struct AzureEventHubs {
1430 /// Output only. An output-only field that indicates the state of the Event
1431 /// Hubs ingestion source.
1432 pub state: crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1433
1434 /// Optional. Name of the resource group within the azure subscription.
1435 pub resource_group: std::string::String,
1436
1437 /// Optional. The name of the Event Hubs namespace.
1438 pub namespace: std::string::String,
1439
1440 /// Optional. The name of the Event Hub.
1441 pub event_hub: std::string::String,
1442
1443 /// Optional. The client id of the Azure application that is being used to
1444 /// authenticate Pub/Sub.
1445 pub client_id: std::string::String,
1446
1447 /// Optional. The tenant id of the Azure application that is being used to
1448 /// authenticate Pub/Sub.
1449 pub tenant_id: std::string::String,
1450
1451 /// Optional. The Azure subscription id.
1452 pub subscription_id: std::string::String,
1453
1454 /// Optional. The GCP service account to be used for Federated Identity
1455 /// authentication.
1456 pub gcp_service_account: std::string::String,
1457
1458 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1459 }
1460
1461 impl AzureEventHubs {
1462 /// Creates a new default instance.
1463 pub fn new() -> Self {
1464 std::default::Default::default()
1465 }
1466
1467 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AzureEventHubs::state].
1468 ///
1469 /// # Example
1470 /// ```ignore,no_run
1471 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1472 /// use google_cloud_pubsub::model::ingestion_data_source_settings::azure_event_hubs::State;
1473 /// let x0 = AzureEventHubs::new().set_state(State::Active);
1474 /// let x1 = AzureEventHubs::new().set_state(State::EventHubsPermissionDenied);
1475 /// let x2 = AzureEventHubs::new().set_state(State::PublishPermissionDenied);
1476 /// ```
1477 pub fn set_state<
1478 T: std::convert::Into<
1479 crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1480 >,
1481 >(
1482 mut self,
1483 v: T,
1484 ) -> Self {
1485 self.state = v.into();
1486 self
1487 }
1488
1489 /// Sets the value of [resource_group][crate::model::ingestion_data_source_settings::AzureEventHubs::resource_group].
1490 ///
1491 /// # Example
1492 /// ```ignore,no_run
1493 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1494 /// let x = AzureEventHubs::new().set_resource_group("example");
1495 /// ```
1496 pub fn set_resource_group<T: std::convert::Into<std::string::String>>(
1497 mut self,
1498 v: T,
1499 ) -> Self {
1500 self.resource_group = v.into();
1501 self
1502 }
1503
1504 /// Sets the value of [namespace][crate::model::ingestion_data_source_settings::AzureEventHubs::namespace].
1505 ///
1506 /// # Example
1507 /// ```ignore,no_run
1508 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1509 /// let x = AzureEventHubs::new().set_namespace("example");
1510 /// ```
1511 pub fn set_namespace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1512 self.namespace = v.into();
1513 self
1514 }
1515
1516 /// Sets the value of [event_hub][crate::model::ingestion_data_source_settings::AzureEventHubs::event_hub].
1517 ///
1518 /// # Example
1519 /// ```ignore,no_run
1520 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1521 /// let x = AzureEventHubs::new().set_event_hub("example");
1522 /// ```
1523 pub fn set_event_hub<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1524 self.event_hub = v.into();
1525 self
1526 }
1527
1528 /// Sets the value of [client_id][crate::model::ingestion_data_source_settings::AzureEventHubs::client_id].
1529 ///
1530 /// # Example
1531 /// ```ignore,no_run
1532 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1533 /// let x = AzureEventHubs::new().set_client_id("example");
1534 /// ```
1535 pub fn set_client_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1536 self.client_id = v.into();
1537 self
1538 }
1539
1540 /// Sets the value of [tenant_id][crate::model::ingestion_data_source_settings::AzureEventHubs::tenant_id].
1541 ///
1542 /// # Example
1543 /// ```ignore,no_run
1544 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1545 /// let x = AzureEventHubs::new().set_tenant_id("example");
1546 /// ```
1547 pub fn set_tenant_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1548 self.tenant_id = v.into();
1549 self
1550 }
1551
1552 /// Sets the value of [subscription_id][crate::model::ingestion_data_source_settings::AzureEventHubs::subscription_id].
1553 ///
1554 /// # Example
1555 /// ```ignore,no_run
1556 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1557 /// let x = AzureEventHubs::new().set_subscription_id("example");
1558 /// ```
1559 pub fn set_subscription_id<T: std::convert::Into<std::string::String>>(
1560 mut self,
1561 v: T,
1562 ) -> Self {
1563 self.subscription_id = v.into();
1564 self
1565 }
1566
1567 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AzureEventHubs::gcp_service_account].
1568 ///
1569 /// # Example
1570 /// ```ignore,no_run
1571 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1572 /// let x = AzureEventHubs::new().set_gcp_service_account("example");
1573 /// ```
1574 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1575 mut self,
1576 v: T,
1577 ) -> Self {
1578 self.gcp_service_account = v.into();
1579 self
1580 }
1581 }
1582
1583 impl wkt::message::Message for AzureEventHubs {
1584 fn typename() -> &'static str {
1585 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs"
1586 }
1587 }
1588
1589 /// Defines additional types related to [AzureEventHubs].
1590 pub mod azure_event_hubs {
1591 #[allow(unused_imports)]
1592 use super::*;
1593
1594 /// Possible states for managed ingestion from Event Hubs.
1595 ///
1596 /// # Working with unknown values
1597 ///
1598 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1599 /// additional enum variants at any time. Adding new variants is not considered
1600 /// a breaking change. Applications should write their code in anticipation of:
1601 ///
1602 /// - New values appearing in future releases of the client library, **and**
1603 /// - New values received dynamically, without application changes.
1604 ///
1605 /// Please consult the [Working with enums] section in the user guide for some
1606 /// guidelines.
1607 ///
1608 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1609 #[derive(Clone, Debug, PartialEq)]
1610 #[non_exhaustive]
1611 pub enum State {
1612 /// Default value. This value is unused.
1613 Unspecified,
1614 /// Ingestion is active.
1615 Active,
1616 /// Permission denied encountered while consuming data from Event Hubs.
1617 /// This can happen when `client_id`, or `tenant_id` are invalid. Or the
1618 /// right permissions haven't been granted.
1619 EventHubsPermissionDenied,
1620 /// Permission denied encountered while publishing to the topic.
1621 PublishPermissionDenied,
1622 /// The provided Event Hubs namespace couldn't be found.
1623 NamespaceNotFound,
1624 /// The provided Event Hub couldn't be found.
1625 EventHubNotFound,
1626 /// The provided Event Hubs subscription couldn't be found.
1627 SubscriptionNotFound,
1628 /// The provided Event Hubs resource group couldn't be found.
1629 ResourceGroupNotFound,
1630 /// Indicates an error state where the ingestion source cannot be
1631 /// processed because the selected ingestion region is not permitted
1632 /// by the Regional Access Boundary (RAB) restrictions on the project's
1633 /// service account.
1634 ConflictingRegionConstraints,
1635 /// If set, the enum was initialized with an unknown value.
1636 ///
1637 /// Applications can examine the value using [State::value] or
1638 /// [State::name].
1639 UnknownValue(state::UnknownValue),
1640 }
1641
1642 #[doc(hidden)]
1643 pub mod state {
1644 #[allow(unused_imports)]
1645 use super::*;
1646 #[derive(Clone, Debug, PartialEq)]
1647 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1648 }
1649
1650 impl State {
1651 /// Gets the enum value.
1652 ///
1653 /// Returns `None` if the enum contains an unknown value deserialized from
1654 /// the string representation of enums.
1655 pub fn value(&self) -> std::option::Option<i32> {
1656 match self {
1657 Self::Unspecified => std::option::Option::Some(0),
1658 Self::Active => std::option::Option::Some(1),
1659 Self::EventHubsPermissionDenied => std::option::Option::Some(2),
1660 Self::PublishPermissionDenied => std::option::Option::Some(3),
1661 Self::NamespaceNotFound => std::option::Option::Some(4),
1662 Self::EventHubNotFound => std::option::Option::Some(5),
1663 Self::SubscriptionNotFound => std::option::Option::Some(6),
1664 Self::ResourceGroupNotFound => std::option::Option::Some(7),
1665 Self::ConflictingRegionConstraints => std::option::Option::Some(8),
1666 Self::UnknownValue(u) => u.0.value(),
1667 }
1668 }
1669
1670 /// Gets the enum value as a string.
1671 ///
1672 /// Returns `None` if the enum contains an unknown value deserialized from
1673 /// the integer representation of enums.
1674 pub fn name(&self) -> std::option::Option<&str> {
1675 match self {
1676 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1677 Self::Active => std::option::Option::Some("ACTIVE"),
1678 Self::EventHubsPermissionDenied => {
1679 std::option::Option::Some("EVENT_HUBS_PERMISSION_DENIED")
1680 }
1681 Self::PublishPermissionDenied => {
1682 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1683 }
1684 Self::NamespaceNotFound => std::option::Option::Some("NAMESPACE_NOT_FOUND"),
1685 Self::EventHubNotFound => std::option::Option::Some("EVENT_HUB_NOT_FOUND"),
1686 Self::SubscriptionNotFound => {
1687 std::option::Option::Some("SUBSCRIPTION_NOT_FOUND")
1688 }
1689 Self::ResourceGroupNotFound => {
1690 std::option::Option::Some("RESOURCE_GROUP_NOT_FOUND")
1691 }
1692 Self::ConflictingRegionConstraints => {
1693 std::option::Option::Some("CONFLICTING_REGION_CONSTRAINTS")
1694 }
1695 Self::UnknownValue(u) => u.0.name(),
1696 }
1697 }
1698 }
1699
1700 impl std::default::Default for State {
1701 fn default() -> Self {
1702 use std::convert::From;
1703 Self::from(0)
1704 }
1705 }
1706
1707 impl std::fmt::Display for State {
1708 fn fmt(
1709 &self,
1710 f: &mut std::fmt::Formatter<'_>,
1711 ) -> std::result::Result<(), std::fmt::Error> {
1712 wkt::internal::display_enum(f, self.name(), self.value())
1713 }
1714 }
1715
1716 impl std::convert::From<i32> for State {
1717 fn from(value: i32) -> Self {
1718 match value {
1719 0 => Self::Unspecified,
1720 1 => Self::Active,
1721 2 => Self::EventHubsPermissionDenied,
1722 3 => Self::PublishPermissionDenied,
1723 4 => Self::NamespaceNotFound,
1724 5 => Self::EventHubNotFound,
1725 6 => Self::SubscriptionNotFound,
1726 7 => Self::ResourceGroupNotFound,
1727 8 => Self::ConflictingRegionConstraints,
1728 _ => Self::UnknownValue(state::UnknownValue(
1729 wkt::internal::UnknownEnumValue::Integer(value),
1730 )),
1731 }
1732 }
1733 }
1734
1735 impl std::convert::From<&str> for State {
1736 fn from(value: &str) -> Self {
1737 use std::string::ToString;
1738 match value {
1739 "STATE_UNSPECIFIED" => Self::Unspecified,
1740 "ACTIVE" => Self::Active,
1741 "EVENT_HUBS_PERMISSION_DENIED" => Self::EventHubsPermissionDenied,
1742 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1743 "NAMESPACE_NOT_FOUND" => Self::NamespaceNotFound,
1744 "EVENT_HUB_NOT_FOUND" => Self::EventHubNotFound,
1745 "SUBSCRIPTION_NOT_FOUND" => Self::SubscriptionNotFound,
1746 "RESOURCE_GROUP_NOT_FOUND" => Self::ResourceGroupNotFound,
1747 "CONFLICTING_REGION_CONSTRAINTS" => Self::ConflictingRegionConstraints,
1748 _ => Self::UnknownValue(state::UnknownValue(
1749 wkt::internal::UnknownEnumValue::String(value.to_string()),
1750 )),
1751 }
1752 }
1753 }
1754
1755 impl serde::ser::Serialize for State {
1756 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1757 where
1758 S: serde::Serializer,
1759 {
1760 match self {
1761 Self::Unspecified => serializer.serialize_i32(0),
1762 Self::Active => serializer.serialize_i32(1),
1763 Self::EventHubsPermissionDenied => serializer.serialize_i32(2),
1764 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1765 Self::NamespaceNotFound => serializer.serialize_i32(4),
1766 Self::EventHubNotFound => serializer.serialize_i32(5),
1767 Self::SubscriptionNotFound => serializer.serialize_i32(6),
1768 Self::ResourceGroupNotFound => serializer.serialize_i32(7),
1769 Self::ConflictingRegionConstraints => serializer.serialize_i32(8),
1770 Self::UnknownValue(u) => u.0.serialize(serializer),
1771 }
1772 }
1773 }
1774
1775 impl<'de> serde::de::Deserialize<'de> for State {
1776 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1777 where
1778 D: serde::Deserializer<'de>,
1779 {
1780 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1781 ".google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs.State",
1782 ))
1783 }
1784 }
1785 }
1786
1787 /// Ingestion settings for Amazon MSK.
1788 #[derive(Clone, Default, PartialEq)]
1789 #[non_exhaustive]
1790 pub struct AwsMsk {
1791 /// Output only. An output-only field that indicates the state of the Amazon
1792 /// MSK ingestion source.
1793 pub state: crate::model::ingestion_data_source_settings::aws_msk::State,
1794
1795 /// Required. The Amazon Resource Name (ARN) that uniquely identifies the
1796 /// cluster.
1797 pub cluster_arn: std::string::String,
1798
1799 /// Required. The name of the topic in the Amazon MSK cluster that Pub/Sub
1800 /// will import from.
1801 pub topic: std::string::String,
1802
1803 /// Required. AWS role ARN to be used for Federated Identity authentication
1804 /// with Amazon MSK. Check the Pub/Sub docs for how to set up this role and
1805 /// the required permissions that need to be attached to it.
1806 pub aws_role_arn: std::string::String,
1807
1808 /// Required. The GCP service account to be used for Federated Identity
1809 /// authentication with Amazon MSK (via a `AssumeRoleWithWebIdentity` call
1810 /// for the provided role). The `aws_role_arn` must be set up with
1811 /// `accounts.google.com:sub` equals to this service account number.
1812 pub gcp_service_account: std::string::String,
1813
1814 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1815 }
1816
1817 impl AwsMsk {
1818 /// Creates a new default instance.
1819 pub fn new() -> Self {
1820 std::default::Default::default()
1821 }
1822
1823 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsMsk::state].
1824 ///
1825 /// # Example
1826 /// ```ignore,no_run
1827 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1828 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_msk::State;
1829 /// let x0 = AwsMsk::new().set_state(State::Active);
1830 /// let x1 = AwsMsk::new().set_state(State::MskPermissionDenied);
1831 /// let x2 = AwsMsk::new().set_state(State::PublishPermissionDenied);
1832 /// ```
1833 pub fn set_state<
1834 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_msk::State>,
1835 >(
1836 mut self,
1837 v: T,
1838 ) -> Self {
1839 self.state = v.into();
1840 self
1841 }
1842
1843 /// Sets the value of [cluster_arn][crate::model::ingestion_data_source_settings::AwsMsk::cluster_arn].
1844 ///
1845 /// # Example
1846 /// ```ignore,no_run
1847 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1848 /// let x = AwsMsk::new().set_cluster_arn("example");
1849 /// ```
1850 pub fn set_cluster_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1851 self.cluster_arn = v.into();
1852 self
1853 }
1854
1855 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::AwsMsk::topic].
1856 ///
1857 /// # Example
1858 /// ```ignore,no_run
1859 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1860 /// # let project_id = "project_id";
1861 /// # let topic_id = "topic_id";
1862 /// let x = AwsMsk::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
1863 /// ```
1864 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1865 self.topic = v.into();
1866 self
1867 }
1868
1869 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsMsk::aws_role_arn].
1870 ///
1871 /// # Example
1872 /// ```ignore,no_run
1873 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1874 /// let x = AwsMsk::new().set_aws_role_arn("example");
1875 /// ```
1876 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
1877 mut self,
1878 v: T,
1879 ) -> Self {
1880 self.aws_role_arn = v.into();
1881 self
1882 }
1883
1884 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsMsk::gcp_service_account].
1885 ///
1886 /// # Example
1887 /// ```ignore,no_run
1888 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1889 /// let x = AwsMsk::new().set_gcp_service_account("example");
1890 /// ```
1891 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1892 mut self,
1893 v: T,
1894 ) -> Self {
1895 self.gcp_service_account = v.into();
1896 self
1897 }
1898 }
1899
1900 impl wkt::message::Message for AwsMsk {
1901 fn typename() -> &'static str {
1902 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsMsk"
1903 }
1904 }
1905
1906 /// Defines additional types related to [AwsMsk].
1907 pub mod aws_msk {
1908 #[allow(unused_imports)]
1909 use super::*;
1910
1911 /// Possible states for managed ingestion from Amazon MSK.
1912 ///
1913 /// # Working with unknown values
1914 ///
1915 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1916 /// additional enum variants at any time. Adding new variants is not considered
1917 /// a breaking change. Applications should write their code in anticipation of:
1918 ///
1919 /// - New values appearing in future releases of the client library, **and**
1920 /// - New values received dynamically, without application changes.
1921 ///
1922 /// Please consult the [Working with enums] section in the user guide for some
1923 /// guidelines.
1924 ///
1925 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1926 #[derive(Clone, Debug, PartialEq)]
1927 #[non_exhaustive]
1928 pub enum State {
1929 /// Default value. This value is unused.
1930 Unspecified,
1931 /// Ingestion is active.
1932 Active,
1933 /// Permission denied encountered while consuming data from Amazon MSK.
1934 MskPermissionDenied,
1935 /// Permission denied encountered while publishing to the topic.
1936 PublishPermissionDenied,
1937 /// The provided MSK cluster wasn't found.
1938 ClusterNotFound,
1939 /// The provided topic wasn't found.
1940 TopicNotFound,
1941 /// Indicates an error state where the ingestion source cannot be
1942 /// processed because the selected ingestion region is not permitted
1943 /// by the Regional Access Boundary (RAB) restrictions on the project's
1944 /// service account.
1945 ConflictingRegionConstraints,
1946 /// If set, the enum was initialized with an unknown value.
1947 ///
1948 /// Applications can examine the value using [State::value] or
1949 /// [State::name].
1950 UnknownValue(state::UnknownValue),
1951 }
1952
1953 #[doc(hidden)]
1954 pub mod state {
1955 #[allow(unused_imports)]
1956 use super::*;
1957 #[derive(Clone, Debug, PartialEq)]
1958 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1959 }
1960
1961 impl State {
1962 /// Gets the enum value.
1963 ///
1964 /// Returns `None` if the enum contains an unknown value deserialized from
1965 /// the string representation of enums.
1966 pub fn value(&self) -> std::option::Option<i32> {
1967 match self {
1968 Self::Unspecified => std::option::Option::Some(0),
1969 Self::Active => std::option::Option::Some(1),
1970 Self::MskPermissionDenied => std::option::Option::Some(2),
1971 Self::PublishPermissionDenied => std::option::Option::Some(3),
1972 Self::ClusterNotFound => std::option::Option::Some(4),
1973 Self::TopicNotFound => std::option::Option::Some(5),
1974 Self::ConflictingRegionConstraints => std::option::Option::Some(6),
1975 Self::UnknownValue(u) => u.0.value(),
1976 }
1977 }
1978
1979 /// Gets the enum value as a string.
1980 ///
1981 /// Returns `None` if the enum contains an unknown value deserialized from
1982 /// the integer representation of enums.
1983 pub fn name(&self) -> std::option::Option<&str> {
1984 match self {
1985 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1986 Self::Active => std::option::Option::Some("ACTIVE"),
1987 Self::MskPermissionDenied => std::option::Option::Some("MSK_PERMISSION_DENIED"),
1988 Self::PublishPermissionDenied => {
1989 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1990 }
1991 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
1992 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
1993 Self::ConflictingRegionConstraints => {
1994 std::option::Option::Some("CONFLICTING_REGION_CONSTRAINTS")
1995 }
1996 Self::UnknownValue(u) => u.0.name(),
1997 }
1998 }
1999 }
2000
2001 impl std::default::Default for State {
2002 fn default() -> Self {
2003 use std::convert::From;
2004 Self::from(0)
2005 }
2006 }
2007
2008 impl std::fmt::Display for State {
2009 fn fmt(
2010 &self,
2011 f: &mut std::fmt::Formatter<'_>,
2012 ) -> std::result::Result<(), std::fmt::Error> {
2013 wkt::internal::display_enum(f, self.name(), self.value())
2014 }
2015 }
2016
2017 impl std::convert::From<i32> for State {
2018 fn from(value: i32) -> Self {
2019 match value {
2020 0 => Self::Unspecified,
2021 1 => Self::Active,
2022 2 => Self::MskPermissionDenied,
2023 3 => Self::PublishPermissionDenied,
2024 4 => Self::ClusterNotFound,
2025 5 => Self::TopicNotFound,
2026 6 => Self::ConflictingRegionConstraints,
2027 _ => Self::UnknownValue(state::UnknownValue(
2028 wkt::internal::UnknownEnumValue::Integer(value),
2029 )),
2030 }
2031 }
2032 }
2033
2034 impl std::convert::From<&str> for State {
2035 fn from(value: &str) -> Self {
2036 use std::string::ToString;
2037 match value {
2038 "STATE_UNSPECIFIED" => Self::Unspecified,
2039 "ACTIVE" => Self::Active,
2040 "MSK_PERMISSION_DENIED" => Self::MskPermissionDenied,
2041 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
2042 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
2043 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
2044 "CONFLICTING_REGION_CONSTRAINTS" => Self::ConflictingRegionConstraints,
2045 _ => Self::UnknownValue(state::UnknownValue(
2046 wkt::internal::UnknownEnumValue::String(value.to_string()),
2047 )),
2048 }
2049 }
2050 }
2051
2052 impl serde::ser::Serialize for State {
2053 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2054 where
2055 S: serde::Serializer,
2056 {
2057 match self {
2058 Self::Unspecified => serializer.serialize_i32(0),
2059 Self::Active => serializer.serialize_i32(1),
2060 Self::MskPermissionDenied => serializer.serialize_i32(2),
2061 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2062 Self::ClusterNotFound => serializer.serialize_i32(4),
2063 Self::TopicNotFound => serializer.serialize_i32(5),
2064 Self::ConflictingRegionConstraints => serializer.serialize_i32(6),
2065 Self::UnknownValue(u) => u.0.serialize(serializer),
2066 }
2067 }
2068 }
2069
2070 impl<'de> serde::de::Deserialize<'de> for State {
2071 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2072 where
2073 D: serde::Deserializer<'de>,
2074 {
2075 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2076 ".google.pubsub.v1.IngestionDataSourceSettings.AwsMsk.State",
2077 ))
2078 }
2079 }
2080 }
2081
2082 /// Ingestion settings for Confluent Cloud.
2083 #[derive(Clone, Default, PartialEq)]
2084 #[non_exhaustive]
2085 pub struct ConfluentCloud {
2086 /// Output only. An output-only field that indicates the state of the
2087 /// Confluent Cloud ingestion source.
2088 pub state: crate::model::ingestion_data_source_settings::confluent_cloud::State,
2089
2090 /// Required. The address of the bootstrap server. The format is url:port.
2091 pub bootstrap_server: std::string::String,
2092
2093 /// Required. The id of the cluster.
2094 pub cluster_id: std::string::String,
2095
2096 /// Required. The name of the topic in the Confluent Cloud cluster that
2097 /// Pub/Sub will import from.
2098 pub topic: std::string::String,
2099
2100 /// Required. The id of the identity pool to be used for Federated Identity
2101 /// authentication with Confluent Cloud. See
2102 /// <https://docs.confluent.io/cloud/current/security/authenticate/workload-identities/identity-providers/oauth/identity-pools.html#add-oauth-identity-pools>.
2103 pub identity_pool_id: std::string::String,
2104
2105 /// Required. The GCP service account to be used for Federated Identity
2106 /// authentication with `identity_pool_id`.
2107 pub gcp_service_account: std::string::String,
2108
2109 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2110 }
2111
2112 impl ConfluentCloud {
2113 /// Creates a new default instance.
2114 pub fn new() -> Self {
2115 std::default::Default::default()
2116 }
2117
2118 /// Sets the value of [state][crate::model::ingestion_data_source_settings::ConfluentCloud::state].
2119 ///
2120 /// # Example
2121 /// ```ignore,no_run
2122 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2123 /// use google_cloud_pubsub::model::ingestion_data_source_settings::confluent_cloud::State;
2124 /// let x0 = ConfluentCloud::new().set_state(State::Active);
2125 /// let x1 = ConfluentCloud::new().set_state(State::ConfluentCloudPermissionDenied);
2126 /// let x2 = ConfluentCloud::new().set_state(State::PublishPermissionDenied);
2127 /// ```
2128 pub fn set_state<
2129 T: std::convert::Into<
2130 crate::model::ingestion_data_source_settings::confluent_cloud::State,
2131 >,
2132 >(
2133 mut self,
2134 v: T,
2135 ) -> Self {
2136 self.state = v.into();
2137 self
2138 }
2139
2140 /// Sets the value of [bootstrap_server][crate::model::ingestion_data_source_settings::ConfluentCloud::bootstrap_server].
2141 ///
2142 /// # Example
2143 /// ```ignore,no_run
2144 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2145 /// let x = ConfluentCloud::new().set_bootstrap_server("example");
2146 /// ```
2147 pub fn set_bootstrap_server<T: std::convert::Into<std::string::String>>(
2148 mut self,
2149 v: T,
2150 ) -> Self {
2151 self.bootstrap_server = v.into();
2152 self
2153 }
2154
2155 /// Sets the value of [cluster_id][crate::model::ingestion_data_source_settings::ConfluentCloud::cluster_id].
2156 ///
2157 /// # Example
2158 /// ```ignore,no_run
2159 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2160 /// let x = ConfluentCloud::new().set_cluster_id("example");
2161 /// ```
2162 pub fn set_cluster_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2163 self.cluster_id = v.into();
2164 self
2165 }
2166
2167 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::ConfluentCloud::topic].
2168 ///
2169 /// # Example
2170 /// ```ignore,no_run
2171 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2172 /// let x = ConfluentCloud::new().set_topic("example");
2173 /// ```
2174 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2175 self.topic = v.into();
2176 self
2177 }
2178
2179 /// Sets the value of [identity_pool_id][crate::model::ingestion_data_source_settings::ConfluentCloud::identity_pool_id].
2180 ///
2181 /// # Example
2182 /// ```ignore,no_run
2183 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2184 /// let x = ConfluentCloud::new().set_identity_pool_id("example");
2185 /// ```
2186 pub fn set_identity_pool_id<T: std::convert::Into<std::string::String>>(
2187 mut self,
2188 v: T,
2189 ) -> Self {
2190 self.identity_pool_id = v.into();
2191 self
2192 }
2193
2194 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::ConfluentCloud::gcp_service_account].
2195 ///
2196 /// # Example
2197 /// ```ignore,no_run
2198 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2199 /// let x = ConfluentCloud::new().set_gcp_service_account("example");
2200 /// ```
2201 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
2202 mut self,
2203 v: T,
2204 ) -> Self {
2205 self.gcp_service_account = v.into();
2206 self
2207 }
2208 }
2209
2210 impl wkt::message::Message for ConfluentCloud {
2211 fn typename() -> &'static str {
2212 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud"
2213 }
2214 }
2215
2216 /// Defines additional types related to [ConfluentCloud].
2217 pub mod confluent_cloud {
2218 #[allow(unused_imports)]
2219 use super::*;
2220
2221 /// Possible states for managed ingestion from Confluent Cloud.
2222 ///
2223 /// # Working with unknown values
2224 ///
2225 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2226 /// additional enum variants at any time. Adding new variants is not considered
2227 /// a breaking change. Applications should write their code in anticipation of:
2228 ///
2229 /// - New values appearing in future releases of the client library, **and**
2230 /// - New values received dynamically, without application changes.
2231 ///
2232 /// Please consult the [Working with enums] section in the user guide for some
2233 /// guidelines.
2234 ///
2235 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2236 #[derive(Clone, Debug, PartialEq)]
2237 #[non_exhaustive]
2238 pub enum State {
2239 /// Default value. This value is unused.
2240 Unspecified,
2241 /// Ingestion is active.
2242 Active,
2243 /// Permission denied encountered while consuming data from Confluent
2244 /// Cloud.
2245 ConfluentCloudPermissionDenied,
2246 /// Permission denied encountered while publishing to the topic.
2247 PublishPermissionDenied,
2248 /// The provided bootstrap server address is unreachable.
2249 UnreachableBootstrapServer,
2250 /// The provided cluster wasn't found.
2251 ClusterNotFound,
2252 /// The provided topic wasn't found.
2253 TopicNotFound,
2254 /// Indicates an error state where the ingestion source cannot be
2255 /// processed because the selected ingestion region is not permitted
2256 /// by the Regional Access Boundary (RAB) restrictions on the project's
2257 /// service account.
2258 ConflictingRegionConstraints,
2259 /// If set, the enum was initialized with an unknown value.
2260 ///
2261 /// Applications can examine the value using [State::value] or
2262 /// [State::name].
2263 UnknownValue(state::UnknownValue),
2264 }
2265
2266 #[doc(hidden)]
2267 pub mod state {
2268 #[allow(unused_imports)]
2269 use super::*;
2270 #[derive(Clone, Debug, PartialEq)]
2271 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2272 }
2273
2274 impl State {
2275 /// Gets the enum value.
2276 ///
2277 /// Returns `None` if the enum contains an unknown value deserialized from
2278 /// the string representation of enums.
2279 pub fn value(&self) -> std::option::Option<i32> {
2280 match self {
2281 Self::Unspecified => std::option::Option::Some(0),
2282 Self::Active => std::option::Option::Some(1),
2283 Self::ConfluentCloudPermissionDenied => std::option::Option::Some(2),
2284 Self::PublishPermissionDenied => std::option::Option::Some(3),
2285 Self::UnreachableBootstrapServer => std::option::Option::Some(4),
2286 Self::ClusterNotFound => std::option::Option::Some(5),
2287 Self::TopicNotFound => std::option::Option::Some(6),
2288 Self::ConflictingRegionConstraints => std::option::Option::Some(7),
2289 Self::UnknownValue(u) => u.0.value(),
2290 }
2291 }
2292
2293 /// Gets the enum value as a string.
2294 ///
2295 /// Returns `None` if the enum contains an unknown value deserialized from
2296 /// the integer representation of enums.
2297 pub fn name(&self) -> std::option::Option<&str> {
2298 match self {
2299 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
2300 Self::Active => std::option::Option::Some("ACTIVE"),
2301 Self::ConfluentCloudPermissionDenied => {
2302 std::option::Option::Some("CONFLUENT_CLOUD_PERMISSION_DENIED")
2303 }
2304 Self::PublishPermissionDenied => {
2305 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
2306 }
2307 Self::UnreachableBootstrapServer => {
2308 std::option::Option::Some("UNREACHABLE_BOOTSTRAP_SERVER")
2309 }
2310 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
2311 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
2312 Self::ConflictingRegionConstraints => {
2313 std::option::Option::Some("CONFLICTING_REGION_CONSTRAINTS")
2314 }
2315 Self::UnknownValue(u) => u.0.name(),
2316 }
2317 }
2318 }
2319
2320 impl std::default::Default for State {
2321 fn default() -> Self {
2322 use std::convert::From;
2323 Self::from(0)
2324 }
2325 }
2326
2327 impl std::fmt::Display for State {
2328 fn fmt(
2329 &self,
2330 f: &mut std::fmt::Formatter<'_>,
2331 ) -> std::result::Result<(), std::fmt::Error> {
2332 wkt::internal::display_enum(f, self.name(), self.value())
2333 }
2334 }
2335
2336 impl std::convert::From<i32> for State {
2337 fn from(value: i32) -> Self {
2338 match value {
2339 0 => Self::Unspecified,
2340 1 => Self::Active,
2341 2 => Self::ConfluentCloudPermissionDenied,
2342 3 => Self::PublishPermissionDenied,
2343 4 => Self::UnreachableBootstrapServer,
2344 5 => Self::ClusterNotFound,
2345 6 => Self::TopicNotFound,
2346 7 => Self::ConflictingRegionConstraints,
2347 _ => Self::UnknownValue(state::UnknownValue(
2348 wkt::internal::UnknownEnumValue::Integer(value),
2349 )),
2350 }
2351 }
2352 }
2353
2354 impl std::convert::From<&str> for State {
2355 fn from(value: &str) -> Self {
2356 use std::string::ToString;
2357 match value {
2358 "STATE_UNSPECIFIED" => Self::Unspecified,
2359 "ACTIVE" => Self::Active,
2360 "CONFLUENT_CLOUD_PERMISSION_DENIED" => Self::ConfluentCloudPermissionDenied,
2361 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
2362 "UNREACHABLE_BOOTSTRAP_SERVER" => Self::UnreachableBootstrapServer,
2363 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
2364 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
2365 "CONFLICTING_REGION_CONSTRAINTS" => Self::ConflictingRegionConstraints,
2366 _ => Self::UnknownValue(state::UnknownValue(
2367 wkt::internal::UnknownEnumValue::String(value.to_string()),
2368 )),
2369 }
2370 }
2371 }
2372
2373 impl serde::ser::Serialize for State {
2374 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2375 where
2376 S: serde::Serializer,
2377 {
2378 match self {
2379 Self::Unspecified => serializer.serialize_i32(0),
2380 Self::Active => serializer.serialize_i32(1),
2381 Self::ConfluentCloudPermissionDenied => serializer.serialize_i32(2),
2382 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2383 Self::UnreachableBootstrapServer => serializer.serialize_i32(4),
2384 Self::ClusterNotFound => serializer.serialize_i32(5),
2385 Self::TopicNotFound => serializer.serialize_i32(6),
2386 Self::ConflictingRegionConstraints => serializer.serialize_i32(7),
2387 Self::UnknownValue(u) => u.0.serialize(serializer),
2388 }
2389 }
2390 }
2391
2392 impl<'de> serde::de::Deserialize<'de> for State {
2393 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2394 where
2395 D: serde::Deserializer<'de>,
2396 {
2397 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2398 ".google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud.State",
2399 ))
2400 }
2401 }
2402 }
2403
2404 /// Only one source type can have settings set.
2405 #[derive(Clone, Debug, PartialEq)]
2406 #[non_exhaustive]
2407 pub enum Source {
2408 /// Optional. Amazon Kinesis Data Streams.
2409 AwsKinesis(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>),
2410 /// Optional. Cloud Storage.
2411 CloudStorage(std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>),
2412 /// Optional. Azure Event Hubs.
2413 AzureEventHubs(
2414 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
2415 ),
2416 /// Optional. Amazon MSK.
2417 AwsMsk(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>),
2418 /// Optional. Confluent Cloud.
2419 ConfluentCloud(
2420 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
2421 ),
2422 }
2423}
2424
2425/// Settings for Platform Logs produced by Pub/Sub.
2426#[derive(Clone, Default, PartialEq)]
2427#[non_exhaustive]
2428pub struct PlatformLogsSettings {
2429 /// Optional. The minimum severity level of Platform Logs that will be written.
2430 pub severity: crate::model::platform_logs_settings::Severity,
2431
2432 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2433}
2434
2435impl PlatformLogsSettings {
2436 /// Creates a new default instance.
2437 pub fn new() -> Self {
2438 std::default::Default::default()
2439 }
2440
2441 /// Sets the value of [severity][crate::model::PlatformLogsSettings::severity].
2442 ///
2443 /// # Example
2444 /// ```ignore,no_run
2445 /// # use google_cloud_pubsub::model::PlatformLogsSettings;
2446 /// use google_cloud_pubsub::model::platform_logs_settings::Severity;
2447 /// let x0 = PlatformLogsSettings::new().set_severity(Severity::Disabled);
2448 /// let x1 = PlatformLogsSettings::new().set_severity(Severity::Debug);
2449 /// let x2 = PlatformLogsSettings::new().set_severity(Severity::Info);
2450 /// ```
2451 pub fn set_severity<T: std::convert::Into<crate::model::platform_logs_settings::Severity>>(
2452 mut self,
2453 v: T,
2454 ) -> Self {
2455 self.severity = v.into();
2456 self
2457 }
2458}
2459
2460impl wkt::message::Message for PlatformLogsSettings {
2461 fn typename() -> &'static str {
2462 "type.googleapis.com/google.pubsub.v1.PlatformLogsSettings"
2463 }
2464}
2465
2466/// Defines additional types related to [PlatformLogsSettings].
2467pub mod platform_logs_settings {
2468 #[allow(unused_imports)]
2469 use super::*;
2470
2471 /// Severity levels of Platform Logs.
2472 ///
2473 /// # Working with unknown values
2474 ///
2475 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2476 /// additional enum variants at any time. Adding new variants is not considered
2477 /// a breaking change. Applications should write their code in anticipation of:
2478 ///
2479 /// - New values appearing in future releases of the client library, **and**
2480 /// - New values received dynamically, without application changes.
2481 ///
2482 /// Please consult the [Working with enums] section in the user guide for some
2483 /// guidelines.
2484 ///
2485 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2486 #[derive(Clone, Debug, PartialEq)]
2487 #[non_exhaustive]
2488 pub enum Severity {
2489 /// Default value. Logs level is unspecified. Logs will be disabled.
2490 Unspecified,
2491 /// Logs will be disabled.
2492 Disabled,
2493 /// Debug logs and higher-severity logs will be written.
2494 Debug,
2495 /// Info logs and higher-severity logs will be written.
2496 Info,
2497 /// Warning logs and higher-severity logs will be written.
2498 Warning,
2499 /// Only error logs will be written.
2500 Error,
2501 /// If set, the enum was initialized with an unknown value.
2502 ///
2503 /// Applications can examine the value using [Severity::value] or
2504 /// [Severity::name].
2505 UnknownValue(severity::UnknownValue),
2506 }
2507
2508 #[doc(hidden)]
2509 pub mod severity {
2510 #[allow(unused_imports)]
2511 use super::*;
2512 #[derive(Clone, Debug, PartialEq)]
2513 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2514 }
2515
2516 impl Severity {
2517 /// Gets the enum value.
2518 ///
2519 /// Returns `None` if the enum contains an unknown value deserialized from
2520 /// the string representation of enums.
2521 pub fn value(&self) -> std::option::Option<i32> {
2522 match self {
2523 Self::Unspecified => std::option::Option::Some(0),
2524 Self::Disabled => std::option::Option::Some(1),
2525 Self::Debug => std::option::Option::Some(2),
2526 Self::Info => std::option::Option::Some(3),
2527 Self::Warning => std::option::Option::Some(4),
2528 Self::Error => std::option::Option::Some(5),
2529 Self::UnknownValue(u) => u.0.value(),
2530 }
2531 }
2532
2533 /// Gets the enum value as a string.
2534 ///
2535 /// Returns `None` if the enum contains an unknown value deserialized from
2536 /// the integer representation of enums.
2537 pub fn name(&self) -> std::option::Option<&str> {
2538 match self {
2539 Self::Unspecified => std::option::Option::Some("SEVERITY_UNSPECIFIED"),
2540 Self::Disabled => std::option::Option::Some("DISABLED"),
2541 Self::Debug => std::option::Option::Some("DEBUG"),
2542 Self::Info => std::option::Option::Some("INFO"),
2543 Self::Warning => std::option::Option::Some("WARNING"),
2544 Self::Error => std::option::Option::Some("ERROR"),
2545 Self::UnknownValue(u) => u.0.name(),
2546 }
2547 }
2548 }
2549
2550 impl std::default::Default for Severity {
2551 fn default() -> Self {
2552 use std::convert::From;
2553 Self::from(0)
2554 }
2555 }
2556
2557 impl std::fmt::Display for Severity {
2558 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2559 wkt::internal::display_enum(f, self.name(), self.value())
2560 }
2561 }
2562
2563 impl std::convert::From<i32> for Severity {
2564 fn from(value: i32) -> Self {
2565 match value {
2566 0 => Self::Unspecified,
2567 1 => Self::Disabled,
2568 2 => Self::Debug,
2569 3 => Self::Info,
2570 4 => Self::Warning,
2571 5 => Self::Error,
2572 _ => Self::UnknownValue(severity::UnknownValue(
2573 wkt::internal::UnknownEnumValue::Integer(value),
2574 )),
2575 }
2576 }
2577 }
2578
2579 impl std::convert::From<&str> for Severity {
2580 fn from(value: &str) -> Self {
2581 use std::string::ToString;
2582 match value {
2583 "SEVERITY_UNSPECIFIED" => Self::Unspecified,
2584 "DISABLED" => Self::Disabled,
2585 "DEBUG" => Self::Debug,
2586 "INFO" => Self::Info,
2587 "WARNING" => Self::Warning,
2588 "ERROR" => Self::Error,
2589 _ => Self::UnknownValue(severity::UnknownValue(
2590 wkt::internal::UnknownEnumValue::String(value.to_string()),
2591 )),
2592 }
2593 }
2594 }
2595
2596 impl serde::ser::Serialize for Severity {
2597 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2598 where
2599 S: serde::Serializer,
2600 {
2601 match self {
2602 Self::Unspecified => serializer.serialize_i32(0),
2603 Self::Disabled => serializer.serialize_i32(1),
2604 Self::Debug => serializer.serialize_i32(2),
2605 Self::Info => serializer.serialize_i32(3),
2606 Self::Warning => serializer.serialize_i32(4),
2607 Self::Error => serializer.serialize_i32(5),
2608 Self::UnknownValue(u) => u.0.serialize(serializer),
2609 }
2610 }
2611 }
2612
2613 impl<'de> serde::de::Deserialize<'de> for Severity {
2614 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2615 where
2616 D: serde::Deserializer<'de>,
2617 {
2618 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Severity>::new(
2619 ".google.pubsub.v1.PlatformLogsSettings.Severity",
2620 ))
2621 }
2622 }
2623}
2624
2625/// User-defined JavaScript function that can transform or filter a Pub/Sub
2626/// message.
2627#[derive(Clone, Default, PartialEq)]
2628#[non_exhaustive]
2629pub struct JavaScriptUDF {
2630 /// Required. Name of the JavasScript function that should applied to Pub/Sub
2631 /// messages.
2632 pub function_name: std::string::String,
2633
2634 /// Required. JavaScript code that contains a function `function_name` with the
2635 /// below signature:
2636 ///
2637 /// ```norust
2638 /// /**
2639 /// * Transforms a Pub/Sub message.
2640 ///
2641 /// * @return {(Object<string, (string | Object<string, string>)>|null)} - To
2642 /// * filter a message, return `null`. To transform a message return a map
2643 /// * with the following keys:
2644 /// * - (required) 'data' : {string}
2645 /// * - (optional) 'attributes' : {Object<string, string>}
2646 /// * Returning empty `attributes` will remove all attributes from the
2647 /// * message.
2648 /// *
2649 /// * @param {(Object<string, (string | Object<string, string>)>} Pub/Sub
2650 /// * message. Keys:
2651 /// * - (required) 'data' : {string}
2652 /// * - (required) 'attributes' : {Object<string, string>}
2653 /// *
2654 /// * @param {Object<string, any>} metadata - Pub/Sub message metadata.
2655 /// * Keys:
2656 /// * - (optional) 'message_id' : {string}
2657 /// * - (optional) 'publish_time': {string} YYYY-MM-DDTHH:MM:SSZ format
2658 /// * - (optional) 'ordering_key': {string}
2659 /// */
2660 ///
2661 /// function <function_name>(message, metadata) {
2662 /// }
2663 /// ```
2664 pub code: std::string::String,
2665
2666 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2667}
2668
2669impl JavaScriptUDF {
2670 /// Creates a new default instance.
2671 pub fn new() -> Self {
2672 std::default::Default::default()
2673 }
2674
2675 /// Sets the value of [function_name][crate::model::JavaScriptUDF::function_name].
2676 ///
2677 /// # Example
2678 /// ```ignore,no_run
2679 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2680 /// let x = JavaScriptUDF::new().set_function_name("example");
2681 /// ```
2682 pub fn set_function_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2683 self.function_name = v.into();
2684 self
2685 }
2686
2687 /// Sets the value of [code][crate::model::JavaScriptUDF::code].
2688 ///
2689 /// # Example
2690 /// ```ignore,no_run
2691 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2692 /// let x = JavaScriptUDF::new().set_code("example");
2693 /// ```
2694 pub fn set_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2695 self.code = v.into();
2696 self
2697 }
2698}
2699
2700impl wkt::message::Message for JavaScriptUDF {
2701 fn typename() -> &'static str {
2702 "type.googleapis.com/google.pubsub.v1.JavaScriptUDF"
2703 }
2704}
2705
2706/// Configuration for compressing/decompressing message data using a
2707/// user-specified compression algorithm.
2708#[derive(Clone, Default, PartialEq)]
2709#[non_exhaustive]
2710pub struct Compression {
2711 /// Required. Specifies the compression algorithm to use.
2712 pub compression_algorithm: crate::model::compression::CompressionAlgorithm,
2713
2714 /// Required. Specifies whether to compress or decompress the message.
2715 pub compression_mode: crate::model::compression::CompressionMode,
2716
2717 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2718}
2719
2720impl Compression {
2721 /// Creates a new default instance.
2722 pub fn new() -> Self {
2723 std::default::Default::default()
2724 }
2725
2726 /// Sets the value of [compression_algorithm][crate::model::Compression::compression_algorithm].
2727 ///
2728 /// # Example
2729 /// ```ignore,no_run
2730 /// # use google_cloud_pubsub::model::Compression;
2731 /// use google_cloud_pubsub::model::compression::CompressionAlgorithm;
2732 /// let x0 = Compression::new().set_compression_algorithm(CompressionAlgorithm::Zlib);
2733 /// ```
2734 pub fn set_compression_algorithm<
2735 T: std::convert::Into<crate::model::compression::CompressionAlgorithm>,
2736 >(
2737 mut self,
2738 v: T,
2739 ) -> Self {
2740 self.compression_algorithm = v.into();
2741 self
2742 }
2743
2744 /// Sets the value of [compression_mode][crate::model::Compression::compression_mode].
2745 ///
2746 /// # Example
2747 /// ```ignore,no_run
2748 /// # use google_cloud_pubsub::model::Compression;
2749 /// use google_cloud_pubsub::model::compression::CompressionMode;
2750 /// let x0 = Compression::new().set_compression_mode(CompressionMode::Compress);
2751 /// let x1 = Compression::new().set_compression_mode(CompressionMode::Decompress);
2752 /// ```
2753 pub fn set_compression_mode<
2754 T: std::convert::Into<crate::model::compression::CompressionMode>,
2755 >(
2756 mut self,
2757 v: T,
2758 ) -> Self {
2759 self.compression_mode = v.into();
2760 self
2761 }
2762}
2763
2764impl wkt::message::Message for Compression {
2765 fn typename() -> &'static str {
2766 "type.googleapis.com/google.pubsub.v1.Compression"
2767 }
2768}
2769
2770/// Defines additional types related to [Compression].
2771pub mod compression {
2772 #[allow(unused_imports)]
2773 use super::*;
2774
2775 /// The compression algorithm to use.
2776 ///
2777 /// # Working with unknown values
2778 ///
2779 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2780 /// additional enum variants at any time. Adding new variants is not considered
2781 /// a breaking change. Applications should write their code in anticipation of:
2782 ///
2783 /// - New values appearing in future releases of the client library, **and**
2784 /// - New values received dynamically, without application changes.
2785 ///
2786 /// Please consult the [Working with enums] section in the user guide for some
2787 /// guidelines.
2788 ///
2789 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2790 #[derive(Clone, Debug, PartialEq)]
2791 #[non_exhaustive]
2792 pub enum CompressionAlgorithm {
2793 /// Unspecified algorithm.
2794 Unspecified,
2795 /// ZLIB compression.
2796 Zlib,
2797 /// If set, the enum was initialized with an unknown value.
2798 ///
2799 /// Applications can examine the value using [CompressionAlgorithm::value] or
2800 /// [CompressionAlgorithm::name].
2801 UnknownValue(compression_algorithm::UnknownValue),
2802 }
2803
2804 #[doc(hidden)]
2805 pub mod compression_algorithm {
2806 #[allow(unused_imports)]
2807 use super::*;
2808 #[derive(Clone, Debug, PartialEq)]
2809 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2810 }
2811
2812 impl CompressionAlgorithm {
2813 /// Gets the enum value.
2814 ///
2815 /// Returns `None` if the enum contains an unknown value deserialized from
2816 /// the string representation of enums.
2817 pub fn value(&self) -> std::option::Option<i32> {
2818 match self {
2819 Self::Unspecified => std::option::Option::Some(0),
2820 Self::Zlib => std::option::Option::Some(1),
2821 Self::UnknownValue(u) => u.0.value(),
2822 }
2823 }
2824
2825 /// Gets the enum value as a string.
2826 ///
2827 /// Returns `None` if the enum contains an unknown value deserialized from
2828 /// the integer representation of enums.
2829 pub fn name(&self) -> std::option::Option<&str> {
2830 match self {
2831 Self::Unspecified => std::option::Option::Some("COMPRESSION_ALGORITHM_UNSPECIFIED"),
2832 Self::Zlib => std::option::Option::Some("ZLIB"),
2833 Self::UnknownValue(u) => u.0.name(),
2834 }
2835 }
2836 }
2837
2838 impl std::default::Default for CompressionAlgorithm {
2839 fn default() -> Self {
2840 use std::convert::From;
2841 Self::from(0)
2842 }
2843 }
2844
2845 impl std::fmt::Display for CompressionAlgorithm {
2846 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2847 wkt::internal::display_enum(f, self.name(), self.value())
2848 }
2849 }
2850
2851 impl std::convert::From<i32> for CompressionAlgorithm {
2852 fn from(value: i32) -> Self {
2853 match value {
2854 0 => Self::Unspecified,
2855 1 => Self::Zlib,
2856 _ => Self::UnknownValue(compression_algorithm::UnknownValue(
2857 wkt::internal::UnknownEnumValue::Integer(value),
2858 )),
2859 }
2860 }
2861 }
2862
2863 impl std::convert::From<&str> for CompressionAlgorithm {
2864 fn from(value: &str) -> Self {
2865 use std::string::ToString;
2866 match value {
2867 "COMPRESSION_ALGORITHM_UNSPECIFIED" => Self::Unspecified,
2868 "ZLIB" => Self::Zlib,
2869 _ => Self::UnknownValue(compression_algorithm::UnknownValue(
2870 wkt::internal::UnknownEnumValue::String(value.to_string()),
2871 )),
2872 }
2873 }
2874 }
2875
2876 impl serde::ser::Serialize for CompressionAlgorithm {
2877 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2878 where
2879 S: serde::Serializer,
2880 {
2881 match self {
2882 Self::Unspecified => serializer.serialize_i32(0),
2883 Self::Zlib => serializer.serialize_i32(1),
2884 Self::UnknownValue(u) => u.0.serialize(serializer),
2885 }
2886 }
2887 }
2888
2889 impl<'de> serde::de::Deserialize<'de> for CompressionAlgorithm {
2890 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2891 where
2892 D: serde::Deserializer<'de>,
2893 {
2894 deserializer.deserialize_any(wkt::internal::EnumVisitor::<CompressionAlgorithm>::new(
2895 ".google.pubsub.v1.Compression.CompressionAlgorithm",
2896 ))
2897 }
2898 }
2899
2900 /// The mode of the compression SMT.
2901 ///
2902 /// # Working with unknown values
2903 ///
2904 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2905 /// additional enum variants at any time. Adding new variants is not considered
2906 /// a breaking change. Applications should write their code in anticipation of:
2907 ///
2908 /// - New values appearing in future releases of the client library, **and**
2909 /// - New values received dynamically, without application changes.
2910 ///
2911 /// Please consult the [Working with enums] section in the user guide for some
2912 /// guidelines.
2913 ///
2914 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2915 #[derive(Clone, Debug, PartialEq)]
2916 #[non_exhaustive]
2917 pub enum CompressionMode {
2918 /// Unspecified mode.
2919 Unspecified,
2920 /// Compress.
2921 Compress,
2922 /// Decompress.
2923 Decompress,
2924 /// If set, the enum was initialized with an unknown value.
2925 ///
2926 /// Applications can examine the value using [CompressionMode::value] or
2927 /// [CompressionMode::name].
2928 UnknownValue(compression_mode::UnknownValue),
2929 }
2930
2931 #[doc(hidden)]
2932 pub mod compression_mode {
2933 #[allow(unused_imports)]
2934 use super::*;
2935 #[derive(Clone, Debug, PartialEq)]
2936 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2937 }
2938
2939 impl CompressionMode {
2940 /// Gets the enum value.
2941 ///
2942 /// Returns `None` if the enum contains an unknown value deserialized from
2943 /// the string representation of enums.
2944 pub fn value(&self) -> std::option::Option<i32> {
2945 match self {
2946 Self::Unspecified => std::option::Option::Some(0),
2947 Self::Compress => std::option::Option::Some(1),
2948 Self::Decompress => std::option::Option::Some(2),
2949 Self::UnknownValue(u) => u.0.value(),
2950 }
2951 }
2952
2953 /// Gets the enum value as a string.
2954 ///
2955 /// Returns `None` if the enum contains an unknown value deserialized from
2956 /// the integer representation of enums.
2957 pub fn name(&self) -> std::option::Option<&str> {
2958 match self {
2959 Self::Unspecified => std::option::Option::Some("COMPRESSION_MODE_UNSPECIFIED"),
2960 Self::Compress => std::option::Option::Some("COMPRESS"),
2961 Self::Decompress => std::option::Option::Some("DECOMPRESS"),
2962 Self::UnknownValue(u) => u.0.name(),
2963 }
2964 }
2965 }
2966
2967 impl std::default::Default for CompressionMode {
2968 fn default() -> Self {
2969 use std::convert::From;
2970 Self::from(0)
2971 }
2972 }
2973
2974 impl std::fmt::Display for CompressionMode {
2975 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2976 wkt::internal::display_enum(f, self.name(), self.value())
2977 }
2978 }
2979
2980 impl std::convert::From<i32> for CompressionMode {
2981 fn from(value: i32) -> Self {
2982 match value {
2983 0 => Self::Unspecified,
2984 1 => Self::Compress,
2985 2 => Self::Decompress,
2986 _ => Self::UnknownValue(compression_mode::UnknownValue(
2987 wkt::internal::UnknownEnumValue::Integer(value),
2988 )),
2989 }
2990 }
2991 }
2992
2993 impl std::convert::From<&str> for CompressionMode {
2994 fn from(value: &str) -> Self {
2995 use std::string::ToString;
2996 match value {
2997 "COMPRESSION_MODE_UNSPECIFIED" => Self::Unspecified,
2998 "COMPRESS" => Self::Compress,
2999 "DECOMPRESS" => Self::Decompress,
3000 _ => Self::UnknownValue(compression_mode::UnknownValue(
3001 wkt::internal::UnknownEnumValue::String(value.to_string()),
3002 )),
3003 }
3004 }
3005 }
3006
3007 impl serde::ser::Serialize for CompressionMode {
3008 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3009 where
3010 S: serde::Serializer,
3011 {
3012 match self {
3013 Self::Unspecified => serializer.serialize_i32(0),
3014 Self::Compress => serializer.serialize_i32(1),
3015 Self::Decompress => serializer.serialize_i32(2),
3016 Self::UnknownValue(u) => u.0.serialize(serializer),
3017 }
3018 }
3019 }
3020
3021 impl<'de> serde::de::Deserialize<'de> for CompressionMode {
3022 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3023 where
3024 D: serde::Deserializer<'de>,
3025 {
3026 deserializer.deserialize_any(wkt::internal::EnumVisitor::<CompressionMode>::new(
3027 ".google.pubsub.v1.Compression.CompressionMode",
3028 ))
3029 }
3030 }
3031}
3032
3033/// Configuration for making inference requests against Vertex AI models.
3034#[derive(Clone, Default, PartialEq)]
3035#[non_exhaustive]
3036pub struct AIInference {
3037 /// Required. An endpoint to a Vertex AI model of the form
3038 /// `projects/{project}/locations/{location}/endpoints/{endpoint}` or
3039 /// `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`.
3040 /// Vertex AI API requests will be sent to this endpoint.
3041 pub endpoint: std::string::String,
3042
3043 /// Optional. The service account to use to make prediction requests against
3044 /// endpoints. The resource creator or updater that specifies this field must
3045 /// have `iam.serviceAccounts.actAs` permission on the service account. If not
3046 /// specified, the Pub/Sub [service
3047 /// agent](https://cloud.google.com/iam/docs/service-agents),
3048 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
3049 pub service_account_email: std::string::String,
3050
3051 /// The format of inference requests made to the endpoint.
3052 pub inference_mode: std::option::Option<crate::model::ai_inference::InferenceMode>,
3053
3054 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3055}
3056
3057impl AIInference {
3058 /// Creates a new default instance.
3059 pub fn new() -> Self {
3060 std::default::Default::default()
3061 }
3062
3063 /// Sets the value of [endpoint][crate::model::AIInference::endpoint].
3064 ///
3065 /// # Example
3066 /// ```ignore,no_run
3067 /// # use google_cloud_pubsub::model::AIInference;
3068 /// let x = AIInference::new().set_endpoint("example");
3069 /// ```
3070 pub fn set_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3071 self.endpoint = v.into();
3072 self
3073 }
3074
3075 /// Sets the value of [service_account_email][crate::model::AIInference::service_account_email].
3076 ///
3077 /// # Example
3078 /// ```ignore,no_run
3079 /// # use google_cloud_pubsub::model::AIInference;
3080 /// let x = AIInference::new().set_service_account_email("example");
3081 /// ```
3082 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
3083 mut self,
3084 v: T,
3085 ) -> Self {
3086 self.service_account_email = v.into();
3087 self
3088 }
3089
3090 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode].
3091 ///
3092 /// Note that all the setters affecting `inference_mode` are mutually
3093 /// exclusive.
3094 ///
3095 /// # Example
3096 /// ```ignore,no_run
3097 /// # use google_cloud_pubsub::model::AIInference;
3098 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
3099 /// let x = AIInference::new().set_inference_mode(Some(
3100 /// google_cloud_pubsub::model::ai_inference::InferenceMode::UnstructuredInference(UnstructuredInference::default().into())));
3101 /// ```
3102 pub fn set_inference_mode<
3103 T: std::convert::Into<std::option::Option<crate::model::ai_inference::InferenceMode>>,
3104 >(
3105 mut self,
3106 v: T,
3107 ) -> Self {
3108 self.inference_mode = v.into();
3109 self
3110 }
3111
3112 /// The value of [inference_mode][crate::model::AIInference::inference_mode]
3113 /// if it holds a `UnstructuredInference`, `None` if the field is not set or
3114 /// holds a different branch.
3115 pub fn unstructured_inference(
3116 &self,
3117 ) -> std::option::Option<&std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>
3118 {
3119 #[allow(unreachable_patterns)]
3120 self.inference_mode.as_ref().and_then(|v| match v {
3121 crate::model::ai_inference::InferenceMode::UnstructuredInference(v) => {
3122 std::option::Option::Some(v)
3123 }
3124 _ => std::option::Option::None,
3125 })
3126 }
3127
3128 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode]
3129 /// to hold a `UnstructuredInference`.
3130 ///
3131 /// Note that all the setters affecting `inference_mode` are
3132 /// mutually exclusive.
3133 ///
3134 /// # Example
3135 /// ```ignore,no_run
3136 /// # use google_cloud_pubsub::model::AIInference;
3137 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
3138 /// let x = AIInference::new().set_unstructured_inference(UnstructuredInference::default()/* use setters */);
3139 /// assert!(x.unstructured_inference().is_some());
3140 /// ```
3141 pub fn set_unstructured_inference<
3142 T: std::convert::Into<std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>,
3143 >(
3144 mut self,
3145 v: T,
3146 ) -> Self {
3147 self.inference_mode = std::option::Option::Some(
3148 crate::model::ai_inference::InferenceMode::UnstructuredInference(v.into()),
3149 );
3150 self
3151 }
3152}
3153
3154impl wkt::message::Message for AIInference {
3155 fn typename() -> &'static str {
3156 "type.googleapis.com/google.pubsub.v1.AIInference"
3157 }
3158}
3159
3160/// Defines additional types related to [AIInference].
3161pub mod ai_inference {
3162 #[allow(unused_imports)]
3163 use super::*;
3164
3165 /// Configuration for making inferences using arbitrary JSON payloads.
3166 #[derive(Clone, Default, PartialEq)]
3167 #[non_exhaustive]
3168 pub struct UnstructuredInference {
3169 /// Optional. A parameters object to be included in each inference request.
3170 /// The parameters object is combined with the data field of the Pub/Sub
3171 /// message to form the inference request.
3172 pub parameters: std::option::Option<wkt::Struct>,
3173
3174 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3175 }
3176
3177 impl UnstructuredInference {
3178 /// Creates a new default instance.
3179 pub fn new() -> Self {
3180 std::default::Default::default()
3181 }
3182
3183 /// Sets the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
3184 ///
3185 /// # Example
3186 /// ```ignore,no_run
3187 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
3188 /// use wkt::Struct;
3189 /// let x = UnstructuredInference::new().set_parameters(Struct::default()/* use setters */);
3190 /// ```
3191 pub fn set_parameters<T>(mut self, v: T) -> Self
3192 where
3193 T: std::convert::Into<wkt::Struct>,
3194 {
3195 self.parameters = std::option::Option::Some(v.into());
3196 self
3197 }
3198
3199 /// Sets or clears the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
3200 ///
3201 /// # Example
3202 /// ```ignore,no_run
3203 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
3204 /// use wkt::Struct;
3205 /// let x = UnstructuredInference::new().set_or_clear_parameters(Some(Struct::default()/* use setters */));
3206 /// let x = UnstructuredInference::new().set_or_clear_parameters(None::<Struct>);
3207 /// ```
3208 pub fn set_or_clear_parameters<T>(mut self, v: std::option::Option<T>) -> Self
3209 where
3210 T: std::convert::Into<wkt::Struct>,
3211 {
3212 self.parameters = v.map(|x| x.into());
3213 self
3214 }
3215 }
3216
3217 impl wkt::message::Message for UnstructuredInference {
3218 fn typename() -> &'static str {
3219 "type.googleapis.com/google.pubsub.v1.AIInference.UnstructuredInference"
3220 }
3221 }
3222
3223 /// The format of inference requests made to the endpoint.
3224 #[derive(Clone, Debug, PartialEq)]
3225 #[non_exhaustive]
3226 pub enum InferenceMode {
3227 /// Optional. Requests and responses can be any arbitrary JSON object.
3228 UnstructuredInference(std::boxed::Box<crate::model::ai_inference::UnstructuredInference>),
3229 }
3230}
3231
3232/// All supported message transforms types.
3233#[derive(Clone, Default, PartialEq)]
3234#[non_exhaustive]
3235pub struct MessageTransform {
3236 /// Optional. This field is deprecated, use the `disabled` field to disable
3237 /// transforms.
3238 #[deprecated]
3239 pub enabled: bool,
3240
3241 /// Optional. If true, the transform is disabled and will not be applied to
3242 /// messages. Defaults to `false`.
3243 pub disabled: bool,
3244
3245 /// The type of transform to apply to messages.
3246 pub transform: std::option::Option<crate::model::message_transform::Transform>,
3247
3248 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3249}
3250
3251impl MessageTransform {
3252 /// Creates a new default instance.
3253 pub fn new() -> Self {
3254 std::default::Default::default()
3255 }
3256
3257 /// Sets the value of [enabled][crate::model::MessageTransform::enabled].
3258 ///
3259 /// # Example
3260 /// ```ignore,no_run
3261 /// # use google_cloud_pubsub::model::MessageTransform;
3262 /// let x = MessageTransform::new().set_enabled(true);
3263 /// ```
3264 #[deprecated]
3265 pub fn set_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3266 self.enabled = v.into();
3267 self
3268 }
3269
3270 /// Sets the value of [disabled][crate::model::MessageTransform::disabled].
3271 ///
3272 /// # Example
3273 /// ```ignore,no_run
3274 /// # use google_cloud_pubsub::model::MessageTransform;
3275 /// let x = MessageTransform::new().set_disabled(true);
3276 /// ```
3277 pub fn set_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3278 self.disabled = v.into();
3279 self
3280 }
3281
3282 /// Sets the value of [transform][crate::model::MessageTransform::transform].
3283 ///
3284 /// Note that all the setters affecting `transform` are mutually
3285 /// exclusive.
3286 ///
3287 /// # Example
3288 /// ```ignore,no_run
3289 /// # use google_cloud_pubsub::model::MessageTransform;
3290 /// use google_cloud_pubsub::model::JavaScriptUDF;
3291 /// let x = MessageTransform::new().set_transform(Some(
3292 /// google_cloud_pubsub::model::message_transform::Transform::JavascriptUdf(JavaScriptUDF::default().into())));
3293 /// ```
3294 pub fn set_transform<
3295 T: std::convert::Into<std::option::Option<crate::model::message_transform::Transform>>,
3296 >(
3297 mut self,
3298 v: T,
3299 ) -> Self {
3300 self.transform = v.into();
3301 self
3302 }
3303
3304 /// The value of [transform][crate::model::MessageTransform::transform]
3305 /// if it holds a `JavascriptUdf`, `None` if the field is not set or
3306 /// holds a different branch.
3307 pub fn javascript_udf(
3308 &self,
3309 ) -> std::option::Option<&std::boxed::Box<crate::model::JavaScriptUDF>> {
3310 #[allow(unreachable_patterns)]
3311 self.transform.as_ref().and_then(|v| match v {
3312 crate::model::message_transform::Transform::JavascriptUdf(v) => {
3313 std::option::Option::Some(v)
3314 }
3315 _ => std::option::Option::None,
3316 })
3317 }
3318
3319 /// Sets the value of [transform][crate::model::MessageTransform::transform]
3320 /// to hold a `JavascriptUdf`.
3321 ///
3322 /// Note that all the setters affecting `transform` are
3323 /// mutually exclusive.
3324 ///
3325 /// # Example
3326 /// ```ignore,no_run
3327 /// # use google_cloud_pubsub::model::MessageTransform;
3328 /// use google_cloud_pubsub::model::JavaScriptUDF;
3329 /// let x = MessageTransform::new().set_javascript_udf(JavaScriptUDF::default()/* use setters */);
3330 /// assert!(x.javascript_udf().is_some());
3331 /// assert!(x.compression().is_none());
3332 /// assert!(x.ai_inference().is_none());
3333 /// ```
3334 pub fn set_javascript_udf<
3335 T: std::convert::Into<std::boxed::Box<crate::model::JavaScriptUDF>>,
3336 >(
3337 mut self,
3338 v: T,
3339 ) -> Self {
3340 self.transform = std::option::Option::Some(
3341 crate::model::message_transform::Transform::JavascriptUdf(v.into()),
3342 );
3343 self
3344 }
3345
3346 /// The value of [transform][crate::model::MessageTransform::transform]
3347 /// if it holds a `Compression`, `None` if the field is not set or
3348 /// holds a different branch.
3349 pub fn compression(&self) -> std::option::Option<&std::boxed::Box<crate::model::Compression>> {
3350 #[allow(unreachable_patterns)]
3351 self.transform.as_ref().and_then(|v| match v {
3352 crate::model::message_transform::Transform::Compression(v) => {
3353 std::option::Option::Some(v)
3354 }
3355 _ => std::option::Option::None,
3356 })
3357 }
3358
3359 /// Sets the value of [transform][crate::model::MessageTransform::transform]
3360 /// to hold a `Compression`.
3361 ///
3362 /// Note that all the setters affecting `transform` are
3363 /// mutually exclusive.
3364 ///
3365 /// # Example
3366 /// ```ignore,no_run
3367 /// # use google_cloud_pubsub::model::MessageTransform;
3368 /// use google_cloud_pubsub::model::Compression;
3369 /// let x = MessageTransform::new().set_compression(Compression::default()/* use setters */);
3370 /// assert!(x.compression().is_some());
3371 /// assert!(x.javascript_udf().is_none());
3372 /// assert!(x.ai_inference().is_none());
3373 /// ```
3374 pub fn set_compression<T: std::convert::Into<std::boxed::Box<crate::model::Compression>>>(
3375 mut self,
3376 v: T,
3377 ) -> Self {
3378 self.transform = std::option::Option::Some(
3379 crate::model::message_transform::Transform::Compression(v.into()),
3380 );
3381 self
3382 }
3383
3384 /// The value of [transform][crate::model::MessageTransform::transform]
3385 /// if it holds a `AiInference`, `None` if the field is not set or
3386 /// holds a different branch.
3387 pub fn ai_inference(&self) -> std::option::Option<&std::boxed::Box<crate::model::AIInference>> {
3388 #[allow(unreachable_patterns)]
3389 self.transform.as_ref().and_then(|v| match v {
3390 crate::model::message_transform::Transform::AiInference(v) => {
3391 std::option::Option::Some(v)
3392 }
3393 _ => std::option::Option::None,
3394 })
3395 }
3396
3397 /// Sets the value of [transform][crate::model::MessageTransform::transform]
3398 /// to hold a `AiInference`.
3399 ///
3400 /// Note that all the setters affecting `transform` are
3401 /// mutually exclusive.
3402 ///
3403 /// # Example
3404 /// ```ignore,no_run
3405 /// # use google_cloud_pubsub::model::MessageTransform;
3406 /// use google_cloud_pubsub::model::AIInference;
3407 /// let x = MessageTransform::new().set_ai_inference(AIInference::default()/* use setters */);
3408 /// assert!(x.ai_inference().is_some());
3409 /// assert!(x.javascript_udf().is_none());
3410 /// assert!(x.compression().is_none());
3411 /// ```
3412 pub fn set_ai_inference<T: std::convert::Into<std::boxed::Box<crate::model::AIInference>>>(
3413 mut self,
3414 v: T,
3415 ) -> Self {
3416 self.transform = std::option::Option::Some(
3417 crate::model::message_transform::Transform::AiInference(v.into()),
3418 );
3419 self
3420 }
3421}
3422
3423impl wkt::message::Message for MessageTransform {
3424 fn typename() -> &'static str {
3425 "type.googleapis.com/google.pubsub.v1.MessageTransform"
3426 }
3427}
3428
3429/// Defines additional types related to [MessageTransform].
3430pub mod message_transform {
3431 #[allow(unused_imports)]
3432 use super::*;
3433
3434 /// The type of transform to apply to messages.
3435 #[derive(Clone, Debug, PartialEq)]
3436 #[non_exhaustive]
3437 pub enum Transform {
3438 /// Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's
3439 /// are specified on a resource, each must have a unique `function_name`.
3440 JavascriptUdf(std::boxed::Box<crate::model::JavaScriptUDF>),
3441 /// Optional. Compression/Decompression.
3442 Compression(std::boxed::Box<crate::model::Compression>),
3443 /// Optional. AI Inference. Specifies the Vertex AI endpoint that inference
3444 /// requests built from the Pub/Sub message data and provided parameters will
3445 /// be sent to.
3446 AiInference(std::boxed::Box<crate::model::AIInference>),
3447 }
3448}
3449
3450/// A topic resource.
3451#[derive(Clone, Default, PartialEq)]
3452#[non_exhaustive]
3453pub struct Topic {
3454 /// Required. Identifier. The name of the topic. It must have the format
3455 /// `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
3456 /// and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
3457 /// underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
3458 /// signs (`%`). It must be between 3 and 255 characters in length, and it
3459 /// must not start with `"goog"`.
3460 pub name: std::string::String,
3461
3462 /// Optional. See [Creating and managing labels]
3463 /// (<https://cloud.google.com/pubsub/docs/labels>).
3464 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
3465
3466 /// Optional. Policy constraining the set of Google Cloud Platform regions
3467 /// where messages published to the topic may be stored. If not present, then
3468 /// no constraints are in effect.
3469 pub message_storage_policy: std::option::Option<crate::model::MessageStoragePolicy>,
3470
3471 /// Optional. The resource name of the Cloud KMS CryptoKey to be used to
3472 /// protect access to messages published on this topic.
3473 ///
3474 /// The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
3475 pub kms_key_name: std::string::String,
3476
3477 /// Optional. Settings for validating messages published against a schema.
3478 pub schema_settings: std::option::Option<crate::model::SchemaSettings>,
3479
3480 /// Optional. Reserved for future use. This field is set only in responses from
3481 /// the server; it is ignored if it is set in any requests.
3482 pub satisfies_pzs: bool,
3483
3484 /// Optional. Indicates the minimum duration to retain a message after it is
3485 /// published to the topic. If this field is set, messages published to the
3486 /// topic in the last `message_retention_duration` are always available to
3487 /// subscribers. For instance, it allows any attached subscription to [seek to
3488 /// a
3489 /// timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
3490 /// that is up to `message_retention_duration` in the past. If this field is
3491 /// not set, message retention is controlled by settings on individual
3492 /// subscriptions. Cannot be more than 31 days or less than 10 minutes.
3493 pub message_retention_duration: std::option::Option<wkt::Duration>,
3494
3495 /// Output only. An output-only field indicating the state of the topic.
3496 pub state: crate::model::topic::State,
3497
3498 /// Optional. Settings for ingestion from a data source into this topic.
3499 pub ingestion_data_source_settings:
3500 std::option::Option<crate::model::IngestionDataSourceSettings>,
3501
3502 /// Optional. Transforms to be applied to messages published to the topic.
3503 /// Transforms are applied in the order specified.
3504 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
3505
3506 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
3507 /// resource. For example:
3508 /// "123/environment": "production",
3509 /// "123/costCenter": "marketing"
3510 /// See
3511 /// https://{$universe.dns_names.final_documentation_domain}/pubsub/docs/tags
3512 /// for more information on using tags with Pub/Sub resources.
3513 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
3514
3515 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3516}
3517
3518impl Topic {
3519 /// Creates a new default instance.
3520 pub fn new() -> Self {
3521 std::default::Default::default()
3522 }
3523
3524 /// Sets the value of [name][crate::model::Topic::name].
3525 ///
3526 /// # Example
3527 /// ```ignore,no_run
3528 /// # use google_cloud_pubsub::model::Topic;
3529 /// # let project_id = "project_id";
3530 /// # let topic_id = "topic_id";
3531 /// let x = Topic::new().set_name(format!("projects/{project_id}/topics/{topic_id}"));
3532 /// ```
3533 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3534 self.name = v.into();
3535 self
3536 }
3537
3538 /// Sets the value of [labels][crate::model::Topic::labels].
3539 ///
3540 /// # Example
3541 /// ```ignore,no_run
3542 /// # use google_cloud_pubsub::model::Topic;
3543 /// let x = Topic::new().set_labels([
3544 /// ("key0", "abc"),
3545 /// ("key1", "xyz"),
3546 /// ]);
3547 /// ```
3548 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
3549 where
3550 T: std::iter::IntoIterator<Item = (K, V)>,
3551 K: std::convert::Into<std::string::String>,
3552 V: std::convert::Into<std::string::String>,
3553 {
3554 use std::iter::Iterator;
3555 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3556 self
3557 }
3558
3559 /// Sets the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3560 ///
3561 /// # Example
3562 /// ```ignore,no_run
3563 /// # use google_cloud_pubsub::model::Topic;
3564 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3565 /// let x = Topic::new().set_message_storage_policy(MessageStoragePolicy::default()/* use setters */);
3566 /// ```
3567 pub fn set_message_storage_policy<T>(mut self, v: T) -> Self
3568 where
3569 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3570 {
3571 self.message_storage_policy = std::option::Option::Some(v.into());
3572 self
3573 }
3574
3575 /// Sets or clears the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3576 ///
3577 /// # Example
3578 /// ```ignore,no_run
3579 /// # use google_cloud_pubsub::model::Topic;
3580 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3581 /// let x = Topic::new().set_or_clear_message_storage_policy(Some(MessageStoragePolicy::default()/* use setters */));
3582 /// let x = Topic::new().set_or_clear_message_storage_policy(None::<MessageStoragePolicy>);
3583 /// ```
3584 pub fn set_or_clear_message_storage_policy<T>(mut self, v: std::option::Option<T>) -> Self
3585 where
3586 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3587 {
3588 self.message_storage_policy = v.map(|x| x.into());
3589 self
3590 }
3591
3592 /// Sets the value of [kms_key_name][crate::model::Topic::kms_key_name].
3593 ///
3594 /// # Example
3595 /// ```ignore,no_run
3596 /// # use google_cloud_pubsub::model::Topic;
3597 /// let x = Topic::new().set_kms_key_name("example");
3598 /// ```
3599 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3600 self.kms_key_name = v.into();
3601 self
3602 }
3603
3604 /// Sets the value of [schema_settings][crate::model::Topic::schema_settings].
3605 ///
3606 /// # Example
3607 /// ```ignore,no_run
3608 /// # use google_cloud_pubsub::model::Topic;
3609 /// use google_cloud_pubsub::model::SchemaSettings;
3610 /// let x = Topic::new().set_schema_settings(SchemaSettings::default()/* use setters */);
3611 /// ```
3612 pub fn set_schema_settings<T>(mut self, v: T) -> Self
3613 where
3614 T: std::convert::Into<crate::model::SchemaSettings>,
3615 {
3616 self.schema_settings = std::option::Option::Some(v.into());
3617 self
3618 }
3619
3620 /// Sets or clears the value of [schema_settings][crate::model::Topic::schema_settings].
3621 ///
3622 /// # Example
3623 /// ```ignore,no_run
3624 /// # use google_cloud_pubsub::model::Topic;
3625 /// use google_cloud_pubsub::model::SchemaSettings;
3626 /// let x = Topic::new().set_or_clear_schema_settings(Some(SchemaSettings::default()/* use setters */));
3627 /// let x = Topic::new().set_or_clear_schema_settings(None::<SchemaSettings>);
3628 /// ```
3629 pub fn set_or_clear_schema_settings<T>(mut self, v: std::option::Option<T>) -> Self
3630 where
3631 T: std::convert::Into<crate::model::SchemaSettings>,
3632 {
3633 self.schema_settings = v.map(|x| x.into());
3634 self
3635 }
3636
3637 /// Sets the value of [satisfies_pzs][crate::model::Topic::satisfies_pzs].
3638 ///
3639 /// # Example
3640 /// ```ignore,no_run
3641 /// # use google_cloud_pubsub::model::Topic;
3642 /// let x = Topic::new().set_satisfies_pzs(true);
3643 /// ```
3644 pub fn set_satisfies_pzs<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3645 self.satisfies_pzs = v.into();
3646 self
3647 }
3648
3649 /// Sets the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3650 ///
3651 /// # Example
3652 /// ```ignore,no_run
3653 /// # use google_cloud_pubsub::model::Topic;
3654 /// use wkt::Duration;
3655 /// let x = Topic::new().set_message_retention_duration(Duration::default()/* use setters */);
3656 /// ```
3657 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
3658 where
3659 T: std::convert::Into<wkt::Duration>,
3660 {
3661 self.message_retention_duration = std::option::Option::Some(v.into());
3662 self
3663 }
3664
3665 /// Sets or clears the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3666 ///
3667 /// # Example
3668 /// ```ignore,no_run
3669 /// # use google_cloud_pubsub::model::Topic;
3670 /// use wkt::Duration;
3671 /// let x = Topic::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
3672 /// let x = Topic::new().set_or_clear_message_retention_duration(None::<Duration>);
3673 /// ```
3674 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
3675 where
3676 T: std::convert::Into<wkt::Duration>,
3677 {
3678 self.message_retention_duration = v.map(|x| x.into());
3679 self
3680 }
3681
3682 /// Sets the value of [state][crate::model::Topic::state].
3683 ///
3684 /// # Example
3685 /// ```ignore,no_run
3686 /// # use google_cloud_pubsub::model::Topic;
3687 /// use google_cloud_pubsub::model::topic::State;
3688 /// let x0 = Topic::new().set_state(State::Active);
3689 /// let x1 = Topic::new().set_state(State::IngestionResourceError);
3690 /// ```
3691 pub fn set_state<T: std::convert::Into<crate::model::topic::State>>(mut self, v: T) -> Self {
3692 self.state = v.into();
3693 self
3694 }
3695
3696 /// Sets the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3697 ///
3698 /// # Example
3699 /// ```ignore,no_run
3700 /// # use google_cloud_pubsub::model::Topic;
3701 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3702 /// let x = Topic::new().set_ingestion_data_source_settings(IngestionDataSourceSettings::default()/* use setters */);
3703 /// ```
3704 pub fn set_ingestion_data_source_settings<T>(mut self, v: T) -> Self
3705 where
3706 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3707 {
3708 self.ingestion_data_source_settings = std::option::Option::Some(v.into());
3709 self
3710 }
3711
3712 /// Sets or clears the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3713 ///
3714 /// # Example
3715 /// ```ignore,no_run
3716 /// # use google_cloud_pubsub::model::Topic;
3717 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3718 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(Some(IngestionDataSourceSettings::default()/* use setters */));
3719 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(None::<IngestionDataSourceSettings>);
3720 /// ```
3721 pub fn set_or_clear_ingestion_data_source_settings<T>(
3722 mut self,
3723 v: std::option::Option<T>,
3724 ) -> Self
3725 where
3726 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3727 {
3728 self.ingestion_data_source_settings = v.map(|x| x.into());
3729 self
3730 }
3731
3732 /// Sets the value of [message_transforms][crate::model::Topic::message_transforms].
3733 ///
3734 /// # Example
3735 /// ```ignore,no_run
3736 /// # use google_cloud_pubsub::model::Topic;
3737 /// use google_cloud_pubsub::model::MessageTransform;
3738 /// let x = Topic::new()
3739 /// .set_message_transforms([
3740 /// MessageTransform::default()/* use setters */,
3741 /// MessageTransform::default()/* use (different) setters */,
3742 /// ]);
3743 /// ```
3744 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
3745 where
3746 T: std::iter::IntoIterator<Item = V>,
3747 V: std::convert::Into<crate::model::MessageTransform>,
3748 {
3749 use std::iter::Iterator;
3750 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
3751 self
3752 }
3753
3754 /// Sets the value of [tags][crate::model::Topic::tags].
3755 ///
3756 /// # Example
3757 /// ```ignore,no_run
3758 /// # use google_cloud_pubsub::model::Topic;
3759 /// let x = Topic::new().set_tags([
3760 /// ("key0", "abc"),
3761 /// ("key1", "xyz"),
3762 /// ]);
3763 /// ```
3764 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
3765 where
3766 T: std::iter::IntoIterator<Item = (K, V)>,
3767 K: std::convert::Into<std::string::String>,
3768 V: std::convert::Into<std::string::String>,
3769 {
3770 use std::iter::Iterator;
3771 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3772 self
3773 }
3774}
3775
3776impl wkt::message::Message for Topic {
3777 fn typename() -> &'static str {
3778 "type.googleapis.com/google.pubsub.v1.Topic"
3779 }
3780}
3781
3782/// Defines additional types related to [Topic].
3783pub mod topic {
3784 #[allow(unused_imports)]
3785 use super::*;
3786
3787 /// The state of the topic.
3788 ///
3789 /// # Working with unknown values
3790 ///
3791 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3792 /// additional enum variants at any time. Adding new variants is not considered
3793 /// a breaking change. Applications should write their code in anticipation of:
3794 ///
3795 /// - New values appearing in future releases of the client library, **and**
3796 /// - New values received dynamically, without application changes.
3797 ///
3798 /// Please consult the [Working with enums] section in the user guide for some
3799 /// guidelines.
3800 ///
3801 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3802 #[derive(Clone, Debug, PartialEq)]
3803 #[non_exhaustive]
3804 pub enum State {
3805 /// Default value. This value is unused.
3806 Unspecified,
3807 /// The topic does not have any persistent errors.
3808 Active,
3809 /// Ingestion from the data source has encountered a permanent error.
3810 /// See the more detailed error state in the corresponding ingestion
3811 /// source configuration.
3812 IngestionResourceError,
3813 /// If set, the enum was initialized with an unknown value.
3814 ///
3815 /// Applications can examine the value using [State::value] or
3816 /// [State::name].
3817 UnknownValue(state::UnknownValue),
3818 }
3819
3820 #[doc(hidden)]
3821 pub mod state {
3822 #[allow(unused_imports)]
3823 use super::*;
3824 #[derive(Clone, Debug, PartialEq)]
3825 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3826 }
3827
3828 impl State {
3829 /// Gets the enum value.
3830 ///
3831 /// Returns `None` if the enum contains an unknown value deserialized from
3832 /// the string representation of enums.
3833 pub fn value(&self) -> std::option::Option<i32> {
3834 match self {
3835 Self::Unspecified => std::option::Option::Some(0),
3836 Self::Active => std::option::Option::Some(1),
3837 Self::IngestionResourceError => std::option::Option::Some(2),
3838 Self::UnknownValue(u) => u.0.value(),
3839 }
3840 }
3841
3842 /// Gets the enum value as a string.
3843 ///
3844 /// Returns `None` if the enum contains an unknown value deserialized from
3845 /// the integer representation of enums.
3846 pub fn name(&self) -> std::option::Option<&str> {
3847 match self {
3848 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
3849 Self::Active => std::option::Option::Some("ACTIVE"),
3850 Self::IngestionResourceError => {
3851 std::option::Option::Some("INGESTION_RESOURCE_ERROR")
3852 }
3853 Self::UnknownValue(u) => u.0.name(),
3854 }
3855 }
3856 }
3857
3858 impl std::default::Default for State {
3859 fn default() -> Self {
3860 use std::convert::From;
3861 Self::from(0)
3862 }
3863 }
3864
3865 impl std::fmt::Display for State {
3866 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3867 wkt::internal::display_enum(f, self.name(), self.value())
3868 }
3869 }
3870
3871 impl std::convert::From<i32> for State {
3872 fn from(value: i32) -> Self {
3873 match value {
3874 0 => Self::Unspecified,
3875 1 => Self::Active,
3876 2 => Self::IngestionResourceError,
3877 _ => Self::UnknownValue(state::UnknownValue(
3878 wkt::internal::UnknownEnumValue::Integer(value),
3879 )),
3880 }
3881 }
3882 }
3883
3884 impl std::convert::From<&str> for State {
3885 fn from(value: &str) -> Self {
3886 use std::string::ToString;
3887 match value {
3888 "STATE_UNSPECIFIED" => Self::Unspecified,
3889 "ACTIVE" => Self::Active,
3890 "INGESTION_RESOURCE_ERROR" => Self::IngestionResourceError,
3891 _ => Self::UnknownValue(state::UnknownValue(
3892 wkt::internal::UnknownEnumValue::String(value.to_string()),
3893 )),
3894 }
3895 }
3896 }
3897
3898 impl serde::ser::Serialize for State {
3899 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3900 where
3901 S: serde::Serializer,
3902 {
3903 match self {
3904 Self::Unspecified => serializer.serialize_i32(0),
3905 Self::Active => serializer.serialize_i32(1),
3906 Self::IngestionResourceError => serializer.serialize_i32(2),
3907 Self::UnknownValue(u) => u.0.serialize(serializer),
3908 }
3909 }
3910 }
3911
3912 impl<'de> serde::de::Deserialize<'de> for State {
3913 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3914 where
3915 D: serde::Deserializer<'de>,
3916 {
3917 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
3918 ".google.pubsub.v1.Topic.State",
3919 ))
3920 }
3921 }
3922}
3923
3924/// Request for the GetTopic method.
3925#[derive(Clone, Default, PartialEq)]
3926#[non_exhaustive]
3927pub struct GetTopicRequest {
3928 /// Required. The name of the topic to get.
3929 /// Format is `projects/{project}/topics/{topic}`.
3930 pub topic: std::string::String,
3931
3932 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3933}
3934
3935impl GetTopicRequest {
3936 /// Creates a new default instance.
3937 pub fn new() -> Self {
3938 std::default::Default::default()
3939 }
3940
3941 /// Sets the value of [topic][crate::model::GetTopicRequest::topic].
3942 ///
3943 /// # Example
3944 /// ```ignore,no_run
3945 /// # use google_cloud_pubsub::model::GetTopicRequest;
3946 /// # let project_id = "project_id";
3947 /// # let topic_id = "topic_id";
3948 /// let x = GetTopicRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
3949 /// ```
3950 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3951 self.topic = v.into();
3952 self
3953 }
3954}
3955
3956impl wkt::message::Message for GetTopicRequest {
3957 fn typename() -> &'static str {
3958 "type.googleapis.com/google.pubsub.v1.GetTopicRequest"
3959 }
3960}
3961
3962/// Request for the UpdateTopic method.
3963#[derive(Clone, Default, PartialEq)]
3964#[non_exhaustive]
3965pub struct UpdateTopicRequest {
3966 /// Required. The updated topic object.
3967 pub topic: std::option::Option<crate::model::Topic>,
3968
3969 /// Required. Indicates which fields in the provided topic to update. Must be
3970 /// specified and non-empty. Note that if `update_mask` contains
3971 /// "message_storage_policy" but the `message_storage_policy` is not set in
3972 /// the `topic` provided above, then the updated value is determined by the
3973 /// policy configured at the project or organization level.
3974 pub update_mask: std::option::Option<wkt::FieldMask>,
3975
3976 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3977}
3978
3979impl UpdateTopicRequest {
3980 /// Creates a new default instance.
3981 pub fn new() -> Self {
3982 std::default::Default::default()
3983 }
3984
3985 /// Sets the value of [topic][crate::model::UpdateTopicRequest::topic].
3986 ///
3987 /// # Example
3988 /// ```ignore,no_run
3989 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3990 /// use google_cloud_pubsub::model::Topic;
3991 /// let x = UpdateTopicRequest::new().set_topic(Topic::default()/* use setters */);
3992 /// ```
3993 pub fn set_topic<T>(mut self, v: T) -> Self
3994 where
3995 T: std::convert::Into<crate::model::Topic>,
3996 {
3997 self.topic = std::option::Option::Some(v.into());
3998 self
3999 }
4000
4001 /// Sets or clears the value of [topic][crate::model::UpdateTopicRequest::topic].
4002 ///
4003 /// # Example
4004 /// ```ignore,no_run
4005 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
4006 /// use google_cloud_pubsub::model::Topic;
4007 /// let x = UpdateTopicRequest::new().set_or_clear_topic(Some(Topic::default()/* use setters */));
4008 /// let x = UpdateTopicRequest::new().set_or_clear_topic(None::<Topic>);
4009 /// ```
4010 pub fn set_or_clear_topic<T>(mut self, v: std::option::Option<T>) -> Self
4011 where
4012 T: std::convert::Into<crate::model::Topic>,
4013 {
4014 self.topic = v.map(|x| x.into());
4015 self
4016 }
4017
4018 /// Sets the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
4019 ///
4020 /// # Example
4021 /// ```ignore,no_run
4022 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
4023 /// use wkt::FieldMask;
4024 /// let x = UpdateTopicRequest::new().set_update_mask(FieldMask::default()/* use setters */);
4025 /// ```
4026 pub fn set_update_mask<T>(mut self, v: T) -> Self
4027 where
4028 T: std::convert::Into<wkt::FieldMask>,
4029 {
4030 self.update_mask = std::option::Option::Some(v.into());
4031 self
4032 }
4033
4034 /// Sets or clears the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
4035 ///
4036 /// # Example
4037 /// ```ignore,no_run
4038 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
4039 /// use wkt::FieldMask;
4040 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
4041 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(None::<FieldMask>);
4042 /// ```
4043 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
4044 where
4045 T: std::convert::Into<wkt::FieldMask>,
4046 {
4047 self.update_mask = v.map(|x| x.into());
4048 self
4049 }
4050}
4051
4052impl wkt::message::Message for UpdateTopicRequest {
4053 fn typename() -> &'static str {
4054 "type.googleapis.com/google.pubsub.v1.UpdateTopicRequest"
4055 }
4056}
4057
4058/// Request for the `ListTopics` method.
4059#[derive(Clone, Default, PartialEq)]
4060#[non_exhaustive]
4061pub struct ListTopicsRequest {
4062 /// Required. The name of the project in which to list topics.
4063 /// Format is `projects/{project-id}`.
4064 pub project: std::string::String,
4065
4066 /// Optional. Maximum number of topics to return.
4067 pub page_size: i32,
4068
4069 /// Optional. The value returned by the last `ListTopicsResponse`; indicates
4070 /// that this is a continuation of a prior `ListTopics` call, and that the
4071 /// system should return the next page of data.
4072 pub page_token: std::string::String,
4073
4074 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4075}
4076
4077impl ListTopicsRequest {
4078 /// Creates a new default instance.
4079 pub fn new() -> Self {
4080 std::default::Default::default()
4081 }
4082
4083 /// Sets the value of [project][crate::model::ListTopicsRequest::project].
4084 ///
4085 /// # Example
4086 /// ```ignore,no_run
4087 /// # use google_cloud_pubsub::model::ListTopicsRequest;
4088 /// let x = ListTopicsRequest::new().set_project("example");
4089 /// ```
4090 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4091 self.project = v.into();
4092 self
4093 }
4094
4095 /// Sets the value of [page_size][crate::model::ListTopicsRequest::page_size].
4096 ///
4097 /// # Example
4098 /// ```ignore,no_run
4099 /// # use google_cloud_pubsub::model::ListTopicsRequest;
4100 /// let x = ListTopicsRequest::new().set_page_size(42);
4101 /// ```
4102 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4103 self.page_size = v.into();
4104 self
4105 }
4106
4107 /// Sets the value of [page_token][crate::model::ListTopicsRequest::page_token].
4108 ///
4109 /// # Example
4110 /// ```ignore,no_run
4111 /// # use google_cloud_pubsub::model::ListTopicsRequest;
4112 /// let x = ListTopicsRequest::new().set_page_token("example");
4113 /// ```
4114 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4115 self.page_token = v.into();
4116 self
4117 }
4118}
4119
4120impl wkt::message::Message for ListTopicsRequest {
4121 fn typename() -> &'static str {
4122 "type.googleapis.com/google.pubsub.v1.ListTopicsRequest"
4123 }
4124}
4125
4126/// Response for the `ListTopics` method.
4127#[derive(Clone, Default, PartialEq)]
4128#[non_exhaustive]
4129pub struct ListTopicsResponse {
4130 /// Optional. The resulting topics.
4131 pub topics: std::vec::Vec<crate::model::Topic>,
4132
4133 /// Optional. If not empty, indicates that there may be more topics that match
4134 /// the request; this value should be passed in a new `ListTopicsRequest`.
4135 pub next_page_token: std::string::String,
4136
4137 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4138}
4139
4140impl ListTopicsResponse {
4141 /// Creates a new default instance.
4142 pub fn new() -> Self {
4143 std::default::Default::default()
4144 }
4145
4146 /// Sets the value of [topics][crate::model::ListTopicsResponse::topics].
4147 ///
4148 /// # Example
4149 /// ```ignore,no_run
4150 /// # use google_cloud_pubsub::model::ListTopicsResponse;
4151 /// use google_cloud_pubsub::model::Topic;
4152 /// let x = ListTopicsResponse::new()
4153 /// .set_topics([
4154 /// Topic::default()/* use setters */,
4155 /// Topic::default()/* use (different) setters */,
4156 /// ]);
4157 /// ```
4158 pub fn set_topics<T, V>(mut self, v: T) -> Self
4159 where
4160 T: std::iter::IntoIterator<Item = V>,
4161 V: std::convert::Into<crate::model::Topic>,
4162 {
4163 use std::iter::Iterator;
4164 self.topics = v.into_iter().map(|i| i.into()).collect();
4165 self
4166 }
4167
4168 /// Sets the value of [next_page_token][crate::model::ListTopicsResponse::next_page_token].
4169 ///
4170 /// # Example
4171 /// ```ignore,no_run
4172 /// # use google_cloud_pubsub::model::ListTopicsResponse;
4173 /// let x = ListTopicsResponse::new().set_next_page_token("example");
4174 /// ```
4175 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4176 self.next_page_token = v.into();
4177 self
4178 }
4179}
4180
4181impl wkt::message::Message for ListTopicsResponse {
4182 fn typename() -> &'static str {
4183 "type.googleapis.com/google.pubsub.v1.ListTopicsResponse"
4184 }
4185}
4186
4187#[doc(hidden)]
4188impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicsResponse {
4189 type PageItem = crate::model::Topic;
4190
4191 fn items(self) -> std::vec::Vec<Self::PageItem> {
4192 self.topics
4193 }
4194
4195 fn next_page_token(&self) -> std::string::String {
4196 use std::clone::Clone;
4197 self.next_page_token.clone()
4198 }
4199}
4200
4201/// Request for the `ListTopicSubscriptions` method.
4202#[derive(Clone, Default, PartialEq)]
4203#[non_exhaustive]
4204pub struct ListTopicSubscriptionsRequest {
4205 /// Required. The name of the topic that subscriptions are attached to.
4206 /// Format is `projects/{project}/topics/{topic}`.
4207 pub topic: std::string::String,
4208
4209 /// Optional. Maximum number of subscription names to return.
4210 pub page_size: i32,
4211
4212 /// Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
4213 /// indicates that this is a continuation of a prior `ListTopicSubscriptions`
4214 /// call, and that the system should return the next page of data.
4215 pub page_token: std::string::String,
4216
4217 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4218}
4219
4220impl ListTopicSubscriptionsRequest {
4221 /// Creates a new default instance.
4222 pub fn new() -> Self {
4223 std::default::Default::default()
4224 }
4225
4226 /// Sets the value of [topic][crate::model::ListTopicSubscriptionsRequest::topic].
4227 ///
4228 /// # Example
4229 /// ```ignore,no_run
4230 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
4231 /// # let project_id = "project_id";
4232 /// # let topic_id = "topic_id";
4233 /// let x = ListTopicSubscriptionsRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4234 /// ```
4235 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4236 self.topic = v.into();
4237 self
4238 }
4239
4240 /// Sets the value of [page_size][crate::model::ListTopicSubscriptionsRequest::page_size].
4241 ///
4242 /// # Example
4243 /// ```ignore,no_run
4244 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
4245 /// let x = ListTopicSubscriptionsRequest::new().set_page_size(42);
4246 /// ```
4247 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4248 self.page_size = v.into();
4249 self
4250 }
4251
4252 /// Sets the value of [page_token][crate::model::ListTopicSubscriptionsRequest::page_token].
4253 ///
4254 /// # Example
4255 /// ```ignore,no_run
4256 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
4257 /// let x = ListTopicSubscriptionsRequest::new().set_page_token("example");
4258 /// ```
4259 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4260 self.page_token = v.into();
4261 self
4262 }
4263}
4264
4265impl wkt::message::Message for ListTopicSubscriptionsRequest {
4266 fn typename() -> &'static str {
4267 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsRequest"
4268 }
4269}
4270
4271/// Response for the `ListTopicSubscriptions` method.
4272#[derive(Clone, Default, PartialEq)]
4273#[non_exhaustive]
4274pub struct ListTopicSubscriptionsResponse {
4275 /// Optional. The names of subscriptions attached to the topic specified in the
4276 /// request.
4277 pub subscriptions: std::vec::Vec<std::string::String>,
4278
4279 /// Optional. If not empty, indicates that there may be more subscriptions that
4280 /// match the request; this value should be passed in a new
4281 /// `ListTopicSubscriptionsRequest` to get more subscriptions.
4282 pub next_page_token: std::string::String,
4283
4284 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4285}
4286
4287impl ListTopicSubscriptionsResponse {
4288 /// Creates a new default instance.
4289 pub fn new() -> Self {
4290 std::default::Default::default()
4291 }
4292
4293 /// Sets the value of [subscriptions][crate::model::ListTopicSubscriptionsResponse::subscriptions].
4294 ///
4295 /// # Example
4296 /// ```ignore,no_run
4297 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
4298 /// let x = ListTopicSubscriptionsResponse::new().set_subscriptions(["a", "b", "c"]);
4299 /// ```
4300 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
4301 where
4302 T: std::iter::IntoIterator<Item = V>,
4303 V: std::convert::Into<std::string::String>,
4304 {
4305 use std::iter::Iterator;
4306 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
4307 self
4308 }
4309
4310 /// Sets the value of [next_page_token][crate::model::ListTopicSubscriptionsResponse::next_page_token].
4311 ///
4312 /// # Example
4313 /// ```ignore,no_run
4314 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
4315 /// let x = ListTopicSubscriptionsResponse::new().set_next_page_token("example");
4316 /// ```
4317 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4318 self.next_page_token = v.into();
4319 self
4320 }
4321}
4322
4323impl wkt::message::Message for ListTopicSubscriptionsResponse {
4324 fn typename() -> &'static str {
4325 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsResponse"
4326 }
4327}
4328
4329#[doc(hidden)]
4330impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicSubscriptionsResponse {
4331 type PageItem = std::string::String;
4332
4333 fn items(self) -> std::vec::Vec<Self::PageItem> {
4334 self.subscriptions
4335 }
4336
4337 fn next_page_token(&self) -> std::string::String {
4338 use std::clone::Clone;
4339 self.next_page_token.clone()
4340 }
4341}
4342
4343/// Request for the `ListTopicSnapshots` method.
4344#[derive(Clone, Default, PartialEq)]
4345#[non_exhaustive]
4346pub struct ListTopicSnapshotsRequest {
4347 /// Required. The name of the topic that snapshots are attached to.
4348 /// Format is `projects/{project}/topics/{topic}`.
4349 pub topic: std::string::String,
4350
4351 /// Optional. Maximum number of snapshot names to return.
4352 pub page_size: i32,
4353
4354 /// Optional. The value returned by the last `ListTopicSnapshotsResponse`;
4355 /// indicates that this is a continuation of a prior `ListTopicSnapshots` call,
4356 /// and that the system should return the next page of data.
4357 pub page_token: std::string::String,
4358
4359 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4360}
4361
4362impl ListTopicSnapshotsRequest {
4363 /// Creates a new default instance.
4364 pub fn new() -> Self {
4365 std::default::Default::default()
4366 }
4367
4368 /// Sets the value of [topic][crate::model::ListTopicSnapshotsRequest::topic].
4369 ///
4370 /// # Example
4371 /// ```ignore,no_run
4372 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
4373 /// # let project_id = "project_id";
4374 /// # let topic_id = "topic_id";
4375 /// let x = ListTopicSnapshotsRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4376 /// ```
4377 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4378 self.topic = v.into();
4379 self
4380 }
4381
4382 /// Sets the value of [page_size][crate::model::ListTopicSnapshotsRequest::page_size].
4383 ///
4384 /// # Example
4385 /// ```ignore,no_run
4386 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
4387 /// let x = ListTopicSnapshotsRequest::new().set_page_size(42);
4388 /// ```
4389 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4390 self.page_size = v.into();
4391 self
4392 }
4393
4394 /// Sets the value of [page_token][crate::model::ListTopicSnapshotsRequest::page_token].
4395 ///
4396 /// # Example
4397 /// ```ignore,no_run
4398 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
4399 /// let x = ListTopicSnapshotsRequest::new().set_page_token("example");
4400 /// ```
4401 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4402 self.page_token = v.into();
4403 self
4404 }
4405}
4406
4407impl wkt::message::Message for ListTopicSnapshotsRequest {
4408 fn typename() -> &'static str {
4409 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsRequest"
4410 }
4411}
4412
4413/// Response for the `ListTopicSnapshots` method.
4414#[derive(Clone, Default, PartialEq)]
4415#[non_exhaustive]
4416pub struct ListTopicSnapshotsResponse {
4417 /// Optional. The names of the snapshots that match the request.
4418 pub snapshots: std::vec::Vec<std::string::String>,
4419
4420 /// Optional. If not empty, indicates that there may be more snapshots that
4421 /// match the request; this value should be passed in a new
4422 /// `ListTopicSnapshotsRequest` to get more snapshots.
4423 pub next_page_token: std::string::String,
4424
4425 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4426}
4427
4428impl ListTopicSnapshotsResponse {
4429 /// Creates a new default instance.
4430 pub fn new() -> Self {
4431 std::default::Default::default()
4432 }
4433
4434 /// Sets the value of [snapshots][crate::model::ListTopicSnapshotsResponse::snapshots].
4435 ///
4436 /// # Example
4437 /// ```ignore,no_run
4438 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
4439 /// let x = ListTopicSnapshotsResponse::new().set_snapshots(["a", "b", "c"]);
4440 /// ```
4441 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
4442 where
4443 T: std::iter::IntoIterator<Item = V>,
4444 V: std::convert::Into<std::string::String>,
4445 {
4446 use std::iter::Iterator;
4447 self.snapshots = v.into_iter().map(|i| i.into()).collect();
4448 self
4449 }
4450
4451 /// Sets the value of [next_page_token][crate::model::ListTopicSnapshotsResponse::next_page_token].
4452 ///
4453 /// # Example
4454 /// ```ignore,no_run
4455 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
4456 /// let x = ListTopicSnapshotsResponse::new().set_next_page_token("example");
4457 /// ```
4458 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4459 self.next_page_token = v.into();
4460 self
4461 }
4462}
4463
4464impl wkt::message::Message for ListTopicSnapshotsResponse {
4465 fn typename() -> &'static str {
4466 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsResponse"
4467 }
4468}
4469
4470/// Request for the `DeleteTopic` method.
4471#[derive(Clone, Default, PartialEq)]
4472#[non_exhaustive]
4473pub struct DeleteTopicRequest {
4474 /// Required. Name of the topic to delete.
4475 /// Format is `projects/{project}/topics/{topic}`.
4476 pub topic: std::string::String,
4477
4478 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4479}
4480
4481impl DeleteTopicRequest {
4482 /// Creates a new default instance.
4483 pub fn new() -> Self {
4484 std::default::Default::default()
4485 }
4486
4487 /// Sets the value of [topic][crate::model::DeleteTopicRequest::topic].
4488 ///
4489 /// # Example
4490 /// ```ignore,no_run
4491 /// # use google_cloud_pubsub::model::DeleteTopicRequest;
4492 /// # let project_id = "project_id";
4493 /// # let topic_id = "topic_id";
4494 /// let x = DeleteTopicRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4495 /// ```
4496 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4497 self.topic = v.into();
4498 self
4499 }
4500}
4501
4502impl wkt::message::Message for DeleteTopicRequest {
4503 fn typename() -> &'static str {
4504 "type.googleapis.com/google.pubsub.v1.DeleteTopicRequest"
4505 }
4506}
4507
4508/// Request for the DetachSubscription method.
4509#[derive(Clone, Default, PartialEq)]
4510#[non_exhaustive]
4511pub struct DetachSubscriptionRequest {
4512 /// Required. The subscription to detach.
4513 /// Format is `projects/{project}/subscriptions/{subscription}`.
4514 pub subscription: std::string::String,
4515
4516 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4517}
4518
4519impl DetachSubscriptionRequest {
4520 /// Creates a new default instance.
4521 pub fn new() -> Self {
4522 std::default::Default::default()
4523 }
4524
4525 /// Sets the value of [subscription][crate::model::DetachSubscriptionRequest::subscription].
4526 ///
4527 /// # Example
4528 /// ```ignore,no_run
4529 /// # use google_cloud_pubsub::model::DetachSubscriptionRequest;
4530 /// # let project_id = "project_id";
4531 /// # let subscription_id = "subscription_id";
4532 /// let x = DetachSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
4533 /// ```
4534 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4535 self.subscription = v.into();
4536 self
4537 }
4538}
4539
4540impl wkt::message::Message for DetachSubscriptionRequest {
4541 fn typename() -> &'static str {
4542 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionRequest"
4543 }
4544}
4545
4546/// Response for the DetachSubscription method.
4547/// Reserved for future use.
4548#[derive(Clone, Default, PartialEq)]
4549#[non_exhaustive]
4550pub struct DetachSubscriptionResponse {
4551 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4552}
4553
4554impl DetachSubscriptionResponse {
4555 /// Creates a new default instance.
4556 pub fn new() -> Self {
4557 std::default::Default::default()
4558 }
4559}
4560
4561impl wkt::message::Message for DetachSubscriptionResponse {
4562 fn typename() -> &'static str {
4563 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionResponse"
4564 }
4565}
4566
4567/// A subscription resource. If none of `push_config`, `bigquery_config`,
4568/// `cloud_storage_config`, or `bigtable_config` is set, then the subscriber will
4569/// pull and ack messages using API methods. At most one of these fields may be
4570/// set.
4571#[derive(Clone, Default, PartialEq)]
4572#[non_exhaustive]
4573pub struct Subscription {
4574 /// Required. Identifier. The name of the subscription. It must have the format
4575 /// `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
4576 /// start with a letter, and contain only letters (`[A-Za-z]`), numbers
4577 /// (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
4578 /// plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
4579 /// in length, and it must not start with `"goog"`.
4580 pub name: std::string::String,
4581
4582 /// Required. The name of the topic from which this subscription is receiving
4583 /// messages. Format is `projects/{project}/topics/{topic}`. The value of this
4584 /// field will be `_deleted-topic_` if the topic has been deleted.
4585 pub topic: std::string::String,
4586
4587 /// Optional. If push delivery is used with this subscription, this field is
4588 /// used to configure it.
4589 pub push_config: std::option::Option<crate::model::PushConfig>,
4590
4591 /// Optional. If delivery to BigQuery is used with this subscription, this
4592 /// field is used to configure it.
4593 pub bigquery_config: std::option::Option<crate::model::BigQueryConfig>,
4594
4595 /// Optional. If delivery to Google Cloud Storage is used with this
4596 /// subscription, this field is used to configure it.
4597 pub cloud_storage_config: std::option::Option<crate::model::CloudStorageConfig>,
4598
4599 /// Optional. If delivery to Bigtable is used with this subscription, this
4600 /// field is used to configure it.
4601 pub bigtable_config: std::option::Option<crate::model::BigtableConfig>,
4602
4603 /// Optional. The approximate amount of time (on a best-effort basis) Pub/Sub
4604 /// waits for the subscriber to acknowledge receipt before resending the
4605 /// message. In the interval after the message is delivered and before it is
4606 /// acknowledged, it is considered to be _outstanding_. During that time
4607 /// period, the message will not be redelivered (on a best-effort basis).
4608 ///
4609 /// For pull subscriptions, this value is used as the initial value for the ack
4610 /// deadline. To override this value for a given message, call
4611 /// `ModifyAckDeadline` with the corresponding `ack_id` if using
4612 /// non-streaming pull or send the `ack_id` in a
4613 /// `StreamingModifyAckDeadlineRequest` if using streaming pull.
4614 /// The minimum custom deadline you can specify is 10 seconds.
4615 /// The maximum custom deadline you can specify is 600 seconds (10 minutes).
4616 /// If this parameter is 0, a default value of 10 seconds is used.
4617 ///
4618 /// For push delivery, this value is also used to set the request timeout for
4619 /// the call to the push endpoint.
4620 ///
4621 /// If the subscriber never acknowledges the message, the Pub/Sub
4622 /// system will eventually redeliver the message.
4623 pub ack_deadline_seconds: i32,
4624
4625 /// Optional. Indicates whether to retain acknowledged messages. If true, then
4626 /// messages are not expunged from the subscription's backlog, even if they are
4627 /// acknowledged, until they fall out of the `message_retention_duration`
4628 /// window. This must be true if you would like to [`Seek` to a timestamp]
4629 /// (<https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time>) in
4630 /// the past to replay previously-acknowledged messages.
4631 pub retain_acked_messages: bool,
4632
4633 /// Optional. How long to retain unacknowledged messages in the subscription's
4634 /// backlog, from the moment a message is published. If `retain_acked_messages`
4635 /// is true, then this also configures the retention of acknowledged messages,
4636 /// and thus configures how far back in time a `Seek` can be done. Defaults to
4637 /// 7 days. Cannot be more than 31 days or less than 10 minutes.
4638 pub message_retention_duration: std::option::Option<wkt::Duration>,
4639
4640 /// Optional. See [Creating and managing
4641 /// labels](https://cloud.google.com/pubsub/docs/labels).
4642 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
4643
4644 /// Optional. If true, messages published with the same `ordering_key` in
4645 /// `PubsubMessage` will be delivered to the subscribers in the order in which
4646 /// they are received by the Pub/Sub system. Otherwise, they may be delivered
4647 /// in any order.
4648 pub enable_message_ordering: bool,
4649
4650 /// Optional. A policy that specifies the conditions for this subscription's
4651 /// expiration. A subscription is considered active as long as any connected
4652 /// subscriber is successfully consuming messages from the subscription or is
4653 /// issuing operations on the subscription. If `expiration_policy` is not set,
4654 /// a *default policy* with `ttl` of 31 days will be used. The minimum allowed
4655 /// value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set,
4656 /// but `expiration_policy.ttl` is not set, the subscription never expires.
4657 pub expiration_policy: std::option::Option<crate::model::ExpirationPolicy>,
4658
4659 /// Optional. An expression written in the Pub/Sub [filter
4660 /// language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
4661 /// then only `PubsubMessage`s whose `attributes` field matches the filter are
4662 /// delivered on this subscription. If empty, then no messages are filtered
4663 /// out.
4664 pub filter: std::string::String,
4665
4666 /// Optional. A policy that specifies the conditions for dead lettering
4667 /// messages in this subscription. If dead_letter_policy is not set, dead
4668 /// lettering is disabled.
4669 ///
4670 /// The Pub/Sub service account associated with this subscriptions's
4671 /// parent project (i.e.,
4672 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
4673 /// permission to Acknowledge() messages on this subscription.
4674 pub dead_letter_policy: std::option::Option<crate::model::DeadLetterPolicy>,
4675
4676 /// Optional. A policy that specifies how Pub/Sub retries message delivery for
4677 /// this subscription.
4678 ///
4679 /// If not set, the default retry policy is applied. This generally implies
4680 /// that messages will be retried as soon as possible for healthy subscribers.
4681 /// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
4682 /// events for a given message.
4683 pub retry_policy: std::option::Option<crate::model::RetryPolicy>,
4684
4685 /// Optional. Indicates whether the subscription is detached from its topic.
4686 /// Detached subscriptions don't receive messages from their topic and don't
4687 /// retain any backlog. `Pull` and `StreamingPull` requests will return
4688 /// FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
4689 /// the endpoint will not be made.
4690 pub detached: bool,
4691
4692 /// Optional. If true, Pub/Sub provides the following guarantees for the
4693 /// delivery of a message with a given value of `message_id` on this
4694 /// subscription:
4695 ///
4696 /// * The message sent to a subscriber is guaranteed not to be resent
4697 /// before the message's acknowledgment deadline expires.
4698 /// * An acknowledged message will not be resent to a subscriber.
4699 ///
4700 /// Note that subscribers may still receive multiple copies of a message
4701 /// when `enable_exactly_once_delivery` is true if the message was published
4702 /// multiple times by a publisher client. These copies are considered distinct
4703 /// by Pub/Sub and have distinct `message_id` values.
4704 pub enable_exactly_once_delivery: bool,
4705
4706 /// Output only. Indicates the minimum duration for which a message is retained
4707 /// after it is published to the subscription's topic. If this field is set,
4708 /// messages published to the subscription's topic in the last
4709 /// `topic_message_retention_duration` are always available to subscribers. See
4710 /// the `message_retention_duration` field in `Topic`. This field is set only
4711 /// in responses from the server; it is ignored if it is set in any requests.
4712 pub topic_message_retention_duration: std::option::Option<wkt::Duration>,
4713
4714 /// Output only. An output-only field indicating whether or not the
4715 /// subscription can receive messages.
4716 pub state: crate::model::subscription::State,
4717
4718 /// Output only. Information about the associated Analytics Hub subscription.
4719 /// Only set if the subscription is created by Analytics Hub.
4720 pub analytics_hub_subscription_info:
4721 std::option::Option<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4722
4723 /// Optional. Transforms to be applied to messages before they are delivered to
4724 /// subscribers. Transforms are applied in the order specified.
4725 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
4726
4727 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
4728 /// resource. For example:
4729 /// "123/environment": "production",
4730 /// "123/costCenter": "marketing"
4731 /// See
4732 /// https://{$universe.dns_names.final_documentation_domain}/pubsub/docs/tags
4733 /// for more information on using tags with Pub/Sub resources.
4734 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
4735
4736 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4737}
4738
4739impl Subscription {
4740 /// Creates a new default instance.
4741 pub fn new() -> Self {
4742 std::default::Default::default()
4743 }
4744
4745 /// Sets the value of [name][crate::model::Subscription::name].
4746 ///
4747 /// # Example
4748 /// ```ignore,no_run
4749 /// # use google_cloud_pubsub::model::Subscription;
4750 /// # let project_id = "project_id";
4751 /// # let subscription_id = "subscription_id";
4752 /// let x = Subscription::new().set_name(format!("projects/{project_id}/subscriptions/{subscription_id}"));
4753 /// ```
4754 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4755 self.name = v.into();
4756 self
4757 }
4758
4759 /// Sets the value of [topic][crate::model::Subscription::topic].
4760 ///
4761 /// # Example
4762 /// ```ignore,no_run
4763 /// # use google_cloud_pubsub::model::Subscription;
4764 /// # let project_id = "project_id";
4765 /// # let topic_id = "topic_id";
4766 /// let x = Subscription::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4767 /// ```
4768 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4769 self.topic = v.into();
4770 self
4771 }
4772
4773 /// Sets the value of [push_config][crate::model::Subscription::push_config].
4774 ///
4775 /// # Example
4776 /// ```ignore,no_run
4777 /// # use google_cloud_pubsub::model::Subscription;
4778 /// use google_cloud_pubsub::model::PushConfig;
4779 /// let x = Subscription::new().set_push_config(PushConfig::default()/* use setters */);
4780 /// ```
4781 pub fn set_push_config<T>(mut self, v: T) -> Self
4782 where
4783 T: std::convert::Into<crate::model::PushConfig>,
4784 {
4785 self.push_config = std::option::Option::Some(v.into());
4786 self
4787 }
4788
4789 /// Sets or clears the value of [push_config][crate::model::Subscription::push_config].
4790 ///
4791 /// # Example
4792 /// ```ignore,no_run
4793 /// # use google_cloud_pubsub::model::Subscription;
4794 /// use google_cloud_pubsub::model::PushConfig;
4795 /// let x = Subscription::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
4796 /// let x = Subscription::new().set_or_clear_push_config(None::<PushConfig>);
4797 /// ```
4798 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
4799 where
4800 T: std::convert::Into<crate::model::PushConfig>,
4801 {
4802 self.push_config = v.map(|x| x.into());
4803 self
4804 }
4805
4806 /// Sets the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4807 ///
4808 /// # Example
4809 /// ```ignore,no_run
4810 /// # use google_cloud_pubsub::model::Subscription;
4811 /// use google_cloud_pubsub::model::BigQueryConfig;
4812 /// let x = Subscription::new().set_bigquery_config(BigQueryConfig::default()/* use setters */);
4813 /// ```
4814 pub fn set_bigquery_config<T>(mut self, v: T) -> Self
4815 where
4816 T: std::convert::Into<crate::model::BigQueryConfig>,
4817 {
4818 self.bigquery_config = std::option::Option::Some(v.into());
4819 self
4820 }
4821
4822 /// Sets or clears the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4823 ///
4824 /// # Example
4825 /// ```ignore,no_run
4826 /// # use google_cloud_pubsub::model::Subscription;
4827 /// use google_cloud_pubsub::model::BigQueryConfig;
4828 /// let x = Subscription::new().set_or_clear_bigquery_config(Some(BigQueryConfig::default()/* use setters */));
4829 /// let x = Subscription::new().set_or_clear_bigquery_config(None::<BigQueryConfig>);
4830 /// ```
4831 pub fn set_or_clear_bigquery_config<T>(mut self, v: std::option::Option<T>) -> Self
4832 where
4833 T: std::convert::Into<crate::model::BigQueryConfig>,
4834 {
4835 self.bigquery_config = v.map(|x| x.into());
4836 self
4837 }
4838
4839 /// Sets the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4840 ///
4841 /// # Example
4842 /// ```ignore,no_run
4843 /// # use google_cloud_pubsub::model::Subscription;
4844 /// use google_cloud_pubsub::model::CloudStorageConfig;
4845 /// let x = Subscription::new().set_cloud_storage_config(CloudStorageConfig::default()/* use setters */);
4846 /// ```
4847 pub fn set_cloud_storage_config<T>(mut self, v: T) -> Self
4848 where
4849 T: std::convert::Into<crate::model::CloudStorageConfig>,
4850 {
4851 self.cloud_storage_config = std::option::Option::Some(v.into());
4852 self
4853 }
4854
4855 /// Sets or clears the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4856 ///
4857 /// # Example
4858 /// ```ignore,no_run
4859 /// # use google_cloud_pubsub::model::Subscription;
4860 /// use google_cloud_pubsub::model::CloudStorageConfig;
4861 /// let x = Subscription::new().set_or_clear_cloud_storage_config(Some(CloudStorageConfig::default()/* use setters */));
4862 /// let x = Subscription::new().set_or_clear_cloud_storage_config(None::<CloudStorageConfig>);
4863 /// ```
4864 pub fn set_or_clear_cloud_storage_config<T>(mut self, v: std::option::Option<T>) -> Self
4865 where
4866 T: std::convert::Into<crate::model::CloudStorageConfig>,
4867 {
4868 self.cloud_storage_config = v.map(|x| x.into());
4869 self
4870 }
4871
4872 /// Sets the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4873 ///
4874 /// # Example
4875 /// ```ignore,no_run
4876 /// # use google_cloud_pubsub::model::Subscription;
4877 /// use google_cloud_pubsub::model::BigtableConfig;
4878 /// let x = Subscription::new().set_bigtable_config(BigtableConfig::default()/* use setters */);
4879 /// ```
4880 pub fn set_bigtable_config<T>(mut self, v: T) -> Self
4881 where
4882 T: std::convert::Into<crate::model::BigtableConfig>,
4883 {
4884 self.bigtable_config = std::option::Option::Some(v.into());
4885 self
4886 }
4887
4888 /// Sets or clears the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4889 ///
4890 /// # Example
4891 /// ```ignore,no_run
4892 /// # use google_cloud_pubsub::model::Subscription;
4893 /// use google_cloud_pubsub::model::BigtableConfig;
4894 /// let x = Subscription::new().set_or_clear_bigtable_config(Some(BigtableConfig::default()/* use setters */));
4895 /// let x = Subscription::new().set_or_clear_bigtable_config(None::<BigtableConfig>);
4896 /// ```
4897 pub fn set_or_clear_bigtable_config<T>(mut self, v: std::option::Option<T>) -> Self
4898 where
4899 T: std::convert::Into<crate::model::BigtableConfig>,
4900 {
4901 self.bigtable_config = v.map(|x| x.into());
4902 self
4903 }
4904
4905 /// Sets the value of [ack_deadline_seconds][crate::model::Subscription::ack_deadline_seconds].
4906 ///
4907 /// # Example
4908 /// ```ignore,no_run
4909 /// # use google_cloud_pubsub::model::Subscription;
4910 /// let x = Subscription::new().set_ack_deadline_seconds(42);
4911 /// ```
4912 pub fn set_ack_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4913 self.ack_deadline_seconds = v.into();
4914 self
4915 }
4916
4917 /// Sets the value of [retain_acked_messages][crate::model::Subscription::retain_acked_messages].
4918 ///
4919 /// # Example
4920 /// ```ignore,no_run
4921 /// # use google_cloud_pubsub::model::Subscription;
4922 /// let x = Subscription::new().set_retain_acked_messages(true);
4923 /// ```
4924 pub fn set_retain_acked_messages<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4925 self.retain_acked_messages = v.into();
4926 self
4927 }
4928
4929 /// Sets the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4930 ///
4931 /// # Example
4932 /// ```ignore,no_run
4933 /// # use google_cloud_pubsub::model::Subscription;
4934 /// use wkt::Duration;
4935 /// let x = Subscription::new().set_message_retention_duration(Duration::default()/* use setters */);
4936 /// ```
4937 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
4938 where
4939 T: std::convert::Into<wkt::Duration>,
4940 {
4941 self.message_retention_duration = std::option::Option::Some(v.into());
4942 self
4943 }
4944
4945 /// Sets or clears the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4946 ///
4947 /// # Example
4948 /// ```ignore,no_run
4949 /// # use google_cloud_pubsub::model::Subscription;
4950 /// use wkt::Duration;
4951 /// let x = Subscription::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
4952 /// let x = Subscription::new().set_or_clear_message_retention_duration(None::<Duration>);
4953 /// ```
4954 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
4955 where
4956 T: std::convert::Into<wkt::Duration>,
4957 {
4958 self.message_retention_duration = v.map(|x| x.into());
4959 self
4960 }
4961
4962 /// Sets the value of [labels][crate::model::Subscription::labels].
4963 ///
4964 /// # Example
4965 /// ```ignore,no_run
4966 /// # use google_cloud_pubsub::model::Subscription;
4967 /// let x = Subscription::new().set_labels([
4968 /// ("key0", "abc"),
4969 /// ("key1", "xyz"),
4970 /// ]);
4971 /// ```
4972 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
4973 where
4974 T: std::iter::IntoIterator<Item = (K, V)>,
4975 K: std::convert::Into<std::string::String>,
4976 V: std::convert::Into<std::string::String>,
4977 {
4978 use std::iter::Iterator;
4979 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4980 self
4981 }
4982
4983 /// Sets the value of [enable_message_ordering][crate::model::Subscription::enable_message_ordering].
4984 ///
4985 /// # Example
4986 /// ```ignore,no_run
4987 /// # use google_cloud_pubsub::model::Subscription;
4988 /// let x = Subscription::new().set_enable_message_ordering(true);
4989 /// ```
4990 pub fn set_enable_message_ordering<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4991 self.enable_message_ordering = v.into();
4992 self
4993 }
4994
4995 /// Sets the value of [expiration_policy][crate::model::Subscription::expiration_policy].
4996 ///
4997 /// # Example
4998 /// ```ignore,no_run
4999 /// # use google_cloud_pubsub::model::Subscription;
5000 /// use google_cloud_pubsub::model::ExpirationPolicy;
5001 /// let x = Subscription::new().set_expiration_policy(ExpirationPolicy::default()/* use setters */);
5002 /// ```
5003 pub fn set_expiration_policy<T>(mut self, v: T) -> Self
5004 where
5005 T: std::convert::Into<crate::model::ExpirationPolicy>,
5006 {
5007 self.expiration_policy = std::option::Option::Some(v.into());
5008 self
5009 }
5010
5011 /// Sets or clears the value of [expiration_policy][crate::model::Subscription::expiration_policy].
5012 ///
5013 /// # Example
5014 /// ```ignore,no_run
5015 /// # use google_cloud_pubsub::model::Subscription;
5016 /// use google_cloud_pubsub::model::ExpirationPolicy;
5017 /// let x = Subscription::new().set_or_clear_expiration_policy(Some(ExpirationPolicy::default()/* use setters */));
5018 /// let x = Subscription::new().set_or_clear_expiration_policy(None::<ExpirationPolicy>);
5019 /// ```
5020 pub fn set_or_clear_expiration_policy<T>(mut self, v: std::option::Option<T>) -> Self
5021 where
5022 T: std::convert::Into<crate::model::ExpirationPolicy>,
5023 {
5024 self.expiration_policy = v.map(|x| x.into());
5025 self
5026 }
5027
5028 /// Sets the value of [filter][crate::model::Subscription::filter].
5029 ///
5030 /// # Example
5031 /// ```ignore,no_run
5032 /// # use google_cloud_pubsub::model::Subscription;
5033 /// let x = Subscription::new().set_filter("example");
5034 /// ```
5035 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5036 self.filter = v.into();
5037 self
5038 }
5039
5040 /// Sets the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
5041 ///
5042 /// # Example
5043 /// ```ignore,no_run
5044 /// # use google_cloud_pubsub::model::Subscription;
5045 /// use google_cloud_pubsub::model::DeadLetterPolicy;
5046 /// let x = Subscription::new().set_dead_letter_policy(DeadLetterPolicy::default()/* use setters */);
5047 /// ```
5048 pub fn set_dead_letter_policy<T>(mut self, v: T) -> Self
5049 where
5050 T: std::convert::Into<crate::model::DeadLetterPolicy>,
5051 {
5052 self.dead_letter_policy = std::option::Option::Some(v.into());
5053 self
5054 }
5055
5056 /// Sets or clears the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
5057 ///
5058 /// # Example
5059 /// ```ignore,no_run
5060 /// # use google_cloud_pubsub::model::Subscription;
5061 /// use google_cloud_pubsub::model::DeadLetterPolicy;
5062 /// let x = Subscription::new().set_or_clear_dead_letter_policy(Some(DeadLetterPolicy::default()/* use setters */));
5063 /// let x = Subscription::new().set_or_clear_dead_letter_policy(None::<DeadLetterPolicy>);
5064 /// ```
5065 pub fn set_or_clear_dead_letter_policy<T>(mut self, v: std::option::Option<T>) -> Self
5066 where
5067 T: std::convert::Into<crate::model::DeadLetterPolicy>,
5068 {
5069 self.dead_letter_policy = v.map(|x| x.into());
5070 self
5071 }
5072
5073 /// Sets the value of [retry_policy][crate::model::Subscription::retry_policy].
5074 ///
5075 /// # Example
5076 /// ```ignore,no_run
5077 /// # use google_cloud_pubsub::model::Subscription;
5078 /// use google_cloud_pubsub::model::RetryPolicy;
5079 /// let x = Subscription::new().set_retry_policy(RetryPolicy::default()/* use setters */);
5080 /// ```
5081 pub fn set_retry_policy<T>(mut self, v: T) -> Self
5082 where
5083 T: std::convert::Into<crate::model::RetryPolicy>,
5084 {
5085 self.retry_policy = std::option::Option::Some(v.into());
5086 self
5087 }
5088
5089 /// Sets or clears the value of [retry_policy][crate::model::Subscription::retry_policy].
5090 ///
5091 /// # Example
5092 /// ```ignore,no_run
5093 /// # use google_cloud_pubsub::model::Subscription;
5094 /// use google_cloud_pubsub::model::RetryPolicy;
5095 /// let x = Subscription::new().set_or_clear_retry_policy(Some(RetryPolicy::default()/* use setters */));
5096 /// let x = Subscription::new().set_or_clear_retry_policy(None::<RetryPolicy>);
5097 /// ```
5098 pub fn set_or_clear_retry_policy<T>(mut self, v: std::option::Option<T>) -> Self
5099 where
5100 T: std::convert::Into<crate::model::RetryPolicy>,
5101 {
5102 self.retry_policy = v.map(|x| x.into());
5103 self
5104 }
5105
5106 /// Sets the value of [detached][crate::model::Subscription::detached].
5107 ///
5108 /// # Example
5109 /// ```ignore,no_run
5110 /// # use google_cloud_pubsub::model::Subscription;
5111 /// let x = Subscription::new().set_detached(true);
5112 /// ```
5113 pub fn set_detached<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5114 self.detached = v.into();
5115 self
5116 }
5117
5118 /// Sets the value of [enable_exactly_once_delivery][crate::model::Subscription::enable_exactly_once_delivery].
5119 ///
5120 /// # Example
5121 /// ```ignore,no_run
5122 /// # use google_cloud_pubsub::model::Subscription;
5123 /// let x = Subscription::new().set_enable_exactly_once_delivery(true);
5124 /// ```
5125 pub fn set_enable_exactly_once_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5126 self.enable_exactly_once_delivery = v.into();
5127 self
5128 }
5129
5130 /// Sets the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
5131 ///
5132 /// # Example
5133 /// ```ignore,no_run
5134 /// # use google_cloud_pubsub::model::Subscription;
5135 /// use wkt::Duration;
5136 /// let x = Subscription::new().set_topic_message_retention_duration(Duration::default()/* use setters */);
5137 /// ```
5138 pub fn set_topic_message_retention_duration<T>(mut self, v: T) -> Self
5139 where
5140 T: std::convert::Into<wkt::Duration>,
5141 {
5142 self.topic_message_retention_duration = std::option::Option::Some(v.into());
5143 self
5144 }
5145
5146 /// Sets or clears the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
5147 ///
5148 /// # Example
5149 /// ```ignore,no_run
5150 /// # use google_cloud_pubsub::model::Subscription;
5151 /// use wkt::Duration;
5152 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(Some(Duration::default()/* use setters */));
5153 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(None::<Duration>);
5154 /// ```
5155 pub fn set_or_clear_topic_message_retention_duration<T>(
5156 mut self,
5157 v: std::option::Option<T>,
5158 ) -> Self
5159 where
5160 T: std::convert::Into<wkt::Duration>,
5161 {
5162 self.topic_message_retention_duration = v.map(|x| x.into());
5163 self
5164 }
5165
5166 /// Sets the value of [state][crate::model::Subscription::state].
5167 ///
5168 /// # Example
5169 /// ```ignore,no_run
5170 /// # use google_cloud_pubsub::model::Subscription;
5171 /// use google_cloud_pubsub::model::subscription::State;
5172 /// let x0 = Subscription::new().set_state(State::Active);
5173 /// let x1 = Subscription::new().set_state(State::ResourceError);
5174 /// ```
5175 pub fn set_state<T: std::convert::Into<crate::model::subscription::State>>(
5176 mut self,
5177 v: T,
5178 ) -> Self {
5179 self.state = v.into();
5180 self
5181 }
5182
5183 /// Sets the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
5184 ///
5185 /// # Example
5186 /// ```ignore,no_run
5187 /// # use google_cloud_pubsub::model::Subscription;
5188 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
5189 /// let x = Subscription::new().set_analytics_hub_subscription_info(AnalyticsHubSubscriptionInfo::default()/* use setters */);
5190 /// ```
5191 pub fn set_analytics_hub_subscription_info<T>(mut self, v: T) -> Self
5192 where
5193 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
5194 {
5195 self.analytics_hub_subscription_info = std::option::Option::Some(v.into());
5196 self
5197 }
5198
5199 /// Sets or clears the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
5200 ///
5201 /// # Example
5202 /// ```ignore,no_run
5203 /// # use google_cloud_pubsub::model::Subscription;
5204 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
5205 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(Some(AnalyticsHubSubscriptionInfo::default()/* use setters */));
5206 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(None::<AnalyticsHubSubscriptionInfo>);
5207 /// ```
5208 pub fn set_or_clear_analytics_hub_subscription_info<T>(
5209 mut self,
5210 v: std::option::Option<T>,
5211 ) -> Self
5212 where
5213 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
5214 {
5215 self.analytics_hub_subscription_info = v.map(|x| x.into());
5216 self
5217 }
5218
5219 /// Sets the value of [message_transforms][crate::model::Subscription::message_transforms].
5220 ///
5221 /// # Example
5222 /// ```ignore,no_run
5223 /// # use google_cloud_pubsub::model::Subscription;
5224 /// use google_cloud_pubsub::model::MessageTransform;
5225 /// let x = Subscription::new()
5226 /// .set_message_transforms([
5227 /// MessageTransform::default()/* use setters */,
5228 /// MessageTransform::default()/* use (different) setters */,
5229 /// ]);
5230 /// ```
5231 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
5232 where
5233 T: std::iter::IntoIterator<Item = V>,
5234 V: std::convert::Into<crate::model::MessageTransform>,
5235 {
5236 use std::iter::Iterator;
5237 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
5238 self
5239 }
5240
5241 /// Sets the value of [tags][crate::model::Subscription::tags].
5242 ///
5243 /// # Example
5244 /// ```ignore,no_run
5245 /// # use google_cloud_pubsub::model::Subscription;
5246 /// let x = Subscription::new().set_tags([
5247 /// ("key0", "abc"),
5248 /// ("key1", "xyz"),
5249 /// ]);
5250 /// ```
5251 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
5252 where
5253 T: std::iter::IntoIterator<Item = (K, V)>,
5254 K: std::convert::Into<std::string::String>,
5255 V: std::convert::Into<std::string::String>,
5256 {
5257 use std::iter::Iterator;
5258 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5259 self
5260 }
5261}
5262
5263impl wkt::message::Message for Subscription {
5264 fn typename() -> &'static str {
5265 "type.googleapis.com/google.pubsub.v1.Subscription"
5266 }
5267}
5268
5269/// Defines additional types related to [Subscription].
5270pub mod subscription {
5271 #[allow(unused_imports)]
5272 use super::*;
5273
5274 /// Information about an associated [Analytics Hub
5275 /// subscription](https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
5276 #[derive(Clone, Default, PartialEq)]
5277 #[non_exhaustive]
5278 pub struct AnalyticsHubSubscriptionInfo {
5279 /// Optional. The name of the associated Analytics Hub listing resource.
5280 /// Pattern:
5281 /// "projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}"
5282 pub listing: std::string::String,
5283
5284 /// Optional. The name of the associated Analytics Hub subscription resource.
5285 /// Pattern:
5286 /// "projects/{project}/locations/{location}/subscriptions/{subscription}"
5287 pub subscription: std::string::String,
5288
5289 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5290 }
5291
5292 impl AnalyticsHubSubscriptionInfo {
5293 /// Creates a new default instance.
5294 pub fn new() -> Self {
5295 std::default::Default::default()
5296 }
5297
5298 /// Sets the value of [listing][crate::model::subscription::AnalyticsHubSubscriptionInfo::listing].
5299 ///
5300 /// # Example
5301 /// ```ignore,no_run
5302 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
5303 /// let x = AnalyticsHubSubscriptionInfo::new().set_listing("example");
5304 /// ```
5305 pub fn set_listing<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5306 self.listing = v.into();
5307 self
5308 }
5309
5310 /// Sets the value of [subscription][crate::model::subscription::AnalyticsHubSubscriptionInfo::subscription].
5311 ///
5312 /// # Example
5313 /// ```ignore,no_run
5314 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
5315 /// let x = AnalyticsHubSubscriptionInfo::new().set_subscription("example");
5316 /// ```
5317 pub fn set_subscription<T: std::convert::Into<std::string::String>>(
5318 mut self,
5319 v: T,
5320 ) -> Self {
5321 self.subscription = v.into();
5322 self
5323 }
5324 }
5325
5326 impl wkt::message::Message for AnalyticsHubSubscriptionInfo {
5327 fn typename() -> &'static str {
5328 "type.googleapis.com/google.pubsub.v1.Subscription.AnalyticsHubSubscriptionInfo"
5329 }
5330 }
5331
5332 /// Possible states for a subscription.
5333 ///
5334 /// # Working with unknown values
5335 ///
5336 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5337 /// additional enum variants at any time. Adding new variants is not considered
5338 /// a breaking change. Applications should write their code in anticipation of:
5339 ///
5340 /// - New values appearing in future releases of the client library, **and**
5341 /// - New values received dynamically, without application changes.
5342 ///
5343 /// Please consult the [Working with enums] section in the user guide for some
5344 /// guidelines.
5345 ///
5346 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5347 #[derive(Clone, Debug, PartialEq)]
5348 #[non_exhaustive]
5349 pub enum State {
5350 /// Default value. This value is unused.
5351 Unspecified,
5352 /// The subscription can actively receive messages
5353 Active,
5354 /// The subscription cannot receive messages because of an error with the
5355 /// resource to which it pushes messages. See the more detailed error state
5356 /// in the corresponding configuration.
5357 ResourceError,
5358 /// If set, the enum was initialized with an unknown value.
5359 ///
5360 /// Applications can examine the value using [State::value] or
5361 /// [State::name].
5362 UnknownValue(state::UnknownValue),
5363 }
5364
5365 #[doc(hidden)]
5366 pub mod state {
5367 #[allow(unused_imports)]
5368 use super::*;
5369 #[derive(Clone, Debug, PartialEq)]
5370 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5371 }
5372
5373 impl State {
5374 /// Gets the enum value.
5375 ///
5376 /// Returns `None` if the enum contains an unknown value deserialized from
5377 /// the string representation of enums.
5378 pub fn value(&self) -> std::option::Option<i32> {
5379 match self {
5380 Self::Unspecified => std::option::Option::Some(0),
5381 Self::Active => std::option::Option::Some(1),
5382 Self::ResourceError => std::option::Option::Some(2),
5383 Self::UnknownValue(u) => u.0.value(),
5384 }
5385 }
5386
5387 /// Gets the enum value as a string.
5388 ///
5389 /// Returns `None` if the enum contains an unknown value deserialized from
5390 /// the integer representation of enums.
5391 pub fn name(&self) -> std::option::Option<&str> {
5392 match self {
5393 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
5394 Self::Active => std::option::Option::Some("ACTIVE"),
5395 Self::ResourceError => std::option::Option::Some("RESOURCE_ERROR"),
5396 Self::UnknownValue(u) => u.0.name(),
5397 }
5398 }
5399 }
5400
5401 impl std::default::Default for State {
5402 fn default() -> Self {
5403 use std::convert::From;
5404 Self::from(0)
5405 }
5406 }
5407
5408 impl std::fmt::Display for State {
5409 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5410 wkt::internal::display_enum(f, self.name(), self.value())
5411 }
5412 }
5413
5414 impl std::convert::From<i32> for State {
5415 fn from(value: i32) -> Self {
5416 match value {
5417 0 => Self::Unspecified,
5418 1 => Self::Active,
5419 2 => Self::ResourceError,
5420 _ => Self::UnknownValue(state::UnknownValue(
5421 wkt::internal::UnknownEnumValue::Integer(value),
5422 )),
5423 }
5424 }
5425 }
5426
5427 impl std::convert::From<&str> for State {
5428 fn from(value: &str) -> Self {
5429 use std::string::ToString;
5430 match value {
5431 "STATE_UNSPECIFIED" => Self::Unspecified,
5432 "ACTIVE" => Self::Active,
5433 "RESOURCE_ERROR" => Self::ResourceError,
5434 _ => Self::UnknownValue(state::UnknownValue(
5435 wkt::internal::UnknownEnumValue::String(value.to_string()),
5436 )),
5437 }
5438 }
5439 }
5440
5441 impl serde::ser::Serialize for State {
5442 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5443 where
5444 S: serde::Serializer,
5445 {
5446 match self {
5447 Self::Unspecified => serializer.serialize_i32(0),
5448 Self::Active => serializer.serialize_i32(1),
5449 Self::ResourceError => serializer.serialize_i32(2),
5450 Self::UnknownValue(u) => u.0.serialize(serializer),
5451 }
5452 }
5453 }
5454
5455 impl<'de> serde::de::Deserialize<'de> for State {
5456 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5457 where
5458 D: serde::Deserializer<'de>,
5459 {
5460 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
5461 ".google.pubsub.v1.Subscription.State",
5462 ))
5463 }
5464 }
5465}
5466
5467/// A policy that specifies how Pub/Sub retries message delivery.
5468///
5469/// Retry delay will be exponential based on provided minimum and maximum
5470/// backoffs. <https://en.wikipedia.org/wiki/Exponential_backoff>.
5471///
5472/// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
5473/// events for a given message.
5474///
5475/// Retry Policy is implemented on a best effort basis. At times, the delay
5476/// between consecutive deliveries may not match the configuration. That is,
5477/// delay can be more or less than configured backoff.
5478#[derive(Clone, Default, PartialEq)]
5479#[non_exhaustive]
5480pub struct RetryPolicy {
5481 /// Optional. The minimum delay between consecutive deliveries of a given
5482 /// message. Value should be between 0 and 600 seconds. Defaults to 10 seconds.
5483 pub minimum_backoff: std::option::Option<wkt::Duration>,
5484
5485 /// Optional. The maximum delay between consecutive deliveries of a given
5486 /// message. Value should be between 0 and 600 seconds. Defaults to 600
5487 /// seconds.
5488 pub maximum_backoff: std::option::Option<wkt::Duration>,
5489
5490 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5491}
5492
5493impl RetryPolicy {
5494 /// Creates a new default instance.
5495 pub fn new() -> Self {
5496 std::default::Default::default()
5497 }
5498
5499 /// Sets the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5500 ///
5501 /// # Example
5502 /// ```ignore,no_run
5503 /// # use google_cloud_pubsub::model::RetryPolicy;
5504 /// use wkt::Duration;
5505 /// let x = RetryPolicy::new().set_minimum_backoff(Duration::default()/* use setters */);
5506 /// ```
5507 pub fn set_minimum_backoff<T>(mut self, v: T) -> Self
5508 where
5509 T: std::convert::Into<wkt::Duration>,
5510 {
5511 self.minimum_backoff = std::option::Option::Some(v.into());
5512 self
5513 }
5514
5515 /// Sets or clears the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5516 ///
5517 /// # Example
5518 /// ```ignore,no_run
5519 /// # use google_cloud_pubsub::model::RetryPolicy;
5520 /// use wkt::Duration;
5521 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(Some(Duration::default()/* use setters */));
5522 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(None::<Duration>);
5523 /// ```
5524 pub fn set_or_clear_minimum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5525 where
5526 T: std::convert::Into<wkt::Duration>,
5527 {
5528 self.minimum_backoff = v.map(|x| x.into());
5529 self
5530 }
5531
5532 /// Sets the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5533 ///
5534 /// # Example
5535 /// ```ignore,no_run
5536 /// # use google_cloud_pubsub::model::RetryPolicy;
5537 /// use wkt::Duration;
5538 /// let x = RetryPolicy::new().set_maximum_backoff(Duration::default()/* use setters */);
5539 /// ```
5540 pub fn set_maximum_backoff<T>(mut self, v: T) -> Self
5541 where
5542 T: std::convert::Into<wkt::Duration>,
5543 {
5544 self.maximum_backoff = std::option::Option::Some(v.into());
5545 self
5546 }
5547
5548 /// Sets or clears the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5549 ///
5550 /// # Example
5551 /// ```ignore,no_run
5552 /// # use google_cloud_pubsub::model::RetryPolicy;
5553 /// use wkt::Duration;
5554 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(Some(Duration::default()/* use setters */));
5555 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(None::<Duration>);
5556 /// ```
5557 pub fn set_or_clear_maximum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5558 where
5559 T: std::convert::Into<wkt::Duration>,
5560 {
5561 self.maximum_backoff = v.map(|x| x.into());
5562 self
5563 }
5564}
5565
5566impl wkt::message::Message for RetryPolicy {
5567 fn typename() -> &'static str {
5568 "type.googleapis.com/google.pubsub.v1.RetryPolicy"
5569 }
5570}
5571
5572/// Dead lettering is done on a best effort basis. The same message might be
5573/// dead lettered multiple times.
5574///
5575/// If validation on any of the fields fails at subscription creation/updation,
5576/// the create/update subscription request will fail.
5577#[derive(Clone, Default, PartialEq)]
5578#[non_exhaustive]
5579pub struct DeadLetterPolicy {
5580 /// Optional. The name of the topic to which dead letter messages should be
5581 /// published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub
5582 /// service account associated with the enclosing subscription's parent project
5583 /// (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must
5584 /// have permission to Publish() to this topic.
5585 ///
5586 /// The operation will fail if the topic does not exist.
5587 /// Users should ensure that there is a subscription attached to this topic
5588 /// since messages published to a topic with no subscriptions are lost.
5589 pub dead_letter_topic: std::string::String,
5590
5591 /// Optional. The maximum number of delivery attempts for any message. The
5592 /// value must be between 5 and 100.
5593 ///
5594 /// The number of delivery attempts is defined as 1 + (the sum of number of
5595 /// NACKs and number of times the acknowledgment deadline has been exceeded
5596 /// for the message).
5597 ///
5598 /// A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
5599 /// client libraries may automatically extend ack_deadlines.
5600 ///
5601 /// This field will be honored on a best effort basis.
5602 ///
5603 /// If this parameter is 0, a default value of 5 is used.
5604 pub max_delivery_attempts: i32,
5605
5606 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5607}
5608
5609impl DeadLetterPolicy {
5610 /// Creates a new default instance.
5611 pub fn new() -> Self {
5612 std::default::Default::default()
5613 }
5614
5615 /// Sets the value of [dead_letter_topic][crate::model::DeadLetterPolicy::dead_letter_topic].
5616 ///
5617 /// # Example
5618 /// ```ignore,no_run
5619 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5620 /// # let project_id = "project_id";
5621 /// # let topic_id = "topic_id";
5622 /// let x = DeadLetterPolicy::new().set_dead_letter_topic(format!("projects/{project_id}/topics/{topic_id}"));
5623 /// ```
5624 pub fn set_dead_letter_topic<T: std::convert::Into<std::string::String>>(
5625 mut self,
5626 v: T,
5627 ) -> Self {
5628 self.dead_letter_topic = v.into();
5629 self
5630 }
5631
5632 /// Sets the value of [max_delivery_attempts][crate::model::DeadLetterPolicy::max_delivery_attempts].
5633 ///
5634 /// # Example
5635 /// ```ignore,no_run
5636 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5637 /// let x = DeadLetterPolicy::new().set_max_delivery_attempts(42);
5638 /// ```
5639 pub fn set_max_delivery_attempts<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5640 self.max_delivery_attempts = v.into();
5641 self
5642 }
5643}
5644
5645impl wkt::message::Message for DeadLetterPolicy {
5646 fn typename() -> &'static str {
5647 "type.googleapis.com/google.pubsub.v1.DeadLetterPolicy"
5648 }
5649}
5650
5651/// A policy that specifies the conditions for resource expiration (i.e.,
5652/// automatic resource deletion).
5653#[derive(Clone, Default, PartialEq)]
5654#[non_exhaustive]
5655pub struct ExpirationPolicy {
5656 /// Optional. Specifies the "time-to-live" duration for an associated resource.
5657 /// The resource expires if it is not active for a period of `ttl`. The
5658 /// definition of "activity" depends on the type of the associated resource.
5659 /// The minimum and maximum allowed values for `ttl` depend on the type of the
5660 /// associated resource, as well. If `ttl` is not set, the associated resource
5661 /// never expires.
5662 pub ttl: std::option::Option<wkt::Duration>,
5663
5664 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5665}
5666
5667impl ExpirationPolicy {
5668 /// Creates a new default instance.
5669 pub fn new() -> Self {
5670 std::default::Default::default()
5671 }
5672
5673 /// Sets the value of [ttl][crate::model::ExpirationPolicy::ttl].
5674 ///
5675 /// # Example
5676 /// ```ignore,no_run
5677 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5678 /// use wkt::Duration;
5679 /// let x = ExpirationPolicy::new().set_ttl(Duration::default()/* use setters */);
5680 /// ```
5681 pub fn set_ttl<T>(mut self, v: T) -> Self
5682 where
5683 T: std::convert::Into<wkt::Duration>,
5684 {
5685 self.ttl = std::option::Option::Some(v.into());
5686 self
5687 }
5688
5689 /// Sets or clears the value of [ttl][crate::model::ExpirationPolicy::ttl].
5690 ///
5691 /// # Example
5692 /// ```ignore,no_run
5693 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5694 /// use wkt::Duration;
5695 /// let x = ExpirationPolicy::new().set_or_clear_ttl(Some(Duration::default()/* use setters */));
5696 /// let x = ExpirationPolicy::new().set_or_clear_ttl(None::<Duration>);
5697 /// ```
5698 pub fn set_or_clear_ttl<T>(mut self, v: std::option::Option<T>) -> Self
5699 where
5700 T: std::convert::Into<wkt::Duration>,
5701 {
5702 self.ttl = v.map(|x| x.into());
5703 self
5704 }
5705}
5706
5707impl wkt::message::Message for ExpirationPolicy {
5708 fn typename() -> &'static str {
5709 "type.googleapis.com/google.pubsub.v1.ExpirationPolicy"
5710 }
5711}
5712
5713/// Configuration for a push delivery endpoint.
5714#[derive(Clone, Default, PartialEq)]
5715#[non_exhaustive]
5716pub struct PushConfig {
5717 /// Optional. A URL locating the endpoint to which messages should be pushed.
5718 /// For example, a Webhook endpoint might use `<https://example.com/push>`.
5719 pub push_endpoint: std::string::String,
5720
5721 /// Optional. Endpoint configuration attributes that can be used to control
5722 /// different aspects of the message delivery.
5723 ///
5724 /// The only currently supported attribute is `x-goog-version`, which you can
5725 /// use to change the format of the pushed message. This attribute
5726 /// indicates the version of the data expected by the endpoint. This
5727 /// controls the shape of the pushed message (i.e., its fields and metadata).
5728 ///
5729 /// If not present during the `CreateSubscription` call, it will default to
5730 /// the version of the Pub/Sub API used to make such call. If not present in a
5731 /// `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
5732 /// calls will always return a valid version, even if the subscription was
5733 /// created without this attribute.
5734 ///
5735 /// The only supported values for the `x-goog-version` attribute are:
5736 ///
5737 /// * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
5738 /// * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
5739 ///
5740 /// For example:
5741 /// `attributes { "x-goog-version": "v1" }`
5742 pub attributes: std::collections::HashMap<std::string::String, std::string::String>,
5743
5744 /// An authentication method used by push endpoints to verify the source of
5745 /// push requests. This can be used with push endpoints that are private by
5746 /// default to allow requests only from the Pub/Sub system, for example.
5747 /// This field is optional and should be set only by users interested in
5748 /// authenticated push.
5749 pub authentication_method: std::option::Option<crate::model::push_config::AuthenticationMethod>,
5750
5751 /// The format of the delivered message to the push endpoint is defined by
5752 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
5753 pub wrapper: std::option::Option<crate::model::push_config::Wrapper>,
5754
5755 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5756}
5757
5758impl PushConfig {
5759 /// Creates a new default instance.
5760 pub fn new() -> Self {
5761 std::default::Default::default()
5762 }
5763
5764 /// Sets the value of [push_endpoint][crate::model::PushConfig::push_endpoint].
5765 ///
5766 /// # Example
5767 /// ```ignore,no_run
5768 /// # use google_cloud_pubsub::model::PushConfig;
5769 /// let x = PushConfig::new().set_push_endpoint("example");
5770 /// ```
5771 pub fn set_push_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5772 self.push_endpoint = v.into();
5773 self
5774 }
5775
5776 /// Sets the value of [attributes][crate::model::PushConfig::attributes].
5777 ///
5778 /// # Example
5779 /// ```ignore,no_run
5780 /// # use google_cloud_pubsub::model::PushConfig;
5781 /// let x = PushConfig::new().set_attributes([
5782 /// ("key0", "abc"),
5783 /// ("key1", "xyz"),
5784 /// ]);
5785 /// ```
5786 pub fn set_attributes<T, K, V>(mut self, v: T) -> Self
5787 where
5788 T: std::iter::IntoIterator<Item = (K, V)>,
5789 K: std::convert::Into<std::string::String>,
5790 V: std::convert::Into<std::string::String>,
5791 {
5792 use std::iter::Iterator;
5793 self.attributes = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5794 self
5795 }
5796
5797 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method].
5798 ///
5799 /// Note that all the setters affecting `authentication_method` are mutually
5800 /// exclusive.
5801 ///
5802 /// # Example
5803 /// ```ignore,no_run
5804 /// # use google_cloud_pubsub::model::PushConfig;
5805 /// use google_cloud_pubsub::model::push_config::OidcToken;
5806 /// let x = PushConfig::new().set_authentication_method(Some(
5807 /// google_cloud_pubsub::model::push_config::AuthenticationMethod::OidcToken(OidcToken::default().into())));
5808 /// ```
5809 pub fn set_authentication_method<
5810 T: std::convert::Into<std::option::Option<crate::model::push_config::AuthenticationMethod>>,
5811 >(
5812 mut self,
5813 v: T,
5814 ) -> Self {
5815 self.authentication_method = v.into();
5816 self
5817 }
5818
5819 /// The value of [authentication_method][crate::model::PushConfig::authentication_method]
5820 /// if it holds a `OidcToken`, `None` if the field is not set or
5821 /// holds a different branch.
5822 pub fn oidc_token(
5823 &self,
5824 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::OidcToken>> {
5825 #[allow(unreachable_patterns)]
5826 self.authentication_method.as_ref().and_then(|v| match v {
5827 crate::model::push_config::AuthenticationMethod::OidcToken(v) => {
5828 std::option::Option::Some(v)
5829 }
5830 _ => std::option::Option::None,
5831 })
5832 }
5833
5834 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method]
5835 /// to hold a `OidcToken`.
5836 ///
5837 /// Note that all the setters affecting `authentication_method` are
5838 /// mutually exclusive.
5839 ///
5840 /// # Example
5841 /// ```ignore,no_run
5842 /// # use google_cloud_pubsub::model::PushConfig;
5843 /// use google_cloud_pubsub::model::push_config::OidcToken;
5844 /// let x = PushConfig::new().set_oidc_token(OidcToken::default()/* use setters */);
5845 /// assert!(x.oidc_token().is_some());
5846 /// ```
5847 pub fn set_oidc_token<
5848 T: std::convert::Into<std::boxed::Box<crate::model::push_config::OidcToken>>,
5849 >(
5850 mut self,
5851 v: T,
5852 ) -> Self {
5853 self.authentication_method = std::option::Option::Some(
5854 crate::model::push_config::AuthenticationMethod::OidcToken(v.into()),
5855 );
5856 self
5857 }
5858
5859 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper].
5860 ///
5861 /// Note that all the setters affecting `wrapper` are mutually
5862 /// exclusive.
5863 ///
5864 /// # Example
5865 /// ```ignore,no_run
5866 /// # use google_cloud_pubsub::model::PushConfig;
5867 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5868 /// let x = PushConfig::new().set_wrapper(Some(
5869 /// google_cloud_pubsub::model::push_config::Wrapper::PubsubWrapper(PubsubWrapper::default().into())));
5870 /// ```
5871 pub fn set_wrapper<
5872 T: std::convert::Into<std::option::Option<crate::model::push_config::Wrapper>>,
5873 >(
5874 mut self,
5875 v: T,
5876 ) -> Self {
5877 self.wrapper = v.into();
5878 self
5879 }
5880
5881 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5882 /// if it holds a `PubsubWrapper`, `None` if the field is not set or
5883 /// holds a different branch.
5884 pub fn pubsub_wrapper(
5885 &self,
5886 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::PubsubWrapper>> {
5887 #[allow(unreachable_patterns)]
5888 self.wrapper.as_ref().and_then(|v| match v {
5889 crate::model::push_config::Wrapper::PubsubWrapper(v) => std::option::Option::Some(v),
5890 _ => std::option::Option::None,
5891 })
5892 }
5893
5894 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5895 /// to hold a `PubsubWrapper`.
5896 ///
5897 /// Note that all the setters affecting `wrapper` are
5898 /// mutually exclusive.
5899 ///
5900 /// # Example
5901 /// ```ignore,no_run
5902 /// # use google_cloud_pubsub::model::PushConfig;
5903 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5904 /// let x = PushConfig::new().set_pubsub_wrapper(PubsubWrapper::default()/* use setters */);
5905 /// assert!(x.pubsub_wrapper().is_some());
5906 /// assert!(x.no_wrapper().is_none());
5907 /// ```
5908 pub fn set_pubsub_wrapper<
5909 T: std::convert::Into<std::boxed::Box<crate::model::push_config::PubsubWrapper>>,
5910 >(
5911 mut self,
5912 v: T,
5913 ) -> Self {
5914 self.wrapper =
5915 std::option::Option::Some(crate::model::push_config::Wrapper::PubsubWrapper(v.into()));
5916 self
5917 }
5918
5919 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5920 /// if it holds a `NoWrapper`, `None` if the field is not set or
5921 /// holds a different branch.
5922 pub fn no_wrapper(
5923 &self,
5924 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::NoWrapper>> {
5925 #[allow(unreachable_patterns)]
5926 self.wrapper.as_ref().and_then(|v| match v {
5927 crate::model::push_config::Wrapper::NoWrapper(v) => std::option::Option::Some(v),
5928 _ => std::option::Option::None,
5929 })
5930 }
5931
5932 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5933 /// to hold a `NoWrapper`.
5934 ///
5935 /// Note that all the setters affecting `wrapper` are
5936 /// mutually exclusive.
5937 ///
5938 /// # Example
5939 /// ```ignore,no_run
5940 /// # use google_cloud_pubsub::model::PushConfig;
5941 /// use google_cloud_pubsub::model::push_config::NoWrapper;
5942 /// let x = PushConfig::new().set_no_wrapper(NoWrapper::default()/* use setters */);
5943 /// assert!(x.no_wrapper().is_some());
5944 /// assert!(x.pubsub_wrapper().is_none());
5945 /// ```
5946 pub fn set_no_wrapper<
5947 T: std::convert::Into<std::boxed::Box<crate::model::push_config::NoWrapper>>,
5948 >(
5949 mut self,
5950 v: T,
5951 ) -> Self {
5952 self.wrapper =
5953 std::option::Option::Some(crate::model::push_config::Wrapper::NoWrapper(v.into()));
5954 self
5955 }
5956}
5957
5958impl wkt::message::Message for PushConfig {
5959 fn typename() -> &'static str {
5960 "type.googleapis.com/google.pubsub.v1.PushConfig"
5961 }
5962}
5963
5964/// Defines additional types related to [PushConfig].
5965pub mod push_config {
5966 #[allow(unused_imports)]
5967 use super::*;
5968
5969 /// Contains information needed for generating an
5970 /// [OpenID Connect
5971 /// token](https://developers.google.com/identity/protocols/OpenIDConnect).
5972 #[derive(Clone, Default, PartialEq)]
5973 #[non_exhaustive]
5974 pub struct OidcToken {
5975 /// Optional. [Service account
5976 /// email](https://cloud.google.com/iam/docs/service-accounts)
5977 /// used for generating the OIDC token. For more information
5978 /// on setting up authentication, see
5979 /// [Push subscriptions](https://cloud.google.com/pubsub/docs/push).
5980 pub service_account_email: std::string::String,
5981
5982 /// Optional. Audience to be used when generating OIDC token. The audience
5983 /// claim identifies the recipients that the JWT is intended for. The
5984 /// audience value is a single case-sensitive string. Having multiple values
5985 /// (array) for the audience field is not supported. More info about the OIDC
5986 /// JWT token audience here:
5987 /// <https://tools.ietf.org/html/rfc7519#section-4.1.3> Note: if not specified,
5988 /// the Push endpoint URL will be used.
5989 pub audience: std::string::String,
5990
5991 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5992 }
5993
5994 impl OidcToken {
5995 /// Creates a new default instance.
5996 pub fn new() -> Self {
5997 std::default::Default::default()
5998 }
5999
6000 /// Sets the value of [service_account_email][crate::model::push_config::OidcToken::service_account_email].
6001 ///
6002 /// # Example
6003 /// ```ignore,no_run
6004 /// # use google_cloud_pubsub::model::push_config::OidcToken;
6005 /// let x = OidcToken::new().set_service_account_email("example");
6006 /// ```
6007 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6008 mut self,
6009 v: T,
6010 ) -> Self {
6011 self.service_account_email = v.into();
6012 self
6013 }
6014
6015 /// Sets the value of [audience][crate::model::push_config::OidcToken::audience].
6016 ///
6017 /// # Example
6018 /// ```ignore,no_run
6019 /// # use google_cloud_pubsub::model::push_config::OidcToken;
6020 /// let x = OidcToken::new().set_audience("example");
6021 /// ```
6022 pub fn set_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6023 self.audience = v.into();
6024 self
6025 }
6026 }
6027
6028 impl wkt::message::Message for OidcToken {
6029 fn typename() -> &'static str {
6030 "type.googleapis.com/google.pubsub.v1.PushConfig.OidcToken"
6031 }
6032 }
6033
6034 /// The payload to the push endpoint is in the form of the JSON representation
6035 /// of a PubsubMessage
6036 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
6037 #[derive(Clone, Default, PartialEq)]
6038 #[non_exhaustive]
6039 pub struct PubsubWrapper {
6040 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6041 }
6042
6043 impl PubsubWrapper {
6044 /// Creates a new default instance.
6045 pub fn new() -> Self {
6046 std::default::Default::default()
6047 }
6048 }
6049
6050 impl wkt::message::Message for PubsubWrapper {
6051 fn typename() -> &'static str {
6052 "type.googleapis.com/google.pubsub.v1.PushConfig.PubsubWrapper"
6053 }
6054 }
6055
6056 /// Sets the `data` field as the HTTP body for delivery.
6057 #[derive(Clone, Default, PartialEq)]
6058 #[non_exhaustive]
6059 pub struct NoWrapper {
6060 /// Optional. When true, writes the Pub/Sub message metadata to
6061 /// `x-goog-pubsub-<KEY>:<VAL>` headers of the HTTP request. Writes the
6062 /// Pub/Sub message attributes to `<KEY>:<VAL>` headers of the HTTP request.
6063 pub write_metadata: bool,
6064
6065 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6066 }
6067
6068 impl NoWrapper {
6069 /// Creates a new default instance.
6070 pub fn new() -> Self {
6071 std::default::Default::default()
6072 }
6073
6074 /// Sets the value of [write_metadata][crate::model::push_config::NoWrapper::write_metadata].
6075 ///
6076 /// # Example
6077 /// ```ignore,no_run
6078 /// # use google_cloud_pubsub::model::push_config::NoWrapper;
6079 /// let x = NoWrapper::new().set_write_metadata(true);
6080 /// ```
6081 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6082 self.write_metadata = v.into();
6083 self
6084 }
6085 }
6086
6087 impl wkt::message::Message for NoWrapper {
6088 fn typename() -> &'static str {
6089 "type.googleapis.com/google.pubsub.v1.PushConfig.NoWrapper"
6090 }
6091 }
6092
6093 /// An authentication method used by push endpoints to verify the source of
6094 /// push requests. This can be used with push endpoints that are private by
6095 /// default to allow requests only from the Pub/Sub system, for example.
6096 /// This field is optional and should be set only by users interested in
6097 /// authenticated push.
6098 #[derive(Clone, Debug, PartialEq)]
6099 #[non_exhaustive]
6100 pub enum AuthenticationMethod {
6101 /// Optional. If specified, Pub/Sub will generate and attach an OIDC JWT
6102 /// token as an `Authorization` header in the HTTP request for every pushed
6103 /// message.
6104 OidcToken(std::boxed::Box<crate::model::push_config::OidcToken>),
6105 }
6106
6107 /// The format of the delivered message to the push endpoint is defined by
6108 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
6109 #[derive(Clone, Debug, PartialEq)]
6110 #[non_exhaustive]
6111 pub enum Wrapper {
6112 /// Optional. When set, the payload to the push endpoint is in the form of
6113 /// the JSON representation of a PubsubMessage
6114 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
6115 PubsubWrapper(std::boxed::Box<crate::model::push_config::PubsubWrapper>),
6116 /// Optional. When set, the payload to the push endpoint is not wrapped.
6117 NoWrapper(std::boxed::Box<crate::model::push_config::NoWrapper>),
6118 }
6119}
6120
6121/// Configuration for a BigQuery subscription.
6122#[derive(Clone, Default, PartialEq)]
6123#[non_exhaustive]
6124pub struct BigQueryConfig {
6125 /// Optional. The name of the table to which to write data, of the form
6126 /// {projectId}.{datasetId}.{tableId}
6127 pub table: std::string::String,
6128
6129 /// Optional. When true, use the topic's schema as the columns to write to in
6130 /// BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be
6131 /// enabled at the same time.
6132 pub use_topic_schema: bool,
6133
6134 /// Optional. When true, write the subscription name, message_id, publish_time,
6135 /// attributes, and ordering_key to additional columns in the table. The
6136 /// subscription name, message_id, and publish_time fields are put in their own
6137 /// columns while all other message properties (other than data) are written to
6138 /// a JSON object in the attributes column.
6139 pub write_metadata: bool,
6140
6141 /// Optional. If true and `use_topic_schema` is true, drops any fields that are
6142 /// part of the topic schema that are not part of the BigQuery table schema
6143 /// when writing to BigQuery. Otherwise, the schemas must be kept in sync and
6144 /// any messages with extra fields are not written and remain in the
6145 /// subscription's backlog. If true and `use_table_schema` is true, drops any
6146 /// fields in the message that are not part of the BigQuery table schema when
6147 /// writing to BigQuery. Otherwise, the write to BigQuery will fail.
6148 pub drop_unknown_fields: bool,
6149
6150 /// Output only. An output-only field that indicates whether or not the
6151 /// subscription can receive messages.
6152 pub state: crate::model::big_query_config::State,
6153
6154 /// Optional. When true, use the BigQuery table's schema as the columns to
6155 /// write to in BigQuery. `use_table_schema` and `use_topic_schema` cannot be
6156 /// enabled at the same time.
6157 pub use_table_schema: bool,
6158
6159 /// Optional. The service account to use to write to BigQuery. The subscription
6160 /// creator or updater that specifies this field must have
6161 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6162 /// specified, the Pub/Sub [service
6163 /// agent](https://cloud.google.com/iam/docs/service-agents),
6164 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6165 pub service_account_email: std::string::String,
6166
6167 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6168}
6169
6170impl BigQueryConfig {
6171 /// Creates a new default instance.
6172 pub fn new() -> Self {
6173 std::default::Default::default()
6174 }
6175
6176 /// Sets the value of [table][crate::model::BigQueryConfig::table].
6177 ///
6178 /// # Example
6179 /// ```ignore,no_run
6180 /// # use google_cloud_pubsub::model::BigQueryConfig;
6181 /// let x = BigQueryConfig::new().set_table("example");
6182 /// ```
6183 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6184 self.table = v.into();
6185 self
6186 }
6187
6188 /// Sets the value of [use_topic_schema][crate::model::BigQueryConfig::use_topic_schema].
6189 ///
6190 /// # Example
6191 /// ```ignore,no_run
6192 /// # use google_cloud_pubsub::model::BigQueryConfig;
6193 /// let x = BigQueryConfig::new().set_use_topic_schema(true);
6194 /// ```
6195 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6196 self.use_topic_schema = v.into();
6197 self
6198 }
6199
6200 /// Sets the value of [write_metadata][crate::model::BigQueryConfig::write_metadata].
6201 ///
6202 /// # Example
6203 /// ```ignore,no_run
6204 /// # use google_cloud_pubsub::model::BigQueryConfig;
6205 /// let x = BigQueryConfig::new().set_write_metadata(true);
6206 /// ```
6207 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6208 self.write_metadata = v.into();
6209 self
6210 }
6211
6212 /// Sets the value of [drop_unknown_fields][crate::model::BigQueryConfig::drop_unknown_fields].
6213 ///
6214 /// # Example
6215 /// ```ignore,no_run
6216 /// # use google_cloud_pubsub::model::BigQueryConfig;
6217 /// let x = BigQueryConfig::new().set_drop_unknown_fields(true);
6218 /// ```
6219 pub fn set_drop_unknown_fields<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6220 self.drop_unknown_fields = v.into();
6221 self
6222 }
6223
6224 /// Sets the value of [state][crate::model::BigQueryConfig::state].
6225 ///
6226 /// # Example
6227 /// ```ignore,no_run
6228 /// # use google_cloud_pubsub::model::BigQueryConfig;
6229 /// use google_cloud_pubsub::model::big_query_config::State;
6230 /// let x0 = BigQueryConfig::new().set_state(State::Active);
6231 /// let x1 = BigQueryConfig::new().set_state(State::PermissionDenied);
6232 /// let x2 = BigQueryConfig::new().set_state(State::NotFound);
6233 /// ```
6234 pub fn set_state<T: std::convert::Into<crate::model::big_query_config::State>>(
6235 mut self,
6236 v: T,
6237 ) -> Self {
6238 self.state = v.into();
6239 self
6240 }
6241
6242 /// Sets the value of [use_table_schema][crate::model::BigQueryConfig::use_table_schema].
6243 ///
6244 /// # Example
6245 /// ```ignore,no_run
6246 /// # use google_cloud_pubsub::model::BigQueryConfig;
6247 /// let x = BigQueryConfig::new().set_use_table_schema(true);
6248 /// ```
6249 pub fn set_use_table_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6250 self.use_table_schema = v.into();
6251 self
6252 }
6253
6254 /// Sets the value of [service_account_email][crate::model::BigQueryConfig::service_account_email].
6255 ///
6256 /// # Example
6257 /// ```ignore,no_run
6258 /// # use google_cloud_pubsub::model::BigQueryConfig;
6259 /// let x = BigQueryConfig::new().set_service_account_email("example");
6260 /// ```
6261 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6262 mut self,
6263 v: T,
6264 ) -> Self {
6265 self.service_account_email = v.into();
6266 self
6267 }
6268}
6269
6270impl wkt::message::Message for BigQueryConfig {
6271 fn typename() -> &'static str {
6272 "type.googleapis.com/google.pubsub.v1.BigQueryConfig"
6273 }
6274}
6275
6276/// Defines additional types related to [BigQueryConfig].
6277pub mod big_query_config {
6278 #[allow(unused_imports)]
6279 use super::*;
6280
6281 /// Possible states for a BigQuery subscription.
6282 ///
6283 /// # Working with unknown values
6284 ///
6285 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6286 /// additional enum variants at any time. Adding new variants is not considered
6287 /// a breaking change. Applications should write their code in anticipation of:
6288 ///
6289 /// - New values appearing in future releases of the client library, **and**
6290 /// - New values received dynamically, without application changes.
6291 ///
6292 /// Please consult the [Working with enums] section in the user guide for some
6293 /// guidelines.
6294 ///
6295 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6296 #[derive(Clone, Debug, PartialEq)]
6297 #[non_exhaustive]
6298 pub enum State {
6299 /// Default value. This value is unused.
6300 Unspecified,
6301 /// The subscription can actively send messages to BigQuery
6302 Active,
6303 /// Cannot write to the BigQuery table because of permission denied errors.
6304 /// This can happen if
6305 ///
6306 /// - Pub/Sub SA has not been granted the [appropriate BigQuery IAM
6307 /// permissions](https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account)
6308 /// - bigquery.googleapis.com API is not enabled for the project
6309 /// ([instructions](https://cloud.google.com/service-usage/docs/enable-disable))
6310 PermissionDenied,
6311 /// Cannot write to the BigQuery table because it does not exist.
6312 NotFound,
6313 /// Cannot write to the BigQuery table due to a schema mismatch.
6314 SchemaMismatch,
6315 /// Cannot write to the destination because enforce_in_transit is set to true
6316 /// and the destination locations are not in the allowed regions.
6317 InTransitLocationRestriction,
6318 /// Cannot write to the BigQuery table because the table is not in the same
6319 /// location as where Vertex AI models used in `message_transform`s are
6320 /// deployed.
6321 VertexAiLocationRestriction,
6322 /// If set, the enum was initialized with an unknown value.
6323 ///
6324 /// Applications can examine the value using [State::value] or
6325 /// [State::name].
6326 UnknownValue(state::UnknownValue),
6327 }
6328
6329 #[doc(hidden)]
6330 pub mod state {
6331 #[allow(unused_imports)]
6332 use super::*;
6333 #[derive(Clone, Debug, PartialEq)]
6334 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6335 }
6336
6337 impl State {
6338 /// Gets the enum value.
6339 ///
6340 /// Returns `None` if the enum contains an unknown value deserialized from
6341 /// the string representation of enums.
6342 pub fn value(&self) -> std::option::Option<i32> {
6343 match self {
6344 Self::Unspecified => std::option::Option::Some(0),
6345 Self::Active => std::option::Option::Some(1),
6346 Self::PermissionDenied => std::option::Option::Some(2),
6347 Self::NotFound => std::option::Option::Some(3),
6348 Self::SchemaMismatch => std::option::Option::Some(4),
6349 Self::InTransitLocationRestriction => std::option::Option::Some(5),
6350 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
6351 Self::UnknownValue(u) => u.0.value(),
6352 }
6353 }
6354
6355 /// Gets the enum value as a string.
6356 ///
6357 /// Returns `None` if the enum contains an unknown value deserialized from
6358 /// the integer representation of enums.
6359 pub fn name(&self) -> std::option::Option<&str> {
6360 match self {
6361 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6362 Self::Active => std::option::Option::Some("ACTIVE"),
6363 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6364 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6365 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6366 Self::InTransitLocationRestriction => {
6367 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6368 }
6369 Self::VertexAiLocationRestriction => {
6370 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6371 }
6372 Self::UnknownValue(u) => u.0.name(),
6373 }
6374 }
6375 }
6376
6377 impl std::default::Default for State {
6378 fn default() -> Self {
6379 use std::convert::From;
6380 Self::from(0)
6381 }
6382 }
6383
6384 impl std::fmt::Display for State {
6385 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6386 wkt::internal::display_enum(f, self.name(), self.value())
6387 }
6388 }
6389
6390 impl std::convert::From<i32> for State {
6391 fn from(value: i32) -> Self {
6392 match value {
6393 0 => Self::Unspecified,
6394 1 => Self::Active,
6395 2 => Self::PermissionDenied,
6396 3 => Self::NotFound,
6397 4 => Self::SchemaMismatch,
6398 5 => Self::InTransitLocationRestriction,
6399 6 => Self::VertexAiLocationRestriction,
6400 _ => Self::UnknownValue(state::UnknownValue(
6401 wkt::internal::UnknownEnumValue::Integer(value),
6402 )),
6403 }
6404 }
6405 }
6406
6407 impl std::convert::From<&str> for State {
6408 fn from(value: &str) -> Self {
6409 use std::string::ToString;
6410 match value {
6411 "STATE_UNSPECIFIED" => Self::Unspecified,
6412 "ACTIVE" => Self::Active,
6413 "PERMISSION_DENIED" => Self::PermissionDenied,
6414 "NOT_FOUND" => Self::NotFound,
6415 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6416 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6417 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6418 _ => Self::UnknownValue(state::UnknownValue(
6419 wkt::internal::UnknownEnumValue::String(value.to_string()),
6420 )),
6421 }
6422 }
6423 }
6424
6425 impl serde::ser::Serialize for State {
6426 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6427 where
6428 S: serde::Serializer,
6429 {
6430 match self {
6431 Self::Unspecified => serializer.serialize_i32(0),
6432 Self::Active => serializer.serialize_i32(1),
6433 Self::PermissionDenied => serializer.serialize_i32(2),
6434 Self::NotFound => serializer.serialize_i32(3),
6435 Self::SchemaMismatch => serializer.serialize_i32(4),
6436 Self::InTransitLocationRestriction => serializer.serialize_i32(5),
6437 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
6438 Self::UnknownValue(u) => u.0.serialize(serializer),
6439 }
6440 }
6441 }
6442
6443 impl<'de> serde::de::Deserialize<'de> for State {
6444 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6445 where
6446 D: serde::Deserializer<'de>,
6447 {
6448 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6449 ".google.pubsub.v1.BigQueryConfig.State",
6450 ))
6451 }
6452 }
6453}
6454
6455/// Configuration for a Bigtable subscription. The Pub/Sub message will be
6456/// written to a Bigtable row as follows:
6457///
6458/// - row key: subscription name, message ID hash, and message ID delimited by
6459/// `#`.
6460/// - columns: message bytes written to a single column family `data` with an
6461/// empty-string column qualifier.
6462/// - cell timestamp: the message publish timestamp.
6463#[derive(Clone, Default, PartialEq)]
6464#[non_exhaustive]
6465pub struct BigtableConfig {
6466 /// Optional. The unique name of the table to write messages to.
6467 ///
6468 /// Values are of the form
6469 /// `projects/<project>/instances/<instance>/tables/<table>`.
6470 pub table: std::string::String,
6471
6472 /// Optional. The app profile to use for the Bigtable writes. If not specified,
6473 /// the "default" application profile will be used. The app profile must use
6474 /// single-cluster routing.
6475 pub app_profile_id: std::string::String,
6476
6477 /// Optional. The service account to use to write to Bigtable. The subscription
6478 /// creator or updater that specifies this field must have
6479 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6480 /// specified, the Pub/Sub [service
6481 /// agent](https://cloud.google.com/iam/docs/service-agents),
6482 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6483 pub service_account_email: std::string::String,
6484
6485 /// Optional. When true, write the subscription name, message_id, publish_time,
6486 /// attributes, and ordering_key to additional columns in the table under the
6487 /// pubsub_metadata column family. The subscription name, message_id, and
6488 /// publish_time fields are put in their own columns while all other message
6489 /// properties (other than data) are written to a JSON object in the attributes
6490 /// column.
6491 pub write_metadata: bool,
6492
6493 /// Output only. An output-only field that indicates whether or not the
6494 /// subscription can receive messages.
6495 pub state: crate::model::bigtable_config::State,
6496
6497 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6498}
6499
6500impl BigtableConfig {
6501 /// Creates a new default instance.
6502 pub fn new() -> Self {
6503 std::default::Default::default()
6504 }
6505
6506 /// Sets the value of [table][crate::model::BigtableConfig::table].
6507 ///
6508 /// # Example
6509 /// ```ignore,no_run
6510 /// # use google_cloud_pubsub::model::BigtableConfig;
6511 /// let x = BigtableConfig::new().set_table("example");
6512 /// ```
6513 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6514 self.table = v.into();
6515 self
6516 }
6517
6518 /// Sets the value of [app_profile_id][crate::model::BigtableConfig::app_profile_id].
6519 ///
6520 /// # Example
6521 /// ```ignore,no_run
6522 /// # use google_cloud_pubsub::model::BigtableConfig;
6523 /// let x = BigtableConfig::new().set_app_profile_id("example");
6524 /// ```
6525 pub fn set_app_profile_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6526 self.app_profile_id = v.into();
6527 self
6528 }
6529
6530 /// Sets the value of [service_account_email][crate::model::BigtableConfig::service_account_email].
6531 ///
6532 /// # Example
6533 /// ```ignore,no_run
6534 /// # use google_cloud_pubsub::model::BigtableConfig;
6535 /// let x = BigtableConfig::new().set_service_account_email("example");
6536 /// ```
6537 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6538 mut self,
6539 v: T,
6540 ) -> Self {
6541 self.service_account_email = v.into();
6542 self
6543 }
6544
6545 /// Sets the value of [write_metadata][crate::model::BigtableConfig::write_metadata].
6546 ///
6547 /// # Example
6548 /// ```ignore,no_run
6549 /// # use google_cloud_pubsub::model::BigtableConfig;
6550 /// let x = BigtableConfig::new().set_write_metadata(true);
6551 /// ```
6552 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6553 self.write_metadata = v.into();
6554 self
6555 }
6556
6557 /// Sets the value of [state][crate::model::BigtableConfig::state].
6558 ///
6559 /// # Example
6560 /// ```ignore,no_run
6561 /// # use google_cloud_pubsub::model::BigtableConfig;
6562 /// use google_cloud_pubsub::model::bigtable_config::State;
6563 /// let x0 = BigtableConfig::new().set_state(State::Active);
6564 /// let x1 = BigtableConfig::new().set_state(State::NotFound);
6565 /// let x2 = BigtableConfig::new().set_state(State::AppProfileMisconfigured);
6566 /// ```
6567 pub fn set_state<T: std::convert::Into<crate::model::bigtable_config::State>>(
6568 mut self,
6569 v: T,
6570 ) -> Self {
6571 self.state = v.into();
6572 self
6573 }
6574}
6575
6576impl wkt::message::Message for BigtableConfig {
6577 fn typename() -> &'static str {
6578 "type.googleapis.com/google.pubsub.v1.BigtableConfig"
6579 }
6580}
6581
6582/// Defines additional types related to [BigtableConfig].
6583pub mod bigtable_config {
6584 #[allow(unused_imports)]
6585 use super::*;
6586
6587 /// Possible states for a Bigtable subscription.
6588 /// Note: more states could be added in the future. Please code accordingly.
6589 ///
6590 /// # Working with unknown values
6591 ///
6592 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6593 /// additional enum variants at any time. Adding new variants is not considered
6594 /// a breaking change. Applications should write their code in anticipation of:
6595 ///
6596 /// - New values appearing in future releases of the client library, **and**
6597 /// - New values received dynamically, without application changes.
6598 ///
6599 /// Please consult the [Working with enums] section in the user guide for some
6600 /// guidelines.
6601 ///
6602 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6603 #[derive(Clone, Debug, PartialEq)]
6604 #[non_exhaustive]
6605 pub enum State {
6606 /// Default value. This value is unused.
6607 Unspecified,
6608 /// The subscription can actively send messages to Bigtable.
6609 Active,
6610 /// Unused in the current implementation. Placeholder for future use.
6611 NotFound,
6612 /// Unused in the current implementation. Placeholder for future use.
6613 AppProfileMisconfigured,
6614 /// Cannot write to Bigtable because of permission denied errors.
6615 /// This can happen if:
6616 ///
6617 /// - The Bigtable instance, table, or app profile does not exist.
6618 /// - The Pub/Sub service agent has not been granted the
6619 /// [appropriate Bigtable IAM permission
6620 /// bigtable.tables.mutateRows]({$universe.dns_names.final_documentation_domain}/bigtable/docs/access-control#permissions)
6621 /// - The bigtable.googleapis.com API is not enabled for the project
6622 /// ([instructions]({$universe.dns_names.final_documentation_domain}/service-usage/docs/enable-disable))
6623 PermissionDenied,
6624 /// Cannot write to Bigtable because of a missing column family (`data`), or
6625 /// if there is no structured row key for the subscription name + message ID,
6626 /// if because the app profile is not configured for single-cluster routing.
6627 SchemaMismatch,
6628 /// Cannot write to the destination because enforce_in_transit is set to true
6629 /// and the destination locations are not in the allowed regions.
6630 InTransitLocationRestriction,
6631 /// Cannot write to Bigtable because the table is not in the same location as
6632 /// where Vertex AI models used in `message_transform`s are deployed.
6633 VertexAiLocationRestriction,
6634 /// If set, the enum was initialized with an unknown value.
6635 ///
6636 /// Applications can examine the value using [State::value] or
6637 /// [State::name].
6638 UnknownValue(state::UnknownValue),
6639 }
6640
6641 #[doc(hidden)]
6642 pub mod state {
6643 #[allow(unused_imports)]
6644 use super::*;
6645 #[derive(Clone, Debug, PartialEq)]
6646 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6647 }
6648
6649 impl State {
6650 /// Gets the enum value.
6651 ///
6652 /// Returns `None` if the enum contains an unknown value deserialized from
6653 /// the string representation of enums.
6654 pub fn value(&self) -> std::option::Option<i32> {
6655 match self {
6656 Self::Unspecified => std::option::Option::Some(0),
6657 Self::Active => std::option::Option::Some(1),
6658 Self::NotFound => std::option::Option::Some(2),
6659 Self::AppProfileMisconfigured => std::option::Option::Some(3),
6660 Self::PermissionDenied => std::option::Option::Some(4),
6661 Self::SchemaMismatch => std::option::Option::Some(5),
6662 Self::InTransitLocationRestriction => std::option::Option::Some(6),
6663 Self::VertexAiLocationRestriction => std::option::Option::Some(7),
6664 Self::UnknownValue(u) => u.0.value(),
6665 }
6666 }
6667
6668 /// Gets the enum value as a string.
6669 ///
6670 /// Returns `None` if the enum contains an unknown value deserialized from
6671 /// the integer representation of enums.
6672 pub fn name(&self) -> std::option::Option<&str> {
6673 match self {
6674 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6675 Self::Active => std::option::Option::Some("ACTIVE"),
6676 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6677 Self::AppProfileMisconfigured => {
6678 std::option::Option::Some("APP_PROFILE_MISCONFIGURED")
6679 }
6680 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6681 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6682 Self::InTransitLocationRestriction => {
6683 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6684 }
6685 Self::VertexAiLocationRestriction => {
6686 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6687 }
6688 Self::UnknownValue(u) => u.0.name(),
6689 }
6690 }
6691 }
6692
6693 impl std::default::Default for State {
6694 fn default() -> Self {
6695 use std::convert::From;
6696 Self::from(0)
6697 }
6698 }
6699
6700 impl std::fmt::Display for State {
6701 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6702 wkt::internal::display_enum(f, self.name(), self.value())
6703 }
6704 }
6705
6706 impl std::convert::From<i32> for State {
6707 fn from(value: i32) -> Self {
6708 match value {
6709 0 => Self::Unspecified,
6710 1 => Self::Active,
6711 2 => Self::NotFound,
6712 3 => Self::AppProfileMisconfigured,
6713 4 => Self::PermissionDenied,
6714 5 => Self::SchemaMismatch,
6715 6 => Self::InTransitLocationRestriction,
6716 7 => Self::VertexAiLocationRestriction,
6717 _ => Self::UnknownValue(state::UnknownValue(
6718 wkt::internal::UnknownEnumValue::Integer(value),
6719 )),
6720 }
6721 }
6722 }
6723
6724 impl std::convert::From<&str> for State {
6725 fn from(value: &str) -> Self {
6726 use std::string::ToString;
6727 match value {
6728 "STATE_UNSPECIFIED" => Self::Unspecified,
6729 "ACTIVE" => Self::Active,
6730 "NOT_FOUND" => Self::NotFound,
6731 "APP_PROFILE_MISCONFIGURED" => Self::AppProfileMisconfigured,
6732 "PERMISSION_DENIED" => Self::PermissionDenied,
6733 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6734 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6735 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6736 _ => Self::UnknownValue(state::UnknownValue(
6737 wkt::internal::UnknownEnumValue::String(value.to_string()),
6738 )),
6739 }
6740 }
6741 }
6742
6743 impl serde::ser::Serialize for State {
6744 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6745 where
6746 S: serde::Serializer,
6747 {
6748 match self {
6749 Self::Unspecified => serializer.serialize_i32(0),
6750 Self::Active => serializer.serialize_i32(1),
6751 Self::NotFound => serializer.serialize_i32(2),
6752 Self::AppProfileMisconfigured => serializer.serialize_i32(3),
6753 Self::PermissionDenied => serializer.serialize_i32(4),
6754 Self::SchemaMismatch => serializer.serialize_i32(5),
6755 Self::InTransitLocationRestriction => serializer.serialize_i32(6),
6756 Self::VertexAiLocationRestriction => serializer.serialize_i32(7),
6757 Self::UnknownValue(u) => u.0.serialize(serializer),
6758 }
6759 }
6760 }
6761
6762 impl<'de> serde::de::Deserialize<'de> for State {
6763 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6764 where
6765 D: serde::Deserializer<'de>,
6766 {
6767 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6768 ".google.pubsub.v1.BigtableConfig.State",
6769 ))
6770 }
6771 }
6772}
6773
6774/// Configuration for a Cloud Storage subscription.
6775#[derive(Clone, Default, PartialEq)]
6776#[non_exhaustive]
6777pub struct CloudStorageConfig {
6778 /// Required. User-provided name for the Cloud Storage bucket.
6779 /// The bucket must be created by the user. The bucket name must be without
6780 /// any prefix like "gs://". See the [bucket naming
6781 /// requirements] (<https://cloud.google.com/storage/docs/buckets#naming>).
6782 pub bucket: std::string::String,
6783
6784 /// Optional. User-provided prefix for Cloud Storage filename. See the [object
6785 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6786 pub filename_prefix: std::string::String,
6787
6788 /// Optional. User-provided suffix for Cloud Storage filename. See the [object
6789 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6790 /// Must not end in "/".
6791 pub filename_suffix: std::string::String,
6792
6793 /// Optional. User-provided format string specifying how to represent datetimes
6794 /// in Cloud Storage filenames. See the [datetime format
6795 /// guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
6796 pub filename_datetime_format: std::string::String,
6797
6798 /// Optional. The maximum duration that can elapse before a new Cloud Storage
6799 /// file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not
6800 /// exceed the subscription's acknowledgment deadline.
6801 pub max_duration: std::option::Option<wkt::Duration>,
6802
6803 /// Optional. The maximum bytes that can be written to a Cloud Storage file
6804 /// before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may
6805 /// be exceeded in cases where messages are larger than the limit.
6806 pub max_bytes: i64,
6807
6808 /// Optional. The maximum number of messages that can be written to a Cloud
6809 /// Storage file before a new file is created. Min 1000 messages.
6810 pub max_messages: i64,
6811
6812 /// Output only. An output-only field that indicates whether or not the
6813 /// subscription can receive messages.
6814 pub state: crate::model::cloud_storage_config::State,
6815
6816 /// Optional. The service account to use to write to Cloud Storage. The
6817 /// subscription creator or updater that specifies this field must have
6818 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6819 /// specified, the Pub/Sub
6820 /// [service agent](https://cloud.google.com/iam/docs/service-agents),
6821 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6822 pub service_account_email: std::string::String,
6823
6824 /// Defaults to text format.
6825 pub output_format: std::option::Option<crate::model::cloud_storage_config::OutputFormat>,
6826
6827 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6828}
6829
6830impl CloudStorageConfig {
6831 /// Creates a new default instance.
6832 pub fn new() -> Self {
6833 std::default::Default::default()
6834 }
6835
6836 /// Sets the value of [bucket][crate::model::CloudStorageConfig::bucket].
6837 ///
6838 /// # Example
6839 /// ```ignore,no_run
6840 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6841 /// let x = CloudStorageConfig::new().set_bucket("example");
6842 /// ```
6843 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6844 self.bucket = v.into();
6845 self
6846 }
6847
6848 /// Sets the value of [filename_prefix][crate::model::CloudStorageConfig::filename_prefix].
6849 ///
6850 /// # Example
6851 /// ```ignore,no_run
6852 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6853 /// let x = CloudStorageConfig::new().set_filename_prefix("example");
6854 /// ```
6855 pub fn set_filename_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6856 self.filename_prefix = v.into();
6857 self
6858 }
6859
6860 /// Sets the value of [filename_suffix][crate::model::CloudStorageConfig::filename_suffix].
6861 ///
6862 /// # Example
6863 /// ```ignore,no_run
6864 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6865 /// let x = CloudStorageConfig::new().set_filename_suffix("example");
6866 /// ```
6867 pub fn set_filename_suffix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6868 self.filename_suffix = v.into();
6869 self
6870 }
6871
6872 /// Sets the value of [filename_datetime_format][crate::model::CloudStorageConfig::filename_datetime_format].
6873 ///
6874 /// # Example
6875 /// ```ignore,no_run
6876 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6877 /// let x = CloudStorageConfig::new().set_filename_datetime_format("example");
6878 /// ```
6879 pub fn set_filename_datetime_format<T: std::convert::Into<std::string::String>>(
6880 mut self,
6881 v: T,
6882 ) -> Self {
6883 self.filename_datetime_format = v.into();
6884 self
6885 }
6886
6887 /// Sets the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6888 ///
6889 /// # Example
6890 /// ```ignore,no_run
6891 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6892 /// use wkt::Duration;
6893 /// let x = CloudStorageConfig::new().set_max_duration(Duration::default()/* use setters */);
6894 /// ```
6895 pub fn set_max_duration<T>(mut self, v: T) -> Self
6896 where
6897 T: std::convert::Into<wkt::Duration>,
6898 {
6899 self.max_duration = std::option::Option::Some(v.into());
6900 self
6901 }
6902
6903 /// Sets or clears the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6904 ///
6905 /// # Example
6906 /// ```ignore,no_run
6907 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6908 /// use wkt::Duration;
6909 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6910 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(None::<Duration>);
6911 /// ```
6912 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6913 where
6914 T: std::convert::Into<wkt::Duration>,
6915 {
6916 self.max_duration = v.map(|x| x.into());
6917 self
6918 }
6919
6920 /// Sets the value of [max_bytes][crate::model::CloudStorageConfig::max_bytes].
6921 ///
6922 /// # Example
6923 /// ```ignore,no_run
6924 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6925 /// let x = CloudStorageConfig::new().set_max_bytes(42);
6926 /// ```
6927 pub fn set_max_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6928 self.max_bytes = v.into();
6929 self
6930 }
6931
6932 /// Sets the value of [max_messages][crate::model::CloudStorageConfig::max_messages].
6933 ///
6934 /// # Example
6935 /// ```ignore,no_run
6936 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6937 /// let x = CloudStorageConfig::new().set_max_messages(42);
6938 /// ```
6939 pub fn set_max_messages<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6940 self.max_messages = v.into();
6941 self
6942 }
6943
6944 /// Sets the value of [state][crate::model::CloudStorageConfig::state].
6945 ///
6946 /// # Example
6947 /// ```ignore,no_run
6948 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6949 /// use google_cloud_pubsub::model::cloud_storage_config::State;
6950 /// let x0 = CloudStorageConfig::new().set_state(State::Active);
6951 /// let x1 = CloudStorageConfig::new().set_state(State::PermissionDenied);
6952 /// let x2 = CloudStorageConfig::new().set_state(State::NotFound);
6953 /// ```
6954 pub fn set_state<T: std::convert::Into<crate::model::cloud_storage_config::State>>(
6955 mut self,
6956 v: T,
6957 ) -> Self {
6958 self.state = v.into();
6959 self
6960 }
6961
6962 /// Sets the value of [service_account_email][crate::model::CloudStorageConfig::service_account_email].
6963 ///
6964 /// # Example
6965 /// ```ignore,no_run
6966 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6967 /// let x = CloudStorageConfig::new().set_service_account_email("example");
6968 /// ```
6969 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6970 mut self,
6971 v: T,
6972 ) -> Self {
6973 self.service_account_email = v.into();
6974 self
6975 }
6976
6977 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format].
6978 ///
6979 /// Note that all the setters affecting `output_format` are mutually
6980 /// exclusive.
6981 ///
6982 /// # Example
6983 /// ```ignore,no_run
6984 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6985 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
6986 /// let x = CloudStorageConfig::new().set_output_format(Some(
6987 /// google_cloud_pubsub::model::cloud_storage_config::OutputFormat::TextConfig(TextConfig::default().into())));
6988 /// ```
6989 pub fn set_output_format<
6990 T: std::convert::Into<std::option::Option<crate::model::cloud_storage_config::OutputFormat>>,
6991 >(
6992 mut self,
6993 v: T,
6994 ) -> Self {
6995 self.output_format = v.into();
6996 self
6997 }
6998
6999 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
7000 /// if it holds a `TextConfig`, `None` if the field is not set or
7001 /// holds a different branch.
7002 pub fn text_config(
7003 &self,
7004 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::TextConfig>> {
7005 #[allow(unreachable_patterns)]
7006 self.output_format.as_ref().and_then(|v| match v {
7007 crate::model::cloud_storage_config::OutputFormat::TextConfig(v) => {
7008 std::option::Option::Some(v)
7009 }
7010 _ => std::option::Option::None,
7011 })
7012 }
7013
7014 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
7015 /// to hold a `TextConfig`.
7016 ///
7017 /// Note that all the setters affecting `output_format` are
7018 /// mutually exclusive.
7019 ///
7020 /// # Example
7021 /// ```ignore,no_run
7022 /// # use google_cloud_pubsub::model::CloudStorageConfig;
7023 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
7024 /// let x = CloudStorageConfig::new().set_text_config(TextConfig::default()/* use setters */);
7025 /// assert!(x.text_config().is_some());
7026 /// assert!(x.avro_config().is_none());
7027 /// ```
7028 pub fn set_text_config<
7029 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::TextConfig>>,
7030 >(
7031 mut self,
7032 v: T,
7033 ) -> Self {
7034 self.output_format = std::option::Option::Some(
7035 crate::model::cloud_storage_config::OutputFormat::TextConfig(v.into()),
7036 );
7037 self
7038 }
7039
7040 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
7041 /// if it holds a `AvroConfig`, `None` if the field is not set or
7042 /// holds a different branch.
7043 pub fn avro_config(
7044 &self,
7045 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>> {
7046 #[allow(unreachable_patterns)]
7047 self.output_format.as_ref().and_then(|v| match v {
7048 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v) => {
7049 std::option::Option::Some(v)
7050 }
7051 _ => std::option::Option::None,
7052 })
7053 }
7054
7055 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
7056 /// to hold a `AvroConfig`.
7057 ///
7058 /// Note that all the setters affecting `output_format` are
7059 /// mutually exclusive.
7060 ///
7061 /// # Example
7062 /// ```ignore,no_run
7063 /// # use google_cloud_pubsub::model::CloudStorageConfig;
7064 /// use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
7065 /// let x = CloudStorageConfig::new().set_avro_config(AvroConfig::default()/* use setters */);
7066 /// assert!(x.avro_config().is_some());
7067 /// assert!(x.text_config().is_none());
7068 /// ```
7069 pub fn set_avro_config<
7070 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>>,
7071 >(
7072 mut self,
7073 v: T,
7074 ) -> Self {
7075 self.output_format = std::option::Option::Some(
7076 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v.into()),
7077 );
7078 self
7079 }
7080}
7081
7082impl wkt::message::Message for CloudStorageConfig {
7083 fn typename() -> &'static str {
7084 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig"
7085 }
7086}
7087
7088/// Defines additional types related to [CloudStorageConfig].
7089pub mod cloud_storage_config {
7090 #[allow(unused_imports)]
7091 use super::*;
7092
7093 /// Configuration for writing message data in text format.
7094 /// Message payloads will be written to files as raw text, separated by a
7095 /// newline.
7096 #[derive(Clone, Default, PartialEq)]
7097 #[non_exhaustive]
7098 pub struct TextConfig {
7099 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7100 }
7101
7102 impl TextConfig {
7103 /// Creates a new default instance.
7104 pub fn new() -> Self {
7105 std::default::Default::default()
7106 }
7107 }
7108
7109 impl wkt::message::Message for TextConfig {
7110 fn typename() -> &'static str {
7111 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.TextConfig"
7112 }
7113 }
7114
7115 /// Configuration for writing message data in Avro format.
7116 /// Message payloads and metadata will be written to files as an Avro binary.
7117 #[derive(Clone, Default, PartialEq)]
7118 #[non_exhaustive]
7119 pub struct AvroConfig {
7120 /// Optional. When true, write the subscription name, message_id,
7121 /// publish_time, attributes, and ordering_key as additional fields in the
7122 /// output. The subscription name, message_id, and publish_time fields are
7123 /// put in their own fields while all other message properties other than
7124 /// data (for example, an ordering_key, if present) are added as entries in
7125 /// the attributes map.
7126 pub write_metadata: bool,
7127
7128 /// Optional. When true, the output Cloud Storage file will be serialized
7129 /// using the topic schema, if it exists.
7130 pub use_topic_schema: bool,
7131
7132 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7133 }
7134
7135 impl AvroConfig {
7136 /// Creates a new default instance.
7137 pub fn new() -> Self {
7138 std::default::Default::default()
7139 }
7140
7141 /// Sets the value of [write_metadata][crate::model::cloud_storage_config::AvroConfig::write_metadata].
7142 ///
7143 /// # Example
7144 /// ```ignore,no_run
7145 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
7146 /// let x = AvroConfig::new().set_write_metadata(true);
7147 /// ```
7148 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7149 self.write_metadata = v.into();
7150 self
7151 }
7152
7153 /// Sets the value of [use_topic_schema][crate::model::cloud_storage_config::AvroConfig::use_topic_schema].
7154 ///
7155 /// # Example
7156 /// ```ignore,no_run
7157 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
7158 /// let x = AvroConfig::new().set_use_topic_schema(true);
7159 /// ```
7160 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
7161 self.use_topic_schema = v.into();
7162 self
7163 }
7164 }
7165
7166 impl wkt::message::Message for AvroConfig {
7167 fn typename() -> &'static str {
7168 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.AvroConfig"
7169 }
7170 }
7171
7172 /// Possible states for a Cloud Storage subscription.
7173 ///
7174 /// # Working with unknown values
7175 ///
7176 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
7177 /// additional enum variants at any time. Adding new variants is not considered
7178 /// a breaking change. Applications should write their code in anticipation of:
7179 ///
7180 /// - New values appearing in future releases of the client library, **and**
7181 /// - New values received dynamically, without application changes.
7182 ///
7183 /// Please consult the [Working with enums] section in the user guide for some
7184 /// guidelines.
7185 ///
7186 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
7187 #[derive(Clone, Debug, PartialEq)]
7188 #[non_exhaustive]
7189 pub enum State {
7190 /// Default value. This value is unused.
7191 Unspecified,
7192 /// The subscription can actively send messages to Cloud Storage.
7193 Active,
7194 /// Cannot write to the Cloud Storage bucket because of permission denied
7195 /// errors.
7196 PermissionDenied,
7197 /// Cannot write to the Cloud Storage bucket because it does not exist.
7198 NotFound,
7199 /// Cannot write to the destination because enforce_in_transit is set to true
7200 /// and the destination locations are not in the allowed regions.
7201 InTransitLocationRestriction,
7202 /// Cannot write to the Cloud Storage bucket due to an incompatibility
7203 /// between the topic schema and subscription settings.
7204 SchemaMismatch,
7205 /// Cannot write to the Cloud Storage bucket because the bucket is not in the
7206 /// same location as where Vertex AI models used in `message_transform`s are
7207 /// deployed.
7208 VertexAiLocationRestriction,
7209 /// If set, the enum was initialized with an unknown value.
7210 ///
7211 /// Applications can examine the value using [State::value] or
7212 /// [State::name].
7213 UnknownValue(state::UnknownValue),
7214 }
7215
7216 #[doc(hidden)]
7217 pub mod state {
7218 #[allow(unused_imports)]
7219 use super::*;
7220 #[derive(Clone, Debug, PartialEq)]
7221 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
7222 }
7223
7224 impl State {
7225 /// Gets the enum value.
7226 ///
7227 /// Returns `None` if the enum contains an unknown value deserialized from
7228 /// the string representation of enums.
7229 pub fn value(&self) -> std::option::Option<i32> {
7230 match self {
7231 Self::Unspecified => std::option::Option::Some(0),
7232 Self::Active => std::option::Option::Some(1),
7233 Self::PermissionDenied => std::option::Option::Some(2),
7234 Self::NotFound => std::option::Option::Some(3),
7235 Self::InTransitLocationRestriction => std::option::Option::Some(4),
7236 Self::SchemaMismatch => std::option::Option::Some(5),
7237 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
7238 Self::UnknownValue(u) => u.0.value(),
7239 }
7240 }
7241
7242 /// Gets the enum value as a string.
7243 ///
7244 /// Returns `None` if the enum contains an unknown value deserialized from
7245 /// the integer representation of enums.
7246 pub fn name(&self) -> std::option::Option<&str> {
7247 match self {
7248 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
7249 Self::Active => std::option::Option::Some("ACTIVE"),
7250 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
7251 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
7252 Self::InTransitLocationRestriction => {
7253 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
7254 }
7255 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
7256 Self::VertexAiLocationRestriction => {
7257 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
7258 }
7259 Self::UnknownValue(u) => u.0.name(),
7260 }
7261 }
7262 }
7263
7264 impl std::default::Default for State {
7265 fn default() -> Self {
7266 use std::convert::From;
7267 Self::from(0)
7268 }
7269 }
7270
7271 impl std::fmt::Display for State {
7272 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
7273 wkt::internal::display_enum(f, self.name(), self.value())
7274 }
7275 }
7276
7277 impl std::convert::From<i32> for State {
7278 fn from(value: i32) -> Self {
7279 match value {
7280 0 => Self::Unspecified,
7281 1 => Self::Active,
7282 2 => Self::PermissionDenied,
7283 3 => Self::NotFound,
7284 4 => Self::InTransitLocationRestriction,
7285 5 => Self::SchemaMismatch,
7286 6 => Self::VertexAiLocationRestriction,
7287 _ => Self::UnknownValue(state::UnknownValue(
7288 wkt::internal::UnknownEnumValue::Integer(value),
7289 )),
7290 }
7291 }
7292 }
7293
7294 impl std::convert::From<&str> for State {
7295 fn from(value: &str) -> Self {
7296 use std::string::ToString;
7297 match value {
7298 "STATE_UNSPECIFIED" => Self::Unspecified,
7299 "ACTIVE" => Self::Active,
7300 "PERMISSION_DENIED" => Self::PermissionDenied,
7301 "NOT_FOUND" => Self::NotFound,
7302 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
7303 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
7304 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
7305 _ => Self::UnknownValue(state::UnknownValue(
7306 wkt::internal::UnknownEnumValue::String(value.to_string()),
7307 )),
7308 }
7309 }
7310 }
7311
7312 impl serde::ser::Serialize for State {
7313 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
7314 where
7315 S: serde::Serializer,
7316 {
7317 match self {
7318 Self::Unspecified => serializer.serialize_i32(0),
7319 Self::Active => serializer.serialize_i32(1),
7320 Self::PermissionDenied => serializer.serialize_i32(2),
7321 Self::NotFound => serializer.serialize_i32(3),
7322 Self::InTransitLocationRestriction => serializer.serialize_i32(4),
7323 Self::SchemaMismatch => serializer.serialize_i32(5),
7324 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
7325 Self::UnknownValue(u) => u.0.serialize(serializer),
7326 }
7327 }
7328 }
7329
7330 impl<'de> serde::de::Deserialize<'de> for State {
7331 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
7332 where
7333 D: serde::Deserializer<'de>,
7334 {
7335 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
7336 ".google.pubsub.v1.CloudStorageConfig.State",
7337 ))
7338 }
7339 }
7340
7341 /// Defaults to text format.
7342 #[derive(Clone, Debug, PartialEq)]
7343 #[non_exhaustive]
7344 pub enum OutputFormat {
7345 /// Optional. If set, message data will be written to Cloud Storage in text
7346 /// format.
7347 TextConfig(std::boxed::Box<crate::model::cloud_storage_config::TextConfig>),
7348 /// Optional. If set, message data will be written to Cloud Storage in Avro
7349 /// format.
7350 AvroConfig(std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>),
7351 }
7352}
7353
7354/// Request for the GetSubscription method.
7355#[derive(Clone, Default, PartialEq)]
7356#[non_exhaustive]
7357pub struct GetSubscriptionRequest {
7358 /// Required. The name of the subscription to get.
7359 /// Format is `projects/{project}/subscriptions/{sub}`.
7360 pub subscription: std::string::String,
7361
7362 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7363}
7364
7365impl GetSubscriptionRequest {
7366 /// Creates a new default instance.
7367 pub fn new() -> Self {
7368 std::default::Default::default()
7369 }
7370
7371 /// Sets the value of [subscription][crate::model::GetSubscriptionRequest::subscription].
7372 ///
7373 /// # Example
7374 /// ```ignore,no_run
7375 /// # use google_cloud_pubsub::model::GetSubscriptionRequest;
7376 /// # let project_id = "project_id";
7377 /// # let subscription_id = "subscription_id";
7378 /// let x = GetSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7379 /// ```
7380 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7381 self.subscription = v.into();
7382 self
7383 }
7384}
7385
7386impl wkt::message::Message for GetSubscriptionRequest {
7387 fn typename() -> &'static str {
7388 "type.googleapis.com/google.pubsub.v1.GetSubscriptionRequest"
7389 }
7390}
7391
7392/// Request for the UpdateSubscription method.
7393#[derive(Clone, Default, PartialEq)]
7394#[non_exhaustive]
7395pub struct UpdateSubscriptionRequest {
7396 /// Required. The updated subscription object.
7397 pub subscription: std::option::Option<crate::model::Subscription>,
7398
7399 /// Required. Indicates which fields in the provided subscription to update.
7400 /// Must be specified and non-empty.
7401 pub update_mask: std::option::Option<wkt::FieldMask>,
7402
7403 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7404}
7405
7406impl UpdateSubscriptionRequest {
7407 /// Creates a new default instance.
7408 pub fn new() -> Self {
7409 std::default::Default::default()
7410 }
7411
7412 /// Sets the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
7413 ///
7414 /// # Example
7415 /// ```ignore,no_run
7416 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7417 /// use google_cloud_pubsub::model::Subscription;
7418 /// let x = UpdateSubscriptionRequest::new().set_subscription(Subscription::default()/* use setters */);
7419 /// ```
7420 pub fn set_subscription<T>(mut self, v: T) -> Self
7421 where
7422 T: std::convert::Into<crate::model::Subscription>,
7423 {
7424 self.subscription = std::option::Option::Some(v.into());
7425 self
7426 }
7427
7428 /// Sets or clears the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
7429 ///
7430 /// # Example
7431 /// ```ignore,no_run
7432 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7433 /// use google_cloud_pubsub::model::Subscription;
7434 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(Some(Subscription::default()/* use setters */));
7435 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(None::<Subscription>);
7436 /// ```
7437 pub fn set_or_clear_subscription<T>(mut self, v: std::option::Option<T>) -> Self
7438 where
7439 T: std::convert::Into<crate::model::Subscription>,
7440 {
7441 self.subscription = v.map(|x| x.into());
7442 self
7443 }
7444
7445 /// Sets the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
7446 ///
7447 /// # Example
7448 /// ```ignore,no_run
7449 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7450 /// use wkt::FieldMask;
7451 /// let x = UpdateSubscriptionRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7452 /// ```
7453 pub fn set_update_mask<T>(mut self, v: T) -> Self
7454 where
7455 T: std::convert::Into<wkt::FieldMask>,
7456 {
7457 self.update_mask = std::option::Option::Some(v.into());
7458 self
7459 }
7460
7461 /// Sets or clears the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
7462 ///
7463 /// # Example
7464 /// ```ignore,no_run
7465 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7466 /// use wkt::FieldMask;
7467 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7468 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7469 /// ```
7470 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7471 where
7472 T: std::convert::Into<wkt::FieldMask>,
7473 {
7474 self.update_mask = v.map(|x| x.into());
7475 self
7476 }
7477}
7478
7479impl wkt::message::Message for UpdateSubscriptionRequest {
7480 fn typename() -> &'static str {
7481 "type.googleapis.com/google.pubsub.v1.UpdateSubscriptionRequest"
7482 }
7483}
7484
7485/// Request for the `ListSubscriptions` method.
7486#[derive(Clone, Default, PartialEq)]
7487#[non_exhaustive]
7488pub struct ListSubscriptionsRequest {
7489 /// Required. The name of the project in which to list subscriptions.
7490 /// Format is `projects/{project-id}`.
7491 pub project: std::string::String,
7492
7493 /// Optional. Maximum number of subscriptions to return.
7494 pub page_size: i32,
7495
7496 /// Optional. The value returned by the last `ListSubscriptionsResponse`;
7497 /// indicates that this is a continuation of a prior `ListSubscriptions` call,
7498 /// and that the system should return the next page of data.
7499 pub page_token: std::string::String,
7500
7501 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7502}
7503
7504impl ListSubscriptionsRequest {
7505 /// Creates a new default instance.
7506 pub fn new() -> Self {
7507 std::default::Default::default()
7508 }
7509
7510 /// Sets the value of [project][crate::model::ListSubscriptionsRequest::project].
7511 ///
7512 /// # Example
7513 /// ```ignore,no_run
7514 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7515 /// let x = ListSubscriptionsRequest::new().set_project("example");
7516 /// ```
7517 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7518 self.project = v.into();
7519 self
7520 }
7521
7522 /// Sets the value of [page_size][crate::model::ListSubscriptionsRequest::page_size].
7523 ///
7524 /// # Example
7525 /// ```ignore,no_run
7526 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7527 /// let x = ListSubscriptionsRequest::new().set_page_size(42);
7528 /// ```
7529 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7530 self.page_size = v.into();
7531 self
7532 }
7533
7534 /// Sets the value of [page_token][crate::model::ListSubscriptionsRequest::page_token].
7535 ///
7536 /// # Example
7537 /// ```ignore,no_run
7538 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7539 /// let x = ListSubscriptionsRequest::new().set_page_token("example");
7540 /// ```
7541 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7542 self.page_token = v.into();
7543 self
7544 }
7545}
7546
7547impl wkt::message::Message for ListSubscriptionsRequest {
7548 fn typename() -> &'static str {
7549 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsRequest"
7550 }
7551}
7552
7553/// Response for the `ListSubscriptions` method.
7554#[derive(Clone, Default, PartialEq)]
7555#[non_exhaustive]
7556pub struct ListSubscriptionsResponse {
7557 /// Optional. The subscriptions that match the request.
7558 pub subscriptions: std::vec::Vec<crate::model::Subscription>,
7559
7560 /// Optional. If not empty, indicates that there may be more subscriptions that
7561 /// match the request; this value should be passed in a new
7562 /// `ListSubscriptionsRequest` to get more subscriptions.
7563 pub next_page_token: std::string::String,
7564
7565 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7566}
7567
7568impl ListSubscriptionsResponse {
7569 /// Creates a new default instance.
7570 pub fn new() -> Self {
7571 std::default::Default::default()
7572 }
7573
7574 /// Sets the value of [subscriptions][crate::model::ListSubscriptionsResponse::subscriptions].
7575 ///
7576 /// # Example
7577 /// ```ignore,no_run
7578 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7579 /// use google_cloud_pubsub::model::Subscription;
7580 /// let x = ListSubscriptionsResponse::new()
7581 /// .set_subscriptions([
7582 /// Subscription::default()/* use setters */,
7583 /// Subscription::default()/* use (different) setters */,
7584 /// ]);
7585 /// ```
7586 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
7587 where
7588 T: std::iter::IntoIterator<Item = V>,
7589 V: std::convert::Into<crate::model::Subscription>,
7590 {
7591 use std::iter::Iterator;
7592 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
7593 self
7594 }
7595
7596 /// Sets the value of [next_page_token][crate::model::ListSubscriptionsResponse::next_page_token].
7597 ///
7598 /// # Example
7599 /// ```ignore,no_run
7600 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7601 /// let x = ListSubscriptionsResponse::new().set_next_page_token("example");
7602 /// ```
7603 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7604 self.next_page_token = v.into();
7605 self
7606 }
7607}
7608
7609impl wkt::message::Message for ListSubscriptionsResponse {
7610 fn typename() -> &'static str {
7611 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsResponse"
7612 }
7613}
7614
7615#[doc(hidden)]
7616impl google_cloud_gax::paginator::internal::PageableResponse for ListSubscriptionsResponse {
7617 type PageItem = crate::model::Subscription;
7618
7619 fn items(self) -> std::vec::Vec<Self::PageItem> {
7620 self.subscriptions
7621 }
7622
7623 fn next_page_token(&self) -> std::string::String {
7624 use std::clone::Clone;
7625 self.next_page_token.clone()
7626 }
7627}
7628
7629/// Request for the DeleteSubscription method.
7630#[derive(Clone, Default, PartialEq)]
7631#[non_exhaustive]
7632pub struct DeleteSubscriptionRequest {
7633 /// Required. The subscription to delete.
7634 /// Format is `projects/{project}/subscriptions/{sub}`.
7635 pub subscription: std::string::String,
7636
7637 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7638}
7639
7640impl DeleteSubscriptionRequest {
7641 /// Creates a new default instance.
7642 pub fn new() -> Self {
7643 std::default::Default::default()
7644 }
7645
7646 /// Sets the value of [subscription][crate::model::DeleteSubscriptionRequest::subscription].
7647 ///
7648 /// # Example
7649 /// ```ignore,no_run
7650 /// # use google_cloud_pubsub::model::DeleteSubscriptionRequest;
7651 /// # let project_id = "project_id";
7652 /// # let subscription_id = "subscription_id";
7653 /// let x = DeleteSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7654 /// ```
7655 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7656 self.subscription = v.into();
7657 self
7658 }
7659}
7660
7661impl wkt::message::Message for DeleteSubscriptionRequest {
7662 fn typename() -> &'static str {
7663 "type.googleapis.com/google.pubsub.v1.DeleteSubscriptionRequest"
7664 }
7665}
7666
7667/// Request for the ModifyPushConfig method.
7668#[derive(Clone, Default, PartialEq)]
7669#[non_exhaustive]
7670pub struct ModifyPushConfigRequest {
7671 /// Required. The name of the subscription.
7672 /// Format is `projects/{project}/subscriptions/{sub}`.
7673 pub subscription: std::string::String,
7674
7675 /// Required. The push configuration for future deliveries.
7676 ///
7677 /// An empty `pushConfig` indicates that the Pub/Sub system should
7678 /// stop pushing messages from the given subscription and allow
7679 /// messages to be pulled and acknowledged - effectively pausing
7680 /// the subscription if `Pull` or `StreamingPull` is not called.
7681 pub push_config: std::option::Option<crate::model::PushConfig>,
7682
7683 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7684}
7685
7686impl ModifyPushConfigRequest {
7687 /// Creates a new default instance.
7688 pub fn new() -> Self {
7689 std::default::Default::default()
7690 }
7691
7692 /// Sets the value of [subscription][crate::model::ModifyPushConfigRequest::subscription].
7693 ///
7694 /// # Example
7695 /// ```ignore,no_run
7696 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7697 /// # let project_id = "project_id";
7698 /// # let subscription_id = "subscription_id";
7699 /// let x = ModifyPushConfigRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7700 /// ```
7701 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7702 self.subscription = v.into();
7703 self
7704 }
7705
7706 /// Sets the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7707 ///
7708 /// # Example
7709 /// ```ignore,no_run
7710 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7711 /// use google_cloud_pubsub::model::PushConfig;
7712 /// let x = ModifyPushConfigRequest::new().set_push_config(PushConfig::default()/* use setters */);
7713 /// ```
7714 pub fn set_push_config<T>(mut self, v: T) -> Self
7715 where
7716 T: std::convert::Into<crate::model::PushConfig>,
7717 {
7718 self.push_config = std::option::Option::Some(v.into());
7719 self
7720 }
7721
7722 /// Sets or clears the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7723 ///
7724 /// # Example
7725 /// ```ignore,no_run
7726 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7727 /// use google_cloud_pubsub::model::PushConfig;
7728 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
7729 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(None::<PushConfig>);
7730 /// ```
7731 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
7732 where
7733 T: std::convert::Into<crate::model::PushConfig>,
7734 {
7735 self.push_config = v.map(|x| x.into());
7736 self
7737 }
7738}
7739
7740impl wkt::message::Message for ModifyPushConfigRequest {
7741 fn typename() -> &'static str {
7742 "type.googleapis.com/google.pubsub.v1.ModifyPushConfigRequest"
7743 }
7744}
7745
7746/// Request for the `CreateSnapshot` method.
7747#[derive(Clone, Default, PartialEq)]
7748#[non_exhaustive]
7749pub struct CreateSnapshotRequest {
7750 /// Required. User-provided name for this snapshot. If the name is not provided
7751 /// in the request, the server will assign a random name for this snapshot on
7752 /// the same project as the subscription. Note that for REST API requests, you
7753 /// must specify a name. See the [resource name
7754 /// rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
7755 /// Format is `projects/{project}/snapshots/{snap}`.
7756 pub name: std::string::String,
7757
7758 /// Required. The subscription whose backlog the snapshot retains.
7759 /// Specifically, the created snapshot is guaranteed to retain:
7760 /// (a) The existing backlog on the subscription. More precisely, this is
7761 /// defined as the messages in the subscription's backlog that are
7762 /// unacknowledged upon the successful completion of the
7763 /// `CreateSnapshot` request; as well as:
7764 /// (b) Any messages published to the subscription's topic following the
7765 /// successful completion of the CreateSnapshot request.
7766 /// Format is `projects/{project}/subscriptions/{sub}`.
7767 pub subscription: std::string::String,
7768
7769 /// Optional. See [Creating and managing
7770 /// labels](https://cloud.google.com/pubsub/docs/labels).
7771 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7772
7773 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
7774 /// resource. For example:
7775 /// "123/environment": "production",
7776 /// "123/costCenter": "marketing"
7777 /// See
7778 /// https://{$universe.dns_names.final_documentation_domain}/pubsub/docs/tags
7779 /// for more information on using tags with Pub/Sub resources.
7780 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
7781
7782 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7783}
7784
7785impl CreateSnapshotRequest {
7786 /// Creates a new default instance.
7787 pub fn new() -> Self {
7788 std::default::Default::default()
7789 }
7790
7791 /// Sets the value of [name][crate::model::CreateSnapshotRequest::name].
7792 ///
7793 /// # Example
7794 /// ```ignore,no_run
7795 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7796 /// # let project_id = "project_id";
7797 /// # let snapshot_id = "snapshot_id";
7798 /// let x = CreateSnapshotRequest::new().set_name(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7799 /// ```
7800 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7801 self.name = v.into();
7802 self
7803 }
7804
7805 /// Sets the value of [subscription][crate::model::CreateSnapshotRequest::subscription].
7806 ///
7807 /// # Example
7808 /// ```ignore,no_run
7809 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7810 /// # let project_id = "project_id";
7811 /// # let subscription_id = "subscription_id";
7812 /// let x = CreateSnapshotRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7813 /// ```
7814 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7815 self.subscription = v.into();
7816 self
7817 }
7818
7819 /// Sets the value of [labels][crate::model::CreateSnapshotRequest::labels].
7820 ///
7821 /// # Example
7822 /// ```ignore,no_run
7823 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7824 /// let x = CreateSnapshotRequest::new().set_labels([
7825 /// ("key0", "abc"),
7826 /// ("key1", "xyz"),
7827 /// ]);
7828 /// ```
7829 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
7830 where
7831 T: std::iter::IntoIterator<Item = (K, V)>,
7832 K: std::convert::Into<std::string::String>,
7833 V: std::convert::Into<std::string::String>,
7834 {
7835 use std::iter::Iterator;
7836 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7837 self
7838 }
7839
7840 /// Sets the value of [tags][crate::model::CreateSnapshotRequest::tags].
7841 ///
7842 /// # Example
7843 /// ```ignore,no_run
7844 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7845 /// let x = CreateSnapshotRequest::new().set_tags([
7846 /// ("key0", "abc"),
7847 /// ("key1", "xyz"),
7848 /// ]);
7849 /// ```
7850 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
7851 where
7852 T: std::iter::IntoIterator<Item = (K, V)>,
7853 K: std::convert::Into<std::string::String>,
7854 V: std::convert::Into<std::string::String>,
7855 {
7856 use std::iter::Iterator;
7857 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7858 self
7859 }
7860}
7861
7862impl wkt::message::Message for CreateSnapshotRequest {
7863 fn typename() -> &'static str {
7864 "type.googleapis.com/google.pubsub.v1.CreateSnapshotRequest"
7865 }
7866}
7867
7868/// Request for the UpdateSnapshot method.
7869#[derive(Clone, Default, PartialEq)]
7870#[non_exhaustive]
7871pub struct UpdateSnapshotRequest {
7872 /// Required. The updated snapshot object.
7873 pub snapshot: std::option::Option<crate::model::Snapshot>,
7874
7875 /// Required. Indicates which fields in the provided snapshot to update.
7876 /// Must be specified and non-empty.
7877 pub update_mask: std::option::Option<wkt::FieldMask>,
7878
7879 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7880}
7881
7882impl UpdateSnapshotRequest {
7883 /// Creates a new default instance.
7884 pub fn new() -> Self {
7885 std::default::Default::default()
7886 }
7887
7888 /// Sets the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7889 ///
7890 /// # Example
7891 /// ```ignore,no_run
7892 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7893 /// use google_cloud_pubsub::model::Snapshot;
7894 /// let x = UpdateSnapshotRequest::new().set_snapshot(Snapshot::default()/* use setters */);
7895 /// ```
7896 pub fn set_snapshot<T>(mut self, v: T) -> Self
7897 where
7898 T: std::convert::Into<crate::model::Snapshot>,
7899 {
7900 self.snapshot = std::option::Option::Some(v.into());
7901 self
7902 }
7903
7904 /// Sets or clears the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7905 ///
7906 /// # Example
7907 /// ```ignore,no_run
7908 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7909 /// use google_cloud_pubsub::model::Snapshot;
7910 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(Some(Snapshot::default()/* use setters */));
7911 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(None::<Snapshot>);
7912 /// ```
7913 pub fn set_or_clear_snapshot<T>(mut self, v: std::option::Option<T>) -> Self
7914 where
7915 T: std::convert::Into<crate::model::Snapshot>,
7916 {
7917 self.snapshot = v.map(|x| x.into());
7918 self
7919 }
7920
7921 /// Sets the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7922 ///
7923 /// # Example
7924 /// ```ignore,no_run
7925 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7926 /// use wkt::FieldMask;
7927 /// let x = UpdateSnapshotRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7928 /// ```
7929 pub fn set_update_mask<T>(mut self, v: T) -> Self
7930 where
7931 T: std::convert::Into<wkt::FieldMask>,
7932 {
7933 self.update_mask = std::option::Option::Some(v.into());
7934 self
7935 }
7936
7937 /// Sets or clears the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7938 ///
7939 /// # Example
7940 /// ```ignore,no_run
7941 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7942 /// use wkt::FieldMask;
7943 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7944 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7945 /// ```
7946 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7947 where
7948 T: std::convert::Into<wkt::FieldMask>,
7949 {
7950 self.update_mask = v.map(|x| x.into());
7951 self
7952 }
7953}
7954
7955impl wkt::message::Message for UpdateSnapshotRequest {
7956 fn typename() -> &'static str {
7957 "type.googleapis.com/google.pubsub.v1.UpdateSnapshotRequest"
7958 }
7959}
7960
7961/// A snapshot resource. Snapshots are used in
7962/// [Seek](https://cloud.google.com/pubsub/docs/replay-overview)
7963/// operations, which allow you to manage message acknowledgments in bulk. That
7964/// is, you can set the acknowledgment state of messages in an existing
7965/// subscription to the state captured by a snapshot.
7966#[derive(Clone, Default, PartialEq)]
7967#[non_exhaustive]
7968pub struct Snapshot {
7969 /// Optional. The name of the snapshot.
7970 pub name: std::string::String,
7971
7972 /// Optional. The name of the topic from which this snapshot is retaining
7973 /// messages.
7974 pub topic: std::string::String,
7975
7976 /// Optional. The snapshot is guaranteed to exist up until this time.
7977 /// A newly-created snapshot expires no later than 7 days from the time of its
7978 /// creation. Its exact lifetime is determined at creation by the existing
7979 /// backlog in the source subscription. Specifically, the lifetime of the
7980 /// snapshot is `7 days - (age of oldest unacked message in the subscription)`.
7981 /// For example, consider a subscription whose oldest unacked message is 3 days
7982 /// old. If a snapshot is created from this subscription, the snapshot -- which
7983 /// will always capture this 3-day-old backlog as long as the snapshot
7984 /// exists -- will expire in 4 days. The service will refuse to create a
7985 /// snapshot that would expire in less than 1 hour after creation.
7986 pub expire_time: std::option::Option<wkt::Timestamp>,
7987
7988 /// Optional. See [Creating and managing labels]
7989 /// (<https://cloud.google.com/pubsub/docs/labels>).
7990 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7991
7992 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7993}
7994
7995impl Snapshot {
7996 /// Creates a new default instance.
7997 pub fn new() -> Self {
7998 std::default::Default::default()
7999 }
8000
8001 /// Sets the value of [name][crate::model::Snapshot::name].
8002 ///
8003 /// # Example
8004 /// ```ignore,no_run
8005 /// # use google_cloud_pubsub::model::Snapshot;
8006 /// # let project_id = "project_id";
8007 /// # let snapshot_id = "snapshot_id";
8008 /// let x = Snapshot::new().set_name(format!("projects/{project_id}/snapshots/{snapshot_id}"));
8009 /// ```
8010 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8011 self.name = v.into();
8012 self
8013 }
8014
8015 /// Sets the value of [topic][crate::model::Snapshot::topic].
8016 ///
8017 /// # Example
8018 /// ```ignore,no_run
8019 /// # use google_cloud_pubsub::model::Snapshot;
8020 /// # let project_id = "project_id";
8021 /// # let topic_id = "topic_id";
8022 /// let x = Snapshot::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
8023 /// ```
8024 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8025 self.topic = v.into();
8026 self
8027 }
8028
8029 /// Sets the value of [expire_time][crate::model::Snapshot::expire_time].
8030 ///
8031 /// # Example
8032 /// ```ignore,no_run
8033 /// # use google_cloud_pubsub::model::Snapshot;
8034 /// use wkt::Timestamp;
8035 /// let x = Snapshot::new().set_expire_time(Timestamp::default()/* use setters */);
8036 /// ```
8037 pub fn set_expire_time<T>(mut self, v: T) -> Self
8038 where
8039 T: std::convert::Into<wkt::Timestamp>,
8040 {
8041 self.expire_time = std::option::Option::Some(v.into());
8042 self
8043 }
8044
8045 /// Sets or clears the value of [expire_time][crate::model::Snapshot::expire_time].
8046 ///
8047 /// # Example
8048 /// ```ignore,no_run
8049 /// # use google_cloud_pubsub::model::Snapshot;
8050 /// use wkt::Timestamp;
8051 /// let x = Snapshot::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
8052 /// let x = Snapshot::new().set_or_clear_expire_time(None::<Timestamp>);
8053 /// ```
8054 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
8055 where
8056 T: std::convert::Into<wkt::Timestamp>,
8057 {
8058 self.expire_time = v.map(|x| x.into());
8059 self
8060 }
8061
8062 /// Sets the value of [labels][crate::model::Snapshot::labels].
8063 ///
8064 /// # Example
8065 /// ```ignore,no_run
8066 /// # use google_cloud_pubsub::model::Snapshot;
8067 /// let x = Snapshot::new().set_labels([
8068 /// ("key0", "abc"),
8069 /// ("key1", "xyz"),
8070 /// ]);
8071 /// ```
8072 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
8073 where
8074 T: std::iter::IntoIterator<Item = (K, V)>,
8075 K: std::convert::Into<std::string::String>,
8076 V: std::convert::Into<std::string::String>,
8077 {
8078 use std::iter::Iterator;
8079 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
8080 self
8081 }
8082}
8083
8084impl wkt::message::Message for Snapshot {
8085 fn typename() -> &'static str {
8086 "type.googleapis.com/google.pubsub.v1.Snapshot"
8087 }
8088}
8089
8090/// Request for the GetSnapshot method.
8091#[derive(Clone, Default, PartialEq)]
8092#[non_exhaustive]
8093pub struct GetSnapshotRequest {
8094 /// Required. The name of the snapshot to get.
8095 /// Format is `projects/{project}/snapshots/{snap}`.
8096 pub snapshot: std::string::String,
8097
8098 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8099}
8100
8101impl GetSnapshotRequest {
8102 /// Creates a new default instance.
8103 pub fn new() -> Self {
8104 std::default::Default::default()
8105 }
8106
8107 /// Sets the value of [snapshot][crate::model::GetSnapshotRequest::snapshot].
8108 ///
8109 /// # Example
8110 /// ```ignore,no_run
8111 /// # use google_cloud_pubsub::model::GetSnapshotRequest;
8112 /// # let project_id = "project_id";
8113 /// # let snapshot_id = "snapshot_id";
8114 /// let x = GetSnapshotRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
8115 /// ```
8116 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8117 self.snapshot = v.into();
8118 self
8119 }
8120}
8121
8122impl wkt::message::Message for GetSnapshotRequest {
8123 fn typename() -> &'static str {
8124 "type.googleapis.com/google.pubsub.v1.GetSnapshotRequest"
8125 }
8126}
8127
8128/// Request for the `ListSnapshots` method.
8129#[derive(Clone, Default, PartialEq)]
8130#[non_exhaustive]
8131pub struct ListSnapshotsRequest {
8132 /// Required. The name of the project in which to list snapshots.
8133 /// Format is `projects/{project-id}`.
8134 pub project: std::string::String,
8135
8136 /// Optional. Maximum number of snapshots to return.
8137 pub page_size: i32,
8138
8139 /// Optional. The value returned by the last `ListSnapshotsResponse`; indicates
8140 /// that this is a continuation of a prior `ListSnapshots` call, and that the
8141 /// system should return the next page of data.
8142 pub page_token: std::string::String,
8143
8144 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8145}
8146
8147impl ListSnapshotsRequest {
8148 /// Creates a new default instance.
8149 pub fn new() -> Self {
8150 std::default::Default::default()
8151 }
8152
8153 /// Sets the value of [project][crate::model::ListSnapshotsRequest::project].
8154 ///
8155 /// # Example
8156 /// ```ignore,no_run
8157 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
8158 /// let x = ListSnapshotsRequest::new().set_project("example");
8159 /// ```
8160 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8161 self.project = v.into();
8162 self
8163 }
8164
8165 /// Sets the value of [page_size][crate::model::ListSnapshotsRequest::page_size].
8166 ///
8167 /// # Example
8168 /// ```ignore,no_run
8169 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
8170 /// let x = ListSnapshotsRequest::new().set_page_size(42);
8171 /// ```
8172 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8173 self.page_size = v.into();
8174 self
8175 }
8176
8177 /// Sets the value of [page_token][crate::model::ListSnapshotsRequest::page_token].
8178 ///
8179 /// # Example
8180 /// ```ignore,no_run
8181 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
8182 /// let x = ListSnapshotsRequest::new().set_page_token("example");
8183 /// ```
8184 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8185 self.page_token = v.into();
8186 self
8187 }
8188}
8189
8190impl wkt::message::Message for ListSnapshotsRequest {
8191 fn typename() -> &'static str {
8192 "type.googleapis.com/google.pubsub.v1.ListSnapshotsRequest"
8193 }
8194}
8195
8196/// Response for the `ListSnapshots` method.
8197#[derive(Clone, Default, PartialEq)]
8198#[non_exhaustive]
8199pub struct ListSnapshotsResponse {
8200 /// Optional. The resulting snapshots.
8201 pub snapshots: std::vec::Vec<crate::model::Snapshot>,
8202
8203 /// Optional. If not empty, indicates that there may be more snapshot that
8204 /// match the request; this value should be passed in a new
8205 /// `ListSnapshotsRequest`.
8206 pub next_page_token: std::string::String,
8207
8208 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8209}
8210
8211impl ListSnapshotsResponse {
8212 /// Creates a new default instance.
8213 pub fn new() -> Self {
8214 std::default::Default::default()
8215 }
8216
8217 /// Sets the value of [snapshots][crate::model::ListSnapshotsResponse::snapshots].
8218 ///
8219 /// # Example
8220 /// ```ignore,no_run
8221 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
8222 /// use google_cloud_pubsub::model::Snapshot;
8223 /// let x = ListSnapshotsResponse::new()
8224 /// .set_snapshots([
8225 /// Snapshot::default()/* use setters */,
8226 /// Snapshot::default()/* use (different) setters */,
8227 /// ]);
8228 /// ```
8229 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
8230 where
8231 T: std::iter::IntoIterator<Item = V>,
8232 V: std::convert::Into<crate::model::Snapshot>,
8233 {
8234 use std::iter::Iterator;
8235 self.snapshots = v.into_iter().map(|i| i.into()).collect();
8236 self
8237 }
8238
8239 /// Sets the value of [next_page_token][crate::model::ListSnapshotsResponse::next_page_token].
8240 ///
8241 /// # Example
8242 /// ```ignore,no_run
8243 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
8244 /// let x = ListSnapshotsResponse::new().set_next_page_token("example");
8245 /// ```
8246 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8247 self.next_page_token = v.into();
8248 self
8249 }
8250}
8251
8252impl wkt::message::Message for ListSnapshotsResponse {
8253 fn typename() -> &'static str {
8254 "type.googleapis.com/google.pubsub.v1.ListSnapshotsResponse"
8255 }
8256}
8257
8258#[doc(hidden)]
8259impl google_cloud_gax::paginator::internal::PageableResponse for ListSnapshotsResponse {
8260 type PageItem = crate::model::Snapshot;
8261
8262 fn items(self) -> std::vec::Vec<Self::PageItem> {
8263 self.snapshots
8264 }
8265
8266 fn next_page_token(&self) -> std::string::String {
8267 use std::clone::Clone;
8268 self.next_page_token.clone()
8269 }
8270}
8271
8272/// Request for the `DeleteSnapshot` method.
8273#[derive(Clone, Default, PartialEq)]
8274#[non_exhaustive]
8275pub struct DeleteSnapshotRequest {
8276 /// Required. The name of the snapshot to delete.
8277 /// Format is `projects/{project}/snapshots/{snap}`.
8278 pub snapshot: std::string::String,
8279
8280 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8281}
8282
8283impl DeleteSnapshotRequest {
8284 /// Creates a new default instance.
8285 pub fn new() -> Self {
8286 std::default::Default::default()
8287 }
8288
8289 /// Sets the value of [snapshot][crate::model::DeleteSnapshotRequest::snapshot].
8290 ///
8291 /// # Example
8292 /// ```ignore,no_run
8293 /// # use google_cloud_pubsub::model::DeleteSnapshotRequest;
8294 /// # let project_id = "project_id";
8295 /// # let snapshot_id = "snapshot_id";
8296 /// let x = DeleteSnapshotRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
8297 /// ```
8298 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8299 self.snapshot = v.into();
8300 self
8301 }
8302}
8303
8304impl wkt::message::Message for DeleteSnapshotRequest {
8305 fn typename() -> &'static str {
8306 "type.googleapis.com/google.pubsub.v1.DeleteSnapshotRequest"
8307 }
8308}
8309
8310/// Request for the `Seek` method.
8311#[derive(Clone, Default, PartialEq)]
8312#[non_exhaustive]
8313pub struct SeekRequest {
8314 /// Required. The subscription to affect.
8315 pub subscription: std::string::String,
8316
8317 #[allow(missing_docs)]
8318 pub target: std::option::Option<crate::model::seek_request::Target>,
8319
8320 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8321}
8322
8323impl SeekRequest {
8324 /// Creates a new default instance.
8325 pub fn new() -> Self {
8326 std::default::Default::default()
8327 }
8328
8329 /// Sets the value of [subscription][crate::model::SeekRequest::subscription].
8330 ///
8331 /// # Example
8332 /// ```ignore,no_run
8333 /// # use google_cloud_pubsub::model::SeekRequest;
8334 /// # let project_id = "project_id";
8335 /// # let subscription_id = "subscription_id";
8336 /// let x = SeekRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
8337 /// ```
8338 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8339 self.subscription = v.into();
8340 self
8341 }
8342
8343 /// Sets the value of [target][crate::model::SeekRequest::target].
8344 ///
8345 /// Note that all the setters affecting `target` are mutually
8346 /// exclusive.
8347 ///
8348 /// # Example
8349 /// ```ignore,no_run
8350 /// # use google_cloud_pubsub::model::SeekRequest;
8351 /// use google_cloud_pubsub::model::seek_request::Target;
8352 /// let x = SeekRequest::new().set_target(Some(Target::Snapshot("example".to_string())));
8353 /// ```
8354 pub fn set_target<
8355 T: std::convert::Into<std::option::Option<crate::model::seek_request::Target>>,
8356 >(
8357 mut self,
8358 v: T,
8359 ) -> Self {
8360 self.target = v.into();
8361 self
8362 }
8363
8364 /// The value of [target][crate::model::SeekRequest::target]
8365 /// if it holds a `Time`, `None` if the field is not set or
8366 /// holds a different branch.
8367 pub fn time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
8368 #[allow(unreachable_patterns)]
8369 self.target.as_ref().and_then(|v| match v {
8370 crate::model::seek_request::Target::Time(v) => std::option::Option::Some(v),
8371 _ => std::option::Option::None,
8372 })
8373 }
8374
8375 /// Sets the value of [target][crate::model::SeekRequest::target]
8376 /// to hold a `Time`.
8377 ///
8378 /// Note that all the setters affecting `target` are
8379 /// mutually exclusive.
8380 ///
8381 /// # Example
8382 /// ```ignore,no_run
8383 /// # use google_cloud_pubsub::model::SeekRequest;
8384 /// use wkt::Timestamp;
8385 /// let x = SeekRequest::new().set_time(Timestamp::default()/* use setters */);
8386 /// assert!(x.time().is_some());
8387 /// assert!(x.snapshot().is_none());
8388 /// ```
8389 pub fn set_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
8390 mut self,
8391 v: T,
8392 ) -> Self {
8393 self.target = std::option::Option::Some(crate::model::seek_request::Target::Time(v.into()));
8394 self
8395 }
8396
8397 /// The value of [target][crate::model::SeekRequest::target]
8398 /// if it holds a `Snapshot`, `None` if the field is not set or
8399 /// holds a different branch.
8400 pub fn snapshot(&self) -> std::option::Option<&std::string::String> {
8401 #[allow(unreachable_patterns)]
8402 self.target.as_ref().and_then(|v| match v {
8403 crate::model::seek_request::Target::Snapshot(v) => std::option::Option::Some(v),
8404 _ => std::option::Option::None,
8405 })
8406 }
8407
8408 /// Sets the value of [target][crate::model::SeekRequest::target]
8409 /// to hold a `Snapshot`.
8410 ///
8411 /// Note that all the setters affecting `target` are
8412 /// mutually exclusive.
8413 ///
8414 /// # Example
8415 /// ```ignore,no_run
8416 /// # use google_cloud_pubsub::model::SeekRequest;
8417 /// # let project_id = "project_id";
8418 /// # let snapshot_id = "snapshot_id";
8419 /// let x = SeekRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
8420 /// assert!(x.snapshot().is_some());
8421 /// assert!(x.time().is_none());
8422 /// ```
8423 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8424 self.target =
8425 std::option::Option::Some(crate::model::seek_request::Target::Snapshot(v.into()));
8426 self
8427 }
8428}
8429
8430impl wkt::message::Message for SeekRequest {
8431 fn typename() -> &'static str {
8432 "type.googleapis.com/google.pubsub.v1.SeekRequest"
8433 }
8434}
8435
8436/// Defines additional types related to [SeekRequest].
8437pub mod seek_request {
8438 #[allow(unused_imports)]
8439 use super::*;
8440
8441 #[allow(missing_docs)]
8442 #[derive(Clone, Debug, PartialEq)]
8443 #[non_exhaustive]
8444 pub enum Target {
8445 /// Optional. The time to seek to.
8446 /// Messages retained in the subscription that were published before this
8447 /// time are marked as acknowledged, and messages retained in the
8448 /// subscription that were published after this time are marked as
8449 /// unacknowledged. Note that this operation affects only those messages
8450 /// retained in the subscription (configured by the combination of
8451 /// `message_retention_duration` and `retain_acked_messages`). For example,
8452 /// if `time` corresponds to a point before the message retention
8453 /// window (or to a point before the system's notion of the subscription
8454 /// creation time), only retained messages will be marked as unacknowledged,
8455 /// and already-expunged messages will not be restored.
8456 Time(std::boxed::Box<wkt::Timestamp>),
8457 /// Optional. The snapshot to seek to. The snapshot's topic must be the same
8458 /// as that of the provided subscription. Format is
8459 /// `projects/{project}/snapshots/{snap}`.
8460 Snapshot(std::string::String),
8461 }
8462}
8463
8464/// Response for the `Seek` method (this response is empty).
8465#[derive(Clone, Default, PartialEq)]
8466#[non_exhaustive]
8467pub struct SeekResponse {
8468 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8469}
8470
8471impl SeekResponse {
8472 /// Creates a new default instance.
8473 pub fn new() -> Self {
8474 std::default::Default::default()
8475 }
8476}
8477
8478impl wkt::message::Message for SeekResponse {
8479 fn typename() -> &'static str {
8480 "type.googleapis.com/google.pubsub.v1.SeekResponse"
8481 }
8482}
8483
8484/// A schema resource.
8485#[derive(Clone, Default, PartialEq)]
8486#[non_exhaustive]
8487pub struct Schema {
8488 /// Required. Name of the schema.
8489 /// Format is `projects/{project}/schemas/{schema}`.
8490 pub name: std::string::String,
8491
8492 /// The type of the schema definition.
8493 pub r#type: crate::model::schema::Type,
8494
8495 /// The definition of the schema. This should contain a string representing
8496 /// the full definition of the schema that is a valid schema definition of
8497 /// the type specified in `type`.
8498 pub definition: std::string::String,
8499
8500 /// Output only. Immutable. The revision ID of the schema.
8501 pub revision_id: std::string::String,
8502
8503 /// Output only. The timestamp that the revision was created.
8504 pub revision_create_time: std::option::Option<wkt::Timestamp>,
8505
8506 /// The configuration of the schema.
8507 /// This field is mutually exclusive with the `definition` field above, meaning
8508 /// either `definition` or one of the fields below can be set in a valid Schema
8509 /// object.
8510 pub configuration: std::option::Option<crate::model::schema::Configuration>,
8511
8512 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8513}
8514
8515impl Schema {
8516 /// Creates a new default instance.
8517 pub fn new() -> Self {
8518 std::default::Default::default()
8519 }
8520
8521 /// Sets the value of [name][crate::model::Schema::name].
8522 ///
8523 /// # Example
8524 /// ```ignore,no_run
8525 /// # use google_cloud_pubsub::model::Schema;
8526 /// # let project_id = "project_id";
8527 /// # let schema_id = "schema_id";
8528 /// let x = Schema::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8529 /// ```
8530 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8531 self.name = v.into();
8532 self
8533 }
8534
8535 /// Sets the value of [r#type][crate::model::Schema::type].
8536 ///
8537 /// # Example
8538 /// ```ignore,no_run
8539 /// # use google_cloud_pubsub::model::Schema;
8540 /// use google_cloud_pubsub::model::schema::Type;
8541 /// let x0 = Schema::new().set_type(Type::ProtocolBuffer);
8542 /// let x1 = Schema::new().set_type(Type::Avro);
8543 /// ```
8544 pub fn set_type<T: std::convert::Into<crate::model::schema::Type>>(mut self, v: T) -> Self {
8545 self.r#type = v.into();
8546 self
8547 }
8548
8549 /// Sets the value of [definition][crate::model::Schema::definition].
8550 ///
8551 /// # Example
8552 /// ```ignore,no_run
8553 /// # use google_cloud_pubsub::model::Schema;
8554 /// let x = Schema::new().set_definition("example");
8555 /// ```
8556 pub fn set_definition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8557 self.definition = v.into();
8558 self
8559 }
8560
8561 /// Sets the value of [revision_id][crate::model::Schema::revision_id].
8562 ///
8563 /// # Example
8564 /// ```ignore,no_run
8565 /// # use google_cloud_pubsub::model::Schema;
8566 /// let x = Schema::new().set_revision_id("example");
8567 /// ```
8568 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8569 self.revision_id = v.into();
8570 self
8571 }
8572
8573 /// Sets the value of [revision_create_time][crate::model::Schema::revision_create_time].
8574 ///
8575 /// # Example
8576 /// ```ignore,no_run
8577 /// # use google_cloud_pubsub::model::Schema;
8578 /// use wkt::Timestamp;
8579 /// let x = Schema::new().set_revision_create_time(Timestamp::default()/* use setters */);
8580 /// ```
8581 pub fn set_revision_create_time<T>(mut self, v: T) -> Self
8582 where
8583 T: std::convert::Into<wkt::Timestamp>,
8584 {
8585 self.revision_create_time = std::option::Option::Some(v.into());
8586 self
8587 }
8588
8589 /// Sets or clears the value of [revision_create_time][crate::model::Schema::revision_create_time].
8590 ///
8591 /// # Example
8592 /// ```ignore,no_run
8593 /// # use google_cloud_pubsub::model::Schema;
8594 /// use wkt::Timestamp;
8595 /// let x = Schema::new().set_or_clear_revision_create_time(Some(Timestamp::default()/* use setters */));
8596 /// let x = Schema::new().set_or_clear_revision_create_time(None::<Timestamp>);
8597 /// ```
8598 pub fn set_or_clear_revision_create_time<T>(mut self, v: std::option::Option<T>) -> Self
8599 where
8600 T: std::convert::Into<wkt::Timestamp>,
8601 {
8602 self.revision_create_time = v.map(|x| x.into());
8603 self
8604 }
8605
8606 /// Sets the value of [configuration][crate::model::Schema::configuration].
8607 ///
8608 /// Note that all the setters affecting `configuration` are mutually
8609 /// exclusive.
8610 ///
8611 /// # Example
8612 /// ```ignore,no_run
8613 /// # use google_cloud_pubsub::model::Schema;
8614 /// use google_cloud_pubsub::model::CompiledProtoSchema;
8615 /// let x = Schema::new().set_configuration(Some(
8616 /// google_cloud_pubsub::model::schema::Configuration::CompiledProtoSchema(CompiledProtoSchema::default().into())));
8617 /// ```
8618 pub fn set_configuration<
8619 T: std::convert::Into<std::option::Option<crate::model::schema::Configuration>>,
8620 >(
8621 mut self,
8622 v: T,
8623 ) -> Self {
8624 self.configuration = v.into();
8625 self
8626 }
8627
8628 /// The value of [configuration][crate::model::Schema::configuration]
8629 /// if it holds a `CompiledProtoSchema`, `None` if the field is not set or
8630 /// holds a different branch.
8631 pub fn compiled_proto_schema(
8632 &self,
8633 ) -> std::option::Option<&std::boxed::Box<crate::model::CompiledProtoSchema>> {
8634 #[allow(unreachable_patterns)]
8635 self.configuration.as_ref().and_then(|v| match v {
8636 crate::model::schema::Configuration::CompiledProtoSchema(v) => {
8637 std::option::Option::Some(v)
8638 }
8639 _ => std::option::Option::None,
8640 })
8641 }
8642
8643 /// Sets the value of [configuration][crate::model::Schema::configuration]
8644 /// to hold a `CompiledProtoSchema`.
8645 ///
8646 /// Note that all the setters affecting `configuration` are
8647 /// mutually exclusive.
8648 ///
8649 /// # Example
8650 /// ```ignore,no_run
8651 /// # use google_cloud_pubsub::model::Schema;
8652 /// use google_cloud_pubsub::model::CompiledProtoSchema;
8653 /// let x = Schema::new().set_compiled_proto_schema(CompiledProtoSchema::default()/* use setters */);
8654 /// assert!(x.compiled_proto_schema().is_some());
8655 /// ```
8656 pub fn set_compiled_proto_schema<
8657 T: std::convert::Into<std::boxed::Box<crate::model::CompiledProtoSchema>>,
8658 >(
8659 mut self,
8660 v: T,
8661 ) -> Self {
8662 self.configuration = std::option::Option::Some(
8663 crate::model::schema::Configuration::CompiledProtoSchema(v.into()),
8664 );
8665 self
8666 }
8667}
8668
8669impl wkt::message::Message for Schema {
8670 fn typename() -> &'static str {
8671 "type.googleapis.com/google.pubsub.v1.Schema"
8672 }
8673}
8674
8675/// Defines additional types related to [Schema].
8676pub mod schema {
8677 #[allow(unused_imports)]
8678 use super::*;
8679
8680 /// Possible schema definition types.
8681 ///
8682 /// # Working with unknown values
8683 ///
8684 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8685 /// additional enum variants at any time. Adding new variants is not considered
8686 /// a breaking change. Applications should write their code in anticipation of:
8687 ///
8688 /// - New values appearing in future releases of the client library, **and**
8689 /// - New values received dynamically, without application changes.
8690 ///
8691 /// Please consult the [Working with enums] section in the user guide for some
8692 /// guidelines.
8693 ///
8694 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8695 #[derive(Clone, Debug, PartialEq)]
8696 #[non_exhaustive]
8697 pub enum Type {
8698 /// Default value. This value is unused.
8699 Unspecified,
8700 /// A Protocol Buffer schema definition.
8701 ProtocolBuffer,
8702 /// An Avro schema definition.
8703 Avro,
8704 /// If set, the enum was initialized with an unknown value.
8705 ///
8706 /// Applications can examine the value using [Type::value] or
8707 /// [Type::name].
8708 UnknownValue(r#type::UnknownValue),
8709 }
8710
8711 #[doc(hidden)]
8712 pub mod r#type {
8713 #[allow(unused_imports)]
8714 use super::*;
8715 #[derive(Clone, Debug, PartialEq)]
8716 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8717 }
8718
8719 impl Type {
8720 /// Gets the enum value.
8721 ///
8722 /// Returns `None` if the enum contains an unknown value deserialized from
8723 /// the string representation of enums.
8724 pub fn value(&self) -> std::option::Option<i32> {
8725 match self {
8726 Self::Unspecified => std::option::Option::Some(0),
8727 Self::ProtocolBuffer => std::option::Option::Some(1),
8728 Self::Avro => std::option::Option::Some(2),
8729 Self::UnknownValue(u) => u.0.value(),
8730 }
8731 }
8732
8733 /// Gets the enum value as a string.
8734 ///
8735 /// Returns `None` if the enum contains an unknown value deserialized from
8736 /// the integer representation of enums.
8737 pub fn name(&self) -> std::option::Option<&str> {
8738 match self {
8739 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
8740 Self::ProtocolBuffer => std::option::Option::Some("PROTOCOL_BUFFER"),
8741 Self::Avro => std::option::Option::Some("AVRO"),
8742 Self::UnknownValue(u) => u.0.name(),
8743 }
8744 }
8745 }
8746
8747 impl std::default::Default for Type {
8748 fn default() -> Self {
8749 use std::convert::From;
8750 Self::from(0)
8751 }
8752 }
8753
8754 impl std::fmt::Display for Type {
8755 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8756 wkt::internal::display_enum(f, self.name(), self.value())
8757 }
8758 }
8759
8760 impl std::convert::From<i32> for Type {
8761 fn from(value: i32) -> Self {
8762 match value {
8763 0 => Self::Unspecified,
8764 1 => Self::ProtocolBuffer,
8765 2 => Self::Avro,
8766 _ => Self::UnknownValue(r#type::UnknownValue(
8767 wkt::internal::UnknownEnumValue::Integer(value),
8768 )),
8769 }
8770 }
8771 }
8772
8773 impl std::convert::From<&str> for Type {
8774 fn from(value: &str) -> Self {
8775 use std::string::ToString;
8776 match value {
8777 "TYPE_UNSPECIFIED" => Self::Unspecified,
8778 "PROTOCOL_BUFFER" => Self::ProtocolBuffer,
8779 "AVRO" => Self::Avro,
8780 _ => Self::UnknownValue(r#type::UnknownValue(
8781 wkt::internal::UnknownEnumValue::String(value.to_string()),
8782 )),
8783 }
8784 }
8785 }
8786
8787 impl serde::ser::Serialize for Type {
8788 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8789 where
8790 S: serde::Serializer,
8791 {
8792 match self {
8793 Self::Unspecified => serializer.serialize_i32(0),
8794 Self::ProtocolBuffer => serializer.serialize_i32(1),
8795 Self::Avro => serializer.serialize_i32(2),
8796 Self::UnknownValue(u) => u.0.serialize(serializer),
8797 }
8798 }
8799 }
8800
8801 impl<'de> serde::de::Deserialize<'de> for Type {
8802 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8803 where
8804 D: serde::Deserializer<'de>,
8805 {
8806 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
8807 ".google.pubsub.v1.Schema.Type",
8808 ))
8809 }
8810 }
8811
8812 /// The configuration of the schema.
8813 /// This field is mutually exclusive with the `definition` field above, meaning
8814 /// either `definition` or one of the fields below can be set in a valid Schema
8815 /// object.
8816 #[derive(Clone, Debug, PartialEq)]
8817 #[non_exhaustive]
8818 pub enum Configuration {
8819 /// Optional. Configuration for a schema provided as a pre-compiled Protocol
8820 /// Buffer FileDescriptorSet. The `type` field above must be set to
8821 /// PROTOCOL_BUFFER.
8822 CompiledProtoSchema(std::boxed::Box<crate::model::CompiledProtoSchema>),
8823 }
8824}
8825
8826/// Request for the CreateSchema method.
8827#[derive(Clone, Default, PartialEq)]
8828#[non_exhaustive]
8829pub struct CreateSchemaRequest {
8830 /// Required. The name of the project in which to create the schema.
8831 /// Format is `projects/{project-id}`.
8832 pub parent: std::string::String,
8833
8834 /// Required. The schema object to create.
8835 ///
8836 /// This schema's `name` parameter is ignored. The schema object returned
8837 /// by CreateSchema will have a `name` made using the given `parent` and
8838 /// `schema_id`.
8839 pub schema: std::option::Option<crate::model::Schema>,
8840
8841 /// The ID to use for the schema, which will become the final component of
8842 /// the schema's resource name.
8843 ///
8844 /// See <https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names> for
8845 /// resource name constraints.
8846 pub schema_id: std::string::String,
8847
8848 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8849}
8850
8851impl CreateSchemaRequest {
8852 /// Creates a new default instance.
8853 pub fn new() -> Self {
8854 std::default::Default::default()
8855 }
8856
8857 /// Sets the value of [parent][crate::model::CreateSchemaRequest::parent].
8858 ///
8859 /// # Example
8860 /// ```ignore,no_run
8861 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8862 /// # let project_id = "project_id";
8863 /// let x = CreateSchemaRequest::new().set_parent(format!("projects/{project_id}"));
8864 /// ```
8865 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8866 self.parent = v.into();
8867 self
8868 }
8869
8870 /// Sets the value of [schema][crate::model::CreateSchemaRequest::schema].
8871 ///
8872 /// # Example
8873 /// ```ignore,no_run
8874 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8875 /// use google_cloud_pubsub::model::Schema;
8876 /// let x = CreateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8877 /// ```
8878 pub fn set_schema<T>(mut self, v: T) -> Self
8879 where
8880 T: std::convert::Into<crate::model::Schema>,
8881 {
8882 self.schema = std::option::Option::Some(v.into());
8883 self
8884 }
8885
8886 /// Sets or clears the value of [schema][crate::model::CreateSchemaRequest::schema].
8887 ///
8888 /// # Example
8889 /// ```ignore,no_run
8890 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8891 /// use google_cloud_pubsub::model::Schema;
8892 /// let x = CreateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
8893 /// let x = CreateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
8894 /// ```
8895 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
8896 where
8897 T: std::convert::Into<crate::model::Schema>,
8898 {
8899 self.schema = v.map(|x| x.into());
8900 self
8901 }
8902
8903 /// Sets the value of [schema_id][crate::model::CreateSchemaRequest::schema_id].
8904 ///
8905 /// # Example
8906 /// ```ignore,no_run
8907 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8908 /// let x = CreateSchemaRequest::new().set_schema_id("example");
8909 /// ```
8910 pub fn set_schema_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8911 self.schema_id = v.into();
8912 self
8913 }
8914}
8915
8916impl wkt::message::Message for CreateSchemaRequest {
8917 fn typename() -> &'static str {
8918 "type.googleapis.com/google.pubsub.v1.CreateSchemaRequest"
8919 }
8920}
8921
8922/// Request for the GetSchema method.
8923#[derive(Clone, Default, PartialEq)]
8924#[non_exhaustive]
8925pub struct GetSchemaRequest {
8926 /// Required. The name of the schema to get.
8927 /// Format is `projects/{project}/schemas/{schema}`.
8928 pub name: std::string::String,
8929
8930 /// The set of fields to return in the response. If not set, returns a Schema
8931 /// with all fields filled out. Set to `BASIC` to omit the `definition`.
8932 pub view: crate::model::SchemaView,
8933
8934 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8935}
8936
8937impl GetSchemaRequest {
8938 /// Creates a new default instance.
8939 pub fn new() -> Self {
8940 std::default::Default::default()
8941 }
8942
8943 /// Sets the value of [name][crate::model::GetSchemaRequest::name].
8944 ///
8945 /// # Example
8946 /// ```ignore,no_run
8947 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8948 /// # let project_id = "project_id";
8949 /// # let schema_id = "schema_id";
8950 /// let x = GetSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8951 /// ```
8952 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8953 self.name = v.into();
8954 self
8955 }
8956
8957 /// Sets the value of [view][crate::model::GetSchemaRequest::view].
8958 ///
8959 /// # Example
8960 /// ```ignore,no_run
8961 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8962 /// use google_cloud_pubsub::model::SchemaView;
8963 /// let x0 = GetSchemaRequest::new().set_view(SchemaView::Basic);
8964 /// let x1 = GetSchemaRequest::new().set_view(SchemaView::Full);
8965 /// ```
8966 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8967 self.view = v.into();
8968 self
8969 }
8970}
8971
8972impl wkt::message::Message for GetSchemaRequest {
8973 fn typename() -> &'static str {
8974 "type.googleapis.com/google.pubsub.v1.GetSchemaRequest"
8975 }
8976}
8977
8978/// Request for the `ListSchemas` method.
8979#[derive(Clone, Default, PartialEq)]
8980#[non_exhaustive]
8981pub struct ListSchemasRequest {
8982 /// Required. The name of the project in which to list schemas.
8983 /// Format is `projects/{project-id}`.
8984 pub parent: std::string::String,
8985
8986 /// The set of Schema fields to return in the response. If not set, returns
8987 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
8988 /// retrieve all fields.
8989 pub view: crate::model::SchemaView,
8990
8991 /// Maximum number of schemas to return.
8992 pub page_size: i32,
8993
8994 /// The value returned by the last `ListSchemasResponse`; indicates that
8995 /// this is a continuation of a prior `ListSchemas` call, and that the
8996 /// system should return the next page of data.
8997 pub page_token: std::string::String,
8998
8999 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9000}
9001
9002impl ListSchemasRequest {
9003 /// Creates a new default instance.
9004 pub fn new() -> Self {
9005 std::default::Default::default()
9006 }
9007
9008 /// Sets the value of [parent][crate::model::ListSchemasRequest::parent].
9009 ///
9010 /// # Example
9011 /// ```ignore,no_run
9012 /// # use google_cloud_pubsub::model::ListSchemasRequest;
9013 /// let x = ListSchemasRequest::new().set_parent("example");
9014 /// ```
9015 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9016 self.parent = v.into();
9017 self
9018 }
9019
9020 /// Sets the value of [view][crate::model::ListSchemasRequest::view].
9021 ///
9022 /// # Example
9023 /// ```ignore,no_run
9024 /// # use google_cloud_pubsub::model::ListSchemasRequest;
9025 /// use google_cloud_pubsub::model::SchemaView;
9026 /// let x0 = ListSchemasRequest::new().set_view(SchemaView::Basic);
9027 /// let x1 = ListSchemasRequest::new().set_view(SchemaView::Full);
9028 /// ```
9029 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
9030 self.view = v.into();
9031 self
9032 }
9033
9034 /// Sets the value of [page_size][crate::model::ListSchemasRequest::page_size].
9035 ///
9036 /// # Example
9037 /// ```ignore,no_run
9038 /// # use google_cloud_pubsub::model::ListSchemasRequest;
9039 /// let x = ListSchemasRequest::new().set_page_size(42);
9040 /// ```
9041 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9042 self.page_size = v.into();
9043 self
9044 }
9045
9046 /// Sets the value of [page_token][crate::model::ListSchemasRequest::page_token].
9047 ///
9048 /// # Example
9049 /// ```ignore,no_run
9050 /// # use google_cloud_pubsub::model::ListSchemasRequest;
9051 /// let x = ListSchemasRequest::new().set_page_token("example");
9052 /// ```
9053 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9054 self.page_token = v.into();
9055 self
9056 }
9057}
9058
9059impl wkt::message::Message for ListSchemasRequest {
9060 fn typename() -> &'static str {
9061 "type.googleapis.com/google.pubsub.v1.ListSchemasRequest"
9062 }
9063}
9064
9065/// Response for the `ListSchemas` method.
9066#[derive(Clone, Default, PartialEq)]
9067#[non_exhaustive]
9068pub struct ListSchemasResponse {
9069 /// The resulting schemas.
9070 pub schemas: std::vec::Vec<crate::model::Schema>,
9071
9072 /// If not empty, indicates that there may be more schemas that match the
9073 /// request; this value should be passed in a new `ListSchemasRequest`.
9074 pub next_page_token: std::string::String,
9075
9076 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9077}
9078
9079impl ListSchemasResponse {
9080 /// Creates a new default instance.
9081 pub fn new() -> Self {
9082 std::default::Default::default()
9083 }
9084
9085 /// Sets the value of [schemas][crate::model::ListSchemasResponse::schemas].
9086 ///
9087 /// # Example
9088 /// ```ignore,no_run
9089 /// # use google_cloud_pubsub::model::ListSchemasResponse;
9090 /// use google_cloud_pubsub::model::Schema;
9091 /// let x = ListSchemasResponse::new()
9092 /// .set_schemas([
9093 /// Schema::default()/* use setters */,
9094 /// Schema::default()/* use (different) setters */,
9095 /// ]);
9096 /// ```
9097 pub fn set_schemas<T, V>(mut self, v: T) -> Self
9098 where
9099 T: std::iter::IntoIterator<Item = V>,
9100 V: std::convert::Into<crate::model::Schema>,
9101 {
9102 use std::iter::Iterator;
9103 self.schemas = v.into_iter().map(|i| i.into()).collect();
9104 self
9105 }
9106
9107 /// Sets the value of [next_page_token][crate::model::ListSchemasResponse::next_page_token].
9108 ///
9109 /// # Example
9110 /// ```ignore,no_run
9111 /// # use google_cloud_pubsub::model::ListSchemasResponse;
9112 /// let x = ListSchemasResponse::new().set_next_page_token("example");
9113 /// ```
9114 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9115 self.next_page_token = v.into();
9116 self
9117 }
9118}
9119
9120impl wkt::message::Message for ListSchemasResponse {
9121 fn typename() -> &'static str {
9122 "type.googleapis.com/google.pubsub.v1.ListSchemasResponse"
9123 }
9124}
9125
9126#[doc(hidden)]
9127impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemasResponse {
9128 type PageItem = crate::model::Schema;
9129
9130 fn items(self) -> std::vec::Vec<Self::PageItem> {
9131 self.schemas
9132 }
9133
9134 fn next_page_token(&self) -> std::string::String {
9135 use std::clone::Clone;
9136 self.next_page_token.clone()
9137 }
9138}
9139
9140/// Request for the `ListSchemaRevisions` method.
9141#[derive(Clone, Default, PartialEq)]
9142#[non_exhaustive]
9143pub struct ListSchemaRevisionsRequest {
9144 /// Required. The name of the schema to list revisions for.
9145 pub name: std::string::String,
9146
9147 /// The set of Schema fields to return in the response. If not set, returns
9148 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
9149 /// retrieve all fields.
9150 pub view: crate::model::SchemaView,
9151
9152 /// The maximum number of revisions to return per page.
9153 pub page_size: i32,
9154
9155 /// The page token, received from a previous ListSchemaRevisions call.
9156 /// Provide this to retrieve the subsequent page.
9157 pub page_token: std::string::String,
9158
9159 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9160}
9161
9162impl ListSchemaRevisionsRequest {
9163 /// Creates a new default instance.
9164 pub fn new() -> Self {
9165 std::default::Default::default()
9166 }
9167
9168 /// Sets the value of [name][crate::model::ListSchemaRevisionsRequest::name].
9169 ///
9170 /// # Example
9171 /// ```ignore,no_run
9172 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
9173 /// # let project_id = "project_id";
9174 /// # let schema_id = "schema_id";
9175 /// let x = ListSchemaRevisionsRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9176 /// ```
9177 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9178 self.name = v.into();
9179 self
9180 }
9181
9182 /// Sets the value of [view][crate::model::ListSchemaRevisionsRequest::view].
9183 ///
9184 /// # Example
9185 /// ```ignore,no_run
9186 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
9187 /// use google_cloud_pubsub::model::SchemaView;
9188 /// let x0 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Basic);
9189 /// let x1 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Full);
9190 /// ```
9191 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
9192 self.view = v.into();
9193 self
9194 }
9195
9196 /// Sets the value of [page_size][crate::model::ListSchemaRevisionsRequest::page_size].
9197 ///
9198 /// # Example
9199 /// ```ignore,no_run
9200 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
9201 /// let x = ListSchemaRevisionsRequest::new().set_page_size(42);
9202 /// ```
9203 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
9204 self.page_size = v.into();
9205 self
9206 }
9207
9208 /// Sets the value of [page_token][crate::model::ListSchemaRevisionsRequest::page_token].
9209 ///
9210 /// # Example
9211 /// ```ignore,no_run
9212 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
9213 /// let x = ListSchemaRevisionsRequest::new().set_page_token("example");
9214 /// ```
9215 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9216 self.page_token = v.into();
9217 self
9218 }
9219}
9220
9221impl wkt::message::Message for ListSchemaRevisionsRequest {
9222 fn typename() -> &'static str {
9223 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsRequest"
9224 }
9225}
9226
9227/// Response for the `ListSchemaRevisions` method.
9228#[derive(Clone, Default, PartialEq)]
9229#[non_exhaustive]
9230pub struct ListSchemaRevisionsResponse {
9231 /// The revisions of the schema.
9232 pub schemas: std::vec::Vec<crate::model::Schema>,
9233
9234 /// A token that can be sent as `page_token` to retrieve the next page.
9235 /// If this field is empty, there are no subsequent pages.
9236 pub next_page_token: std::string::String,
9237
9238 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9239}
9240
9241impl ListSchemaRevisionsResponse {
9242 /// Creates a new default instance.
9243 pub fn new() -> Self {
9244 std::default::Default::default()
9245 }
9246
9247 /// Sets the value of [schemas][crate::model::ListSchemaRevisionsResponse::schemas].
9248 ///
9249 /// # Example
9250 /// ```ignore,no_run
9251 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
9252 /// use google_cloud_pubsub::model::Schema;
9253 /// let x = ListSchemaRevisionsResponse::new()
9254 /// .set_schemas([
9255 /// Schema::default()/* use setters */,
9256 /// Schema::default()/* use (different) setters */,
9257 /// ]);
9258 /// ```
9259 pub fn set_schemas<T, V>(mut self, v: T) -> Self
9260 where
9261 T: std::iter::IntoIterator<Item = V>,
9262 V: std::convert::Into<crate::model::Schema>,
9263 {
9264 use std::iter::Iterator;
9265 self.schemas = v.into_iter().map(|i| i.into()).collect();
9266 self
9267 }
9268
9269 /// Sets the value of [next_page_token][crate::model::ListSchemaRevisionsResponse::next_page_token].
9270 ///
9271 /// # Example
9272 /// ```ignore,no_run
9273 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
9274 /// let x = ListSchemaRevisionsResponse::new().set_next_page_token("example");
9275 /// ```
9276 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9277 self.next_page_token = v.into();
9278 self
9279 }
9280}
9281
9282impl wkt::message::Message for ListSchemaRevisionsResponse {
9283 fn typename() -> &'static str {
9284 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsResponse"
9285 }
9286}
9287
9288#[doc(hidden)]
9289impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemaRevisionsResponse {
9290 type PageItem = crate::model::Schema;
9291
9292 fn items(self) -> std::vec::Vec<Self::PageItem> {
9293 self.schemas
9294 }
9295
9296 fn next_page_token(&self) -> std::string::String {
9297 use std::clone::Clone;
9298 self.next_page_token.clone()
9299 }
9300}
9301
9302/// Request for CommitSchema method.
9303#[derive(Clone, Default, PartialEq)]
9304#[non_exhaustive]
9305pub struct CommitSchemaRequest {
9306 /// Required. The name of the schema we are revising.
9307 /// Format is `projects/{project}/schemas/{schema}`.
9308 pub name: std::string::String,
9309
9310 /// Required. The schema revision to commit.
9311 pub schema: std::option::Option<crate::model::Schema>,
9312
9313 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9314}
9315
9316impl CommitSchemaRequest {
9317 /// Creates a new default instance.
9318 pub fn new() -> Self {
9319 std::default::Default::default()
9320 }
9321
9322 /// Sets the value of [name][crate::model::CommitSchemaRequest::name].
9323 ///
9324 /// # Example
9325 /// ```ignore,no_run
9326 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
9327 /// # let project_id = "project_id";
9328 /// # let schema_id = "schema_id";
9329 /// let x = CommitSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9330 /// ```
9331 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9332 self.name = v.into();
9333 self
9334 }
9335
9336 /// Sets the value of [schema][crate::model::CommitSchemaRequest::schema].
9337 ///
9338 /// # Example
9339 /// ```ignore,no_run
9340 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
9341 /// use google_cloud_pubsub::model::Schema;
9342 /// let x = CommitSchemaRequest::new().set_schema(Schema::default()/* use setters */);
9343 /// ```
9344 pub fn set_schema<T>(mut self, v: T) -> Self
9345 where
9346 T: std::convert::Into<crate::model::Schema>,
9347 {
9348 self.schema = std::option::Option::Some(v.into());
9349 self
9350 }
9351
9352 /// Sets or clears the value of [schema][crate::model::CommitSchemaRequest::schema].
9353 ///
9354 /// # Example
9355 /// ```ignore,no_run
9356 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
9357 /// use google_cloud_pubsub::model::Schema;
9358 /// let x = CommitSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
9359 /// let x = CommitSchemaRequest::new().set_or_clear_schema(None::<Schema>);
9360 /// ```
9361 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
9362 where
9363 T: std::convert::Into<crate::model::Schema>,
9364 {
9365 self.schema = v.map(|x| x.into());
9366 self
9367 }
9368}
9369
9370impl wkt::message::Message for CommitSchemaRequest {
9371 fn typename() -> &'static str {
9372 "type.googleapis.com/google.pubsub.v1.CommitSchemaRequest"
9373 }
9374}
9375
9376/// Request for the `RollbackSchema` method.
9377#[derive(Clone, Default, PartialEq)]
9378#[non_exhaustive]
9379pub struct RollbackSchemaRequest {
9380 /// Required. The schema being rolled back with revision id.
9381 pub name: std::string::String,
9382
9383 /// Required. The revision ID to roll back to.
9384 /// It must be a revision of the same schema.
9385 ///
9386 /// Example: c7cfa2a8
9387 pub revision_id: std::string::String,
9388
9389 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9390}
9391
9392impl RollbackSchemaRequest {
9393 /// Creates a new default instance.
9394 pub fn new() -> Self {
9395 std::default::Default::default()
9396 }
9397
9398 /// Sets the value of [name][crate::model::RollbackSchemaRequest::name].
9399 ///
9400 /// # Example
9401 /// ```ignore,no_run
9402 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
9403 /// # let project_id = "project_id";
9404 /// # let schema_id = "schema_id";
9405 /// let x = RollbackSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9406 /// ```
9407 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9408 self.name = v.into();
9409 self
9410 }
9411
9412 /// Sets the value of [revision_id][crate::model::RollbackSchemaRequest::revision_id].
9413 ///
9414 /// # Example
9415 /// ```ignore,no_run
9416 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
9417 /// let x = RollbackSchemaRequest::new().set_revision_id("example");
9418 /// ```
9419 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9420 self.revision_id = v.into();
9421 self
9422 }
9423}
9424
9425impl wkt::message::Message for RollbackSchemaRequest {
9426 fn typename() -> &'static str {
9427 "type.googleapis.com/google.pubsub.v1.RollbackSchemaRequest"
9428 }
9429}
9430
9431/// Request for the `DeleteSchemaRevision` method.
9432#[derive(Clone, Default, PartialEq)]
9433#[non_exhaustive]
9434pub struct DeleteSchemaRevisionRequest {
9435 /// Required. The name of the schema revision to be deleted, with a revision ID
9436 /// explicitly included.
9437 ///
9438 /// Example: `projects/123/schemas/my-schema@c7cfa2a8`
9439 pub name: std::string::String,
9440
9441 /// Optional. This field is deprecated and should not be used for specifying
9442 /// the revision ID. The revision ID should be specified via the `name`
9443 /// parameter.
9444 #[deprecated]
9445 pub revision_id: std::string::String,
9446
9447 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9448}
9449
9450impl DeleteSchemaRevisionRequest {
9451 /// Creates a new default instance.
9452 pub fn new() -> Self {
9453 std::default::Default::default()
9454 }
9455
9456 /// Sets the value of [name][crate::model::DeleteSchemaRevisionRequest::name].
9457 ///
9458 /// # Example
9459 /// ```ignore,no_run
9460 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
9461 /// # let project_id = "project_id";
9462 /// # let schema_id = "schema_id";
9463 /// let x = DeleteSchemaRevisionRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9464 /// ```
9465 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9466 self.name = v.into();
9467 self
9468 }
9469
9470 /// Sets the value of [revision_id][crate::model::DeleteSchemaRevisionRequest::revision_id].
9471 ///
9472 /// # Example
9473 /// ```ignore,no_run
9474 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
9475 /// let x = DeleteSchemaRevisionRequest::new().set_revision_id("example");
9476 /// ```
9477 #[deprecated]
9478 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9479 self.revision_id = v.into();
9480 self
9481 }
9482}
9483
9484impl wkt::message::Message for DeleteSchemaRevisionRequest {
9485 fn typename() -> &'static str {
9486 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRevisionRequest"
9487 }
9488}
9489
9490/// Request for the `DeleteSchema` method.
9491#[derive(Clone, Default, PartialEq)]
9492#[non_exhaustive]
9493pub struct DeleteSchemaRequest {
9494 /// Required. Name of the schema to delete.
9495 /// Format is `projects/{project}/schemas/{schema}`.
9496 pub name: std::string::String,
9497
9498 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9499}
9500
9501impl DeleteSchemaRequest {
9502 /// Creates a new default instance.
9503 pub fn new() -> Self {
9504 std::default::Default::default()
9505 }
9506
9507 /// Sets the value of [name][crate::model::DeleteSchemaRequest::name].
9508 ///
9509 /// # Example
9510 /// ```ignore,no_run
9511 /// # use google_cloud_pubsub::model::DeleteSchemaRequest;
9512 /// # let project_id = "project_id";
9513 /// # let schema_id = "schema_id";
9514 /// let x = DeleteSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9515 /// ```
9516 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9517 self.name = v.into();
9518 self
9519 }
9520}
9521
9522impl wkt::message::Message for DeleteSchemaRequest {
9523 fn typename() -> &'static str {
9524 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRequest"
9525 }
9526}
9527
9528/// Request for the `ValidateSchema` method.
9529#[derive(Clone, Default, PartialEq)]
9530#[non_exhaustive]
9531pub struct ValidateSchemaRequest {
9532 /// Required. The name of the project in which to validate schemas.
9533 /// Format is `projects/{project-id}`.
9534 pub parent: std::string::String,
9535
9536 /// Required. The schema object to validate.
9537 pub schema: std::option::Option<crate::model::Schema>,
9538
9539 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9540}
9541
9542impl ValidateSchemaRequest {
9543 /// Creates a new default instance.
9544 pub fn new() -> Self {
9545 std::default::Default::default()
9546 }
9547
9548 /// Sets the value of [parent][crate::model::ValidateSchemaRequest::parent].
9549 ///
9550 /// # Example
9551 /// ```ignore,no_run
9552 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9553 /// let x = ValidateSchemaRequest::new().set_parent("example");
9554 /// ```
9555 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9556 self.parent = v.into();
9557 self
9558 }
9559
9560 /// Sets the value of [schema][crate::model::ValidateSchemaRequest::schema].
9561 ///
9562 /// # Example
9563 /// ```ignore,no_run
9564 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9565 /// use google_cloud_pubsub::model::Schema;
9566 /// let x = ValidateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
9567 /// ```
9568 pub fn set_schema<T>(mut self, v: T) -> Self
9569 where
9570 T: std::convert::Into<crate::model::Schema>,
9571 {
9572 self.schema = std::option::Option::Some(v.into());
9573 self
9574 }
9575
9576 /// Sets or clears the value of [schema][crate::model::ValidateSchemaRequest::schema].
9577 ///
9578 /// # Example
9579 /// ```ignore,no_run
9580 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9581 /// use google_cloud_pubsub::model::Schema;
9582 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
9583 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
9584 /// ```
9585 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
9586 where
9587 T: std::convert::Into<crate::model::Schema>,
9588 {
9589 self.schema = v.map(|x| x.into());
9590 self
9591 }
9592}
9593
9594impl wkt::message::Message for ValidateSchemaRequest {
9595 fn typename() -> &'static str {
9596 "type.googleapis.com/google.pubsub.v1.ValidateSchemaRequest"
9597 }
9598}
9599
9600/// Response for the `ValidateSchema` method.
9601/// Empty for now.
9602#[derive(Clone, Default, PartialEq)]
9603#[non_exhaustive]
9604pub struct ValidateSchemaResponse {
9605 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9606}
9607
9608impl ValidateSchemaResponse {
9609 /// Creates a new default instance.
9610 pub fn new() -> Self {
9611 std::default::Default::default()
9612 }
9613}
9614
9615impl wkt::message::Message for ValidateSchemaResponse {
9616 fn typename() -> &'static str {
9617 "type.googleapis.com/google.pubsub.v1.ValidateSchemaResponse"
9618 }
9619}
9620
9621/// Request for the `ValidateMessage` method.
9622#[derive(Clone, Default, PartialEq)]
9623#[non_exhaustive]
9624pub struct ValidateMessageRequest {
9625 /// Required. The name of the project in which to validate schemas.
9626 /// Format is `projects/{project-id}`.
9627 pub parent: std::string::String,
9628
9629 /// Message to validate against the provided `schema_spec`.
9630 pub message: ::bytes::Bytes,
9631
9632 /// The encoding expected for messages
9633 pub encoding: crate::model::Encoding,
9634
9635 #[allow(missing_docs)]
9636 pub schema_spec: std::option::Option<crate::model::validate_message_request::SchemaSpec>,
9637
9638 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9639}
9640
9641impl ValidateMessageRequest {
9642 /// Creates a new default instance.
9643 pub fn new() -> Self {
9644 std::default::Default::default()
9645 }
9646
9647 /// Sets the value of [parent][crate::model::ValidateMessageRequest::parent].
9648 ///
9649 /// # Example
9650 /// ```ignore,no_run
9651 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9652 /// let x = ValidateMessageRequest::new().set_parent("example");
9653 /// ```
9654 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9655 self.parent = v.into();
9656 self
9657 }
9658
9659 /// Sets the value of [message][crate::model::ValidateMessageRequest::message].
9660 ///
9661 /// # Example
9662 /// ```ignore,no_run
9663 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9664 /// let x = ValidateMessageRequest::new().set_message(bytes::Bytes::from_static(b"example"));
9665 /// ```
9666 pub fn set_message<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9667 self.message = v.into();
9668 self
9669 }
9670
9671 /// Sets the value of [encoding][crate::model::ValidateMessageRequest::encoding].
9672 ///
9673 /// # Example
9674 /// ```ignore,no_run
9675 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9676 /// use google_cloud_pubsub::model::Encoding;
9677 /// let x0 = ValidateMessageRequest::new().set_encoding(Encoding::Json);
9678 /// let x1 = ValidateMessageRequest::new().set_encoding(Encoding::Binary);
9679 /// ```
9680 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
9681 self.encoding = v.into();
9682 self
9683 }
9684
9685 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec].
9686 ///
9687 /// Note that all the setters affecting `schema_spec` are mutually
9688 /// exclusive.
9689 ///
9690 /// # Example
9691 /// ```ignore,no_run
9692 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9693 /// use google_cloud_pubsub::model::validate_message_request::SchemaSpec;
9694 /// let x = ValidateMessageRequest::new().set_schema_spec(Some(SchemaSpec::Name("example".to_string())));
9695 /// ```
9696 pub fn set_schema_spec<
9697 T: std::convert::Into<std::option::Option<crate::model::validate_message_request::SchemaSpec>>,
9698 >(
9699 mut self,
9700 v: T,
9701 ) -> Self {
9702 self.schema_spec = v.into();
9703 self
9704 }
9705
9706 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9707 /// if it holds a `Name`, `None` if the field is not set or
9708 /// holds a different branch.
9709 pub fn name(&self) -> std::option::Option<&std::string::String> {
9710 #[allow(unreachable_patterns)]
9711 self.schema_spec.as_ref().and_then(|v| match v {
9712 crate::model::validate_message_request::SchemaSpec::Name(v) => {
9713 std::option::Option::Some(v)
9714 }
9715 _ => std::option::Option::None,
9716 })
9717 }
9718
9719 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9720 /// to hold a `Name`.
9721 ///
9722 /// Note that all the setters affecting `schema_spec` are
9723 /// mutually exclusive.
9724 ///
9725 /// # Example
9726 /// ```ignore,no_run
9727 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9728 /// # let project_id = "project_id";
9729 /// # let schema_id = "schema_id";
9730 /// let x = ValidateMessageRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9731 /// assert!(x.name().is_some());
9732 /// assert!(x.schema().is_none());
9733 /// ```
9734 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9735 self.schema_spec = std::option::Option::Some(
9736 crate::model::validate_message_request::SchemaSpec::Name(v.into()),
9737 );
9738 self
9739 }
9740
9741 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9742 /// if it holds a `Schema`, `None` if the field is not set or
9743 /// holds a different branch.
9744 pub fn schema(&self) -> std::option::Option<&std::boxed::Box<crate::model::Schema>> {
9745 #[allow(unreachable_patterns)]
9746 self.schema_spec.as_ref().and_then(|v| match v {
9747 crate::model::validate_message_request::SchemaSpec::Schema(v) => {
9748 std::option::Option::Some(v)
9749 }
9750 _ => std::option::Option::None,
9751 })
9752 }
9753
9754 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9755 /// to hold a `Schema`.
9756 ///
9757 /// Note that all the setters affecting `schema_spec` are
9758 /// mutually exclusive.
9759 ///
9760 /// # Example
9761 /// ```ignore,no_run
9762 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9763 /// use google_cloud_pubsub::model::Schema;
9764 /// let x = ValidateMessageRequest::new().set_schema(Schema::default()/* use setters */);
9765 /// assert!(x.schema().is_some());
9766 /// assert!(x.name().is_none());
9767 /// ```
9768 pub fn set_schema<T: std::convert::Into<std::boxed::Box<crate::model::Schema>>>(
9769 mut self,
9770 v: T,
9771 ) -> Self {
9772 self.schema_spec = std::option::Option::Some(
9773 crate::model::validate_message_request::SchemaSpec::Schema(v.into()),
9774 );
9775 self
9776 }
9777}
9778
9779impl wkt::message::Message for ValidateMessageRequest {
9780 fn typename() -> &'static str {
9781 "type.googleapis.com/google.pubsub.v1.ValidateMessageRequest"
9782 }
9783}
9784
9785/// Defines additional types related to [ValidateMessageRequest].
9786pub mod validate_message_request {
9787 #[allow(unused_imports)]
9788 use super::*;
9789
9790 #[allow(missing_docs)]
9791 #[derive(Clone, Debug, PartialEq)]
9792 #[non_exhaustive]
9793 pub enum SchemaSpec {
9794 /// Name of the schema against which to validate.
9795 ///
9796 /// Format is `projects/{project}/schemas/{schema}`.
9797 Name(std::string::String),
9798 /// Ad-hoc schema against which to validate
9799 Schema(std::boxed::Box<crate::model::Schema>),
9800 }
9801}
9802
9803/// Response for the `ValidateMessage` method.
9804/// Empty for now.
9805#[derive(Clone, Default, PartialEq)]
9806#[non_exhaustive]
9807pub struct ValidateMessageResponse {
9808 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9809}
9810
9811impl ValidateMessageResponse {
9812 /// Creates a new default instance.
9813 pub fn new() -> Self {
9814 std::default::Default::default()
9815 }
9816}
9817
9818impl wkt::message::Message for ValidateMessageResponse {
9819 fn typename() -> &'static str {
9820 "type.googleapis.com/google.pubsub.v1.ValidateMessageResponse"
9821 }
9822}
9823
9824/// Configuration specific to compiled Protocol Buffer schemas.
9825#[derive(Clone, Default, PartialEq)]
9826#[non_exhaustive]
9827pub struct CompiledProtoSchema {
9828 /// Required. The name of the root message type in the schema.
9829 pub root_message: std::string::String,
9830
9831 /// Required. The compiled FileDescriptorSet binary.
9832 pub compiled_bytes: ::bytes::Bytes,
9833
9834 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9835}
9836
9837impl CompiledProtoSchema {
9838 /// Creates a new default instance.
9839 pub fn new() -> Self {
9840 std::default::Default::default()
9841 }
9842
9843 /// Sets the value of [root_message][crate::model::CompiledProtoSchema::root_message].
9844 ///
9845 /// # Example
9846 /// ```ignore,no_run
9847 /// # use google_cloud_pubsub::model::CompiledProtoSchema;
9848 /// let x = CompiledProtoSchema::new().set_root_message("example");
9849 /// ```
9850 pub fn set_root_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9851 self.root_message = v.into();
9852 self
9853 }
9854
9855 /// Sets the value of [compiled_bytes][crate::model::CompiledProtoSchema::compiled_bytes].
9856 ///
9857 /// # Example
9858 /// ```ignore,no_run
9859 /// # use google_cloud_pubsub::model::CompiledProtoSchema;
9860 /// let x = CompiledProtoSchema::new().set_compiled_bytes(bytes::Bytes::from_static(b"example"));
9861 /// ```
9862 pub fn set_compiled_bytes<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9863 self.compiled_bytes = v.into();
9864 self
9865 }
9866}
9867
9868impl wkt::message::Message for CompiledProtoSchema {
9869 fn typename() -> &'static str {
9870 "type.googleapis.com/google.pubsub.v1.CompiledProtoSchema"
9871 }
9872}
9873
9874/// View of Schema object fields to be returned by GetSchema and ListSchemas.
9875///
9876/// # Working with unknown values
9877///
9878/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9879/// additional enum variants at any time. Adding new variants is not considered
9880/// a breaking change. Applications should write their code in anticipation of:
9881///
9882/// - New values appearing in future releases of the client library, **and**
9883/// - New values received dynamically, without application changes.
9884///
9885/// Please consult the [Working with enums] section in the user guide for some
9886/// guidelines.
9887///
9888/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9889#[derive(Clone, Debug, PartialEq)]
9890#[non_exhaustive]
9891pub enum SchemaView {
9892 /// The default / unset value.
9893 /// The API will default to the BASIC view.
9894 Unspecified,
9895 /// Include the name and type of the schema, but not the definition.
9896 Basic,
9897 /// Include all Schema object fields.
9898 Full,
9899 /// If set, the enum was initialized with an unknown value.
9900 ///
9901 /// Applications can examine the value using [SchemaView::value] or
9902 /// [SchemaView::name].
9903 UnknownValue(schema_view::UnknownValue),
9904}
9905
9906#[doc(hidden)]
9907pub mod schema_view {
9908 #[allow(unused_imports)]
9909 use super::*;
9910 #[derive(Clone, Debug, PartialEq)]
9911 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9912}
9913
9914impl SchemaView {
9915 /// Gets the enum value.
9916 ///
9917 /// Returns `None` if the enum contains an unknown value deserialized from
9918 /// the string representation of enums.
9919 pub fn value(&self) -> std::option::Option<i32> {
9920 match self {
9921 Self::Unspecified => std::option::Option::Some(0),
9922 Self::Basic => std::option::Option::Some(1),
9923 Self::Full => std::option::Option::Some(2),
9924 Self::UnknownValue(u) => u.0.value(),
9925 }
9926 }
9927
9928 /// Gets the enum value as a string.
9929 ///
9930 /// Returns `None` if the enum contains an unknown value deserialized from
9931 /// the integer representation of enums.
9932 pub fn name(&self) -> std::option::Option<&str> {
9933 match self {
9934 Self::Unspecified => std::option::Option::Some("SCHEMA_VIEW_UNSPECIFIED"),
9935 Self::Basic => std::option::Option::Some("BASIC"),
9936 Self::Full => std::option::Option::Some("FULL"),
9937 Self::UnknownValue(u) => u.0.name(),
9938 }
9939 }
9940}
9941
9942impl std::default::Default for SchemaView {
9943 fn default() -> Self {
9944 use std::convert::From;
9945 Self::from(0)
9946 }
9947}
9948
9949impl std::fmt::Display for SchemaView {
9950 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
9951 wkt::internal::display_enum(f, self.name(), self.value())
9952 }
9953}
9954
9955impl std::convert::From<i32> for SchemaView {
9956 fn from(value: i32) -> Self {
9957 match value {
9958 0 => Self::Unspecified,
9959 1 => Self::Basic,
9960 2 => Self::Full,
9961 _ => Self::UnknownValue(schema_view::UnknownValue(
9962 wkt::internal::UnknownEnumValue::Integer(value),
9963 )),
9964 }
9965 }
9966}
9967
9968impl std::convert::From<&str> for SchemaView {
9969 fn from(value: &str) -> Self {
9970 use std::string::ToString;
9971 match value {
9972 "SCHEMA_VIEW_UNSPECIFIED" => Self::Unspecified,
9973 "BASIC" => Self::Basic,
9974 "FULL" => Self::Full,
9975 _ => Self::UnknownValue(schema_view::UnknownValue(
9976 wkt::internal::UnknownEnumValue::String(value.to_string()),
9977 )),
9978 }
9979 }
9980}
9981
9982impl serde::ser::Serialize for SchemaView {
9983 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9984 where
9985 S: serde::Serializer,
9986 {
9987 match self {
9988 Self::Unspecified => serializer.serialize_i32(0),
9989 Self::Basic => serializer.serialize_i32(1),
9990 Self::Full => serializer.serialize_i32(2),
9991 Self::UnknownValue(u) => u.0.serialize(serializer),
9992 }
9993 }
9994}
9995
9996impl<'de> serde::de::Deserialize<'de> for SchemaView {
9997 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9998 where
9999 D: serde::Deserializer<'de>,
10000 {
10001 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SchemaView>::new(
10002 ".google.pubsub.v1.SchemaView",
10003 ))
10004 }
10005}
10006
10007/// Possible encoding types for messages.
10008///
10009/// # Working with unknown values
10010///
10011/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
10012/// additional enum variants at any time. Adding new variants is not considered
10013/// a breaking change. Applications should write their code in anticipation of:
10014///
10015/// - New values appearing in future releases of the client library, **and**
10016/// - New values received dynamically, without application changes.
10017///
10018/// Please consult the [Working with enums] section in the user guide for some
10019/// guidelines.
10020///
10021/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
10022#[derive(Clone, Debug, PartialEq)]
10023#[non_exhaustive]
10024pub enum Encoding {
10025 /// Unspecified
10026 Unspecified,
10027 /// JSON encoding
10028 Json,
10029 /// Binary encoding, as defined by the schema type. For some schema types,
10030 /// binary encoding may not be available.
10031 Binary,
10032 /// If set, the enum was initialized with an unknown value.
10033 ///
10034 /// Applications can examine the value using [Encoding::value] or
10035 /// [Encoding::name].
10036 UnknownValue(encoding::UnknownValue),
10037}
10038
10039#[doc(hidden)]
10040pub mod encoding {
10041 #[allow(unused_imports)]
10042 use super::*;
10043 #[derive(Clone, Debug, PartialEq)]
10044 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
10045}
10046
10047impl Encoding {
10048 /// Gets the enum value.
10049 ///
10050 /// Returns `None` if the enum contains an unknown value deserialized from
10051 /// the string representation of enums.
10052 pub fn value(&self) -> std::option::Option<i32> {
10053 match self {
10054 Self::Unspecified => std::option::Option::Some(0),
10055 Self::Json => std::option::Option::Some(1),
10056 Self::Binary => std::option::Option::Some(2),
10057 Self::UnknownValue(u) => u.0.value(),
10058 }
10059 }
10060
10061 /// Gets the enum value as a string.
10062 ///
10063 /// Returns `None` if the enum contains an unknown value deserialized from
10064 /// the integer representation of enums.
10065 pub fn name(&self) -> std::option::Option<&str> {
10066 match self {
10067 Self::Unspecified => std::option::Option::Some("ENCODING_UNSPECIFIED"),
10068 Self::Json => std::option::Option::Some("JSON"),
10069 Self::Binary => std::option::Option::Some("BINARY"),
10070 Self::UnknownValue(u) => u.0.name(),
10071 }
10072 }
10073}
10074
10075impl std::default::Default for Encoding {
10076 fn default() -> Self {
10077 use std::convert::From;
10078 Self::from(0)
10079 }
10080}
10081
10082impl std::fmt::Display for Encoding {
10083 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
10084 wkt::internal::display_enum(f, self.name(), self.value())
10085 }
10086}
10087
10088impl std::convert::From<i32> for Encoding {
10089 fn from(value: i32) -> Self {
10090 match value {
10091 0 => Self::Unspecified,
10092 1 => Self::Json,
10093 2 => Self::Binary,
10094 _ => Self::UnknownValue(encoding::UnknownValue(
10095 wkt::internal::UnknownEnumValue::Integer(value),
10096 )),
10097 }
10098 }
10099}
10100
10101impl std::convert::From<&str> for Encoding {
10102 fn from(value: &str) -> Self {
10103 use std::string::ToString;
10104 match value {
10105 "ENCODING_UNSPECIFIED" => Self::Unspecified,
10106 "JSON" => Self::Json,
10107 "BINARY" => Self::Binary,
10108 _ => Self::UnknownValue(encoding::UnknownValue(
10109 wkt::internal::UnknownEnumValue::String(value.to_string()),
10110 )),
10111 }
10112 }
10113}
10114
10115impl serde::ser::Serialize for Encoding {
10116 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
10117 where
10118 S: serde::Serializer,
10119 {
10120 match self {
10121 Self::Unspecified => serializer.serialize_i32(0),
10122 Self::Json => serializer.serialize_i32(1),
10123 Self::Binary => serializer.serialize_i32(2),
10124 Self::UnknownValue(u) => u.0.serialize(serializer),
10125 }
10126 }
10127}
10128
10129impl<'de> serde::de::Deserialize<'de> for Encoding {
10130 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
10131 where
10132 D: serde::Deserializer<'de>,
10133 {
10134 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Encoding>::new(
10135 ".google.pubsub.v1.Encoding",
10136 ))
10137 }
10138}