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