google_cloud_pubsub/generated/gapic/model.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19
20mod debug;
21mod deserialize;
22mod serialize;
23
24/// A policy constraining the storage of messages published to the topic.
25#[derive(Clone, Default, PartialEq)]
26#[non_exhaustive]
27pub struct MessageStoragePolicy {
28 /// Optional. A list of IDs of Google Cloud regions where messages that are
29 /// published to the topic may be persisted in storage. Messages published by
30 /// publishers running in non-allowed Google Cloud regions (or running outside
31 /// of Google Cloud altogether) are routed for storage in one of the allowed
32 /// regions. An empty list means that no regions are allowed, and is not a
33 /// valid configuration.
34 pub allowed_persistence_regions: std::vec::Vec<std::string::String>,
35
36 /// Optional. If true, `allowed_persistence_regions` is also used to enforce
37 /// in-transit guarantees for messages. That is, Pub/Sub will fail
38 /// Publish operations on this topic and subscribe operations
39 /// on any subscription attached to this topic in any region that is
40 /// not in `allowed_persistence_regions`.
41 pub enforce_in_transit: bool,
42
43 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
44}
45
46impl MessageStoragePolicy {
47 /// Creates a new default instance.
48 pub fn new() -> Self {
49 std::default::Default::default()
50 }
51
52 /// Sets the value of [allowed_persistence_regions][crate::model::MessageStoragePolicy::allowed_persistence_regions].
53 ///
54 /// # Example
55 /// ```ignore,no_run
56 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
57 /// let x = MessageStoragePolicy::new().set_allowed_persistence_regions(["a", "b", "c"]);
58 /// ```
59 pub fn set_allowed_persistence_regions<T, V>(mut self, v: T) -> Self
60 where
61 T: std::iter::IntoIterator<Item = V>,
62 V: std::convert::Into<std::string::String>,
63 {
64 use std::iter::Iterator;
65 self.allowed_persistence_regions = v.into_iter().map(|i| i.into()).collect();
66 self
67 }
68
69 /// Sets the value of [enforce_in_transit][crate::model::MessageStoragePolicy::enforce_in_transit].
70 ///
71 /// # Example
72 /// ```ignore,no_run
73 /// # use google_cloud_pubsub::model::MessageStoragePolicy;
74 /// let x = MessageStoragePolicy::new().set_enforce_in_transit(true);
75 /// ```
76 pub fn set_enforce_in_transit<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
77 self.enforce_in_transit = v.into();
78 self
79 }
80}
81
82impl wkt::message::Message for MessageStoragePolicy {
83 fn typename() -> &'static str {
84 "type.googleapis.com/google.pubsub.v1.MessageStoragePolicy"
85 }
86}
87
88/// Settings for validating messages published against a schema.
89#[derive(Clone, Default, PartialEq)]
90#[non_exhaustive]
91pub struct SchemaSettings {
92 /// Required. The name of the schema that messages published should be
93 /// validated against. Format is `projects/{project}/schemas/{schema}`. The
94 /// value of this field will be `_deleted-schema_` if the schema has been
95 /// deleted.
96 pub schema: std::string::String,
97
98 /// Optional. The encoding of messages validated against `schema`.
99 pub encoding: crate::model::Encoding,
100
101 /// Optional. The minimum (inclusive) revision allowed for validating messages.
102 /// If empty or not present, allow any revision to be validated against
103 /// last_revision or any revision created before.
104 pub first_revision_id: std::string::String,
105
106 /// Optional. The maximum (inclusive) revision allowed for validating messages.
107 /// If empty or not present, allow any revision to be validated against
108 /// first_revision or any revision created after.
109 pub last_revision_id: std::string::String,
110
111 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
112}
113
114impl SchemaSettings {
115 /// Creates a new default instance.
116 pub fn new() -> Self {
117 std::default::Default::default()
118 }
119
120 /// Sets the value of [schema][crate::model::SchemaSettings::schema].
121 ///
122 /// # Example
123 /// ```ignore,no_run
124 /// # use google_cloud_pubsub::model::SchemaSettings;
125 /// # let project_id = "project_id";
126 /// # let schema_id = "schema_id";
127 /// let x = SchemaSettings::new().set_schema(format!("projects/{project_id}/schemas/{schema_id}"));
128 /// ```
129 pub fn set_schema<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
130 self.schema = v.into();
131 self
132 }
133
134 /// Sets the value of [encoding][crate::model::SchemaSettings::encoding].
135 ///
136 /// # Example
137 /// ```ignore,no_run
138 /// # use google_cloud_pubsub::model::SchemaSettings;
139 /// use google_cloud_pubsub::model::Encoding;
140 /// let x0 = SchemaSettings::new().set_encoding(Encoding::Json);
141 /// let x1 = SchemaSettings::new().set_encoding(Encoding::Binary);
142 /// ```
143 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
144 self.encoding = v.into();
145 self
146 }
147
148 /// Sets the value of [first_revision_id][crate::model::SchemaSettings::first_revision_id].
149 ///
150 /// # Example
151 /// ```ignore,no_run
152 /// # use google_cloud_pubsub::model::SchemaSettings;
153 /// let x = SchemaSettings::new().set_first_revision_id("example");
154 /// ```
155 pub fn set_first_revision_id<T: std::convert::Into<std::string::String>>(
156 mut self,
157 v: T,
158 ) -> Self {
159 self.first_revision_id = v.into();
160 self
161 }
162
163 /// Sets the value of [last_revision_id][crate::model::SchemaSettings::last_revision_id].
164 ///
165 /// # Example
166 /// ```ignore,no_run
167 /// # use google_cloud_pubsub::model::SchemaSettings;
168 /// let x = SchemaSettings::new().set_last_revision_id("example");
169 /// ```
170 pub fn set_last_revision_id<T: std::convert::Into<std::string::String>>(
171 mut self,
172 v: T,
173 ) -> Self {
174 self.last_revision_id = v.into();
175 self
176 }
177}
178
179impl wkt::message::Message for SchemaSettings {
180 fn typename() -> &'static str {
181 "type.googleapis.com/google.pubsub.v1.SchemaSettings"
182 }
183}
184
185/// Settings for an ingestion data source on a topic.
186#[derive(Clone, Default, PartialEq)]
187#[non_exhaustive]
188pub struct IngestionDataSourceSettings {
189 /// Optional. Platform Logs settings. If unset, no Platform Logs will be
190 /// generated.
191 pub platform_logs_settings: std::option::Option<crate::model::PlatformLogsSettings>,
192
193 /// Only one source type can have settings set.
194 pub source: std::option::Option<crate::model::ingestion_data_source_settings::Source>,
195
196 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
197}
198
199impl IngestionDataSourceSettings {
200 /// Creates a new default instance.
201 pub fn new() -> Self {
202 std::default::Default::default()
203 }
204
205 /// Sets the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
206 ///
207 /// # Example
208 /// ```ignore,no_run
209 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
210 /// use google_cloud_pubsub::model::PlatformLogsSettings;
211 /// let x = IngestionDataSourceSettings::new().set_platform_logs_settings(PlatformLogsSettings::default()/* use setters */);
212 /// ```
213 pub fn set_platform_logs_settings<T>(mut self, v: T) -> Self
214 where
215 T: std::convert::Into<crate::model::PlatformLogsSettings>,
216 {
217 self.platform_logs_settings = std::option::Option::Some(v.into());
218 self
219 }
220
221 /// Sets or clears the value of [platform_logs_settings][crate::model::IngestionDataSourceSettings::platform_logs_settings].
222 ///
223 /// # Example
224 /// ```ignore,no_run
225 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
226 /// use google_cloud_pubsub::model::PlatformLogsSettings;
227 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(Some(PlatformLogsSettings::default()/* use setters */));
228 /// let x = IngestionDataSourceSettings::new().set_or_clear_platform_logs_settings(None::<PlatformLogsSettings>);
229 /// ```
230 pub fn set_or_clear_platform_logs_settings<T>(mut self, v: std::option::Option<T>) -> Self
231 where
232 T: std::convert::Into<crate::model::PlatformLogsSettings>,
233 {
234 self.platform_logs_settings = v.map(|x| x.into());
235 self
236 }
237
238 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source].
239 ///
240 /// Note that all the setters affecting `source` are mutually
241 /// exclusive.
242 ///
243 /// # Example
244 /// ```ignore,no_run
245 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
246 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
247 /// let x = IngestionDataSourceSettings::new().set_source(Some(
248 /// google_cloud_pubsub::model::ingestion_data_source_settings::Source::AwsKinesis(AwsKinesis::default().into())));
249 /// ```
250 pub fn set_source<
251 T: std::convert::Into<
252 std::option::Option<crate::model::ingestion_data_source_settings::Source>,
253 >,
254 >(
255 mut self,
256 v: T,
257 ) -> Self {
258 self.source = v.into();
259 self
260 }
261
262 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
263 /// if it holds a `AwsKinesis`, `None` if the field is not set or
264 /// holds a different branch.
265 pub fn aws_kinesis(
266 &self,
267 ) -> std::option::Option<
268 &std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
269 > {
270 #[allow(unreachable_patterns)]
271 self.source.as_ref().and_then(|v| match v {
272 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v) => {
273 std::option::Option::Some(v)
274 }
275 _ => std::option::Option::None,
276 })
277 }
278
279 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
280 /// to hold a `AwsKinesis`.
281 ///
282 /// Note that all the setters affecting `source` are
283 /// mutually exclusive.
284 ///
285 /// # Example
286 /// ```ignore,no_run
287 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
288 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
289 /// let x = IngestionDataSourceSettings::new().set_aws_kinesis(AwsKinesis::default()/* use setters */);
290 /// assert!(x.aws_kinesis().is_some());
291 /// assert!(x.cloud_storage().is_none());
292 /// assert!(x.azure_event_hubs().is_none());
293 /// assert!(x.aws_msk().is_none());
294 /// assert!(x.confluent_cloud().is_none());
295 /// ```
296 pub fn set_aws_kinesis<
297 T: std::convert::Into<
298 std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>,
299 >,
300 >(
301 mut self,
302 v: T,
303 ) -> Self {
304 self.source = std::option::Option::Some(
305 crate::model::ingestion_data_source_settings::Source::AwsKinesis(v.into()),
306 );
307 self
308 }
309
310 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
311 /// if it holds a `CloudStorage`, `None` if the field is not set or
312 /// holds a different branch.
313 pub fn cloud_storage(
314 &self,
315 ) -> std::option::Option<
316 &std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
317 > {
318 #[allow(unreachable_patterns)]
319 self.source.as_ref().and_then(|v| match v {
320 crate::model::ingestion_data_source_settings::Source::CloudStorage(v) => {
321 std::option::Option::Some(v)
322 }
323 _ => std::option::Option::None,
324 })
325 }
326
327 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
328 /// to hold a `CloudStorage`.
329 ///
330 /// Note that all the setters affecting `source` are
331 /// mutually exclusive.
332 ///
333 /// # Example
334 /// ```ignore,no_run
335 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
336 /// use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
337 /// let x = IngestionDataSourceSettings::new().set_cloud_storage(CloudStorage::default()/* use setters */);
338 /// assert!(x.cloud_storage().is_some());
339 /// assert!(x.aws_kinesis().is_none());
340 /// assert!(x.azure_event_hubs().is_none());
341 /// assert!(x.aws_msk().is_none());
342 /// assert!(x.confluent_cloud().is_none());
343 /// ```
344 pub fn set_cloud_storage<
345 T: std::convert::Into<
346 std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>,
347 >,
348 >(
349 mut self,
350 v: T,
351 ) -> Self {
352 self.source = std::option::Option::Some(
353 crate::model::ingestion_data_source_settings::Source::CloudStorage(v.into()),
354 );
355 self
356 }
357
358 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
359 /// if it holds a `AzureEventHubs`, `None` if the field is not set or
360 /// holds a different branch.
361 pub fn azure_event_hubs(
362 &self,
363 ) -> std::option::Option<
364 &std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
365 > {
366 #[allow(unreachable_patterns)]
367 self.source.as_ref().and_then(|v| match v {
368 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v) => {
369 std::option::Option::Some(v)
370 }
371 _ => std::option::Option::None,
372 })
373 }
374
375 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
376 /// to hold a `AzureEventHubs`.
377 ///
378 /// Note that all the setters affecting `source` are
379 /// mutually exclusive.
380 ///
381 /// # Example
382 /// ```ignore,no_run
383 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
384 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
385 /// let x = IngestionDataSourceSettings::new().set_azure_event_hubs(AzureEventHubs::default()/* use setters */);
386 /// assert!(x.azure_event_hubs().is_some());
387 /// assert!(x.aws_kinesis().is_none());
388 /// assert!(x.cloud_storage().is_none());
389 /// assert!(x.aws_msk().is_none());
390 /// assert!(x.confluent_cloud().is_none());
391 /// ```
392 pub fn set_azure_event_hubs<
393 T: std::convert::Into<
394 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
395 >,
396 >(
397 mut self,
398 v: T,
399 ) -> Self {
400 self.source = std::option::Option::Some(
401 crate::model::ingestion_data_source_settings::Source::AzureEventHubs(v.into()),
402 );
403 self
404 }
405
406 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
407 /// if it holds a `AwsMsk`, `None` if the field is not set or
408 /// holds a different branch.
409 pub fn aws_msk(
410 &self,
411 ) -> std::option::Option<&std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>
412 {
413 #[allow(unreachable_patterns)]
414 self.source.as_ref().and_then(|v| match v {
415 crate::model::ingestion_data_source_settings::Source::AwsMsk(v) => {
416 std::option::Option::Some(v)
417 }
418 _ => std::option::Option::None,
419 })
420 }
421
422 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
423 /// to hold a `AwsMsk`.
424 ///
425 /// Note that all the setters affecting `source` are
426 /// mutually exclusive.
427 ///
428 /// # Example
429 /// ```ignore,no_run
430 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
431 /// use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
432 /// let x = IngestionDataSourceSettings::new().set_aws_msk(AwsMsk::default()/* use setters */);
433 /// assert!(x.aws_msk().is_some());
434 /// assert!(x.aws_kinesis().is_none());
435 /// assert!(x.cloud_storage().is_none());
436 /// assert!(x.azure_event_hubs().is_none());
437 /// assert!(x.confluent_cloud().is_none());
438 /// ```
439 pub fn set_aws_msk<
440 T: std::convert::Into<std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>>,
441 >(
442 mut self,
443 v: T,
444 ) -> Self {
445 self.source = std::option::Option::Some(
446 crate::model::ingestion_data_source_settings::Source::AwsMsk(v.into()),
447 );
448 self
449 }
450
451 /// The value of [source][crate::model::IngestionDataSourceSettings::source]
452 /// if it holds a `ConfluentCloud`, `None` if the field is not set or
453 /// holds a different branch.
454 pub fn confluent_cloud(
455 &self,
456 ) -> std::option::Option<
457 &std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
458 > {
459 #[allow(unreachable_patterns)]
460 self.source.as_ref().and_then(|v| match v {
461 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v) => {
462 std::option::Option::Some(v)
463 }
464 _ => std::option::Option::None,
465 })
466 }
467
468 /// Sets the value of [source][crate::model::IngestionDataSourceSettings::source]
469 /// to hold a `ConfluentCloud`.
470 ///
471 /// Note that all the setters affecting `source` are
472 /// mutually exclusive.
473 ///
474 /// # Example
475 /// ```ignore,no_run
476 /// # use google_cloud_pubsub::model::IngestionDataSourceSettings;
477 /// use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
478 /// let x = IngestionDataSourceSettings::new().set_confluent_cloud(ConfluentCloud::default()/* use setters */);
479 /// assert!(x.confluent_cloud().is_some());
480 /// assert!(x.aws_kinesis().is_none());
481 /// assert!(x.cloud_storage().is_none());
482 /// assert!(x.azure_event_hubs().is_none());
483 /// assert!(x.aws_msk().is_none());
484 /// ```
485 pub fn set_confluent_cloud<
486 T: std::convert::Into<
487 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
488 >,
489 >(
490 mut self,
491 v: T,
492 ) -> Self {
493 self.source = std::option::Option::Some(
494 crate::model::ingestion_data_source_settings::Source::ConfluentCloud(v.into()),
495 );
496 self
497 }
498}
499
500impl wkt::message::Message for IngestionDataSourceSettings {
501 fn typename() -> &'static str {
502 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings"
503 }
504}
505
506/// Defines additional types related to [IngestionDataSourceSettings].
507pub mod ingestion_data_source_settings {
508 #[allow(unused_imports)]
509 use super::*;
510
511 /// Ingestion settings for Amazon Kinesis Data Streams.
512 #[derive(Clone, Default, PartialEq)]
513 #[non_exhaustive]
514 pub struct AwsKinesis {
515 /// Output only. An output-only field that indicates the state of the Kinesis
516 /// ingestion source.
517 pub state: crate::model::ingestion_data_source_settings::aws_kinesis::State,
518
519 /// Required. The Kinesis stream ARN to ingest data from.
520 pub stream_arn: std::string::String,
521
522 /// Required. The Kinesis consumer ARN to used for ingestion in Enhanced
523 /// Fan-Out mode. The consumer must be already created and ready to be used.
524 pub consumer_arn: std::string::String,
525
526 /// Required. AWS role ARN to be used for Federated Identity authentication
527 /// with Kinesis. Check the Pub/Sub docs for how to set up this role and the
528 /// required permissions that need to be attached to it.
529 pub aws_role_arn: std::string::String,
530
531 /// Required. The GCP service account to be used for Federated Identity
532 /// authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for
533 /// the provided role). The `aws_role_arn` must be set up with
534 /// `accounts.google.com:sub` equals to this service account number.
535 pub gcp_service_account: std::string::String,
536
537 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
538 }
539
540 impl AwsKinesis {
541 /// Creates a new default instance.
542 pub fn new() -> Self {
543 std::default::Default::default()
544 }
545
546 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsKinesis::state].
547 ///
548 /// # Example
549 /// ```ignore,no_run
550 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
551 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_kinesis::State;
552 /// let x0 = AwsKinesis::new().set_state(State::Active);
553 /// let x1 = AwsKinesis::new().set_state(State::KinesisPermissionDenied);
554 /// let x2 = AwsKinesis::new().set_state(State::PublishPermissionDenied);
555 /// ```
556 pub fn set_state<
557 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_kinesis::State>,
558 >(
559 mut self,
560 v: T,
561 ) -> Self {
562 self.state = v.into();
563 self
564 }
565
566 /// Sets the value of [stream_arn][crate::model::ingestion_data_source_settings::AwsKinesis::stream_arn].
567 ///
568 /// # Example
569 /// ```ignore,no_run
570 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
571 /// let x = AwsKinesis::new().set_stream_arn("example");
572 /// ```
573 pub fn set_stream_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
574 self.stream_arn = v.into();
575 self
576 }
577
578 /// Sets the value of [consumer_arn][crate::model::ingestion_data_source_settings::AwsKinesis::consumer_arn].
579 ///
580 /// # Example
581 /// ```ignore,no_run
582 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
583 /// let x = AwsKinesis::new().set_consumer_arn("example");
584 /// ```
585 pub fn set_consumer_arn<T: std::convert::Into<std::string::String>>(
586 mut self,
587 v: T,
588 ) -> Self {
589 self.consumer_arn = v.into();
590 self
591 }
592
593 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsKinesis::aws_role_arn].
594 ///
595 /// # Example
596 /// ```ignore,no_run
597 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
598 /// let x = AwsKinesis::new().set_aws_role_arn("example");
599 /// ```
600 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
601 mut self,
602 v: T,
603 ) -> Self {
604 self.aws_role_arn = v.into();
605 self
606 }
607
608 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsKinesis::gcp_service_account].
609 ///
610 /// # Example
611 /// ```ignore,no_run
612 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsKinesis;
613 /// let x = AwsKinesis::new().set_gcp_service_account("example");
614 /// ```
615 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
616 mut self,
617 v: T,
618 ) -> Self {
619 self.gcp_service_account = v.into();
620 self
621 }
622 }
623
624 impl wkt::message::Message for AwsKinesis {
625 fn typename() -> &'static str {
626 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis"
627 }
628 }
629
630 /// Defines additional types related to [AwsKinesis].
631 pub mod aws_kinesis {
632 #[allow(unused_imports)]
633 use super::*;
634
635 /// Possible states for ingestion from Amazon Kinesis Data Streams.
636 ///
637 /// # Working with unknown values
638 ///
639 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
640 /// additional enum variants at any time. Adding new variants is not considered
641 /// a breaking change. Applications should write their code in anticipation of:
642 ///
643 /// - New values appearing in future releases of the client library, **and**
644 /// - New values received dynamically, without application changes.
645 ///
646 /// Please consult the [Working with enums] section in the user guide for some
647 /// guidelines.
648 ///
649 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
650 #[derive(Clone, Debug, PartialEq)]
651 #[non_exhaustive]
652 pub enum State {
653 /// Default value. This value is unused.
654 Unspecified,
655 /// Ingestion is active.
656 Active,
657 /// Permission denied encountered while consuming data from Kinesis.
658 /// This can happen if:
659 ///
660 /// - The provided `aws_role_arn` does not exist or does not have the
661 /// appropriate permissions attached.
662 /// - The provided `aws_role_arn` is not set up properly for Identity
663 /// Federation using `gcp_service_account`.
664 /// - The Pub/Sub SA is not granted the
665 /// `iam.serviceAccounts.getOpenIdToken` permission on
666 /// `gcp_service_account`.
667 KinesisPermissionDenied,
668 /// Permission denied encountered while publishing to the topic. This can
669 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
670 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
671 PublishPermissionDenied,
672 /// The Kinesis stream does not exist.
673 StreamNotFound,
674 /// The Kinesis consumer does not exist.
675 ConsumerNotFound,
676 /// If set, the enum was initialized with an unknown value.
677 ///
678 /// Applications can examine the value using [State::value] or
679 /// [State::name].
680 UnknownValue(state::UnknownValue),
681 }
682
683 #[doc(hidden)]
684 pub mod state {
685 #[allow(unused_imports)]
686 use super::*;
687 #[derive(Clone, Debug, PartialEq)]
688 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
689 }
690
691 impl State {
692 /// Gets the enum value.
693 ///
694 /// Returns `None` if the enum contains an unknown value deserialized from
695 /// the string representation of enums.
696 pub fn value(&self) -> std::option::Option<i32> {
697 match self {
698 Self::Unspecified => std::option::Option::Some(0),
699 Self::Active => std::option::Option::Some(1),
700 Self::KinesisPermissionDenied => std::option::Option::Some(2),
701 Self::PublishPermissionDenied => std::option::Option::Some(3),
702 Self::StreamNotFound => std::option::Option::Some(4),
703 Self::ConsumerNotFound => std::option::Option::Some(5),
704 Self::UnknownValue(u) => u.0.value(),
705 }
706 }
707
708 /// Gets the enum value as a string.
709 ///
710 /// Returns `None` if the enum contains an unknown value deserialized from
711 /// the integer representation of enums.
712 pub fn name(&self) -> std::option::Option<&str> {
713 match self {
714 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
715 Self::Active => std::option::Option::Some("ACTIVE"),
716 Self::KinesisPermissionDenied => {
717 std::option::Option::Some("KINESIS_PERMISSION_DENIED")
718 }
719 Self::PublishPermissionDenied => {
720 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
721 }
722 Self::StreamNotFound => std::option::Option::Some("STREAM_NOT_FOUND"),
723 Self::ConsumerNotFound => std::option::Option::Some("CONSUMER_NOT_FOUND"),
724 Self::UnknownValue(u) => u.0.name(),
725 }
726 }
727 }
728
729 impl std::default::Default for State {
730 fn default() -> Self {
731 use std::convert::From;
732 Self::from(0)
733 }
734 }
735
736 impl std::fmt::Display for State {
737 fn fmt(
738 &self,
739 f: &mut std::fmt::Formatter<'_>,
740 ) -> std::result::Result<(), std::fmt::Error> {
741 wkt::internal::display_enum(f, self.name(), self.value())
742 }
743 }
744
745 impl std::convert::From<i32> for State {
746 fn from(value: i32) -> Self {
747 match value {
748 0 => Self::Unspecified,
749 1 => Self::Active,
750 2 => Self::KinesisPermissionDenied,
751 3 => Self::PublishPermissionDenied,
752 4 => Self::StreamNotFound,
753 5 => Self::ConsumerNotFound,
754 _ => Self::UnknownValue(state::UnknownValue(
755 wkt::internal::UnknownEnumValue::Integer(value),
756 )),
757 }
758 }
759 }
760
761 impl std::convert::From<&str> for State {
762 fn from(value: &str) -> Self {
763 use std::string::ToString;
764 match value {
765 "STATE_UNSPECIFIED" => Self::Unspecified,
766 "ACTIVE" => Self::Active,
767 "KINESIS_PERMISSION_DENIED" => Self::KinesisPermissionDenied,
768 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
769 "STREAM_NOT_FOUND" => Self::StreamNotFound,
770 "CONSUMER_NOT_FOUND" => Self::ConsumerNotFound,
771 _ => Self::UnknownValue(state::UnknownValue(
772 wkt::internal::UnknownEnumValue::String(value.to_string()),
773 )),
774 }
775 }
776 }
777
778 impl serde::ser::Serialize for State {
779 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
780 where
781 S: serde::Serializer,
782 {
783 match self {
784 Self::Unspecified => serializer.serialize_i32(0),
785 Self::Active => serializer.serialize_i32(1),
786 Self::KinesisPermissionDenied => serializer.serialize_i32(2),
787 Self::PublishPermissionDenied => serializer.serialize_i32(3),
788 Self::StreamNotFound => serializer.serialize_i32(4),
789 Self::ConsumerNotFound => serializer.serialize_i32(5),
790 Self::UnknownValue(u) => u.0.serialize(serializer),
791 }
792 }
793 }
794
795 impl<'de> serde::de::Deserialize<'de> for State {
796 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
797 where
798 D: serde::Deserializer<'de>,
799 {
800 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
801 ".google.pubsub.v1.IngestionDataSourceSettings.AwsKinesis.State",
802 ))
803 }
804 }
805 }
806
807 /// Ingestion settings for Cloud Storage.
808 #[derive(Clone, Default, PartialEq)]
809 #[non_exhaustive]
810 pub struct CloudStorage {
811 /// Output only. An output-only field that indicates the state of the Cloud
812 /// Storage ingestion source.
813 pub state: crate::model::ingestion_data_source_settings::cloud_storage::State,
814
815 /// Optional. Cloud Storage bucket. The bucket name must be without any
816 /// prefix like "gs://". See the [bucket naming requirements]
817 /// (<https://cloud.google.com/storage/docs/buckets#naming>).
818 pub bucket: std::string::String,
819
820 /// Optional. Only objects with a larger or equal creation timestamp will be
821 /// ingested.
822 pub minimum_object_create_time: std::option::Option<wkt::Timestamp>,
823
824 /// Optional. Glob pattern used to match objects that will be ingested. If
825 /// unset, all objects will be ingested. See the [supported
826 /// patterns](https://cloud.google.com/storage/docs/json_api/v1/objects/list#list-objects-and-prefixes-using-glob).
827 pub match_glob: std::string::String,
828
829 /// Defaults to text format.
830 pub input_format: std::option::Option<
831 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
832 >,
833
834 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
835 }
836
837 impl CloudStorage {
838 /// Creates a new default instance.
839 pub fn new() -> Self {
840 std::default::Default::default()
841 }
842
843 /// Sets the value of [state][crate::model::ingestion_data_source_settings::CloudStorage::state].
844 ///
845 /// # Example
846 /// ```ignore,no_run
847 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
848 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::State;
849 /// let x0 = CloudStorage::new().set_state(State::Active);
850 /// let x1 = CloudStorage::new().set_state(State::CloudStoragePermissionDenied);
851 /// let x2 = CloudStorage::new().set_state(State::PublishPermissionDenied);
852 /// ```
853 pub fn set_state<
854 T: std::convert::Into<crate::model::ingestion_data_source_settings::cloud_storage::State>,
855 >(
856 mut self,
857 v: T,
858 ) -> Self {
859 self.state = v.into();
860 self
861 }
862
863 /// Sets the value of [bucket][crate::model::ingestion_data_source_settings::CloudStorage::bucket].
864 ///
865 /// # Example
866 /// ```ignore,no_run
867 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
868 /// let x = CloudStorage::new().set_bucket("example");
869 /// ```
870 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
871 self.bucket = v.into();
872 self
873 }
874
875 /// Sets the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
876 ///
877 /// # Example
878 /// ```ignore,no_run
879 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
880 /// use wkt::Timestamp;
881 /// let x = CloudStorage::new().set_minimum_object_create_time(Timestamp::default()/* use setters */);
882 /// ```
883 pub fn set_minimum_object_create_time<T>(mut self, v: T) -> Self
884 where
885 T: std::convert::Into<wkt::Timestamp>,
886 {
887 self.minimum_object_create_time = std::option::Option::Some(v.into());
888 self
889 }
890
891 /// Sets or clears the value of [minimum_object_create_time][crate::model::ingestion_data_source_settings::CloudStorage::minimum_object_create_time].
892 ///
893 /// # Example
894 /// ```ignore,no_run
895 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
896 /// use wkt::Timestamp;
897 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(Some(Timestamp::default()/* use setters */));
898 /// let x = CloudStorage::new().set_or_clear_minimum_object_create_time(None::<Timestamp>);
899 /// ```
900 pub fn set_or_clear_minimum_object_create_time<T>(
901 mut self,
902 v: std::option::Option<T>,
903 ) -> Self
904 where
905 T: std::convert::Into<wkt::Timestamp>,
906 {
907 self.minimum_object_create_time = v.map(|x| x.into());
908 self
909 }
910
911 /// Sets the value of [match_glob][crate::model::ingestion_data_source_settings::CloudStorage::match_glob].
912 ///
913 /// # Example
914 /// ```ignore,no_run
915 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
916 /// let x = CloudStorage::new().set_match_glob("example");
917 /// ```
918 pub fn set_match_glob<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
919 self.match_glob = v.into();
920 self
921 }
922
923 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format].
924 ///
925 /// Note that all the setters affecting `input_format` are mutually
926 /// exclusive.
927 ///
928 /// # Example
929 /// ```ignore,no_run
930 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
931 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
932 /// let x = CloudStorage::new().set_input_format(Some(
933 /// google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(TextFormat::default().into())));
934 /// ```
935 pub fn set_input_format<
936 T: std::convert::Into<
937 std::option::Option<
938 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat,
939 >,
940 >,
941 >(
942 mut self,
943 v: T,
944 ) -> Self {
945 self.input_format = v.into();
946 self
947 }
948
949 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
950 /// if it holds a `TextFormat`, `None` if the field is not set or
951 /// holds a different branch.
952 pub fn text_format(
953 &self,
954 ) -> std::option::Option<
955 &std::boxed::Box<
956 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
957 >,
958 > {
959 #[allow(unreachable_patterns)]
960 self.input_format.as_ref().and_then(|v| match v {
961 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(v) => std::option::Option::Some(v),
962 _ => std::option::Option::None,
963 })
964 }
965
966 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
967 /// to hold a `TextFormat`.
968 ///
969 /// Note that all the setters affecting `input_format` are
970 /// mutually exclusive.
971 ///
972 /// # Example
973 /// ```ignore,no_run
974 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
975 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
976 /// let x = CloudStorage::new().set_text_format(TextFormat::default()/* use setters */);
977 /// assert!(x.text_format().is_some());
978 /// assert!(x.avro_format().is_none());
979 /// assert!(x.pubsub_avro_format().is_none());
980 /// ```
981 pub fn set_text_format<
982 T: std::convert::Into<
983 std::boxed::Box<
984 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
985 >,
986 >,
987 >(
988 mut self,
989 v: T,
990 ) -> Self {
991 self.input_format = std::option::Option::Some(
992 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::TextFormat(
993 v.into()
994 )
995 );
996 self
997 }
998
999 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1000 /// if it holds a `AvroFormat`, `None` if the field is not set or
1001 /// holds a different branch.
1002 pub fn avro_format(
1003 &self,
1004 ) -> std::option::Option<
1005 &std::boxed::Box<
1006 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1007 >,
1008 > {
1009 #[allow(unreachable_patterns)]
1010 self.input_format.as_ref().and_then(|v| match v {
1011 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(v) => std::option::Option::Some(v),
1012 _ => std::option::Option::None,
1013 })
1014 }
1015
1016 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1017 /// to hold a `AvroFormat`.
1018 ///
1019 /// Note that all the setters affecting `input_format` are
1020 /// mutually exclusive.
1021 ///
1022 /// # Example
1023 /// ```ignore,no_run
1024 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1025 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::AvroFormat;
1026 /// let x = CloudStorage::new().set_avro_format(AvroFormat::default()/* use setters */);
1027 /// assert!(x.avro_format().is_some());
1028 /// assert!(x.text_format().is_none());
1029 /// assert!(x.pubsub_avro_format().is_none());
1030 /// ```
1031 pub fn set_avro_format<
1032 T: std::convert::Into<
1033 std::boxed::Box<
1034 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1035 >,
1036 >,
1037 >(
1038 mut self,
1039 v: T,
1040 ) -> Self {
1041 self.input_format = std::option::Option::Some(
1042 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::AvroFormat(
1043 v.into()
1044 )
1045 );
1046 self
1047 }
1048
1049 /// The value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1050 /// if it holds a `PubsubAvroFormat`, `None` if the field is not set or
1051 /// holds a different branch.
1052 pub fn pubsub_avro_format(
1053 &self,
1054 ) -> std::option::Option<
1055 &std::boxed::Box<
1056 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1057 >,
1058 > {
1059 #[allow(unreachable_patterns)]
1060 self.input_format.as_ref().and_then(|v| match v {
1061 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(v) => std::option::Option::Some(v),
1062 _ => std::option::Option::None,
1063 })
1064 }
1065
1066 /// Sets the value of [input_format][crate::model::ingestion_data_source_settings::CloudStorage::input_format]
1067 /// to hold a `PubsubAvroFormat`.
1068 ///
1069 /// Note that all the setters affecting `input_format` are
1070 /// mutually exclusive.
1071 ///
1072 /// # Example
1073 /// ```ignore,no_run
1074 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::CloudStorage;
1075 /// use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat;
1076 /// let x = CloudStorage::new().set_pubsub_avro_format(PubSubAvroFormat::default()/* use setters */);
1077 /// assert!(x.pubsub_avro_format().is_some());
1078 /// assert!(x.text_format().is_none());
1079 /// assert!(x.avro_format().is_none());
1080 /// ```
1081 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{
1082 self.input_format = std::option::Option::Some(
1083 crate::model::ingestion_data_source_settings::cloud_storage::InputFormat::PubsubAvroFormat(
1084 v.into()
1085 )
1086 );
1087 self
1088 }
1089 }
1090
1091 impl wkt::message::Message for CloudStorage {
1092 fn typename() -> &'static str {
1093 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage"
1094 }
1095 }
1096
1097 /// Defines additional types related to [CloudStorage].
1098 pub mod cloud_storage {
1099 #[allow(unused_imports)]
1100 use super::*;
1101
1102 /// Configuration for reading Cloud Storage data in text format. Each line of
1103 /// text as specified by the delimiter will be set to the `data` field of a
1104 /// Pub/Sub message.
1105 #[derive(Clone, Default, PartialEq)]
1106 #[non_exhaustive]
1107 pub struct TextFormat {
1108 /// Optional. When unset, '\n' is used.
1109 pub delimiter: std::option::Option<std::string::String>,
1110
1111 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1112 }
1113
1114 impl TextFormat {
1115 /// Creates a new default instance.
1116 pub fn new() -> Self {
1117 std::default::Default::default()
1118 }
1119
1120 /// Sets the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1121 ///
1122 /// # Example
1123 /// ```ignore,no_run
1124 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1125 /// let x = TextFormat::new().set_delimiter("example");
1126 /// ```
1127 pub fn set_delimiter<T>(mut self, v: T) -> Self
1128 where
1129 T: std::convert::Into<std::string::String>,
1130 {
1131 self.delimiter = std::option::Option::Some(v.into());
1132 self
1133 }
1134
1135 /// Sets or clears the value of [delimiter][crate::model::ingestion_data_source_settings::cloud_storage::TextFormat::delimiter].
1136 ///
1137 /// # Example
1138 /// ```ignore,no_run
1139 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::cloud_storage::TextFormat;
1140 /// let x = TextFormat::new().set_or_clear_delimiter(Some("example"));
1141 /// let x = TextFormat::new().set_or_clear_delimiter(None::<String>);
1142 /// ```
1143 pub fn set_or_clear_delimiter<T>(mut self, v: std::option::Option<T>) -> Self
1144 where
1145 T: std::convert::Into<std::string::String>,
1146 {
1147 self.delimiter = v.map(|x| x.into());
1148 self
1149 }
1150 }
1151
1152 impl wkt::message::Message for TextFormat {
1153 fn typename() -> &'static str {
1154 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.TextFormat"
1155 }
1156 }
1157
1158 /// Configuration for reading Cloud Storage data in Avro binary format. The
1159 /// bytes of each object will be set to the `data` field of a Pub/Sub
1160 /// message.
1161 #[derive(Clone, Default, PartialEq)]
1162 #[non_exhaustive]
1163 pub struct AvroFormat {
1164 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1165 }
1166
1167 impl AvroFormat {
1168 /// Creates a new default instance.
1169 pub fn new() -> Self {
1170 std::default::Default::default()
1171 }
1172 }
1173
1174 impl wkt::message::Message for AvroFormat {
1175 fn typename() -> &'static str {
1176 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.AvroFormat"
1177 }
1178 }
1179
1180 /// Configuration for reading Cloud Storage data written via [Cloud Storage
1181 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage). The
1182 /// data and attributes fields of the originally exported Pub/Sub message
1183 /// will be restored when publishing.
1184 #[derive(Clone, Default, PartialEq)]
1185 #[non_exhaustive]
1186 pub struct PubSubAvroFormat {
1187 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1188 }
1189
1190 impl PubSubAvroFormat {
1191 /// Creates a new default instance.
1192 pub fn new() -> Self {
1193 std::default::Default::default()
1194 }
1195 }
1196
1197 impl wkt::message::Message for PubSubAvroFormat {
1198 fn typename() -> &'static str {
1199 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.PubSubAvroFormat"
1200 }
1201 }
1202
1203 /// Possible states for ingestion from Cloud Storage.
1204 ///
1205 /// # Working with unknown values
1206 ///
1207 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1208 /// additional enum variants at any time. Adding new variants is not considered
1209 /// a breaking change. Applications should write their code in anticipation of:
1210 ///
1211 /// - New values appearing in future releases of the client library, **and**
1212 /// - New values received dynamically, without application changes.
1213 ///
1214 /// Please consult the [Working with enums] section in the user guide for some
1215 /// guidelines.
1216 ///
1217 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1218 #[derive(Clone, Debug, PartialEq)]
1219 #[non_exhaustive]
1220 pub enum State {
1221 /// Default value. This value is unused.
1222 Unspecified,
1223 /// Ingestion is active.
1224 Active,
1225 /// Permission denied encountered while calling the Cloud Storage API. This
1226 /// can happen if the Pub/Sub SA has not been granted the
1227 /// [appropriate
1228 /// permissions](https://cloud.google.com/storage/docs/access-control/iam-permissions):
1229 ///
1230 /// - storage.objects.list: to list the objects in a bucket.
1231 /// - storage.objects.get: to read the objects in a bucket.
1232 /// - storage.buckets.get: to verify the bucket exists.
1233 CloudStoragePermissionDenied,
1234 /// Permission denied encountered while publishing to the topic. This can
1235 /// happen if the Pub/Sub SA has not been granted the [appropriate publish
1236 /// permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
1237 PublishPermissionDenied,
1238 /// The provided Cloud Storage bucket doesn't exist.
1239 BucketNotFound,
1240 /// The Cloud Storage bucket has too many objects, ingestion will be
1241 /// paused.
1242 TooManyObjects,
1243 /// If set, the enum was initialized with an unknown value.
1244 ///
1245 /// Applications can examine the value using [State::value] or
1246 /// [State::name].
1247 UnknownValue(state::UnknownValue),
1248 }
1249
1250 #[doc(hidden)]
1251 pub mod state {
1252 #[allow(unused_imports)]
1253 use super::*;
1254 #[derive(Clone, Debug, PartialEq)]
1255 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1256 }
1257
1258 impl State {
1259 /// Gets the enum value.
1260 ///
1261 /// Returns `None` if the enum contains an unknown value deserialized from
1262 /// the string representation of enums.
1263 pub fn value(&self) -> std::option::Option<i32> {
1264 match self {
1265 Self::Unspecified => std::option::Option::Some(0),
1266 Self::Active => std::option::Option::Some(1),
1267 Self::CloudStoragePermissionDenied => std::option::Option::Some(2),
1268 Self::PublishPermissionDenied => std::option::Option::Some(3),
1269 Self::BucketNotFound => std::option::Option::Some(4),
1270 Self::TooManyObjects => std::option::Option::Some(5),
1271 Self::UnknownValue(u) => u.0.value(),
1272 }
1273 }
1274
1275 /// Gets the enum value as a string.
1276 ///
1277 /// Returns `None` if the enum contains an unknown value deserialized from
1278 /// the integer representation of enums.
1279 pub fn name(&self) -> std::option::Option<&str> {
1280 match self {
1281 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1282 Self::Active => std::option::Option::Some("ACTIVE"),
1283 Self::CloudStoragePermissionDenied => {
1284 std::option::Option::Some("CLOUD_STORAGE_PERMISSION_DENIED")
1285 }
1286 Self::PublishPermissionDenied => {
1287 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1288 }
1289 Self::BucketNotFound => std::option::Option::Some("BUCKET_NOT_FOUND"),
1290 Self::TooManyObjects => std::option::Option::Some("TOO_MANY_OBJECTS"),
1291 Self::UnknownValue(u) => u.0.name(),
1292 }
1293 }
1294 }
1295
1296 impl std::default::Default for State {
1297 fn default() -> Self {
1298 use std::convert::From;
1299 Self::from(0)
1300 }
1301 }
1302
1303 impl std::fmt::Display for State {
1304 fn fmt(
1305 &self,
1306 f: &mut std::fmt::Formatter<'_>,
1307 ) -> std::result::Result<(), std::fmt::Error> {
1308 wkt::internal::display_enum(f, self.name(), self.value())
1309 }
1310 }
1311
1312 impl std::convert::From<i32> for State {
1313 fn from(value: i32) -> Self {
1314 match value {
1315 0 => Self::Unspecified,
1316 1 => Self::Active,
1317 2 => Self::CloudStoragePermissionDenied,
1318 3 => Self::PublishPermissionDenied,
1319 4 => Self::BucketNotFound,
1320 5 => Self::TooManyObjects,
1321 _ => Self::UnknownValue(state::UnknownValue(
1322 wkt::internal::UnknownEnumValue::Integer(value),
1323 )),
1324 }
1325 }
1326 }
1327
1328 impl std::convert::From<&str> for State {
1329 fn from(value: &str) -> Self {
1330 use std::string::ToString;
1331 match value {
1332 "STATE_UNSPECIFIED" => Self::Unspecified,
1333 "ACTIVE" => Self::Active,
1334 "CLOUD_STORAGE_PERMISSION_DENIED" => Self::CloudStoragePermissionDenied,
1335 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1336 "BUCKET_NOT_FOUND" => Self::BucketNotFound,
1337 "TOO_MANY_OBJECTS" => Self::TooManyObjects,
1338 _ => Self::UnknownValue(state::UnknownValue(
1339 wkt::internal::UnknownEnumValue::String(value.to_string()),
1340 )),
1341 }
1342 }
1343 }
1344
1345 impl serde::ser::Serialize for State {
1346 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1347 where
1348 S: serde::Serializer,
1349 {
1350 match self {
1351 Self::Unspecified => serializer.serialize_i32(0),
1352 Self::Active => serializer.serialize_i32(1),
1353 Self::CloudStoragePermissionDenied => serializer.serialize_i32(2),
1354 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1355 Self::BucketNotFound => serializer.serialize_i32(4),
1356 Self::TooManyObjects => serializer.serialize_i32(5),
1357 Self::UnknownValue(u) => u.0.serialize(serializer),
1358 }
1359 }
1360 }
1361
1362 impl<'de> serde::de::Deserialize<'de> for State {
1363 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1364 where
1365 D: serde::Deserializer<'de>,
1366 {
1367 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1368 ".google.pubsub.v1.IngestionDataSourceSettings.CloudStorage.State",
1369 ))
1370 }
1371 }
1372
1373 /// Defaults to text format.
1374 #[derive(Clone, Debug, PartialEq)]
1375 #[non_exhaustive]
1376 pub enum InputFormat {
1377 /// Optional. Data from Cloud Storage will be interpreted as text.
1378 TextFormat(
1379 std::boxed::Box<
1380 crate::model::ingestion_data_source_settings::cloud_storage::TextFormat,
1381 >,
1382 ),
1383 /// Optional. Data from Cloud Storage will be interpreted in Avro format.
1384 AvroFormat(
1385 std::boxed::Box<
1386 crate::model::ingestion_data_source_settings::cloud_storage::AvroFormat,
1387 >,
1388 ),
1389 /// Optional. It will be assumed data from Cloud Storage was written via
1390 /// [Cloud Storage
1391 /// subscriptions](https://cloud.google.com/pubsub/docs/cloudstorage).
1392 PubsubAvroFormat(
1393 std::boxed::Box<
1394 crate::model::ingestion_data_source_settings::cloud_storage::PubSubAvroFormat,
1395 >,
1396 ),
1397 }
1398 }
1399
1400 /// Ingestion settings for Azure Event Hubs.
1401 #[derive(Clone, Default, PartialEq)]
1402 #[non_exhaustive]
1403 pub struct AzureEventHubs {
1404 /// Output only. An output-only field that indicates the state of the Event
1405 /// Hubs ingestion source.
1406 pub state: crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1407
1408 /// Optional. Name of the resource group within the azure subscription.
1409 pub resource_group: std::string::String,
1410
1411 /// Optional. The name of the Event Hubs namespace.
1412 pub namespace: std::string::String,
1413
1414 /// Optional. The name of the Event Hub.
1415 pub event_hub: std::string::String,
1416
1417 /// Optional. The client id of the Azure application that is being used to
1418 /// authenticate Pub/Sub.
1419 pub client_id: std::string::String,
1420
1421 /// Optional. The tenant id of the Azure application that is being used to
1422 /// authenticate Pub/Sub.
1423 pub tenant_id: std::string::String,
1424
1425 /// Optional. The Azure subscription id.
1426 pub subscription_id: std::string::String,
1427
1428 /// Optional. The GCP service account to be used for Federated Identity
1429 /// authentication.
1430 pub gcp_service_account: std::string::String,
1431
1432 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1433 }
1434
1435 impl AzureEventHubs {
1436 /// Creates a new default instance.
1437 pub fn new() -> Self {
1438 std::default::Default::default()
1439 }
1440
1441 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AzureEventHubs::state].
1442 ///
1443 /// # Example
1444 /// ```ignore,no_run
1445 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1446 /// use google_cloud_pubsub::model::ingestion_data_source_settings::azure_event_hubs::State;
1447 /// let x0 = AzureEventHubs::new().set_state(State::Active);
1448 /// let x1 = AzureEventHubs::new().set_state(State::EventHubsPermissionDenied);
1449 /// let x2 = AzureEventHubs::new().set_state(State::PublishPermissionDenied);
1450 /// ```
1451 pub fn set_state<
1452 T: std::convert::Into<
1453 crate::model::ingestion_data_source_settings::azure_event_hubs::State,
1454 >,
1455 >(
1456 mut self,
1457 v: T,
1458 ) -> Self {
1459 self.state = v.into();
1460 self
1461 }
1462
1463 /// Sets the value of [resource_group][crate::model::ingestion_data_source_settings::AzureEventHubs::resource_group].
1464 ///
1465 /// # Example
1466 /// ```ignore,no_run
1467 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1468 /// let x = AzureEventHubs::new().set_resource_group("example");
1469 /// ```
1470 pub fn set_resource_group<T: std::convert::Into<std::string::String>>(
1471 mut self,
1472 v: T,
1473 ) -> Self {
1474 self.resource_group = v.into();
1475 self
1476 }
1477
1478 /// Sets the value of [namespace][crate::model::ingestion_data_source_settings::AzureEventHubs::namespace].
1479 ///
1480 /// # Example
1481 /// ```ignore,no_run
1482 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1483 /// let x = AzureEventHubs::new().set_namespace("example");
1484 /// ```
1485 pub fn set_namespace<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1486 self.namespace = v.into();
1487 self
1488 }
1489
1490 /// Sets the value of [event_hub][crate::model::ingestion_data_source_settings::AzureEventHubs::event_hub].
1491 ///
1492 /// # Example
1493 /// ```ignore,no_run
1494 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1495 /// let x = AzureEventHubs::new().set_event_hub("example");
1496 /// ```
1497 pub fn set_event_hub<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1498 self.event_hub = v.into();
1499 self
1500 }
1501
1502 /// Sets the value of [client_id][crate::model::ingestion_data_source_settings::AzureEventHubs::client_id].
1503 ///
1504 /// # Example
1505 /// ```ignore,no_run
1506 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1507 /// let x = AzureEventHubs::new().set_client_id("example");
1508 /// ```
1509 pub fn set_client_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1510 self.client_id = v.into();
1511 self
1512 }
1513
1514 /// Sets the value of [tenant_id][crate::model::ingestion_data_source_settings::AzureEventHubs::tenant_id].
1515 ///
1516 /// # Example
1517 /// ```ignore,no_run
1518 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1519 /// let x = AzureEventHubs::new().set_tenant_id("example");
1520 /// ```
1521 pub fn set_tenant_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1522 self.tenant_id = v.into();
1523 self
1524 }
1525
1526 /// Sets the value of [subscription_id][crate::model::ingestion_data_source_settings::AzureEventHubs::subscription_id].
1527 ///
1528 /// # Example
1529 /// ```ignore,no_run
1530 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1531 /// let x = AzureEventHubs::new().set_subscription_id("example");
1532 /// ```
1533 pub fn set_subscription_id<T: std::convert::Into<std::string::String>>(
1534 mut self,
1535 v: T,
1536 ) -> Self {
1537 self.subscription_id = v.into();
1538 self
1539 }
1540
1541 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AzureEventHubs::gcp_service_account].
1542 ///
1543 /// # Example
1544 /// ```ignore,no_run
1545 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AzureEventHubs;
1546 /// let x = AzureEventHubs::new().set_gcp_service_account("example");
1547 /// ```
1548 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1549 mut self,
1550 v: T,
1551 ) -> Self {
1552 self.gcp_service_account = v.into();
1553 self
1554 }
1555 }
1556
1557 impl wkt::message::Message for AzureEventHubs {
1558 fn typename() -> &'static str {
1559 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs"
1560 }
1561 }
1562
1563 /// Defines additional types related to [AzureEventHubs].
1564 pub mod azure_event_hubs {
1565 #[allow(unused_imports)]
1566 use super::*;
1567
1568 /// Possible states for managed ingestion from Event Hubs.
1569 ///
1570 /// # Working with unknown values
1571 ///
1572 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1573 /// additional enum variants at any time. Adding new variants is not considered
1574 /// a breaking change. Applications should write their code in anticipation of:
1575 ///
1576 /// - New values appearing in future releases of the client library, **and**
1577 /// - New values received dynamically, without application changes.
1578 ///
1579 /// Please consult the [Working with enums] section in the user guide for some
1580 /// guidelines.
1581 ///
1582 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1583 #[derive(Clone, Debug, PartialEq)]
1584 #[non_exhaustive]
1585 pub enum State {
1586 /// Default value. This value is unused.
1587 Unspecified,
1588 /// Ingestion is active.
1589 Active,
1590 /// Permission denied encountered while consuming data from Event Hubs.
1591 /// This can happen when `client_id`, or `tenant_id` are invalid. Or the
1592 /// right permissions haven't been granted.
1593 EventHubsPermissionDenied,
1594 /// Permission denied encountered while publishing to the topic.
1595 PublishPermissionDenied,
1596 /// The provided Event Hubs namespace couldn't be found.
1597 NamespaceNotFound,
1598 /// The provided Event Hub couldn't be found.
1599 EventHubNotFound,
1600 /// The provided Event Hubs subscription couldn't be found.
1601 SubscriptionNotFound,
1602 /// The provided Event Hubs resource group couldn't be found.
1603 ResourceGroupNotFound,
1604 /// If set, the enum was initialized with an unknown value.
1605 ///
1606 /// Applications can examine the value using [State::value] or
1607 /// [State::name].
1608 UnknownValue(state::UnknownValue),
1609 }
1610
1611 #[doc(hidden)]
1612 pub mod state {
1613 #[allow(unused_imports)]
1614 use super::*;
1615 #[derive(Clone, Debug, PartialEq)]
1616 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1617 }
1618
1619 impl State {
1620 /// Gets the enum value.
1621 ///
1622 /// Returns `None` if the enum contains an unknown value deserialized from
1623 /// the string representation of enums.
1624 pub fn value(&self) -> std::option::Option<i32> {
1625 match self {
1626 Self::Unspecified => std::option::Option::Some(0),
1627 Self::Active => std::option::Option::Some(1),
1628 Self::EventHubsPermissionDenied => std::option::Option::Some(2),
1629 Self::PublishPermissionDenied => std::option::Option::Some(3),
1630 Self::NamespaceNotFound => std::option::Option::Some(4),
1631 Self::EventHubNotFound => std::option::Option::Some(5),
1632 Self::SubscriptionNotFound => std::option::Option::Some(6),
1633 Self::ResourceGroupNotFound => std::option::Option::Some(7),
1634 Self::UnknownValue(u) => u.0.value(),
1635 }
1636 }
1637
1638 /// Gets the enum value as a string.
1639 ///
1640 /// Returns `None` if the enum contains an unknown value deserialized from
1641 /// the integer representation of enums.
1642 pub fn name(&self) -> std::option::Option<&str> {
1643 match self {
1644 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1645 Self::Active => std::option::Option::Some("ACTIVE"),
1646 Self::EventHubsPermissionDenied => {
1647 std::option::Option::Some("EVENT_HUBS_PERMISSION_DENIED")
1648 }
1649 Self::PublishPermissionDenied => {
1650 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1651 }
1652 Self::NamespaceNotFound => std::option::Option::Some("NAMESPACE_NOT_FOUND"),
1653 Self::EventHubNotFound => std::option::Option::Some("EVENT_HUB_NOT_FOUND"),
1654 Self::SubscriptionNotFound => {
1655 std::option::Option::Some("SUBSCRIPTION_NOT_FOUND")
1656 }
1657 Self::ResourceGroupNotFound => {
1658 std::option::Option::Some("RESOURCE_GROUP_NOT_FOUND")
1659 }
1660 Self::UnknownValue(u) => u.0.name(),
1661 }
1662 }
1663 }
1664
1665 impl std::default::Default for State {
1666 fn default() -> Self {
1667 use std::convert::From;
1668 Self::from(0)
1669 }
1670 }
1671
1672 impl std::fmt::Display for State {
1673 fn fmt(
1674 &self,
1675 f: &mut std::fmt::Formatter<'_>,
1676 ) -> std::result::Result<(), std::fmt::Error> {
1677 wkt::internal::display_enum(f, self.name(), self.value())
1678 }
1679 }
1680
1681 impl std::convert::From<i32> for State {
1682 fn from(value: i32) -> Self {
1683 match value {
1684 0 => Self::Unspecified,
1685 1 => Self::Active,
1686 2 => Self::EventHubsPermissionDenied,
1687 3 => Self::PublishPermissionDenied,
1688 4 => Self::NamespaceNotFound,
1689 5 => Self::EventHubNotFound,
1690 6 => Self::SubscriptionNotFound,
1691 7 => Self::ResourceGroupNotFound,
1692 _ => Self::UnknownValue(state::UnknownValue(
1693 wkt::internal::UnknownEnumValue::Integer(value),
1694 )),
1695 }
1696 }
1697 }
1698
1699 impl std::convert::From<&str> for State {
1700 fn from(value: &str) -> Self {
1701 use std::string::ToString;
1702 match value {
1703 "STATE_UNSPECIFIED" => Self::Unspecified,
1704 "ACTIVE" => Self::Active,
1705 "EVENT_HUBS_PERMISSION_DENIED" => Self::EventHubsPermissionDenied,
1706 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1707 "NAMESPACE_NOT_FOUND" => Self::NamespaceNotFound,
1708 "EVENT_HUB_NOT_FOUND" => Self::EventHubNotFound,
1709 "SUBSCRIPTION_NOT_FOUND" => Self::SubscriptionNotFound,
1710 "RESOURCE_GROUP_NOT_FOUND" => Self::ResourceGroupNotFound,
1711 _ => Self::UnknownValue(state::UnknownValue(
1712 wkt::internal::UnknownEnumValue::String(value.to_string()),
1713 )),
1714 }
1715 }
1716 }
1717
1718 impl serde::ser::Serialize for State {
1719 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1720 where
1721 S: serde::Serializer,
1722 {
1723 match self {
1724 Self::Unspecified => serializer.serialize_i32(0),
1725 Self::Active => serializer.serialize_i32(1),
1726 Self::EventHubsPermissionDenied => serializer.serialize_i32(2),
1727 Self::PublishPermissionDenied => serializer.serialize_i32(3),
1728 Self::NamespaceNotFound => serializer.serialize_i32(4),
1729 Self::EventHubNotFound => serializer.serialize_i32(5),
1730 Self::SubscriptionNotFound => serializer.serialize_i32(6),
1731 Self::ResourceGroupNotFound => serializer.serialize_i32(7),
1732 Self::UnknownValue(u) => u.0.serialize(serializer),
1733 }
1734 }
1735 }
1736
1737 impl<'de> serde::de::Deserialize<'de> for State {
1738 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1739 where
1740 D: serde::Deserializer<'de>,
1741 {
1742 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
1743 ".google.pubsub.v1.IngestionDataSourceSettings.AzureEventHubs.State",
1744 ))
1745 }
1746 }
1747 }
1748
1749 /// Ingestion settings for Amazon MSK.
1750 #[derive(Clone, Default, PartialEq)]
1751 #[non_exhaustive]
1752 pub struct AwsMsk {
1753 /// Output only. An output-only field that indicates the state of the Amazon
1754 /// MSK ingestion source.
1755 pub state: crate::model::ingestion_data_source_settings::aws_msk::State,
1756
1757 /// Required. The Amazon Resource Name (ARN) that uniquely identifies the
1758 /// cluster.
1759 pub cluster_arn: std::string::String,
1760
1761 /// Required. The name of the topic in the Amazon MSK cluster that Pub/Sub
1762 /// will import from.
1763 pub topic: std::string::String,
1764
1765 /// Required. AWS role ARN to be used for Federated Identity authentication
1766 /// with Amazon MSK. Check the Pub/Sub docs for how to set up this role and
1767 /// the required permissions that need to be attached to it.
1768 pub aws_role_arn: std::string::String,
1769
1770 /// Required. The GCP service account to be used for Federated Identity
1771 /// authentication with Amazon MSK (via a `AssumeRoleWithWebIdentity` call
1772 /// for the provided role). The `aws_role_arn` must be set up with
1773 /// `accounts.google.com:sub` equals to this service account number.
1774 pub gcp_service_account: std::string::String,
1775
1776 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1777 }
1778
1779 impl AwsMsk {
1780 /// Creates a new default instance.
1781 pub fn new() -> Self {
1782 std::default::Default::default()
1783 }
1784
1785 /// Sets the value of [state][crate::model::ingestion_data_source_settings::AwsMsk::state].
1786 ///
1787 /// # Example
1788 /// ```ignore,no_run
1789 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1790 /// use google_cloud_pubsub::model::ingestion_data_source_settings::aws_msk::State;
1791 /// let x0 = AwsMsk::new().set_state(State::Active);
1792 /// let x1 = AwsMsk::new().set_state(State::MskPermissionDenied);
1793 /// let x2 = AwsMsk::new().set_state(State::PublishPermissionDenied);
1794 /// ```
1795 pub fn set_state<
1796 T: std::convert::Into<crate::model::ingestion_data_source_settings::aws_msk::State>,
1797 >(
1798 mut self,
1799 v: T,
1800 ) -> Self {
1801 self.state = v.into();
1802 self
1803 }
1804
1805 /// Sets the value of [cluster_arn][crate::model::ingestion_data_source_settings::AwsMsk::cluster_arn].
1806 ///
1807 /// # Example
1808 /// ```ignore,no_run
1809 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1810 /// let x = AwsMsk::new().set_cluster_arn("example");
1811 /// ```
1812 pub fn set_cluster_arn<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1813 self.cluster_arn = v.into();
1814 self
1815 }
1816
1817 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::AwsMsk::topic].
1818 ///
1819 /// # Example
1820 /// ```ignore,no_run
1821 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1822 /// # let project_id = "project_id";
1823 /// # let topic_id = "topic_id";
1824 /// let x = AwsMsk::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
1825 /// ```
1826 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1827 self.topic = v.into();
1828 self
1829 }
1830
1831 /// Sets the value of [aws_role_arn][crate::model::ingestion_data_source_settings::AwsMsk::aws_role_arn].
1832 ///
1833 /// # Example
1834 /// ```ignore,no_run
1835 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1836 /// let x = AwsMsk::new().set_aws_role_arn("example");
1837 /// ```
1838 pub fn set_aws_role_arn<T: std::convert::Into<std::string::String>>(
1839 mut self,
1840 v: T,
1841 ) -> Self {
1842 self.aws_role_arn = v.into();
1843 self
1844 }
1845
1846 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::AwsMsk::gcp_service_account].
1847 ///
1848 /// # Example
1849 /// ```ignore,no_run
1850 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::AwsMsk;
1851 /// let x = AwsMsk::new().set_gcp_service_account("example");
1852 /// ```
1853 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
1854 mut self,
1855 v: T,
1856 ) -> Self {
1857 self.gcp_service_account = v.into();
1858 self
1859 }
1860 }
1861
1862 impl wkt::message::Message for AwsMsk {
1863 fn typename() -> &'static str {
1864 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.AwsMsk"
1865 }
1866 }
1867
1868 /// Defines additional types related to [AwsMsk].
1869 pub mod aws_msk {
1870 #[allow(unused_imports)]
1871 use super::*;
1872
1873 /// Possible states for managed ingestion from Amazon MSK.
1874 ///
1875 /// # Working with unknown values
1876 ///
1877 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1878 /// additional enum variants at any time. Adding new variants is not considered
1879 /// a breaking change. Applications should write their code in anticipation of:
1880 ///
1881 /// - New values appearing in future releases of the client library, **and**
1882 /// - New values received dynamically, without application changes.
1883 ///
1884 /// Please consult the [Working with enums] section in the user guide for some
1885 /// guidelines.
1886 ///
1887 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1888 #[derive(Clone, Debug, PartialEq)]
1889 #[non_exhaustive]
1890 pub enum State {
1891 /// Default value. This value is unused.
1892 Unspecified,
1893 /// Ingestion is active.
1894 Active,
1895 /// Permission denied encountered while consuming data from Amazon MSK.
1896 MskPermissionDenied,
1897 /// Permission denied encountered while publishing to the topic.
1898 PublishPermissionDenied,
1899 /// The provided MSK cluster wasn't found.
1900 ClusterNotFound,
1901 /// The provided topic wasn't found.
1902 TopicNotFound,
1903 /// If set, the enum was initialized with an unknown value.
1904 ///
1905 /// Applications can examine the value using [State::value] or
1906 /// [State::name].
1907 UnknownValue(state::UnknownValue),
1908 }
1909
1910 #[doc(hidden)]
1911 pub mod state {
1912 #[allow(unused_imports)]
1913 use super::*;
1914 #[derive(Clone, Debug, PartialEq)]
1915 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1916 }
1917
1918 impl State {
1919 /// Gets the enum value.
1920 ///
1921 /// Returns `None` if the enum contains an unknown value deserialized from
1922 /// the string representation of enums.
1923 pub fn value(&self) -> std::option::Option<i32> {
1924 match self {
1925 Self::Unspecified => std::option::Option::Some(0),
1926 Self::Active => std::option::Option::Some(1),
1927 Self::MskPermissionDenied => std::option::Option::Some(2),
1928 Self::PublishPermissionDenied => std::option::Option::Some(3),
1929 Self::ClusterNotFound => std::option::Option::Some(4),
1930 Self::TopicNotFound => std::option::Option::Some(5),
1931 Self::UnknownValue(u) => u.0.value(),
1932 }
1933 }
1934
1935 /// Gets the enum value as a string.
1936 ///
1937 /// Returns `None` if the enum contains an unknown value deserialized from
1938 /// the integer representation of enums.
1939 pub fn name(&self) -> std::option::Option<&str> {
1940 match self {
1941 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
1942 Self::Active => std::option::Option::Some("ACTIVE"),
1943 Self::MskPermissionDenied => std::option::Option::Some("MSK_PERMISSION_DENIED"),
1944 Self::PublishPermissionDenied => {
1945 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
1946 }
1947 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
1948 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
1949 Self::UnknownValue(u) => u.0.name(),
1950 }
1951 }
1952 }
1953
1954 impl std::default::Default for State {
1955 fn default() -> Self {
1956 use std::convert::From;
1957 Self::from(0)
1958 }
1959 }
1960
1961 impl std::fmt::Display for State {
1962 fn fmt(
1963 &self,
1964 f: &mut std::fmt::Formatter<'_>,
1965 ) -> std::result::Result<(), std::fmt::Error> {
1966 wkt::internal::display_enum(f, self.name(), self.value())
1967 }
1968 }
1969
1970 impl std::convert::From<i32> for State {
1971 fn from(value: i32) -> Self {
1972 match value {
1973 0 => Self::Unspecified,
1974 1 => Self::Active,
1975 2 => Self::MskPermissionDenied,
1976 3 => Self::PublishPermissionDenied,
1977 4 => Self::ClusterNotFound,
1978 5 => Self::TopicNotFound,
1979 _ => Self::UnknownValue(state::UnknownValue(
1980 wkt::internal::UnknownEnumValue::Integer(value),
1981 )),
1982 }
1983 }
1984 }
1985
1986 impl std::convert::From<&str> for State {
1987 fn from(value: &str) -> Self {
1988 use std::string::ToString;
1989 match value {
1990 "STATE_UNSPECIFIED" => Self::Unspecified,
1991 "ACTIVE" => Self::Active,
1992 "MSK_PERMISSION_DENIED" => Self::MskPermissionDenied,
1993 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
1994 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
1995 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
1996 _ => Self::UnknownValue(state::UnknownValue(
1997 wkt::internal::UnknownEnumValue::String(value.to_string()),
1998 )),
1999 }
2000 }
2001 }
2002
2003 impl serde::ser::Serialize for State {
2004 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2005 where
2006 S: serde::Serializer,
2007 {
2008 match self {
2009 Self::Unspecified => serializer.serialize_i32(0),
2010 Self::Active => serializer.serialize_i32(1),
2011 Self::MskPermissionDenied => serializer.serialize_i32(2),
2012 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2013 Self::ClusterNotFound => serializer.serialize_i32(4),
2014 Self::TopicNotFound => serializer.serialize_i32(5),
2015 Self::UnknownValue(u) => u.0.serialize(serializer),
2016 }
2017 }
2018 }
2019
2020 impl<'de> serde::de::Deserialize<'de> for State {
2021 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2022 where
2023 D: serde::Deserializer<'de>,
2024 {
2025 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2026 ".google.pubsub.v1.IngestionDataSourceSettings.AwsMsk.State",
2027 ))
2028 }
2029 }
2030 }
2031
2032 /// Ingestion settings for Confluent Cloud.
2033 #[derive(Clone, Default, PartialEq)]
2034 #[non_exhaustive]
2035 pub struct ConfluentCloud {
2036 /// Output only. An output-only field that indicates the state of the
2037 /// Confluent Cloud ingestion source.
2038 pub state: crate::model::ingestion_data_source_settings::confluent_cloud::State,
2039
2040 /// Required. The address of the bootstrap server. The format is url:port.
2041 pub bootstrap_server: std::string::String,
2042
2043 /// Required. The id of the cluster.
2044 pub cluster_id: std::string::String,
2045
2046 /// Required. The name of the topic in the Confluent Cloud cluster that
2047 /// Pub/Sub will import from.
2048 pub topic: std::string::String,
2049
2050 /// Required. The id of the identity pool to be used for Federated Identity
2051 /// authentication with Confluent Cloud. See
2052 /// <https://docs.confluent.io/cloud/current/security/authenticate/workload-identities/identity-providers/oauth/identity-pools.html#add-oauth-identity-pools>.
2053 pub identity_pool_id: std::string::String,
2054
2055 /// Required. The GCP service account to be used for Federated Identity
2056 /// authentication with `identity_pool_id`.
2057 pub gcp_service_account: std::string::String,
2058
2059 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2060 }
2061
2062 impl ConfluentCloud {
2063 /// Creates a new default instance.
2064 pub fn new() -> Self {
2065 std::default::Default::default()
2066 }
2067
2068 /// Sets the value of [state][crate::model::ingestion_data_source_settings::ConfluentCloud::state].
2069 ///
2070 /// # Example
2071 /// ```ignore,no_run
2072 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2073 /// use google_cloud_pubsub::model::ingestion_data_source_settings::confluent_cloud::State;
2074 /// let x0 = ConfluentCloud::new().set_state(State::Active);
2075 /// let x1 = ConfluentCloud::new().set_state(State::ConfluentCloudPermissionDenied);
2076 /// let x2 = ConfluentCloud::new().set_state(State::PublishPermissionDenied);
2077 /// ```
2078 pub fn set_state<
2079 T: std::convert::Into<
2080 crate::model::ingestion_data_source_settings::confluent_cloud::State,
2081 >,
2082 >(
2083 mut self,
2084 v: T,
2085 ) -> Self {
2086 self.state = v.into();
2087 self
2088 }
2089
2090 /// Sets the value of [bootstrap_server][crate::model::ingestion_data_source_settings::ConfluentCloud::bootstrap_server].
2091 ///
2092 /// # Example
2093 /// ```ignore,no_run
2094 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2095 /// let x = ConfluentCloud::new().set_bootstrap_server("example");
2096 /// ```
2097 pub fn set_bootstrap_server<T: std::convert::Into<std::string::String>>(
2098 mut self,
2099 v: T,
2100 ) -> Self {
2101 self.bootstrap_server = v.into();
2102 self
2103 }
2104
2105 /// Sets the value of [cluster_id][crate::model::ingestion_data_source_settings::ConfluentCloud::cluster_id].
2106 ///
2107 /// # Example
2108 /// ```ignore,no_run
2109 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2110 /// let x = ConfluentCloud::new().set_cluster_id("example");
2111 /// ```
2112 pub fn set_cluster_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2113 self.cluster_id = v.into();
2114 self
2115 }
2116
2117 /// Sets the value of [topic][crate::model::ingestion_data_source_settings::ConfluentCloud::topic].
2118 ///
2119 /// # Example
2120 /// ```ignore,no_run
2121 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2122 /// let x = ConfluentCloud::new().set_topic("example");
2123 /// ```
2124 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2125 self.topic = v.into();
2126 self
2127 }
2128
2129 /// Sets the value of [identity_pool_id][crate::model::ingestion_data_source_settings::ConfluentCloud::identity_pool_id].
2130 ///
2131 /// # Example
2132 /// ```ignore,no_run
2133 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2134 /// let x = ConfluentCloud::new().set_identity_pool_id("example");
2135 /// ```
2136 pub fn set_identity_pool_id<T: std::convert::Into<std::string::String>>(
2137 mut self,
2138 v: T,
2139 ) -> Self {
2140 self.identity_pool_id = v.into();
2141 self
2142 }
2143
2144 /// Sets the value of [gcp_service_account][crate::model::ingestion_data_source_settings::ConfluentCloud::gcp_service_account].
2145 ///
2146 /// # Example
2147 /// ```ignore,no_run
2148 /// # use google_cloud_pubsub::model::ingestion_data_source_settings::ConfluentCloud;
2149 /// let x = ConfluentCloud::new().set_gcp_service_account("example");
2150 /// ```
2151 pub fn set_gcp_service_account<T: std::convert::Into<std::string::String>>(
2152 mut self,
2153 v: T,
2154 ) -> Self {
2155 self.gcp_service_account = v.into();
2156 self
2157 }
2158 }
2159
2160 impl wkt::message::Message for ConfluentCloud {
2161 fn typename() -> &'static str {
2162 "type.googleapis.com/google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud"
2163 }
2164 }
2165
2166 /// Defines additional types related to [ConfluentCloud].
2167 pub mod confluent_cloud {
2168 #[allow(unused_imports)]
2169 use super::*;
2170
2171 /// Possible states for managed ingestion from Confluent Cloud.
2172 ///
2173 /// # Working with unknown values
2174 ///
2175 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2176 /// additional enum variants at any time. Adding new variants is not considered
2177 /// a breaking change. Applications should write their code in anticipation of:
2178 ///
2179 /// - New values appearing in future releases of the client library, **and**
2180 /// - New values received dynamically, without application changes.
2181 ///
2182 /// Please consult the [Working with enums] section in the user guide for some
2183 /// guidelines.
2184 ///
2185 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2186 #[derive(Clone, Debug, PartialEq)]
2187 #[non_exhaustive]
2188 pub enum State {
2189 /// Default value. This value is unused.
2190 Unspecified,
2191 /// Ingestion is active.
2192 Active,
2193 /// Permission denied encountered while consuming data from Confluent
2194 /// Cloud.
2195 ConfluentCloudPermissionDenied,
2196 /// Permission denied encountered while publishing to the topic.
2197 PublishPermissionDenied,
2198 /// The provided bootstrap server address is unreachable.
2199 UnreachableBootstrapServer,
2200 /// The provided cluster wasn't found.
2201 ClusterNotFound,
2202 /// The provided topic wasn't found.
2203 TopicNotFound,
2204 /// If set, the enum was initialized with an unknown value.
2205 ///
2206 /// Applications can examine the value using [State::value] or
2207 /// [State::name].
2208 UnknownValue(state::UnknownValue),
2209 }
2210
2211 #[doc(hidden)]
2212 pub mod state {
2213 #[allow(unused_imports)]
2214 use super::*;
2215 #[derive(Clone, Debug, PartialEq)]
2216 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2217 }
2218
2219 impl State {
2220 /// Gets the enum value.
2221 ///
2222 /// Returns `None` if the enum contains an unknown value deserialized from
2223 /// the string representation of enums.
2224 pub fn value(&self) -> std::option::Option<i32> {
2225 match self {
2226 Self::Unspecified => std::option::Option::Some(0),
2227 Self::Active => std::option::Option::Some(1),
2228 Self::ConfluentCloudPermissionDenied => std::option::Option::Some(2),
2229 Self::PublishPermissionDenied => std::option::Option::Some(3),
2230 Self::UnreachableBootstrapServer => std::option::Option::Some(4),
2231 Self::ClusterNotFound => std::option::Option::Some(5),
2232 Self::TopicNotFound => std::option::Option::Some(6),
2233 Self::UnknownValue(u) => u.0.value(),
2234 }
2235 }
2236
2237 /// Gets the enum value as a string.
2238 ///
2239 /// Returns `None` if the enum contains an unknown value deserialized from
2240 /// the integer representation of enums.
2241 pub fn name(&self) -> std::option::Option<&str> {
2242 match self {
2243 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
2244 Self::Active => std::option::Option::Some("ACTIVE"),
2245 Self::ConfluentCloudPermissionDenied => {
2246 std::option::Option::Some("CONFLUENT_CLOUD_PERMISSION_DENIED")
2247 }
2248 Self::PublishPermissionDenied => {
2249 std::option::Option::Some("PUBLISH_PERMISSION_DENIED")
2250 }
2251 Self::UnreachableBootstrapServer => {
2252 std::option::Option::Some("UNREACHABLE_BOOTSTRAP_SERVER")
2253 }
2254 Self::ClusterNotFound => std::option::Option::Some("CLUSTER_NOT_FOUND"),
2255 Self::TopicNotFound => std::option::Option::Some("TOPIC_NOT_FOUND"),
2256 Self::UnknownValue(u) => u.0.name(),
2257 }
2258 }
2259 }
2260
2261 impl std::default::Default for State {
2262 fn default() -> Self {
2263 use std::convert::From;
2264 Self::from(0)
2265 }
2266 }
2267
2268 impl std::fmt::Display for State {
2269 fn fmt(
2270 &self,
2271 f: &mut std::fmt::Formatter<'_>,
2272 ) -> std::result::Result<(), std::fmt::Error> {
2273 wkt::internal::display_enum(f, self.name(), self.value())
2274 }
2275 }
2276
2277 impl std::convert::From<i32> for State {
2278 fn from(value: i32) -> Self {
2279 match value {
2280 0 => Self::Unspecified,
2281 1 => Self::Active,
2282 2 => Self::ConfluentCloudPermissionDenied,
2283 3 => Self::PublishPermissionDenied,
2284 4 => Self::UnreachableBootstrapServer,
2285 5 => Self::ClusterNotFound,
2286 6 => Self::TopicNotFound,
2287 _ => Self::UnknownValue(state::UnknownValue(
2288 wkt::internal::UnknownEnumValue::Integer(value),
2289 )),
2290 }
2291 }
2292 }
2293
2294 impl std::convert::From<&str> for State {
2295 fn from(value: &str) -> Self {
2296 use std::string::ToString;
2297 match value {
2298 "STATE_UNSPECIFIED" => Self::Unspecified,
2299 "ACTIVE" => Self::Active,
2300 "CONFLUENT_CLOUD_PERMISSION_DENIED" => Self::ConfluentCloudPermissionDenied,
2301 "PUBLISH_PERMISSION_DENIED" => Self::PublishPermissionDenied,
2302 "UNREACHABLE_BOOTSTRAP_SERVER" => Self::UnreachableBootstrapServer,
2303 "CLUSTER_NOT_FOUND" => Self::ClusterNotFound,
2304 "TOPIC_NOT_FOUND" => Self::TopicNotFound,
2305 _ => Self::UnknownValue(state::UnknownValue(
2306 wkt::internal::UnknownEnumValue::String(value.to_string()),
2307 )),
2308 }
2309 }
2310 }
2311
2312 impl serde::ser::Serialize for State {
2313 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2314 where
2315 S: serde::Serializer,
2316 {
2317 match self {
2318 Self::Unspecified => serializer.serialize_i32(0),
2319 Self::Active => serializer.serialize_i32(1),
2320 Self::ConfluentCloudPermissionDenied => serializer.serialize_i32(2),
2321 Self::PublishPermissionDenied => serializer.serialize_i32(3),
2322 Self::UnreachableBootstrapServer => serializer.serialize_i32(4),
2323 Self::ClusterNotFound => serializer.serialize_i32(5),
2324 Self::TopicNotFound => serializer.serialize_i32(6),
2325 Self::UnknownValue(u) => u.0.serialize(serializer),
2326 }
2327 }
2328 }
2329
2330 impl<'de> serde::de::Deserialize<'de> for State {
2331 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2332 where
2333 D: serde::Deserializer<'de>,
2334 {
2335 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
2336 ".google.pubsub.v1.IngestionDataSourceSettings.ConfluentCloud.State",
2337 ))
2338 }
2339 }
2340 }
2341
2342 /// Only one source type can have settings set.
2343 #[derive(Clone, Debug, PartialEq)]
2344 #[non_exhaustive]
2345 pub enum Source {
2346 /// Optional. Amazon Kinesis Data Streams.
2347 AwsKinesis(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsKinesis>),
2348 /// Optional. Cloud Storage.
2349 CloudStorage(std::boxed::Box<crate::model::ingestion_data_source_settings::CloudStorage>),
2350 /// Optional. Azure Event Hubs.
2351 AzureEventHubs(
2352 std::boxed::Box<crate::model::ingestion_data_source_settings::AzureEventHubs>,
2353 ),
2354 /// Optional. Amazon MSK.
2355 AwsMsk(std::boxed::Box<crate::model::ingestion_data_source_settings::AwsMsk>),
2356 /// Optional. Confluent Cloud.
2357 ConfluentCloud(
2358 std::boxed::Box<crate::model::ingestion_data_source_settings::ConfluentCloud>,
2359 ),
2360 }
2361}
2362
2363/// Settings for Platform Logs produced by Pub/Sub.
2364#[derive(Clone, Default, PartialEq)]
2365#[non_exhaustive]
2366pub struct PlatformLogsSettings {
2367 /// Optional. The minimum severity level of Platform Logs that will be written.
2368 pub severity: crate::model::platform_logs_settings::Severity,
2369
2370 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2371}
2372
2373impl PlatformLogsSettings {
2374 /// Creates a new default instance.
2375 pub fn new() -> Self {
2376 std::default::Default::default()
2377 }
2378
2379 /// Sets the value of [severity][crate::model::PlatformLogsSettings::severity].
2380 ///
2381 /// # Example
2382 /// ```ignore,no_run
2383 /// # use google_cloud_pubsub::model::PlatformLogsSettings;
2384 /// use google_cloud_pubsub::model::platform_logs_settings::Severity;
2385 /// let x0 = PlatformLogsSettings::new().set_severity(Severity::Disabled);
2386 /// let x1 = PlatformLogsSettings::new().set_severity(Severity::Debug);
2387 /// let x2 = PlatformLogsSettings::new().set_severity(Severity::Info);
2388 /// ```
2389 pub fn set_severity<T: std::convert::Into<crate::model::platform_logs_settings::Severity>>(
2390 mut self,
2391 v: T,
2392 ) -> Self {
2393 self.severity = v.into();
2394 self
2395 }
2396}
2397
2398impl wkt::message::Message for PlatformLogsSettings {
2399 fn typename() -> &'static str {
2400 "type.googleapis.com/google.pubsub.v1.PlatformLogsSettings"
2401 }
2402}
2403
2404/// Defines additional types related to [PlatformLogsSettings].
2405pub mod platform_logs_settings {
2406 #[allow(unused_imports)]
2407 use super::*;
2408
2409 /// Severity levels of Platform Logs.
2410 ///
2411 /// # Working with unknown values
2412 ///
2413 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2414 /// additional enum variants at any time. Adding new variants is not considered
2415 /// a breaking change. Applications should write their code in anticipation of:
2416 ///
2417 /// - New values appearing in future releases of the client library, **and**
2418 /// - New values received dynamically, without application changes.
2419 ///
2420 /// Please consult the [Working with enums] section in the user guide for some
2421 /// guidelines.
2422 ///
2423 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2424 #[derive(Clone, Debug, PartialEq)]
2425 #[non_exhaustive]
2426 pub enum Severity {
2427 /// Default value. Logs level is unspecified. Logs will be disabled.
2428 Unspecified,
2429 /// Logs will be disabled.
2430 Disabled,
2431 /// Debug logs and higher-severity logs will be written.
2432 Debug,
2433 /// Info logs and higher-severity logs will be written.
2434 Info,
2435 /// Warning logs and higher-severity logs will be written.
2436 Warning,
2437 /// Only error logs will be written.
2438 Error,
2439 /// If set, the enum was initialized with an unknown value.
2440 ///
2441 /// Applications can examine the value using [Severity::value] or
2442 /// [Severity::name].
2443 UnknownValue(severity::UnknownValue),
2444 }
2445
2446 #[doc(hidden)]
2447 pub mod severity {
2448 #[allow(unused_imports)]
2449 use super::*;
2450 #[derive(Clone, Debug, PartialEq)]
2451 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2452 }
2453
2454 impl Severity {
2455 /// Gets the enum value.
2456 ///
2457 /// Returns `None` if the enum contains an unknown value deserialized from
2458 /// the string representation of enums.
2459 pub fn value(&self) -> std::option::Option<i32> {
2460 match self {
2461 Self::Unspecified => std::option::Option::Some(0),
2462 Self::Disabled => std::option::Option::Some(1),
2463 Self::Debug => std::option::Option::Some(2),
2464 Self::Info => std::option::Option::Some(3),
2465 Self::Warning => std::option::Option::Some(4),
2466 Self::Error => std::option::Option::Some(5),
2467 Self::UnknownValue(u) => u.0.value(),
2468 }
2469 }
2470
2471 /// Gets the enum value as a string.
2472 ///
2473 /// Returns `None` if the enum contains an unknown value deserialized from
2474 /// the integer representation of enums.
2475 pub fn name(&self) -> std::option::Option<&str> {
2476 match self {
2477 Self::Unspecified => std::option::Option::Some("SEVERITY_UNSPECIFIED"),
2478 Self::Disabled => std::option::Option::Some("DISABLED"),
2479 Self::Debug => std::option::Option::Some("DEBUG"),
2480 Self::Info => std::option::Option::Some("INFO"),
2481 Self::Warning => std::option::Option::Some("WARNING"),
2482 Self::Error => std::option::Option::Some("ERROR"),
2483 Self::UnknownValue(u) => u.0.name(),
2484 }
2485 }
2486 }
2487
2488 impl std::default::Default for Severity {
2489 fn default() -> Self {
2490 use std::convert::From;
2491 Self::from(0)
2492 }
2493 }
2494
2495 impl std::fmt::Display for Severity {
2496 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2497 wkt::internal::display_enum(f, self.name(), self.value())
2498 }
2499 }
2500
2501 impl std::convert::From<i32> for Severity {
2502 fn from(value: i32) -> Self {
2503 match value {
2504 0 => Self::Unspecified,
2505 1 => Self::Disabled,
2506 2 => Self::Debug,
2507 3 => Self::Info,
2508 4 => Self::Warning,
2509 5 => Self::Error,
2510 _ => Self::UnknownValue(severity::UnknownValue(
2511 wkt::internal::UnknownEnumValue::Integer(value),
2512 )),
2513 }
2514 }
2515 }
2516
2517 impl std::convert::From<&str> for Severity {
2518 fn from(value: &str) -> Self {
2519 use std::string::ToString;
2520 match value {
2521 "SEVERITY_UNSPECIFIED" => Self::Unspecified,
2522 "DISABLED" => Self::Disabled,
2523 "DEBUG" => Self::Debug,
2524 "INFO" => Self::Info,
2525 "WARNING" => Self::Warning,
2526 "ERROR" => Self::Error,
2527 _ => Self::UnknownValue(severity::UnknownValue(
2528 wkt::internal::UnknownEnumValue::String(value.to_string()),
2529 )),
2530 }
2531 }
2532 }
2533
2534 impl serde::ser::Serialize for Severity {
2535 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2536 where
2537 S: serde::Serializer,
2538 {
2539 match self {
2540 Self::Unspecified => serializer.serialize_i32(0),
2541 Self::Disabled => serializer.serialize_i32(1),
2542 Self::Debug => serializer.serialize_i32(2),
2543 Self::Info => serializer.serialize_i32(3),
2544 Self::Warning => serializer.serialize_i32(4),
2545 Self::Error => serializer.serialize_i32(5),
2546 Self::UnknownValue(u) => u.0.serialize(serializer),
2547 }
2548 }
2549 }
2550
2551 impl<'de> serde::de::Deserialize<'de> for Severity {
2552 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2553 where
2554 D: serde::Deserializer<'de>,
2555 {
2556 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Severity>::new(
2557 ".google.pubsub.v1.PlatformLogsSettings.Severity",
2558 ))
2559 }
2560 }
2561}
2562
2563/// User-defined JavaScript function that can transform or filter a Pub/Sub
2564/// message.
2565#[derive(Clone, Default, PartialEq)]
2566#[non_exhaustive]
2567pub struct JavaScriptUDF {
2568 /// Required. Name of the JavasScript function that should applied to Pub/Sub
2569 /// messages.
2570 pub function_name: std::string::String,
2571
2572 /// Required. JavaScript code that contains a function `function_name` with the
2573 /// below signature:
2574 ///
2575 /// ```norust
2576 /// /**
2577 /// * Transforms a Pub/Sub message.
2578 ///
2579 /// * @return {(Object<string, (string | Object<string, string>)>|null)} - To
2580 /// * filter a message, return `null`. To transform a message return a map
2581 /// * with the following keys:
2582 /// * - (required) 'data' : {string}
2583 /// * - (optional) 'attributes' : {Object<string, string>}
2584 /// * Returning empty `attributes` will remove all attributes from the
2585 /// * message.
2586 /// *
2587 /// * @param {(Object<string, (string | Object<string, string>)>} Pub/Sub
2588 /// * message. Keys:
2589 /// * - (required) 'data' : {string}
2590 /// * - (required) 'attributes' : {Object<string, string>}
2591 /// *
2592 /// * @param {Object<string, any>} metadata - Pub/Sub message metadata.
2593 /// * Keys:
2594 /// * - (optional) 'message_id' : {string}
2595 /// * - (optional) 'publish_time': {string} YYYY-MM-DDTHH:MM:SSZ format
2596 /// * - (optional) 'ordering_key': {string}
2597 /// */
2598 ///
2599 /// function <function_name>(message, metadata) {
2600 /// }
2601 /// ```
2602 pub code: std::string::String,
2603
2604 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2605}
2606
2607impl JavaScriptUDF {
2608 /// Creates a new default instance.
2609 pub fn new() -> Self {
2610 std::default::Default::default()
2611 }
2612
2613 /// Sets the value of [function_name][crate::model::JavaScriptUDF::function_name].
2614 ///
2615 /// # Example
2616 /// ```ignore,no_run
2617 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2618 /// let x = JavaScriptUDF::new().set_function_name("example");
2619 /// ```
2620 pub fn set_function_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2621 self.function_name = v.into();
2622 self
2623 }
2624
2625 /// Sets the value of [code][crate::model::JavaScriptUDF::code].
2626 ///
2627 /// # Example
2628 /// ```ignore,no_run
2629 /// # use google_cloud_pubsub::model::JavaScriptUDF;
2630 /// let x = JavaScriptUDF::new().set_code("example");
2631 /// ```
2632 pub fn set_code<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2633 self.code = v.into();
2634 self
2635 }
2636}
2637
2638impl wkt::message::Message for JavaScriptUDF {
2639 fn typename() -> &'static str {
2640 "type.googleapis.com/google.pubsub.v1.JavaScriptUDF"
2641 }
2642}
2643
2644/// Configuration for making inference requests against Vertex AI models.
2645#[derive(Clone, Default, PartialEq)]
2646#[non_exhaustive]
2647pub struct AIInference {
2648 /// Required. An endpoint to a Vertex AI model of the form
2649 /// `projects/{project}/locations/{location}/endpoints/{endpoint}` or
2650 /// `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`.
2651 /// Vertex AI API requests will be sent to this endpoint.
2652 pub endpoint: std::string::String,
2653
2654 /// Optional. The service account to use to make prediction requests against
2655 /// endpoints. The resource creator or updater that specifies this field must
2656 /// have `iam.serviceAccounts.actAs` permission on the service account. If not
2657 /// specified, the Pub/Sub [service
2658 /// agent](https://cloud.google.com/iam/docs/service-agents),
2659 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
2660 pub service_account_email: std::string::String,
2661
2662 /// The format of inference requests made to the endpoint.
2663 pub inference_mode: std::option::Option<crate::model::ai_inference::InferenceMode>,
2664
2665 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2666}
2667
2668impl AIInference {
2669 /// Creates a new default instance.
2670 pub fn new() -> Self {
2671 std::default::Default::default()
2672 }
2673
2674 /// Sets the value of [endpoint][crate::model::AIInference::endpoint].
2675 ///
2676 /// # Example
2677 /// ```ignore,no_run
2678 /// # use google_cloud_pubsub::model::AIInference;
2679 /// let x = AIInference::new().set_endpoint("example");
2680 /// ```
2681 pub fn set_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2682 self.endpoint = v.into();
2683 self
2684 }
2685
2686 /// Sets the value of [service_account_email][crate::model::AIInference::service_account_email].
2687 ///
2688 /// # Example
2689 /// ```ignore,no_run
2690 /// # use google_cloud_pubsub::model::AIInference;
2691 /// let x = AIInference::new().set_service_account_email("example");
2692 /// ```
2693 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
2694 mut self,
2695 v: T,
2696 ) -> Self {
2697 self.service_account_email = v.into();
2698 self
2699 }
2700
2701 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode].
2702 ///
2703 /// Note that all the setters affecting `inference_mode` are mutually
2704 /// exclusive.
2705 ///
2706 /// # Example
2707 /// ```ignore,no_run
2708 /// # use google_cloud_pubsub::model::AIInference;
2709 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2710 /// let x = AIInference::new().set_inference_mode(Some(
2711 /// google_cloud_pubsub::model::ai_inference::InferenceMode::UnstructuredInference(UnstructuredInference::default().into())));
2712 /// ```
2713 pub fn set_inference_mode<
2714 T: std::convert::Into<std::option::Option<crate::model::ai_inference::InferenceMode>>,
2715 >(
2716 mut self,
2717 v: T,
2718 ) -> Self {
2719 self.inference_mode = v.into();
2720 self
2721 }
2722
2723 /// The value of [inference_mode][crate::model::AIInference::inference_mode]
2724 /// if it holds a `UnstructuredInference`, `None` if the field is not set or
2725 /// holds a different branch.
2726 pub fn unstructured_inference(
2727 &self,
2728 ) -> std::option::Option<&std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>
2729 {
2730 #[allow(unreachable_patterns)]
2731 self.inference_mode.as_ref().and_then(|v| match v {
2732 crate::model::ai_inference::InferenceMode::UnstructuredInference(v) => {
2733 std::option::Option::Some(v)
2734 }
2735 _ => std::option::Option::None,
2736 })
2737 }
2738
2739 /// Sets the value of [inference_mode][crate::model::AIInference::inference_mode]
2740 /// to hold a `UnstructuredInference`.
2741 ///
2742 /// Note that all the setters affecting `inference_mode` are
2743 /// mutually exclusive.
2744 ///
2745 /// # Example
2746 /// ```ignore,no_run
2747 /// # use google_cloud_pubsub::model::AIInference;
2748 /// use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2749 /// let x = AIInference::new().set_unstructured_inference(UnstructuredInference::default()/* use setters */);
2750 /// assert!(x.unstructured_inference().is_some());
2751 /// ```
2752 pub fn set_unstructured_inference<
2753 T: std::convert::Into<std::boxed::Box<crate::model::ai_inference::UnstructuredInference>>,
2754 >(
2755 mut self,
2756 v: T,
2757 ) -> Self {
2758 self.inference_mode = std::option::Option::Some(
2759 crate::model::ai_inference::InferenceMode::UnstructuredInference(v.into()),
2760 );
2761 self
2762 }
2763}
2764
2765impl wkt::message::Message for AIInference {
2766 fn typename() -> &'static str {
2767 "type.googleapis.com/google.pubsub.v1.AIInference"
2768 }
2769}
2770
2771/// Defines additional types related to [AIInference].
2772pub mod ai_inference {
2773 #[allow(unused_imports)]
2774 use super::*;
2775
2776 /// Configuration for making inferences using arbitrary JSON payloads.
2777 #[derive(Clone, Default, PartialEq)]
2778 #[non_exhaustive]
2779 pub struct UnstructuredInference {
2780 /// Optional. A parameters object to be included in each inference request.
2781 /// The parameters object is combined with the data field of the Pub/Sub
2782 /// message to form the inference request.
2783 pub parameters: std::option::Option<wkt::Struct>,
2784
2785 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2786 }
2787
2788 impl UnstructuredInference {
2789 /// Creates a new default instance.
2790 pub fn new() -> Self {
2791 std::default::Default::default()
2792 }
2793
2794 /// Sets the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
2795 ///
2796 /// # Example
2797 /// ```ignore,no_run
2798 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2799 /// use wkt::Struct;
2800 /// let x = UnstructuredInference::new().set_parameters(Struct::default()/* use setters */);
2801 /// ```
2802 pub fn set_parameters<T>(mut self, v: T) -> Self
2803 where
2804 T: std::convert::Into<wkt::Struct>,
2805 {
2806 self.parameters = std::option::Option::Some(v.into());
2807 self
2808 }
2809
2810 /// Sets or clears the value of [parameters][crate::model::ai_inference::UnstructuredInference::parameters].
2811 ///
2812 /// # Example
2813 /// ```ignore,no_run
2814 /// # use google_cloud_pubsub::model::ai_inference::UnstructuredInference;
2815 /// use wkt::Struct;
2816 /// let x = UnstructuredInference::new().set_or_clear_parameters(Some(Struct::default()/* use setters */));
2817 /// let x = UnstructuredInference::new().set_or_clear_parameters(None::<Struct>);
2818 /// ```
2819 pub fn set_or_clear_parameters<T>(mut self, v: std::option::Option<T>) -> Self
2820 where
2821 T: std::convert::Into<wkt::Struct>,
2822 {
2823 self.parameters = v.map(|x| x.into());
2824 self
2825 }
2826 }
2827
2828 impl wkt::message::Message for UnstructuredInference {
2829 fn typename() -> &'static str {
2830 "type.googleapis.com/google.pubsub.v1.AIInference.UnstructuredInference"
2831 }
2832 }
2833
2834 /// The format of inference requests made to the endpoint.
2835 #[derive(Clone, Debug, PartialEq)]
2836 #[non_exhaustive]
2837 pub enum InferenceMode {
2838 /// Optional. Requests and responses can be any arbitrary JSON object.
2839 UnstructuredInference(std::boxed::Box<crate::model::ai_inference::UnstructuredInference>),
2840 }
2841}
2842
2843/// All supported message transforms types.
2844#[derive(Clone, Default, PartialEq)]
2845#[non_exhaustive]
2846pub struct MessageTransform {
2847 /// Optional. This field is deprecated, use the `disabled` field to disable
2848 /// transforms.
2849 #[deprecated]
2850 pub enabled: bool,
2851
2852 /// Optional. If true, the transform is disabled and will not be applied to
2853 /// messages. Defaults to `false`.
2854 pub disabled: bool,
2855
2856 /// The type of transform to apply to messages.
2857 pub transform: std::option::Option<crate::model::message_transform::Transform>,
2858
2859 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2860}
2861
2862impl MessageTransform {
2863 /// Creates a new default instance.
2864 pub fn new() -> Self {
2865 std::default::Default::default()
2866 }
2867
2868 /// Sets the value of [enabled][crate::model::MessageTransform::enabled].
2869 ///
2870 /// # Example
2871 /// ```ignore,no_run
2872 /// # use google_cloud_pubsub::model::MessageTransform;
2873 /// let x = MessageTransform::new().set_enabled(true);
2874 /// ```
2875 #[deprecated]
2876 pub fn set_enabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2877 self.enabled = v.into();
2878 self
2879 }
2880
2881 /// Sets the value of [disabled][crate::model::MessageTransform::disabled].
2882 ///
2883 /// # Example
2884 /// ```ignore,no_run
2885 /// # use google_cloud_pubsub::model::MessageTransform;
2886 /// let x = MessageTransform::new().set_disabled(true);
2887 /// ```
2888 pub fn set_disabled<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2889 self.disabled = v.into();
2890 self
2891 }
2892
2893 /// Sets the value of [transform][crate::model::MessageTransform::transform].
2894 ///
2895 /// Note that all the setters affecting `transform` are mutually
2896 /// exclusive.
2897 ///
2898 /// # Example
2899 /// ```ignore,no_run
2900 /// # use google_cloud_pubsub::model::MessageTransform;
2901 /// use google_cloud_pubsub::model::JavaScriptUDF;
2902 /// let x = MessageTransform::new().set_transform(Some(
2903 /// google_cloud_pubsub::model::message_transform::Transform::JavascriptUdf(JavaScriptUDF::default().into())));
2904 /// ```
2905 pub fn set_transform<
2906 T: std::convert::Into<std::option::Option<crate::model::message_transform::Transform>>,
2907 >(
2908 mut self,
2909 v: T,
2910 ) -> Self {
2911 self.transform = v.into();
2912 self
2913 }
2914
2915 /// The value of [transform][crate::model::MessageTransform::transform]
2916 /// if it holds a `JavascriptUdf`, `None` if the field is not set or
2917 /// holds a different branch.
2918 pub fn javascript_udf(
2919 &self,
2920 ) -> std::option::Option<&std::boxed::Box<crate::model::JavaScriptUDF>> {
2921 #[allow(unreachable_patterns)]
2922 self.transform.as_ref().and_then(|v| match v {
2923 crate::model::message_transform::Transform::JavascriptUdf(v) => {
2924 std::option::Option::Some(v)
2925 }
2926 _ => std::option::Option::None,
2927 })
2928 }
2929
2930 /// Sets the value of [transform][crate::model::MessageTransform::transform]
2931 /// to hold a `JavascriptUdf`.
2932 ///
2933 /// Note that all the setters affecting `transform` are
2934 /// mutually exclusive.
2935 ///
2936 /// # Example
2937 /// ```ignore,no_run
2938 /// # use google_cloud_pubsub::model::MessageTransform;
2939 /// use google_cloud_pubsub::model::JavaScriptUDF;
2940 /// let x = MessageTransform::new().set_javascript_udf(JavaScriptUDF::default()/* use setters */);
2941 /// assert!(x.javascript_udf().is_some());
2942 /// assert!(x.ai_inference().is_none());
2943 /// ```
2944 pub fn set_javascript_udf<
2945 T: std::convert::Into<std::boxed::Box<crate::model::JavaScriptUDF>>,
2946 >(
2947 mut self,
2948 v: T,
2949 ) -> Self {
2950 self.transform = std::option::Option::Some(
2951 crate::model::message_transform::Transform::JavascriptUdf(v.into()),
2952 );
2953 self
2954 }
2955
2956 /// The value of [transform][crate::model::MessageTransform::transform]
2957 /// if it holds a `AiInference`, `None` if the field is not set or
2958 /// holds a different branch.
2959 pub fn ai_inference(&self) -> std::option::Option<&std::boxed::Box<crate::model::AIInference>> {
2960 #[allow(unreachable_patterns)]
2961 self.transform.as_ref().and_then(|v| match v {
2962 crate::model::message_transform::Transform::AiInference(v) => {
2963 std::option::Option::Some(v)
2964 }
2965 _ => std::option::Option::None,
2966 })
2967 }
2968
2969 /// Sets the value of [transform][crate::model::MessageTransform::transform]
2970 /// to hold a `AiInference`.
2971 ///
2972 /// Note that all the setters affecting `transform` are
2973 /// mutually exclusive.
2974 ///
2975 /// # Example
2976 /// ```ignore,no_run
2977 /// # use google_cloud_pubsub::model::MessageTransform;
2978 /// use google_cloud_pubsub::model::AIInference;
2979 /// let x = MessageTransform::new().set_ai_inference(AIInference::default()/* use setters */);
2980 /// assert!(x.ai_inference().is_some());
2981 /// assert!(x.javascript_udf().is_none());
2982 /// ```
2983 pub fn set_ai_inference<T: std::convert::Into<std::boxed::Box<crate::model::AIInference>>>(
2984 mut self,
2985 v: T,
2986 ) -> Self {
2987 self.transform = std::option::Option::Some(
2988 crate::model::message_transform::Transform::AiInference(v.into()),
2989 );
2990 self
2991 }
2992}
2993
2994impl wkt::message::Message for MessageTransform {
2995 fn typename() -> &'static str {
2996 "type.googleapis.com/google.pubsub.v1.MessageTransform"
2997 }
2998}
2999
3000/// Defines additional types related to [MessageTransform].
3001pub mod message_transform {
3002 #[allow(unused_imports)]
3003 use super::*;
3004
3005 /// The type of transform to apply to messages.
3006 #[derive(Clone, Debug, PartialEq)]
3007 #[non_exhaustive]
3008 pub enum Transform {
3009 /// Optional. JavaScript User Defined Function. If multiple JavaScriptUDF's
3010 /// are specified on a resource, each must have a unique `function_name`.
3011 JavascriptUdf(std::boxed::Box<crate::model::JavaScriptUDF>),
3012 /// Optional. AI Inference. Specifies the Vertex AI endpoint that inference
3013 /// requests built from the Pub/Sub message data and provided parameters will
3014 /// be sent to.
3015 AiInference(std::boxed::Box<crate::model::AIInference>),
3016 }
3017}
3018
3019/// A topic resource.
3020#[derive(Clone, Default, PartialEq)]
3021#[non_exhaustive]
3022pub struct Topic {
3023 /// Required. Identifier. The name of the topic. It must have the format
3024 /// `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
3025 /// and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
3026 /// underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
3027 /// signs (`%`). It must be between 3 and 255 characters in length, and it
3028 /// must not start with `"goog"`.
3029 pub name: std::string::String,
3030
3031 /// Optional. See [Creating and managing labels]
3032 /// (<https://cloud.google.com/pubsub/docs/labels>).
3033 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
3034
3035 /// Optional. Policy constraining the set of Google Cloud Platform regions
3036 /// where messages published to the topic may be stored. If not present, then
3037 /// no constraints are in effect.
3038 pub message_storage_policy: std::option::Option<crate::model::MessageStoragePolicy>,
3039
3040 /// Optional. The resource name of the Cloud KMS CryptoKey to be used to
3041 /// protect access to messages published on this topic.
3042 ///
3043 /// The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
3044 pub kms_key_name: std::string::String,
3045
3046 /// Optional. Settings for validating messages published against a schema.
3047 pub schema_settings: std::option::Option<crate::model::SchemaSettings>,
3048
3049 /// Optional. Reserved for future use. This field is set only in responses from
3050 /// the server; it is ignored if it is set in any requests.
3051 pub satisfies_pzs: bool,
3052
3053 /// Optional. Indicates the minimum duration to retain a message after it is
3054 /// published to the topic. If this field is set, messages published to the
3055 /// topic in the last `message_retention_duration` are always available to
3056 /// subscribers. For instance, it allows any attached subscription to [seek to
3057 /// a
3058 /// timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
3059 /// that is up to `message_retention_duration` in the past. If this field is
3060 /// not set, message retention is controlled by settings on individual
3061 /// subscriptions. Cannot be more than 31 days or less than 10 minutes.
3062 pub message_retention_duration: std::option::Option<wkt::Duration>,
3063
3064 /// Output only. An output-only field indicating the state of the topic.
3065 pub state: crate::model::topic::State,
3066
3067 /// Optional. Settings for ingestion from a data source into this topic.
3068 pub ingestion_data_source_settings:
3069 std::option::Option<crate::model::IngestionDataSourceSettings>,
3070
3071 /// Optional. Transforms to be applied to messages published to the topic.
3072 /// Transforms are applied in the order specified.
3073 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
3074
3075 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
3076 /// resource. For example:
3077 /// "123/environment": "production",
3078 /// "123/costCenter": "marketing"
3079 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
3080 /// using tags with Pub/Sub resources.
3081 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
3082
3083 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3084}
3085
3086impl Topic {
3087 /// Creates a new default instance.
3088 pub fn new() -> Self {
3089 std::default::Default::default()
3090 }
3091
3092 /// Sets the value of [name][crate::model::Topic::name].
3093 ///
3094 /// # Example
3095 /// ```ignore,no_run
3096 /// # use google_cloud_pubsub::model::Topic;
3097 /// # let project_id = "project_id";
3098 /// # let topic_id = "topic_id";
3099 /// let x = Topic::new().set_name(format!("projects/{project_id}/topics/{topic_id}"));
3100 /// ```
3101 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3102 self.name = v.into();
3103 self
3104 }
3105
3106 /// Sets the value of [labels][crate::model::Topic::labels].
3107 ///
3108 /// # Example
3109 /// ```ignore,no_run
3110 /// # use google_cloud_pubsub::model::Topic;
3111 /// let x = Topic::new().set_labels([
3112 /// ("key0", "abc"),
3113 /// ("key1", "xyz"),
3114 /// ]);
3115 /// ```
3116 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
3117 where
3118 T: std::iter::IntoIterator<Item = (K, V)>,
3119 K: std::convert::Into<std::string::String>,
3120 V: std::convert::Into<std::string::String>,
3121 {
3122 use std::iter::Iterator;
3123 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3124 self
3125 }
3126
3127 /// Sets the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3128 ///
3129 /// # Example
3130 /// ```ignore,no_run
3131 /// # use google_cloud_pubsub::model::Topic;
3132 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3133 /// let x = Topic::new().set_message_storage_policy(MessageStoragePolicy::default()/* use setters */);
3134 /// ```
3135 pub fn set_message_storage_policy<T>(mut self, v: T) -> Self
3136 where
3137 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3138 {
3139 self.message_storage_policy = std::option::Option::Some(v.into());
3140 self
3141 }
3142
3143 /// Sets or clears the value of [message_storage_policy][crate::model::Topic::message_storage_policy].
3144 ///
3145 /// # Example
3146 /// ```ignore,no_run
3147 /// # use google_cloud_pubsub::model::Topic;
3148 /// use google_cloud_pubsub::model::MessageStoragePolicy;
3149 /// let x = Topic::new().set_or_clear_message_storage_policy(Some(MessageStoragePolicy::default()/* use setters */));
3150 /// let x = Topic::new().set_or_clear_message_storage_policy(None::<MessageStoragePolicy>);
3151 /// ```
3152 pub fn set_or_clear_message_storage_policy<T>(mut self, v: std::option::Option<T>) -> Self
3153 where
3154 T: std::convert::Into<crate::model::MessageStoragePolicy>,
3155 {
3156 self.message_storage_policy = v.map(|x| x.into());
3157 self
3158 }
3159
3160 /// Sets the value of [kms_key_name][crate::model::Topic::kms_key_name].
3161 ///
3162 /// # Example
3163 /// ```ignore,no_run
3164 /// # use google_cloud_pubsub::model::Topic;
3165 /// let x = Topic::new().set_kms_key_name("example");
3166 /// ```
3167 pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3168 self.kms_key_name = v.into();
3169 self
3170 }
3171
3172 /// Sets the value of [schema_settings][crate::model::Topic::schema_settings].
3173 ///
3174 /// # Example
3175 /// ```ignore,no_run
3176 /// # use google_cloud_pubsub::model::Topic;
3177 /// use google_cloud_pubsub::model::SchemaSettings;
3178 /// let x = Topic::new().set_schema_settings(SchemaSettings::default()/* use setters */);
3179 /// ```
3180 pub fn set_schema_settings<T>(mut self, v: T) -> Self
3181 where
3182 T: std::convert::Into<crate::model::SchemaSettings>,
3183 {
3184 self.schema_settings = std::option::Option::Some(v.into());
3185 self
3186 }
3187
3188 /// Sets or clears the value of [schema_settings][crate::model::Topic::schema_settings].
3189 ///
3190 /// # Example
3191 /// ```ignore,no_run
3192 /// # use google_cloud_pubsub::model::Topic;
3193 /// use google_cloud_pubsub::model::SchemaSettings;
3194 /// let x = Topic::new().set_or_clear_schema_settings(Some(SchemaSettings::default()/* use setters */));
3195 /// let x = Topic::new().set_or_clear_schema_settings(None::<SchemaSettings>);
3196 /// ```
3197 pub fn set_or_clear_schema_settings<T>(mut self, v: std::option::Option<T>) -> Self
3198 where
3199 T: std::convert::Into<crate::model::SchemaSettings>,
3200 {
3201 self.schema_settings = v.map(|x| x.into());
3202 self
3203 }
3204
3205 /// Sets the value of [satisfies_pzs][crate::model::Topic::satisfies_pzs].
3206 ///
3207 /// # Example
3208 /// ```ignore,no_run
3209 /// # use google_cloud_pubsub::model::Topic;
3210 /// let x = Topic::new().set_satisfies_pzs(true);
3211 /// ```
3212 pub fn set_satisfies_pzs<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
3213 self.satisfies_pzs = v.into();
3214 self
3215 }
3216
3217 /// Sets the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3218 ///
3219 /// # Example
3220 /// ```ignore,no_run
3221 /// # use google_cloud_pubsub::model::Topic;
3222 /// use wkt::Duration;
3223 /// let x = Topic::new().set_message_retention_duration(Duration::default()/* use setters */);
3224 /// ```
3225 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
3226 where
3227 T: std::convert::Into<wkt::Duration>,
3228 {
3229 self.message_retention_duration = std::option::Option::Some(v.into());
3230 self
3231 }
3232
3233 /// Sets or clears the value of [message_retention_duration][crate::model::Topic::message_retention_duration].
3234 ///
3235 /// # Example
3236 /// ```ignore,no_run
3237 /// # use google_cloud_pubsub::model::Topic;
3238 /// use wkt::Duration;
3239 /// let x = Topic::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
3240 /// let x = Topic::new().set_or_clear_message_retention_duration(None::<Duration>);
3241 /// ```
3242 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
3243 where
3244 T: std::convert::Into<wkt::Duration>,
3245 {
3246 self.message_retention_duration = v.map(|x| x.into());
3247 self
3248 }
3249
3250 /// Sets the value of [state][crate::model::Topic::state].
3251 ///
3252 /// # Example
3253 /// ```ignore,no_run
3254 /// # use google_cloud_pubsub::model::Topic;
3255 /// use google_cloud_pubsub::model::topic::State;
3256 /// let x0 = Topic::new().set_state(State::Active);
3257 /// let x1 = Topic::new().set_state(State::IngestionResourceError);
3258 /// ```
3259 pub fn set_state<T: std::convert::Into<crate::model::topic::State>>(mut self, v: T) -> Self {
3260 self.state = v.into();
3261 self
3262 }
3263
3264 /// Sets the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3265 ///
3266 /// # Example
3267 /// ```ignore,no_run
3268 /// # use google_cloud_pubsub::model::Topic;
3269 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3270 /// let x = Topic::new().set_ingestion_data_source_settings(IngestionDataSourceSettings::default()/* use setters */);
3271 /// ```
3272 pub fn set_ingestion_data_source_settings<T>(mut self, v: T) -> Self
3273 where
3274 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3275 {
3276 self.ingestion_data_source_settings = std::option::Option::Some(v.into());
3277 self
3278 }
3279
3280 /// Sets or clears the value of [ingestion_data_source_settings][crate::model::Topic::ingestion_data_source_settings].
3281 ///
3282 /// # Example
3283 /// ```ignore,no_run
3284 /// # use google_cloud_pubsub::model::Topic;
3285 /// use google_cloud_pubsub::model::IngestionDataSourceSettings;
3286 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(Some(IngestionDataSourceSettings::default()/* use setters */));
3287 /// let x = Topic::new().set_or_clear_ingestion_data_source_settings(None::<IngestionDataSourceSettings>);
3288 /// ```
3289 pub fn set_or_clear_ingestion_data_source_settings<T>(
3290 mut self,
3291 v: std::option::Option<T>,
3292 ) -> Self
3293 where
3294 T: std::convert::Into<crate::model::IngestionDataSourceSettings>,
3295 {
3296 self.ingestion_data_source_settings = v.map(|x| x.into());
3297 self
3298 }
3299
3300 /// Sets the value of [message_transforms][crate::model::Topic::message_transforms].
3301 ///
3302 /// # Example
3303 /// ```ignore,no_run
3304 /// # use google_cloud_pubsub::model::Topic;
3305 /// use google_cloud_pubsub::model::MessageTransform;
3306 /// let x = Topic::new()
3307 /// .set_message_transforms([
3308 /// MessageTransform::default()/* use setters */,
3309 /// MessageTransform::default()/* use (different) setters */,
3310 /// ]);
3311 /// ```
3312 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
3313 where
3314 T: std::iter::IntoIterator<Item = V>,
3315 V: std::convert::Into<crate::model::MessageTransform>,
3316 {
3317 use std::iter::Iterator;
3318 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
3319 self
3320 }
3321
3322 /// Sets the value of [tags][crate::model::Topic::tags].
3323 ///
3324 /// # Example
3325 /// ```ignore,no_run
3326 /// # use google_cloud_pubsub::model::Topic;
3327 /// let x = Topic::new().set_tags([
3328 /// ("key0", "abc"),
3329 /// ("key1", "xyz"),
3330 /// ]);
3331 /// ```
3332 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
3333 where
3334 T: std::iter::IntoIterator<Item = (K, V)>,
3335 K: std::convert::Into<std::string::String>,
3336 V: std::convert::Into<std::string::String>,
3337 {
3338 use std::iter::Iterator;
3339 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
3340 self
3341 }
3342}
3343
3344impl wkt::message::Message for Topic {
3345 fn typename() -> &'static str {
3346 "type.googleapis.com/google.pubsub.v1.Topic"
3347 }
3348}
3349
3350/// Defines additional types related to [Topic].
3351pub mod topic {
3352 #[allow(unused_imports)]
3353 use super::*;
3354
3355 /// The state of the topic.
3356 ///
3357 /// # Working with unknown values
3358 ///
3359 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3360 /// additional enum variants at any time. Adding new variants is not considered
3361 /// a breaking change. Applications should write their code in anticipation of:
3362 ///
3363 /// - New values appearing in future releases of the client library, **and**
3364 /// - New values received dynamically, without application changes.
3365 ///
3366 /// Please consult the [Working with enums] section in the user guide for some
3367 /// guidelines.
3368 ///
3369 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3370 #[derive(Clone, Debug, PartialEq)]
3371 #[non_exhaustive]
3372 pub enum State {
3373 /// Default value. This value is unused.
3374 Unspecified,
3375 /// The topic does not have any persistent errors.
3376 Active,
3377 /// Ingestion from the data source has encountered a permanent error.
3378 /// See the more detailed error state in the corresponding ingestion
3379 /// source configuration.
3380 IngestionResourceError,
3381 /// If set, the enum was initialized with an unknown value.
3382 ///
3383 /// Applications can examine the value using [State::value] or
3384 /// [State::name].
3385 UnknownValue(state::UnknownValue),
3386 }
3387
3388 #[doc(hidden)]
3389 pub mod state {
3390 #[allow(unused_imports)]
3391 use super::*;
3392 #[derive(Clone, Debug, PartialEq)]
3393 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3394 }
3395
3396 impl State {
3397 /// Gets the enum value.
3398 ///
3399 /// Returns `None` if the enum contains an unknown value deserialized from
3400 /// the string representation of enums.
3401 pub fn value(&self) -> std::option::Option<i32> {
3402 match self {
3403 Self::Unspecified => std::option::Option::Some(0),
3404 Self::Active => std::option::Option::Some(1),
3405 Self::IngestionResourceError => std::option::Option::Some(2),
3406 Self::UnknownValue(u) => u.0.value(),
3407 }
3408 }
3409
3410 /// Gets the enum value as a string.
3411 ///
3412 /// Returns `None` if the enum contains an unknown value deserialized from
3413 /// the integer representation of enums.
3414 pub fn name(&self) -> std::option::Option<&str> {
3415 match self {
3416 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
3417 Self::Active => std::option::Option::Some("ACTIVE"),
3418 Self::IngestionResourceError => {
3419 std::option::Option::Some("INGESTION_RESOURCE_ERROR")
3420 }
3421 Self::UnknownValue(u) => u.0.name(),
3422 }
3423 }
3424 }
3425
3426 impl std::default::Default for State {
3427 fn default() -> Self {
3428 use std::convert::From;
3429 Self::from(0)
3430 }
3431 }
3432
3433 impl std::fmt::Display for State {
3434 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3435 wkt::internal::display_enum(f, self.name(), self.value())
3436 }
3437 }
3438
3439 impl std::convert::From<i32> for State {
3440 fn from(value: i32) -> Self {
3441 match value {
3442 0 => Self::Unspecified,
3443 1 => Self::Active,
3444 2 => Self::IngestionResourceError,
3445 _ => Self::UnknownValue(state::UnknownValue(
3446 wkt::internal::UnknownEnumValue::Integer(value),
3447 )),
3448 }
3449 }
3450 }
3451
3452 impl std::convert::From<&str> for State {
3453 fn from(value: &str) -> Self {
3454 use std::string::ToString;
3455 match value {
3456 "STATE_UNSPECIFIED" => Self::Unspecified,
3457 "ACTIVE" => Self::Active,
3458 "INGESTION_RESOURCE_ERROR" => Self::IngestionResourceError,
3459 _ => Self::UnknownValue(state::UnknownValue(
3460 wkt::internal::UnknownEnumValue::String(value.to_string()),
3461 )),
3462 }
3463 }
3464 }
3465
3466 impl serde::ser::Serialize for State {
3467 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3468 where
3469 S: serde::Serializer,
3470 {
3471 match self {
3472 Self::Unspecified => serializer.serialize_i32(0),
3473 Self::Active => serializer.serialize_i32(1),
3474 Self::IngestionResourceError => serializer.serialize_i32(2),
3475 Self::UnknownValue(u) => u.0.serialize(serializer),
3476 }
3477 }
3478 }
3479
3480 impl<'de> serde::de::Deserialize<'de> for State {
3481 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3482 where
3483 D: serde::Deserializer<'de>,
3484 {
3485 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
3486 ".google.pubsub.v1.Topic.State",
3487 ))
3488 }
3489 }
3490}
3491
3492/// Request for the GetTopic method.
3493#[derive(Clone, Default, PartialEq)]
3494#[non_exhaustive]
3495pub struct GetTopicRequest {
3496 /// Required. The name of the topic to get.
3497 /// Format is `projects/{project}/topics/{topic}`.
3498 pub topic: std::string::String,
3499
3500 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3501}
3502
3503impl GetTopicRequest {
3504 /// Creates a new default instance.
3505 pub fn new() -> Self {
3506 std::default::Default::default()
3507 }
3508
3509 /// Sets the value of [topic][crate::model::GetTopicRequest::topic].
3510 ///
3511 /// # Example
3512 /// ```ignore,no_run
3513 /// # use google_cloud_pubsub::model::GetTopicRequest;
3514 /// # let project_id = "project_id";
3515 /// # let topic_id = "topic_id";
3516 /// let x = GetTopicRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
3517 /// ```
3518 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3519 self.topic = v.into();
3520 self
3521 }
3522}
3523
3524impl wkt::message::Message for GetTopicRequest {
3525 fn typename() -> &'static str {
3526 "type.googleapis.com/google.pubsub.v1.GetTopicRequest"
3527 }
3528}
3529
3530/// Request for the UpdateTopic method.
3531#[derive(Clone, Default, PartialEq)]
3532#[non_exhaustive]
3533pub struct UpdateTopicRequest {
3534 /// Required. The updated topic object.
3535 pub topic: std::option::Option<crate::model::Topic>,
3536
3537 /// Required. Indicates which fields in the provided topic to update. Must be
3538 /// specified and non-empty. Note that if `update_mask` contains
3539 /// "message_storage_policy" but the `message_storage_policy` is not set in
3540 /// the `topic` provided above, then the updated value is determined by the
3541 /// policy configured at the project or organization level.
3542 pub update_mask: std::option::Option<wkt::FieldMask>,
3543
3544 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3545}
3546
3547impl UpdateTopicRequest {
3548 /// Creates a new default instance.
3549 pub fn new() -> Self {
3550 std::default::Default::default()
3551 }
3552
3553 /// Sets the value of [topic][crate::model::UpdateTopicRequest::topic].
3554 ///
3555 /// # Example
3556 /// ```ignore,no_run
3557 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3558 /// use google_cloud_pubsub::model::Topic;
3559 /// let x = UpdateTopicRequest::new().set_topic(Topic::default()/* use setters */);
3560 /// ```
3561 pub fn set_topic<T>(mut self, v: T) -> Self
3562 where
3563 T: std::convert::Into<crate::model::Topic>,
3564 {
3565 self.topic = std::option::Option::Some(v.into());
3566 self
3567 }
3568
3569 /// Sets or clears the value of [topic][crate::model::UpdateTopicRequest::topic].
3570 ///
3571 /// # Example
3572 /// ```ignore,no_run
3573 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3574 /// use google_cloud_pubsub::model::Topic;
3575 /// let x = UpdateTopicRequest::new().set_or_clear_topic(Some(Topic::default()/* use setters */));
3576 /// let x = UpdateTopicRequest::new().set_or_clear_topic(None::<Topic>);
3577 /// ```
3578 pub fn set_or_clear_topic<T>(mut self, v: std::option::Option<T>) -> Self
3579 where
3580 T: std::convert::Into<crate::model::Topic>,
3581 {
3582 self.topic = v.map(|x| x.into());
3583 self
3584 }
3585
3586 /// Sets the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
3587 ///
3588 /// # Example
3589 /// ```ignore,no_run
3590 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3591 /// use wkt::FieldMask;
3592 /// let x = UpdateTopicRequest::new().set_update_mask(FieldMask::default()/* use setters */);
3593 /// ```
3594 pub fn set_update_mask<T>(mut self, v: T) -> Self
3595 where
3596 T: std::convert::Into<wkt::FieldMask>,
3597 {
3598 self.update_mask = std::option::Option::Some(v.into());
3599 self
3600 }
3601
3602 /// Sets or clears the value of [update_mask][crate::model::UpdateTopicRequest::update_mask].
3603 ///
3604 /// # Example
3605 /// ```ignore,no_run
3606 /// # use google_cloud_pubsub::model::UpdateTopicRequest;
3607 /// use wkt::FieldMask;
3608 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
3609 /// let x = UpdateTopicRequest::new().set_or_clear_update_mask(None::<FieldMask>);
3610 /// ```
3611 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
3612 where
3613 T: std::convert::Into<wkt::FieldMask>,
3614 {
3615 self.update_mask = v.map(|x| x.into());
3616 self
3617 }
3618}
3619
3620impl wkt::message::Message for UpdateTopicRequest {
3621 fn typename() -> &'static str {
3622 "type.googleapis.com/google.pubsub.v1.UpdateTopicRequest"
3623 }
3624}
3625
3626/// Request for the `ListTopics` method.
3627#[derive(Clone, Default, PartialEq)]
3628#[non_exhaustive]
3629pub struct ListTopicsRequest {
3630 /// Required. The name of the project in which to list topics.
3631 /// Format is `projects/{project-id}`.
3632 pub project: std::string::String,
3633
3634 /// Optional. Maximum number of topics to return.
3635 pub page_size: i32,
3636
3637 /// Optional. The value returned by the last `ListTopicsResponse`; indicates
3638 /// that this is a continuation of a prior `ListTopics` call, and that the
3639 /// system should return the next page of data.
3640 pub page_token: std::string::String,
3641
3642 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3643}
3644
3645impl ListTopicsRequest {
3646 /// Creates a new default instance.
3647 pub fn new() -> Self {
3648 std::default::Default::default()
3649 }
3650
3651 /// Sets the value of [project][crate::model::ListTopicsRequest::project].
3652 ///
3653 /// # Example
3654 /// ```ignore,no_run
3655 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3656 /// let x = ListTopicsRequest::new().set_project("example");
3657 /// ```
3658 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3659 self.project = v.into();
3660 self
3661 }
3662
3663 /// Sets the value of [page_size][crate::model::ListTopicsRequest::page_size].
3664 ///
3665 /// # Example
3666 /// ```ignore,no_run
3667 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3668 /// let x = ListTopicsRequest::new().set_page_size(42);
3669 /// ```
3670 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3671 self.page_size = v.into();
3672 self
3673 }
3674
3675 /// Sets the value of [page_token][crate::model::ListTopicsRequest::page_token].
3676 ///
3677 /// # Example
3678 /// ```ignore,no_run
3679 /// # use google_cloud_pubsub::model::ListTopicsRequest;
3680 /// let x = ListTopicsRequest::new().set_page_token("example");
3681 /// ```
3682 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3683 self.page_token = v.into();
3684 self
3685 }
3686}
3687
3688impl wkt::message::Message for ListTopicsRequest {
3689 fn typename() -> &'static str {
3690 "type.googleapis.com/google.pubsub.v1.ListTopicsRequest"
3691 }
3692}
3693
3694/// Response for the `ListTopics` method.
3695#[derive(Clone, Default, PartialEq)]
3696#[non_exhaustive]
3697pub struct ListTopicsResponse {
3698 /// Optional. The resulting topics.
3699 pub topics: std::vec::Vec<crate::model::Topic>,
3700
3701 /// Optional. If not empty, indicates that there may be more topics that match
3702 /// the request; this value should be passed in a new `ListTopicsRequest`.
3703 pub next_page_token: std::string::String,
3704
3705 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3706}
3707
3708impl ListTopicsResponse {
3709 /// Creates a new default instance.
3710 pub fn new() -> Self {
3711 std::default::Default::default()
3712 }
3713
3714 /// Sets the value of [topics][crate::model::ListTopicsResponse::topics].
3715 ///
3716 /// # Example
3717 /// ```ignore,no_run
3718 /// # use google_cloud_pubsub::model::ListTopicsResponse;
3719 /// use google_cloud_pubsub::model::Topic;
3720 /// let x = ListTopicsResponse::new()
3721 /// .set_topics([
3722 /// Topic::default()/* use setters */,
3723 /// Topic::default()/* use (different) setters */,
3724 /// ]);
3725 /// ```
3726 pub fn set_topics<T, V>(mut self, v: T) -> Self
3727 where
3728 T: std::iter::IntoIterator<Item = V>,
3729 V: std::convert::Into<crate::model::Topic>,
3730 {
3731 use std::iter::Iterator;
3732 self.topics = v.into_iter().map(|i| i.into()).collect();
3733 self
3734 }
3735
3736 /// Sets the value of [next_page_token][crate::model::ListTopicsResponse::next_page_token].
3737 ///
3738 /// # Example
3739 /// ```ignore,no_run
3740 /// # use google_cloud_pubsub::model::ListTopicsResponse;
3741 /// let x = ListTopicsResponse::new().set_next_page_token("example");
3742 /// ```
3743 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3744 self.next_page_token = v.into();
3745 self
3746 }
3747}
3748
3749impl wkt::message::Message for ListTopicsResponse {
3750 fn typename() -> &'static str {
3751 "type.googleapis.com/google.pubsub.v1.ListTopicsResponse"
3752 }
3753}
3754
3755#[doc(hidden)]
3756impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicsResponse {
3757 type PageItem = crate::model::Topic;
3758
3759 fn items(self) -> std::vec::Vec<Self::PageItem> {
3760 self.topics
3761 }
3762
3763 fn next_page_token(&self) -> std::string::String {
3764 use std::clone::Clone;
3765 self.next_page_token.clone()
3766 }
3767}
3768
3769/// Request for the `ListTopicSubscriptions` method.
3770#[derive(Clone, Default, PartialEq)]
3771#[non_exhaustive]
3772pub struct ListTopicSubscriptionsRequest {
3773 /// Required. The name of the topic that subscriptions are attached to.
3774 /// Format is `projects/{project}/topics/{topic}`.
3775 pub topic: std::string::String,
3776
3777 /// Optional. Maximum number of subscription names to return.
3778 pub page_size: i32,
3779
3780 /// Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
3781 /// indicates that this is a continuation of a prior `ListTopicSubscriptions`
3782 /// call, and that the system should return the next page of data.
3783 pub page_token: std::string::String,
3784
3785 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3786}
3787
3788impl ListTopicSubscriptionsRequest {
3789 /// Creates a new default instance.
3790 pub fn new() -> Self {
3791 std::default::Default::default()
3792 }
3793
3794 /// Sets the value of [topic][crate::model::ListTopicSubscriptionsRequest::topic].
3795 ///
3796 /// # Example
3797 /// ```ignore,no_run
3798 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3799 /// # let project_id = "project_id";
3800 /// # let topic_id = "topic_id";
3801 /// let x = ListTopicSubscriptionsRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
3802 /// ```
3803 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3804 self.topic = v.into();
3805 self
3806 }
3807
3808 /// Sets the value of [page_size][crate::model::ListTopicSubscriptionsRequest::page_size].
3809 ///
3810 /// # Example
3811 /// ```ignore,no_run
3812 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3813 /// let x = ListTopicSubscriptionsRequest::new().set_page_size(42);
3814 /// ```
3815 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3816 self.page_size = v.into();
3817 self
3818 }
3819
3820 /// Sets the value of [page_token][crate::model::ListTopicSubscriptionsRequest::page_token].
3821 ///
3822 /// # Example
3823 /// ```ignore,no_run
3824 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsRequest;
3825 /// let x = ListTopicSubscriptionsRequest::new().set_page_token("example");
3826 /// ```
3827 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3828 self.page_token = v.into();
3829 self
3830 }
3831}
3832
3833impl wkt::message::Message for ListTopicSubscriptionsRequest {
3834 fn typename() -> &'static str {
3835 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsRequest"
3836 }
3837}
3838
3839/// Response for the `ListTopicSubscriptions` method.
3840#[derive(Clone, Default, PartialEq)]
3841#[non_exhaustive]
3842pub struct ListTopicSubscriptionsResponse {
3843 /// Optional. The names of subscriptions attached to the topic specified in the
3844 /// request.
3845 pub subscriptions: std::vec::Vec<std::string::String>,
3846
3847 /// Optional. If not empty, indicates that there may be more subscriptions that
3848 /// match the request; this value should be passed in a new
3849 /// `ListTopicSubscriptionsRequest` to get more subscriptions.
3850 pub next_page_token: std::string::String,
3851
3852 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3853}
3854
3855impl ListTopicSubscriptionsResponse {
3856 /// Creates a new default instance.
3857 pub fn new() -> Self {
3858 std::default::Default::default()
3859 }
3860
3861 /// Sets the value of [subscriptions][crate::model::ListTopicSubscriptionsResponse::subscriptions].
3862 ///
3863 /// # Example
3864 /// ```ignore,no_run
3865 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
3866 /// let x = ListTopicSubscriptionsResponse::new().set_subscriptions(["a", "b", "c"]);
3867 /// ```
3868 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
3869 where
3870 T: std::iter::IntoIterator<Item = V>,
3871 V: std::convert::Into<std::string::String>,
3872 {
3873 use std::iter::Iterator;
3874 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
3875 self
3876 }
3877
3878 /// Sets the value of [next_page_token][crate::model::ListTopicSubscriptionsResponse::next_page_token].
3879 ///
3880 /// # Example
3881 /// ```ignore,no_run
3882 /// # use google_cloud_pubsub::model::ListTopicSubscriptionsResponse;
3883 /// let x = ListTopicSubscriptionsResponse::new().set_next_page_token("example");
3884 /// ```
3885 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3886 self.next_page_token = v.into();
3887 self
3888 }
3889}
3890
3891impl wkt::message::Message for ListTopicSubscriptionsResponse {
3892 fn typename() -> &'static str {
3893 "type.googleapis.com/google.pubsub.v1.ListTopicSubscriptionsResponse"
3894 }
3895}
3896
3897#[doc(hidden)]
3898impl google_cloud_gax::paginator::internal::PageableResponse for ListTopicSubscriptionsResponse {
3899 type PageItem = std::string::String;
3900
3901 fn items(self) -> std::vec::Vec<Self::PageItem> {
3902 self.subscriptions
3903 }
3904
3905 fn next_page_token(&self) -> std::string::String {
3906 use std::clone::Clone;
3907 self.next_page_token.clone()
3908 }
3909}
3910
3911/// Request for the `ListTopicSnapshots` method.
3912#[derive(Clone, Default, PartialEq)]
3913#[non_exhaustive]
3914pub struct ListTopicSnapshotsRequest {
3915 /// Required. The name of the topic that snapshots are attached to.
3916 /// Format is `projects/{project}/topics/{topic}`.
3917 pub topic: std::string::String,
3918
3919 /// Optional. Maximum number of snapshot names to return.
3920 pub page_size: i32,
3921
3922 /// Optional. The value returned by the last `ListTopicSnapshotsResponse`;
3923 /// indicates that this is a continuation of a prior `ListTopicSnapshots` call,
3924 /// and that the system should return the next page of data.
3925 pub page_token: std::string::String,
3926
3927 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3928}
3929
3930impl ListTopicSnapshotsRequest {
3931 /// Creates a new default instance.
3932 pub fn new() -> Self {
3933 std::default::Default::default()
3934 }
3935
3936 /// Sets the value of [topic][crate::model::ListTopicSnapshotsRequest::topic].
3937 ///
3938 /// # Example
3939 /// ```ignore,no_run
3940 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3941 /// # let project_id = "project_id";
3942 /// # let topic_id = "topic_id";
3943 /// let x = ListTopicSnapshotsRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
3944 /// ```
3945 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3946 self.topic = v.into();
3947 self
3948 }
3949
3950 /// Sets the value of [page_size][crate::model::ListTopicSnapshotsRequest::page_size].
3951 ///
3952 /// # Example
3953 /// ```ignore,no_run
3954 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3955 /// let x = ListTopicSnapshotsRequest::new().set_page_size(42);
3956 /// ```
3957 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3958 self.page_size = v.into();
3959 self
3960 }
3961
3962 /// Sets the value of [page_token][crate::model::ListTopicSnapshotsRequest::page_token].
3963 ///
3964 /// # Example
3965 /// ```ignore,no_run
3966 /// # use google_cloud_pubsub::model::ListTopicSnapshotsRequest;
3967 /// let x = ListTopicSnapshotsRequest::new().set_page_token("example");
3968 /// ```
3969 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3970 self.page_token = v.into();
3971 self
3972 }
3973}
3974
3975impl wkt::message::Message for ListTopicSnapshotsRequest {
3976 fn typename() -> &'static str {
3977 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsRequest"
3978 }
3979}
3980
3981/// Response for the `ListTopicSnapshots` method.
3982#[derive(Clone, Default, PartialEq)]
3983#[non_exhaustive]
3984pub struct ListTopicSnapshotsResponse {
3985 /// Optional. The names of the snapshots that match the request.
3986 pub snapshots: std::vec::Vec<std::string::String>,
3987
3988 /// Optional. If not empty, indicates that there may be more snapshots that
3989 /// match the request; this value should be passed in a new
3990 /// `ListTopicSnapshotsRequest` to get more snapshots.
3991 pub next_page_token: std::string::String,
3992
3993 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3994}
3995
3996impl ListTopicSnapshotsResponse {
3997 /// Creates a new default instance.
3998 pub fn new() -> Self {
3999 std::default::Default::default()
4000 }
4001
4002 /// Sets the value of [snapshots][crate::model::ListTopicSnapshotsResponse::snapshots].
4003 ///
4004 /// # Example
4005 /// ```ignore,no_run
4006 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
4007 /// let x = ListTopicSnapshotsResponse::new().set_snapshots(["a", "b", "c"]);
4008 /// ```
4009 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
4010 where
4011 T: std::iter::IntoIterator<Item = V>,
4012 V: std::convert::Into<std::string::String>,
4013 {
4014 use std::iter::Iterator;
4015 self.snapshots = v.into_iter().map(|i| i.into()).collect();
4016 self
4017 }
4018
4019 /// Sets the value of [next_page_token][crate::model::ListTopicSnapshotsResponse::next_page_token].
4020 ///
4021 /// # Example
4022 /// ```ignore,no_run
4023 /// # use google_cloud_pubsub::model::ListTopicSnapshotsResponse;
4024 /// let x = ListTopicSnapshotsResponse::new().set_next_page_token("example");
4025 /// ```
4026 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4027 self.next_page_token = v.into();
4028 self
4029 }
4030}
4031
4032impl wkt::message::Message for ListTopicSnapshotsResponse {
4033 fn typename() -> &'static str {
4034 "type.googleapis.com/google.pubsub.v1.ListTopicSnapshotsResponse"
4035 }
4036}
4037
4038/// Request for the `DeleteTopic` method.
4039#[derive(Clone, Default, PartialEq)]
4040#[non_exhaustive]
4041pub struct DeleteTopicRequest {
4042 /// Required. Name of the topic to delete.
4043 /// Format is `projects/{project}/topics/{topic}`.
4044 pub topic: std::string::String,
4045
4046 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4047}
4048
4049impl DeleteTopicRequest {
4050 /// Creates a new default instance.
4051 pub fn new() -> Self {
4052 std::default::Default::default()
4053 }
4054
4055 /// Sets the value of [topic][crate::model::DeleteTopicRequest::topic].
4056 ///
4057 /// # Example
4058 /// ```ignore,no_run
4059 /// # use google_cloud_pubsub::model::DeleteTopicRequest;
4060 /// # let project_id = "project_id";
4061 /// # let topic_id = "topic_id";
4062 /// let x = DeleteTopicRequest::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4063 /// ```
4064 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4065 self.topic = v.into();
4066 self
4067 }
4068}
4069
4070impl wkt::message::Message for DeleteTopicRequest {
4071 fn typename() -> &'static str {
4072 "type.googleapis.com/google.pubsub.v1.DeleteTopicRequest"
4073 }
4074}
4075
4076/// Request for the DetachSubscription method.
4077#[derive(Clone, Default, PartialEq)]
4078#[non_exhaustive]
4079pub struct DetachSubscriptionRequest {
4080 /// Required. The subscription to detach.
4081 /// Format is `projects/{project}/subscriptions/{subscription}`.
4082 pub subscription: std::string::String,
4083
4084 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4085}
4086
4087impl DetachSubscriptionRequest {
4088 /// Creates a new default instance.
4089 pub fn new() -> Self {
4090 std::default::Default::default()
4091 }
4092
4093 /// Sets the value of [subscription][crate::model::DetachSubscriptionRequest::subscription].
4094 ///
4095 /// # Example
4096 /// ```ignore,no_run
4097 /// # use google_cloud_pubsub::model::DetachSubscriptionRequest;
4098 /// # let project_id = "project_id";
4099 /// # let subscription_id = "subscription_id";
4100 /// let x = DetachSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
4101 /// ```
4102 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4103 self.subscription = v.into();
4104 self
4105 }
4106}
4107
4108impl wkt::message::Message for DetachSubscriptionRequest {
4109 fn typename() -> &'static str {
4110 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionRequest"
4111 }
4112}
4113
4114/// Response for the DetachSubscription method.
4115/// Reserved for future use.
4116#[derive(Clone, Default, PartialEq)]
4117#[non_exhaustive]
4118pub struct DetachSubscriptionResponse {
4119 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4120}
4121
4122impl DetachSubscriptionResponse {
4123 /// Creates a new default instance.
4124 pub fn new() -> Self {
4125 std::default::Default::default()
4126 }
4127}
4128
4129impl wkt::message::Message for DetachSubscriptionResponse {
4130 fn typename() -> &'static str {
4131 "type.googleapis.com/google.pubsub.v1.DetachSubscriptionResponse"
4132 }
4133}
4134
4135/// A subscription resource. If none of `push_config`, `bigquery_config`, or
4136/// `cloud_storage_config` is set, then the subscriber will pull and ack messages
4137/// using API methods. At most one of these fields may be set.
4138#[derive(Clone, Default, PartialEq)]
4139#[non_exhaustive]
4140pub struct Subscription {
4141 /// Required. Identifier. The name of the subscription. It must have the format
4142 /// `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
4143 /// start with a letter, and contain only letters (`[A-Za-z]`), numbers
4144 /// (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
4145 /// plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
4146 /// in length, and it must not start with `"goog"`.
4147 pub name: std::string::String,
4148
4149 /// Required. The name of the topic from which this subscription is receiving
4150 /// messages. Format is `projects/{project}/topics/{topic}`. The value of this
4151 /// field will be `_deleted-topic_` if the topic has been deleted.
4152 pub topic: std::string::String,
4153
4154 /// Optional. If push delivery is used with this subscription, this field is
4155 /// used to configure it.
4156 pub push_config: std::option::Option<crate::model::PushConfig>,
4157
4158 /// Optional. If delivery to BigQuery is used with this subscription, this
4159 /// field is used to configure it.
4160 pub bigquery_config: std::option::Option<crate::model::BigQueryConfig>,
4161
4162 /// Optional. If delivery to Google Cloud Storage is used with this
4163 /// subscription, this field is used to configure it.
4164 pub cloud_storage_config: std::option::Option<crate::model::CloudStorageConfig>,
4165
4166 /// Optional. If delivery to Bigtable is used with this subscription, this
4167 /// field is used to configure it.
4168 pub bigtable_config: std::option::Option<crate::model::BigtableConfig>,
4169
4170 /// Optional. The approximate amount of time (on a best-effort basis) Pub/Sub
4171 /// waits for the subscriber to acknowledge receipt before resending the
4172 /// message. In the interval after the message is delivered and before it is
4173 /// acknowledged, it is considered to be _outstanding_. During that time
4174 /// period, the message will not be redelivered (on a best-effort basis).
4175 ///
4176 /// For pull subscriptions, this value is used as the initial value for the ack
4177 /// deadline. To override this value for a given message, call
4178 /// `ModifyAckDeadline` with the corresponding `ack_id` if using
4179 /// non-streaming pull or send the `ack_id` in a
4180 /// `StreamingModifyAckDeadlineRequest` if using streaming pull.
4181 /// The minimum custom deadline you can specify is 10 seconds.
4182 /// The maximum custom deadline you can specify is 600 seconds (10 minutes).
4183 /// If this parameter is 0, a default value of 10 seconds is used.
4184 ///
4185 /// For push delivery, this value is also used to set the request timeout for
4186 /// the call to the push endpoint.
4187 ///
4188 /// If the subscriber never acknowledges the message, the Pub/Sub
4189 /// system will eventually redeliver the message.
4190 pub ack_deadline_seconds: i32,
4191
4192 /// Optional. Indicates whether to retain acknowledged messages. If true, then
4193 /// messages are not expunged from the subscription's backlog, even if they are
4194 /// acknowledged, until they fall out of the `message_retention_duration`
4195 /// window. This must be true if you would like to [`Seek` to a timestamp]
4196 /// (<https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time>) in
4197 /// the past to replay previously-acknowledged messages.
4198 pub retain_acked_messages: bool,
4199
4200 /// Optional. How long to retain unacknowledged messages in the subscription's
4201 /// backlog, from the moment a message is published. If `retain_acked_messages`
4202 /// is true, then this also configures the retention of acknowledged messages,
4203 /// and thus configures how far back in time a `Seek` can be done. Defaults to
4204 /// 7 days. Cannot be more than 31 days or less than 10 minutes.
4205 pub message_retention_duration: std::option::Option<wkt::Duration>,
4206
4207 /// Optional. See [Creating and managing
4208 /// labels](https://cloud.google.com/pubsub/docs/labels).
4209 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
4210
4211 /// Optional. If true, messages published with the same `ordering_key` in
4212 /// `PubsubMessage` will be delivered to the subscribers in the order in which
4213 /// they are received by the Pub/Sub system. Otherwise, they may be delivered
4214 /// in any order.
4215 pub enable_message_ordering: bool,
4216
4217 /// Optional. A policy that specifies the conditions for this subscription's
4218 /// expiration. A subscription is considered active as long as any connected
4219 /// subscriber is successfully consuming messages from the subscription or is
4220 /// issuing operations on the subscription. If `expiration_policy` is not set,
4221 /// a *default policy* with `ttl` of 31 days will be used. The minimum allowed
4222 /// value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set,
4223 /// but `expiration_policy.ttl` is not set, the subscription never expires.
4224 pub expiration_policy: std::option::Option<crate::model::ExpirationPolicy>,
4225
4226 /// Optional. An expression written in the Pub/Sub [filter
4227 /// language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
4228 /// then only `PubsubMessage`s whose `attributes` field matches the filter are
4229 /// delivered on this subscription. If empty, then no messages are filtered
4230 /// out.
4231 pub filter: std::string::String,
4232
4233 /// Optional. A policy that specifies the conditions for dead lettering
4234 /// messages in this subscription. If dead_letter_policy is not set, dead
4235 /// lettering is disabled.
4236 ///
4237 /// The Pub/Sub service account associated with this subscriptions's
4238 /// parent project (i.e.,
4239 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
4240 /// permission to Acknowledge() messages on this subscription.
4241 pub dead_letter_policy: std::option::Option<crate::model::DeadLetterPolicy>,
4242
4243 /// Optional. A policy that specifies how Pub/Sub retries message delivery for
4244 /// this subscription.
4245 ///
4246 /// If not set, the default retry policy is applied. This generally implies
4247 /// that messages will be retried as soon as possible for healthy subscribers.
4248 /// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
4249 /// events for a given message.
4250 pub retry_policy: std::option::Option<crate::model::RetryPolicy>,
4251
4252 /// Optional. Indicates whether the subscription is detached from its topic.
4253 /// Detached subscriptions don't receive messages from their topic and don't
4254 /// retain any backlog. `Pull` and `StreamingPull` requests will return
4255 /// FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
4256 /// the endpoint will not be made.
4257 pub detached: bool,
4258
4259 /// Optional. If true, Pub/Sub provides the following guarantees for the
4260 /// delivery of a message with a given value of `message_id` on this
4261 /// subscription:
4262 ///
4263 /// * The message sent to a subscriber is guaranteed not to be resent
4264 /// before the message's acknowledgment deadline expires.
4265 /// * An acknowledged message will not be resent to a subscriber.
4266 ///
4267 /// Note that subscribers may still receive multiple copies of a message
4268 /// when `enable_exactly_once_delivery` is true if the message was published
4269 /// multiple times by a publisher client. These copies are considered distinct
4270 /// by Pub/Sub and have distinct `message_id` values.
4271 pub enable_exactly_once_delivery: bool,
4272
4273 /// Output only. Indicates the minimum duration for which a message is retained
4274 /// after it is published to the subscription's topic. If this field is set,
4275 /// messages published to the subscription's topic in the last
4276 /// `topic_message_retention_duration` are always available to subscribers. See
4277 /// the `message_retention_duration` field in `Topic`. This field is set only
4278 /// in responses from the server; it is ignored if it is set in any requests.
4279 pub topic_message_retention_duration: std::option::Option<wkt::Duration>,
4280
4281 /// Output only. An output-only field indicating whether or not the
4282 /// subscription can receive messages.
4283 pub state: crate::model::subscription::State,
4284
4285 /// Output only. Information about the associated Analytics Hub subscription.
4286 /// Only set if the subscription is created by Analytics Hub.
4287 pub analytics_hub_subscription_info:
4288 std::option::Option<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4289
4290 /// Optional. Transforms to be applied to messages before they are delivered to
4291 /// subscribers. Transforms are applied in the order specified.
4292 pub message_transforms: std::vec::Vec<crate::model::MessageTransform>,
4293
4294 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
4295 /// resource. For example:
4296 /// "123/environment": "production",
4297 /// "123/costCenter": "marketing"
4298 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
4299 /// using tags with Pub/Sub resources.
4300 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
4301
4302 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4303}
4304
4305impl Subscription {
4306 /// Creates a new default instance.
4307 pub fn new() -> Self {
4308 std::default::Default::default()
4309 }
4310
4311 /// Sets the value of [name][crate::model::Subscription::name].
4312 ///
4313 /// # Example
4314 /// ```ignore,no_run
4315 /// # use google_cloud_pubsub::model::Subscription;
4316 /// # let project_id = "project_id";
4317 /// # let subscription_id = "subscription_id";
4318 /// let x = Subscription::new().set_name(format!("projects/{project_id}/subscriptions/{subscription_id}"));
4319 /// ```
4320 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4321 self.name = v.into();
4322 self
4323 }
4324
4325 /// Sets the value of [topic][crate::model::Subscription::topic].
4326 ///
4327 /// # Example
4328 /// ```ignore,no_run
4329 /// # use google_cloud_pubsub::model::Subscription;
4330 /// # let project_id = "project_id";
4331 /// # let topic_id = "topic_id";
4332 /// let x = Subscription::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
4333 /// ```
4334 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4335 self.topic = v.into();
4336 self
4337 }
4338
4339 /// Sets the value of [push_config][crate::model::Subscription::push_config].
4340 ///
4341 /// # Example
4342 /// ```ignore,no_run
4343 /// # use google_cloud_pubsub::model::Subscription;
4344 /// use google_cloud_pubsub::model::PushConfig;
4345 /// let x = Subscription::new().set_push_config(PushConfig::default()/* use setters */);
4346 /// ```
4347 pub fn set_push_config<T>(mut self, v: T) -> Self
4348 where
4349 T: std::convert::Into<crate::model::PushConfig>,
4350 {
4351 self.push_config = std::option::Option::Some(v.into());
4352 self
4353 }
4354
4355 /// Sets or clears the value of [push_config][crate::model::Subscription::push_config].
4356 ///
4357 /// # Example
4358 /// ```ignore,no_run
4359 /// # use google_cloud_pubsub::model::Subscription;
4360 /// use google_cloud_pubsub::model::PushConfig;
4361 /// let x = Subscription::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
4362 /// let x = Subscription::new().set_or_clear_push_config(None::<PushConfig>);
4363 /// ```
4364 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
4365 where
4366 T: std::convert::Into<crate::model::PushConfig>,
4367 {
4368 self.push_config = v.map(|x| x.into());
4369 self
4370 }
4371
4372 /// Sets the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4373 ///
4374 /// # Example
4375 /// ```ignore,no_run
4376 /// # use google_cloud_pubsub::model::Subscription;
4377 /// use google_cloud_pubsub::model::BigQueryConfig;
4378 /// let x = Subscription::new().set_bigquery_config(BigQueryConfig::default()/* use setters */);
4379 /// ```
4380 pub fn set_bigquery_config<T>(mut self, v: T) -> Self
4381 where
4382 T: std::convert::Into<crate::model::BigQueryConfig>,
4383 {
4384 self.bigquery_config = std::option::Option::Some(v.into());
4385 self
4386 }
4387
4388 /// Sets or clears the value of [bigquery_config][crate::model::Subscription::bigquery_config].
4389 ///
4390 /// # Example
4391 /// ```ignore,no_run
4392 /// # use google_cloud_pubsub::model::Subscription;
4393 /// use google_cloud_pubsub::model::BigQueryConfig;
4394 /// let x = Subscription::new().set_or_clear_bigquery_config(Some(BigQueryConfig::default()/* use setters */));
4395 /// let x = Subscription::new().set_or_clear_bigquery_config(None::<BigQueryConfig>);
4396 /// ```
4397 pub fn set_or_clear_bigquery_config<T>(mut self, v: std::option::Option<T>) -> Self
4398 where
4399 T: std::convert::Into<crate::model::BigQueryConfig>,
4400 {
4401 self.bigquery_config = v.map(|x| x.into());
4402 self
4403 }
4404
4405 /// Sets the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4406 ///
4407 /// # Example
4408 /// ```ignore,no_run
4409 /// # use google_cloud_pubsub::model::Subscription;
4410 /// use google_cloud_pubsub::model::CloudStorageConfig;
4411 /// let x = Subscription::new().set_cloud_storage_config(CloudStorageConfig::default()/* use setters */);
4412 /// ```
4413 pub fn set_cloud_storage_config<T>(mut self, v: T) -> Self
4414 where
4415 T: std::convert::Into<crate::model::CloudStorageConfig>,
4416 {
4417 self.cloud_storage_config = std::option::Option::Some(v.into());
4418 self
4419 }
4420
4421 /// Sets or clears the value of [cloud_storage_config][crate::model::Subscription::cloud_storage_config].
4422 ///
4423 /// # Example
4424 /// ```ignore,no_run
4425 /// # use google_cloud_pubsub::model::Subscription;
4426 /// use google_cloud_pubsub::model::CloudStorageConfig;
4427 /// let x = Subscription::new().set_or_clear_cloud_storage_config(Some(CloudStorageConfig::default()/* use setters */));
4428 /// let x = Subscription::new().set_or_clear_cloud_storage_config(None::<CloudStorageConfig>);
4429 /// ```
4430 pub fn set_or_clear_cloud_storage_config<T>(mut self, v: std::option::Option<T>) -> Self
4431 where
4432 T: std::convert::Into<crate::model::CloudStorageConfig>,
4433 {
4434 self.cloud_storage_config = v.map(|x| x.into());
4435 self
4436 }
4437
4438 /// Sets the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4439 ///
4440 /// # Example
4441 /// ```ignore,no_run
4442 /// # use google_cloud_pubsub::model::Subscription;
4443 /// use google_cloud_pubsub::model::BigtableConfig;
4444 /// let x = Subscription::new().set_bigtable_config(BigtableConfig::default()/* use setters */);
4445 /// ```
4446 pub fn set_bigtable_config<T>(mut self, v: T) -> Self
4447 where
4448 T: std::convert::Into<crate::model::BigtableConfig>,
4449 {
4450 self.bigtable_config = std::option::Option::Some(v.into());
4451 self
4452 }
4453
4454 /// Sets or clears the value of [bigtable_config][crate::model::Subscription::bigtable_config].
4455 ///
4456 /// # Example
4457 /// ```ignore,no_run
4458 /// # use google_cloud_pubsub::model::Subscription;
4459 /// use google_cloud_pubsub::model::BigtableConfig;
4460 /// let x = Subscription::new().set_or_clear_bigtable_config(Some(BigtableConfig::default()/* use setters */));
4461 /// let x = Subscription::new().set_or_clear_bigtable_config(None::<BigtableConfig>);
4462 /// ```
4463 pub fn set_or_clear_bigtable_config<T>(mut self, v: std::option::Option<T>) -> Self
4464 where
4465 T: std::convert::Into<crate::model::BigtableConfig>,
4466 {
4467 self.bigtable_config = v.map(|x| x.into());
4468 self
4469 }
4470
4471 /// Sets the value of [ack_deadline_seconds][crate::model::Subscription::ack_deadline_seconds].
4472 ///
4473 /// # Example
4474 /// ```ignore,no_run
4475 /// # use google_cloud_pubsub::model::Subscription;
4476 /// let x = Subscription::new().set_ack_deadline_seconds(42);
4477 /// ```
4478 pub fn set_ack_deadline_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
4479 self.ack_deadline_seconds = v.into();
4480 self
4481 }
4482
4483 /// Sets the value of [retain_acked_messages][crate::model::Subscription::retain_acked_messages].
4484 ///
4485 /// # Example
4486 /// ```ignore,no_run
4487 /// # use google_cloud_pubsub::model::Subscription;
4488 /// let x = Subscription::new().set_retain_acked_messages(true);
4489 /// ```
4490 pub fn set_retain_acked_messages<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4491 self.retain_acked_messages = v.into();
4492 self
4493 }
4494
4495 /// Sets the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4496 ///
4497 /// # Example
4498 /// ```ignore,no_run
4499 /// # use google_cloud_pubsub::model::Subscription;
4500 /// use wkt::Duration;
4501 /// let x = Subscription::new().set_message_retention_duration(Duration::default()/* use setters */);
4502 /// ```
4503 pub fn set_message_retention_duration<T>(mut self, v: T) -> Self
4504 where
4505 T: std::convert::Into<wkt::Duration>,
4506 {
4507 self.message_retention_duration = std::option::Option::Some(v.into());
4508 self
4509 }
4510
4511 /// Sets or clears the value of [message_retention_duration][crate::model::Subscription::message_retention_duration].
4512 ///
4513 /// # Example
4514 /// ```ignore,no_run
4515 /// # use google_cloud_pubsub::model::Subscription;
4516 /// use wkt::Duration;
4517 /// let x = Subscription::new().set_or_clear_message_retention_duration(Some(Duration::default()/* use setters */));
4518 /// let x = Subscription::new().set_or_clear_message_retention_duration(None::<Duration>);
4519 /// ```
4520 pub fn set_or_clear_message_retention_duration<T>(mut self, v: std::option::Option<T>) -> Self
4521 where
4522 T: std::convert::Into<wkt::Duration>,
4523 {
4524 self.message_retention_duration = v.map(|x| x.into());
4525 self
4526 }
4527
4528 /// Sets the value of [labels][crate::model::Subscription::labels].
4529 ///
4530 /// # Example
4531 /// ```ignore,no_run
4532 /// # use google_cloud_pubsub::model::Subscription;
4533 /// let x = Subscription::new().set_labels([
4534 /// ("key0", "abc"),
4535 /// ("key1", "xyz"),
4536 /// ]);
4537 /// ```
4538 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
4539 where
4540 T: std::iter::IntoIterator<Item = (K, V)>,
4541 K: std::convert::Into<std::string::String>,
4542 V: std::convert::Into<std::string::String>,
4543 {
4544 use std::iter::Iterator;
4545 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4546 self
4547 }
4548
4549 /// Sets the value of [enable_message_ordering][crate::model::Subscription::enable_message_ordering].
4550 ///
4551 /// # Example
4552 /// ```ignore,no_run
4553 /// # use google_cloud_pubsub::model::Subscription;
4554 /// let x = Subscription::new().set_enable_message_ordering(true);
4555 /// ```
4556 pub fn set_enable_message_ordering<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4557 self.enable_message_ordering = v.into();
4558 self
4559 }
4560
4561 /// Sets the value of [expiration_policy][crate::model::Subscription::expiration_policy].
4562 ///
4563 /// # Example
4564 /// ```ignore,no_run
4565 /// # use google_cloud_pubsub::model::Subscription;
4566 /// use google_cloud_pubsub::model::ExpirationPolicy;
4567 /// let x = Subscription::new().set_expiration_policy(ExpirationPolicy::default()/* use setters */);
4568 /// ```
4569 pub fn set_expiration_policy<T>(mut self, v: T) -> Self
4570 where
4571 T: std::convert::Into<crate::model::ExpirationPolicy>,
4572 {
4573 self.expiration_policy = std::option::Option::Some(v.into());
4574 self
4575 }
4576
4577 /// Sets or clears the value of [expiration_policy][crate::model::Subscription::expiration_policy].
4578 ///
4579 /// # Example
4580 /// ```ignore,no_run
4581 /// # use google_cloud_pubsub::model::Subscription;
4582 /// use google_cloud_pubsub::model::ExpirationPolicy;
4583 /// let x = Subscription::new().set_or_clear_expiration_policy(Some(ExpirationPolicy::default()/* use setters */));
4584 /// let x = Subscription::new().set_or_clear_expiration_policy(None::<ExpirationPolicy>);
4585 /// ```
4586 pub fn set_or_clear_expiration_policy<T>(mut self, v: std::option::Option<T>) -> Self
4587 where
4588 T: std::convert::Into<crate::model::ExpirationPolicy>,
4589 {
4590 self.expiration_policy = v.map(|x| x.into());
4591 self
4592 }
4593
4594 /// Sets the value of [filter][crate::model::Subscription::filter].
4595 ///
4596 /// # Example
4597 /// ```ignore,no_run
4598 /// # use google_cloud_pubsub::model::Subscription;
4599 /// let x = Subscription::new().set_filter("example");
4600 /// ```
4601 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4602 self.filter = v.into();
4603 self
4604 }
4605
4606 /// Sets the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
4607 ///
4608 /// # Example
4609 /// ```ignore,no_run
4610 /// # use google_cloud_pubsub::model::Subscription;
4611 /// use google_cloud_pubsub::model::DeadLetterPolicy;
4612 /// let x = Subscription::new().set_dead_letter_policy(DeadLetterPolicy::default()/* use setters */);
4613 /// ```
4614 pub fn set_dead_letter_policy<T>(mut self, v: T) -> Self
4615 where
4616 T: std::convert::Into<crate::model::DeadLetterPolicy>,
4617 {
4618 self.dead_letter_policy = std::option::Option::Some(v.into());
4619 self
4620 }
4621
4622 /// Sets or clears the value of [dead_letter_policy][crate::model::Subscription::dead_letter_policy].
4623 ///
4624 /// # Example
4625 /// ```ignore,no_run
4626 /// # use google_cloud_pubsub::model::Subscription;
4627 /// use google_cloud_pubsub::model::DeadLetterPolicy;
4628 /// let x = Subscription::new().set_or_clear_dead_letter_policy(Some(DeadLetterPolicy::default()/* use setters */));
4629 /// let x = Subscription::new().set_or_clear_dead_letter_policy(None::<DeadLetterPolicy>);
4630 /// ```
4631 pub fn set_or_clear_dead_letter_policy<T>(mut self, v: std::option::Option<T>) -> Self
4632 where
4633 T: std::convert::Into<crate::model::DeadLetterPolicy>,
4634 {
4635 self.dead_letter_policy = v.map(|x| x.into());
4636 self
4637 }
4638
4639 /// Sets the value of [retry_policy][crate::model::Subscription::retry_policy].
4640 ///
4641 /// # Example
4642 /// ```ignore,no_run
4643 /// # use google_cloud_pubsub::model::Subscription;
4644 /// use google_cloud_pubsub::model::RetryPolicy;
4645 /// let x = Subscription::new().set_retry_policy(RetryPolicy::default()/* use setters */);
4646 /// ```
4647 pub fn set_retry_policy<T>(mut self, v: T) -> Self
4648 where
4649 T: std::convert::Into<crate::model::RetryPolicy>,
4650 {
4651 self.retry_policy = std::option::Option::Some(v.into());
4652 self
4653 }
4654
4655 /// Sets or clears the value of [retry_policy][crate::model::Subscription::retry_policy].
4656 ///
4657 /// # Example
4658 /// ```ignore,no_run
4659 /// # use google_cloud_pubsub::model::Subscription;
4660 /// use google_cloud_pubsub::model::RetryPolicy;
4661 /// let x = Subscription::new().set_or_clear_retry_policy(Some(RetryPolicy::default()/* use setters */));
4662 /// let x = Subscription::new().set_or_clear_retry_policy(None::<RetryPolicy>);
4663 /// ```
4664 pub fn set_or_clear_retry_policy<T>(mut self, v: std::option::Option<T>) -> Self
4665 where
4666 T: std::convert::Into<crate::model::RetryPolicy>,
4667 {
4668 self.retry_policy = v.map(|x| x.into());
4669 self
4670 }
4671
4672 /// Sets the value of [detached][crate::model::Subscription::detached].
4673 ///
4674 /// # Example
4675 /// ```ignore,no_run
4676 /// # use google_cloud_pubsub::model::Subscription;
4677 /// let x = Subscription::new().set_detached(true);
4678 /// ```
4679 pub fn set_detached<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4680 self.detached = v.into();
4681 self
4682 }
4683
4684 /// Sets the value of [enable_exactly_once_delivery][crate::model::Subscription::enable_exactly_once_delivery].
4685 ///
4686 /// # Example
4687 /// ```ignore,no_run
4688 /// # use google_cloud_pubsub::model::Subscription;
4689 /// let x = Subscription::new().set_enable_exactly_once_delivery(true);
4690 /// ```
4691 pub fn set_enable_exactly_once_delivery<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4692 self.enable_exactly_once_delivery = v.into();
4693 self
4694 }
4695
4696 /// Sets the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
4697 ///
4698 /// # Example
4699 /// ```ignore,no_run
4700 /// # use google_cloud_pubsub::model::Subscription;
4701 /// use wkt::Duration;
4702 /// let x = Subscription::new().set_topic_message_retention_duration(Duration::default()/* use setters */);
4703 /// ```
4704 pub fn set_topic_message_retention_duration<T>(mut self, v: T) -> Self
4705 where
4706 T: std::convert::Into<wkt::Duration>,
4707 {
4708 self.topic_message_retention_duration = std::option::Option::Some(v.into());
4709 self
4710 }
4711
4712 /// Sets or clears the value of [topic_message_retention_duration][crate::model::Subscription::topic_message_retention_duration].
4713 ///
4714 /// # Example
4715 /// ```ignore,no_run
4716 /// # use google_cloud_pubsub::model::Subscription;
4717 /// use wkt::Duration;
4718 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(Some(Duration::default()/* use setters */));
4719 /// let x = Subscription::new().set_or_clear_topic_message_retention_duration(None::<Duration>);
4720 /// ```
4721 pub fn set_or_clear_topic_message_retention_duration<T>(
4722 mut self,
4723 v: std::option::Option<T>,
4724 ) -> Self
4725 where
4726 T: std::convert::Into<wkt::Duration>,
4727 {
4728 self.topic_message_retention_duration = v.map(|x| x.into());
4729 self
4730 }
4731
4732 /// Sets the value of [state][crate::model::Subscription::state].
4733 ///
4734 /// # Example
4735 /// ```ignore,no_run
4736 /// # use google_cloud_pubsub::model::Subscription;
4737 /// use google_cloud_pubsub::model::subscription::State;
4738 /// let x0 = Subscription::new().set_state(State::Active);
4739 /// let x1 = Subscription::new().set_state(State::ResourceError);
4740 /// ```
4741 pub fn set_state<T: std::convert::Into<crate::model::subscription::State>>(
4742 mut self,
4743 v: T,
4744 ) -> Self {
4745 self.state = v.into();
4746 self
4747 }
4748
4749 /// Sets the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
4750 ///
4751 /// # Example
4752 /// ```ignore,no_run
4753 /// # use google_cloud_pubsub::model::Subscription;
4754 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4755 /// let x = Subscription::new().set_analytics_hub_subscription_info(AnalyticsHubSubscriptionInfo::default()/* use setters */);
4756 /// ```
4757 pub fn set_analytics_hub_subscription_info<T>(mut self, v: T) -> Self
4758 where
4759 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4760 {
4761 self.analytics_hub_subscription_info = std::option::Option::Some(v.into());
4762 self
4763 }
4764
4765 /// Sets or clears the value of [analytics_hub_subscription_info][crate::model::Subscription::analytics_hub_subscription_info].
4766 ///
4767 /// # Example
4768 /// ```ignore,no_run
4769 /// # use google_cloud_pubsub::model::Subscription;
4770 /// use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4771 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(Some(AnalyticsHubSubscriptionInfo::default()/* use setters */));
4772 /// let x = Subscription::new().set_or_clear_analytics_hub_subscription_info(None::<AnalyticsHubSubscriptionInfo>);
4773 /// ```
4774 pub fn set_or_clear_analytics_hub_subscription_info<T>(
4775 mut self,
4776 v: std::option::Option<T>,
4777 ) -> Self
4778 where
4779 T: std::convert::Into<crate::model::subscription::AnalyticsHubSubscriptionInfo>,
4780 {
4781 self.analytics_hub_subscription_info = v.map(|x| x.into());
4782 self
4783 }
4784
4785 /// Sets the value of [message_transforms][crate::model::Subscription::message_transforms].
4786 ///
4787 /// # Example
4788 /// ```ignore,no_run
4789 /// # use google_cloud_pubsub::model::Subscription;
4790 /// use google_cloud_pubsub::model::MessageTransform;
4791 /// let x = Subscription::new()
4792 /// .set_message_transforms([
4793 /// MessageTransform::default()/* use setters */,
4794 /// MessageTransform::default()/* use (different) setters */,
4795 /// ]);
4796 /// ```
4797 pub fn set_message_transforms<T, V>(mut self, v: T) -> Self
4798 where
4799 T: std::iter::IntoIterator<Item = V>,
4800 V: std::convert::Into<crate::model::MessageTransform>,
4801 {
4802 use std::iter::Iterator;
4803 self.message_transforms = v.into_iter().map(|i| i.into()).collect();
4804 self
4805 }
4806
4807 /// Sets the value of [tags][crate::model::Subscription::tags].
4808 ///
4809 /// # Example
4810 /// ```ignore,no_run
4811 /// # use google_cloud_pubsub::model::Subscription;
4812 /// let x = Subscription::new().set_tags([
4813 /// ("key0", "abc"),
4814 /// ("key1", "xyz"),
4815 /// ]);
4816 /// ```
4817 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
4818 where
4819 T: std::iter::IntoIterator<Item = (K, V)>,
4820 K: std::convert::Into<std::string::String>,
4821 V: std::convert::Into<std::string::String>,
4822 {
4823 use std::iter::Iterator;
4824 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
4825 self
4826 }
4827}
4828
4829impl wkt::message::Message for Subscription {
4830 fn typename() -> &'static str {
4831 "type.googleapis.com/google.pubsub.v1.Subscription"
4832 }
4833}
4834
4835/// Defines additional types related to [Subscription].
4836pub mod subscription {
4837 #[allow(unused_imports)]
4838 use super::*;
4839
4840 /// Information about an associated [Analytics Hub
4841 /// subscription](https://cloud.google.com/bigquery/docs/analytics-hub-manage-subscriptions).
4842 #[derive(Clone, Default, PartialEq)]
4843 #[non_exhaustive]
4844 pub struct AnalyticsHubSubscriptionInfo {
4845 /// Optional. The name of the associated Analytics Hub listing resource.
4846 /// Pattern:
4847 /// "projects/{project}/locations/{location}/dataExchanges/{data_exchange}/listings/{listing}"
4848 pub listing: std::string::String,
4849
4850 /// Optional. The name of the associated Analytics Hub subscription resource.
4851 /// Pattern:
4852 /// "projects/{project}/locations/{location}/subscriptions/{subscription}"
4853 pub subscription: std::string::String,
4854
4855 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4856 }
4857
4858 impl AnalyticsHubSubscriptionInfo {
4859 /// Creates a new default instance.
4860 pub fn new() -> Self {
4861 std::default::Default::default()
4862 }
4863
4864 /// Sets the value of [listing][crate::model::subscription::AnalyticsHubSubscriptionInfo::listing].
4865 ///
4866 /// # Example
4867 /// ```ignore,no_run
4868 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4869 /// let x = AnalyticsHubSubscriptionInfo::new().set_listing("example");
4870 /// ```
4871 pub fn set_listing<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4872 self.listing = v.into();
4873 self
4874 }
4875
4876 /// Sets the value of [subscription][crate::model::subscription::AnalyticsHubSubscriptionInfo::subscription].
4877 ///
4878 /// # Example
4879 /// ```ignore,no_run
4880 /// # use google_cloud_pubsub::model::subscription::AnalyticsHubSubscriptionInfo;
4881 /// let x = AnalyticsHubSubscriptionInfo::new().set_subscription("example");
4882 /// ```
4883 pub fn set_subscription<T: std::convert::Into<std::string::String>>(
4884 mut self,
4885 v: T,
4886 ) -> Self {
4887 self.subscription = v.into();
4888 self
4889 }
4890 }
4891
4892 impl wkt::message::Message for AnalyticsHubSubscriptionInfo {
4893 fn typename() -> &'static str {
4894 "type.googleapis.com/google.pubsub.v1.Subscription.AnalyticsHubSubscriptionInfo"
4895 }
4896 }
4897
4898 /// Possible states for a subscription.
4899 ///
4900 /// # Working with unknown values
4901 ///
4902 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4903 /// additional enum variants at any time. Adding new variants is not considered
4904 /// a breaking change. Applications should write their code in anticipation of:
4905 ///
4906 /// - New values appearing in future releases of the client library, **and**
4907 /// - New values received dynamically, without application changes.
4908 ///
4909 /// Please consult the [Working with enums] section in the user guide for some
4910 /// guidelines.
4911 ///
4912 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4913 #[derive(Clone, Debug, PartialEq)]
4914 #[non_exhaustive]
4915 pub enum State {
4916 /// Default value. This value is unused.
4917 Unspecified,
4918 /// The subscription can actively receive messages
4919 Active,
4920 /// The subscription cannot receive messages because of an error with the
4921 /// resource to which it pushes messages. See the more detailed error state
4922 /// in the corresponding configuration.
4923 ResourceError,
4924 /// If set, the enum was initialized with an unknown value.
4925 ///
4926 /// Applications can examine the value using [State::value] or
4927 /// [State::name].
4928 UnknownValue(state::UnknownValue),
4929 }
4930
4931 #[doc(hidden)]
4932 pub mod state {
4933 #[allow(unused_imports)]
4934 use super::*;
4935 #[derive(Clone, Debug, PartialEq)]
4936 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4937 }
4938
4939 impl State {
4940 /// Gets the enum value.
4941 ///
4942 /// Returns `None` if the enum contains an unknown value deserialized from
4943 /// the string representation of enums.
4944 pub fn value(&self) -> std::option::Option<i32> {
4945 match self {
4946 Self::Unspecified => std::option::Option::Some(0),
4947 Self::Active => std::option::Option::Some(1),
4948 Self::ResourceError => std::option::Option::Some(2),
4949 Self::UnknownValue(u) => u.0.value(),
4950 }
4951 }
4952
4953 /// Gets the enum value as a string.
4954 ///
4955 /// Returns `None` if the enum contains an unknown value deserialized from
4956 /// the integer representation of enums.
4957 pub fn name(&self) -> std::option::Option<&str> {
4958 match self {
4959 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
4960 Self::Active => std::option::Option::Some("ACTIVE"),
4961 Self::ResourceError => std::option::Option::Some("RESOURCE_ERROR"),
4962 Self::UnknownValue(u) => u.0.name(),
4963 }
4964 }
4965 }
4966
4967 impl std::default::Default for State {
4968 fn default() -> Self {
4969 use std::convert::From;
4970 Self::from(0)
4971 }
4972 }
4973
4974 impl std::fmt::Display for State {
4975 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4976 wkt::internal::display_enum(f, self.name(), self.value())
4977 }
4978 }
4979
4980 impl std::convert::From<i32> for State {
4981 fn from(value: i32) -> Self {
4982 match value {
4983 0 => Self::Unspecified,
4984 1 => Self::Active,
4985 2 => Self::ResourceError,
4986 _ => Self::UnknownValue(state::UnknownValue(
4987 wkt::internal::UnknownEnumValue::Integer(value),
4988 )),
4989 }
4990 }
4991 }
4992
4993 impl std::convert::From<&str> for State {
4994 fn from(value: &str) -> Self {
4995 use std::string::ToString;
4996 match value {
4997 "STATE_UNSPECIFIED" => Self::Unspecified,
4998 "ACTIVE" => Self::Active,
4999 "RESOURCE_ERROR" => Self::ResourceError,
5000 _ => Self::UnknownValue(state::UnknownValue(
5001 wkt::internal::UnknownEnumValue::String(value.to_string()),
5002 )),
5003 }
5004 }
5005 }
5006
5007 impl serde::ser::Serialize for State {
5008 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5009 where
5010 S: serde::Serializer,
5011 {
5012 match self {
5013 Self::Unspecified => serializer.serialize_i32(0),
5014 Self::Active => serializer.serialize_i32(1),
5015 Self::ResourceError => serializer.serialize_i32(2),
5016 Self::UnknownValue(u) => u.0.serialize(serializer),
5017 }
5018 }
5019 }
5020
5021 impl<'de> serde::de::Deserialize<'de> for State {
5022 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5023 where
5024 D: serde::Deserializer<'de>,
5025 {
5026 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
5027 ".google.pubsub.v1.Subscription.State",
5028 ))
5029 }
5030 }
5031}
5032
5033/// A policy that specifies how Pub/Sub retries message delivery.
5034///
5035/// Retry delay will be exponential based on provided minimum and maximum
5036/// backoffs. <https://en.wikipedia.org/wiki/Exponential_backoff>.
5037///
5038/// RetryPolicy will be triggered on NACKs or acknowledgment deadline exceeded
5039/// events for a given message.
5040///
5041/// Retry Policy is implemented on a best effort basis. At times, the delay
5042/// between consecutive deliveries may not match the configuration. That is,
5043/// delay can be more or less than configured backoff.
5044#[derive(Clone, Default, PartialEq)]
5045#[non_exhaustive]
5046pub struct RetryPolicy {
5047 /// Optional. The minimum delay between consecutive deliveries of a given
5048 /// message. Value should be between 0 and 600 seconds. Defaults to 10 seconds.
5049 pub minimum_backoff: std::option::Option<wkt::Duration>,
5050
5051 /// Optional. The maximum delay between consecutive deliveries of a given
5052 /// message. Value should be between 0 and 600 seconds. Defaults to 600
5053 /// seconds.
5054 pub maximum_backoff: std::option::Option<wkt::Duration>,
5055
5056 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5057}
5058
5059impl RetryPolicy {
5060 /// Creates a new default instance.
5061 pub fn new() -> Self {
5062 std::default::Default::default()
5063 }
5064
5065 /// Sets the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5066 ///
5067 /// # Example
5068 /// ```ignore,no_run
5069 /// # use google_cloud_pubsub::model::RetryPolicy;
5070 /// use wkt::Duration;
5071 /// let x = RetryPolicy::new().set_minimum_backoff(Duration::default()/* use setters */);
5072 /// ```
5073 pub fn set_minimum_backoff<T>(mut self, v: T) -> Self
5074 where
5075 T: std::convert::Into<wkt::Duration>,
5076 {
5077 self.minimum_backoff = std::option::Option::Some(v.into());
5078 self
5079 }
5080
5081 /// Sets or clears the value of [minimum_backoff][crate::model::RetryPolicy::minimum_backoff].
5082 ///
5083 /// # Example
5084 /// ```ignore,no_run
5085 /// # use google_cloud_pubsub::model::RetryPolicy;
5086 /// use wkt::Duration;
5087 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(Some(Duration::default()/* use setters */));
5088 /// let x = RetryPolicy::new().set_or_clear_minimum_backoff(None::<Duration>);
5089 /// ```
5090 pub fn set_or_clear_minimum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5091 where
5092 T: std::convert::Into<wkt::Duration>,
5093 {
5094 self.minimum_backoff = v.map(|x| x.into());
5095 self
5096 }
5097
5098 /// Sets the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5099 ///
5100 /// # Example
5101 /// ```ignore,no_run
5102 /// # use google_cloud_pubsub::model::RetryPolicy;
5103 /// use wkt::Duration;
5104 /// let x = RetryPolicy::new().set_maximum_backoff(Duration::default()/* use setters */);
5105 /// ```
5106 pub fn set_maximum_backoff<T>(mut self, v: T) -> Self
5107 where
5108 T: std::convert::Into<wkt::Duration>,
5109 {
5110 self.maximum_backoff = std::option::Option::Some(v.into());
5111 self
5112 }
5113
5114 /// Sets or clears the value of [maximum_backoff][crate::model::RetryPolicy::maximum_backoff].
5115 ///
5116 /// # Example
5117 /// ```ignore,no_run
5118 /// # use google_cloud_pubsub::model::RetryPolicy;
5119 /// use wkt::Duration;
5120 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(Some(Duration::default()/* use setters */));
5121 /// let x = RetryPolicy::new().set_or_clear_maximum_backoff(None::<Duration>);
5122 /// ```
5123 pub fn set_or_clear_maximum_backoff<T>(mut self, v: std::option::Option<T>) -> Self
5124 where
5125 T: std::convert::Into<wkt::Duration>,
5126 {
5127 self.maximum_backoff = v.map(|x| x.into());
5128 self
5129 }
5130}
5131
5132impl wkt::message::Message for RetryPolicy {
5133 fn typename() -> &'static str {
5134 "type.googleapis.com/google.pubsub.v1.RetryPolicy"
5135 }
5136}
5137
5138/// Dead lettering is done on a best effort basis. The same message might be
5139/// dead lettered multiple times.
5140///
5141/// If validation on any of the fields fails at subscription creation/updation,
5142/// the create/update subscription request will fail.
5143#[derive(Clone, Default, PartialEq)]
5144#[non_exhaustive]
5145pub struct DeadLetterPolicy {
5146 /// Optional. The name of the topic to which dead letter messages should be
5147 /// published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub
5148 /// service account associated with the enclosing subscription's parent project
5149 /// (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must
5150 /// have permission to Publish() to this topic.
5151 ///
5152 /// The operation will fail if the topic does not exist.
5153 /// Users should ensure that there is a subscription attached to this topic
5154 /// since messages published to a topic with no subscriptions are lost.
5155 pub dead_letter_topic: std::string::String,
5156
5157 /// Optional. The maximum number of delivery attempts for any message. The
5158 /// value must be between 5 and 100.
5159 ///
5160 /// The number of delivery attempts is defined as 1 + (the sum of number of
5161 /// NACKs and number of times the acknowledgment deadline has been exceeded
5162 /// for the message).
5163 ///
5164 /// A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
5165 /// client libraries may automatically extend ack_deadlines.
5166 ///
5167 /// This field will be honored on a best effort basis.
5168 ///
5169 /// If this parameter is 0, a default value of 5 is used.
5170 pub max_delivery_attempts: i32,
5171
5172 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5173}
5174
5175impl DeadLetterPolicy {
5176 /// Creates a new default instance.
5177 pub fn new() -> Self {
5178 std::default::Default::default()
5179 }
5180
5181 /// Sets the value of [dead_letter_topic][crate::model::DeadLetterPolicy::dead_letter_topic].
5182 ///
5183 /// # Example
5184 /// ```ignore,no_run
5185 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5186 /// # let project_id = "project_id";
5187 /// # let topic_id = "topic_id";
5188 /// let x = DeadLetterPolicy::new().set_dead_letter_topic(format!("projects/{project_id}/topics/{topic_id}"));
5189 /// ```
5190 pub fn set_dead_letter_topic<T: std::convert::Into<std::string::String>>(
5191 mut self,
5192 v: T,
5193 ) -> Self {
5194 self.dead_letter_topic = v.into();
5195 self
5196 }
5197
5198 /// Sets the value of [max_delivery_attempts][crate::model::DeadLetterPolicy::max_delivery_attempts].
5199 ///
5200 /// # Example
5201 /// ```ignore,no_run
5202 /// # use google_cloud_pubsub::model::DeadLetterPolicy;
5203 /// let x = DeadLetterPolicy::new().set_max_delivery_attempts(42);
5204 /// ```
5205 pub fn set_max_delivery_attempts<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
5206 self.max_delivery_attempts = v.into();
5207 self
5208 }
5209}
5210
5211impl wkt::message::Message for DeadLetterPolicy {
5212 fn typename() -> &'static str {
5213 "type.googleapis.com/google.pubsub.v1.DeadLetterPolicy"
5214 }
5215}
5216
5217/// A policy that specifies the conditions for resource expiration (i.e.,
5218/// automatic resource deletion).
5219#[derive(Clone, Default, PartialEq)]
5220#[non_exhaustive]
5221pub struct ExpirationPolicy {
5222 /// Optional. Specifies the "time-to-live" duration for an associated resource.
5223 /// The resource expires if it is not active for a period of `ttl`. The
5224 /// definition of "activity" depends on the type of the associated resource.
5225 /// The minimum and maximum allowed values for `ttl` depend on the type of the
5226 /// associated resource, as well. If `ttl` is not set, the associated resource
5227 /// never expires.
5228 pub ttl: std::option::Option<wkt::Duration>,
5229
5230 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5231}
5232
5233impl ExpirationPolicy {
5234 /// Creates a new default instance.
5235 pub fn new() -> Self {
5236 std::default::Default::default()
5237 }
5238
5239 /// Sets the value of [ttl][crate::model::ExpirationPolicy::ttl].
5240 ///
5241 /// # Example
5242 /// ```ignore,no_run
5243 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5244 /// use wkt::Duration;
5245 /// let x = ExpirationPolicy::new().set_ttl(Duration::default()/* use setters */);
5246 /// ```
5247 pub fn set_ttl<T>(mut self, v: T) -> Self
5248 where
5249 T: std::convert::Into<wkt::Duration>,
5250 {
5251 self.ttl = std::option::Option::Some(v.into());
5252 self
5253 }
5254
5255 /// Sets or clears the value of [ttl][crate::model::ExpirationPolicy::ttl].
5256 ///
5257 /// # Example
5258 /// ```ignore,no_run
5259 /// # use google_cloud_pubsub::model::ExpirationPolicy;
5260 /// use wkt::Duration;
5261 /// let x = ExpirationPolicy::new().set_or_clear_ttl(Some(Duration::default()/* use setters */));
5262 /// let x = ExpirationPolicy::new().set_or_clear_ttl(None::<Duration>);
5263 /// ```
5264 pub fn set_or_clear_ttl<T>(mut self, v: std::option::Option<T>) -> Self
5265 where
5266 T: std::convert::Into<wkt::Duration>,
5267 {
5268 self.ttl = v.map(|x| x.into());
5269 self
5270 }
5271}
5272
5273impl wkt::message::Message for ExpirationPolicy {
5274 fn typename() -> &'static str {
5275 "type.googleapis.com/google.pubsub.v1.ExpirationPolicy"
5276 }
5277}
5278
5279/// Configuration for a push delivery endpoint.
5280#[derive(Clone, Default, PartialEq)]
5281#[non_exhaustive]
5282pub struct PushConfig {
5283 /// Optional. A URL locating the endpoint to which messages should be pushed.
5284 /// For example, a Webhook endpoint might use `<https://example.com/push>`.
5285 pub push_endpoint: std::string::String,
5286
5287 /// Optional. Endpoint configuration attributes that can be used to control
5288 /// different aspects of the message delivery.
5289 ///
5290 /// The only currently supported attribute is `x-goog-version`, which you can
5291 /// use to change the format of the pushed message. This attribute
5292 /// indicates the version of the data expected by the endpoint. This
5293 /// controls the shape of the pushed message (i.e., its fields and metadata).
5294 ///
5295 /// If not present during the `CreateSubscription` call, it will default to
5296 /// the version of the Pub/Sub API used to make such call. If not present in a
5297 /// `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
5298 /// calls will always return a valid version, even if the subscription was
5299 /// created without this attribute.
5300 ///
5301 /// The only supported values for the `x-goog-version` attribute are:
5302 ///
5303 /// * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
5304 /// * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
5305 ///
5306 /// For example:
5307 /// `attributes { "x-goog-version": "v1" }`
5308 pub attributes: std::collections::HashMap<std::string::String, std::string::String>,
5309
5310 /// An authentication method used by push endpoints to verify the source of
5311 /// push requests. This can be used with push endpoints that are private by
5312 /// default to allow requests only from the Pub/Sub system, for example.
5313 /// This field is optional and should be set only by users interested in
5314 /// authenticated push.
5315 pub authentication_method: std::option::Option<crate::model::push_config::AuthenticationMethod>,
5316
5317 /// The format of the delivered message to the push endpoint is defined by
5318 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
5319 pub wrapper: std::option::Option<crate::model::push_config::Wrapper>,
5320
5321 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5322}
5323
5324impl PushConfig {
5325 /// Creates a new default instance.
5326 pub fn new() -> Self {
5327 std::default::Default::default()
5328 }
5329
5330 /// Sets the value of [push_endpoint][crate::model::PushConfig::push_endpoint].
5331 ///
5332 /// # Example
5333 /// ```ignore,no_run
5334 /// # use google_cloud_pubsub::model::PushConfig;
5335 /// let x = PushConfig::new().set_push_endpoint("example");
5336 /// ```
5337 pub fn set_push_endpoint<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5338 self.push_endpoint = v.into();
5339 self
5340 }
5341
5342 /// Sets the value of [attributes][crate::model::PushConfig::attributes].
5343 ///
5344 /// # Example
5345 /// ```ignore,no_run
5346 /// # use google_cloud_pubsub::model::PushConfig;
5347 /// let x = PushConfig::new().set_attributes([
5348 /// ("key0", "abc"),
5349 /// ("key1", "xyz"),
5350 /// ]);
5351 /// ```
5352 pub fn set_attributes<T, K, V>(mut self, v: T) -> Self
5353 where
5354 T: std::iter::IntoIterator<Item = (K, V)>,
5355 K: std::convert::Into<std::string::String>,
5356 V: std::convert::Into<std::string::String>,
5357 {
5358 use std::iter::Iterator;
5359 self.attributes = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
5360 self
5361 }
5362
5363 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method].
5364 ///
5365 /// Note that all the setters affecting `authentication_method` are mutually
5366 /// exclusive.
5367 ///
5368 /// # Example
5369 /// ```ignore,no_run
5370 /// # use google_cloud_pubsub::model::PushConfig;
5371 /// use google_cloud_pubsub::model::push_config::OidcToken;
5372 /// let x = PushConfig::new().set_authentication_method(Some(
5373 /// google_cloud_pubsub::model::push_config::AuthenticationMethod::OidcToken(OidcToken::default().into())));
5374 /// ```
5375 pub fn set_authentication_method<
5376 T: std::convert::Into<std::option::Option<crate::model::push_config::AuthenticationMethod>>,
5377 >(
5378 mut self,
5379 v: T,
5380 ) -> Self {
5381 self.authentication_method = v.into();
5382 self
5383 }
5384
5385 /// The value of [authentication_method][crate::model::PushConfig::authentication_method]
5386 /// if it holds a `OidcToken`, `None` if the field is not set or
5387 /// holds a different branch.
5388 pub fn oidc_token(
5389 &self,
5390 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::OidcToken>> {
5391 #[allow(unreachable_patterns)]
5392 self.authentication_method.as_ref().and_then(|v| match v {
5393 crate::model::push_config::AuthenticationMethod::OidcToken(v) => {
5394 std::option::Option::Some(v)
5395 }
5396 _ => std::option::Option::None,
5397 })
5398 }
5399
5400 /// Sets the value of [authentication_method][crate::model::PushConfig::authentication_method]
5401 /// to hold a `OidcToken`.
5402 ///
5403 /// Note that all the setters affecting `authentication_method` are
5404 /// mutually exclusive.
5405 ///
5406 /// # Example
5407 /// ```ignore,no_run
5408 /// # use google_cloud_pubsub::model::PushConfig;
5409 /// use google_cloud_pubsub::model::push_config::OidcToken;
5410 /// let x = PushConfig::new().set_oidc_token(OidcToken::default()/* use setters */);
5411 /// assert!(x.oidc_token().is_some());
5412 /// ```
5413 pub fn set_oidc_token<
5414 T: std::convert::Into<std::boxed::Box<crate::model::push_config::OidcToken>>,
5415 >(
5416 mut self,
5417 v: T,
5418 ) -> Self {
5419 self.authentication_method = std::option::Option::Some(
5420 crate::model::push_config::AuthenticationMethod::OidcToken(v.into()),
5421 );
5422 self
5423 }
5424
5425 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper].
5426 ///
5427 /// Note that all the setters affecting `wrapper` are mutually
5428 /// exclusive.
5429 ///
5430 /// # Example
5431 /// ```ignore,no_run
5432 /// # use google_cloud_pubsub::model::PushConfig;
5433 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5434 /// let x = PushConfig::new().set_wrapper(Some(
5435 /// google_cloud_pubsub::model::push_config::Wrapper::PubsubWrapper(PubsubWrapper::default().into())));
5436 /// ```
5437 pub fn set_wrapper<
5438 T: std::convert::Into<std::option::Option<crate::model::push_config::Wrapper>>,
5439 >(
5440 mut self,
5441 v: T,
5442 ) -> Self {
5443 self.wrapper = v.into();
5444 self
5445 }
5446
5447 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5448 /// if it holds a `PubsubWrapper`, `None` if the field is not set or
5449 /// holds a different branch.
5450 pub fn pubsub_wrapper(
5451 &self,
5452 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::PubsubWrapper>> {
5453 #[allow(unreachable_patterns)]
5454 self.wrapper.as_ref().and_then(|v| match v {
5455 crate::model::push_config::Wrapper::PubsubWrapper(v) => std::option::Option::Some(v),
5456 _ => std::option::Option::None,
5457 })
5458 }
5459
5460 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5461 /// to hold a `PubsubWrapper`.
5462 ///
5463 /// Note that all the setters affecting `wrapper` are
5464 /// mutually exclusive.
5465 ///
5466 /// # Example
5467 /// ```ignore,no_run
5468 /// # use google_cloud_pubsub::model::PushConfig;
5469 /// use google_cloud_pubsub::model::push_config::PubsubWrapper;
5470 /// let x = PushConfig::new().set_pubsub_wrapper(PubsubWrapper::default()/* use setters */);
5471 /// assert!(x.pubsub_wrapper().is_some());
5472 /// assert!(x.no_wrapper().is_none());
5473 /// ```
5474 pub fn set_pubsub_wrapper<
5475 T: std::convert::Into<std::boxed::Box<crate::model::push_config::PubsubWrapper>>,
5476 >(
5477 mut self,
5478 v: T,
5479 ) -> Self {
5480 self.wrapper =
5481 std::option::Option::Some(crate::model::push_config::Wrapper::PubsubWrapper(v.into()));
5482 self
5483 }
5484
5485 /// The value of [wrapper][crate::model::PushConfig::wrapper]
5486 /// if it holds a `NoWrapper`, `None` if the field is not set or
5487 /// holds a different branch.
5488 pub fn no_wrapper(
5489 &self,
5490 ) -> std::option::Option<&std::boxed::Box<crate::model::push_config::NoWrapper>> {
5491 #[allow(unreachable_patterns)]
5492 self.wrapper.as_ref().and_then(|v| match v {
5493 crate::model::push_config::Wrapper::NoWrapper(v) => std::option::Option::Some(v),
5494 _ => std::option::Option::None,
5495 })
5496 }
5497
5498 /// Sets the value of [wrapper][crate::model::PushConfig::wrapper]
5499 /// to hold a `NoWrapper`.
5500 ///
5501 /// Note that all the setters affecting `wrapper` are
5502 /// mutually exclusive.
5503 ///
5504 /// # Example
5505 /// ```ignore,no_run
5506 /// # use google_cloud_pubsub::model::PushConfig;
5507 /// use google_cloud_pubsub::model::push_config::NoWrapper;
5508 /// let x = PushConfig::new().set_no_wrapper(NoWrapper::default()/* use setters */);
5509 /// assert!(x.no_wrapper().is_some());
5510 /// assert!(x.pubsub_wrapper().is_none());
5511 /// ```
5512 pub fn set_no_wrapper<
5513 T: std::convert::Into<std::boxed::Box<crate::model::push_config::NoWrapper>>,
5514 >(
5515 mut self,
5516 v: T,
5517 ) -> Self {
5518 self.wrapper =
5519 std::option::Option::Some(crate::model::push_config::Wrapper::NoWrapper(v.into()));
5520 self
5521 }
5522}
5523
5524impl wkt::message::Message for PushConfig {
5525 fn typename() -> &'static str {
5526 "type.googleapis.com/google.pubsub.v1.PushConfig"
5527 }
5528}
5529
5530/// Defines additional types related to [PushConfig].
5531pub mod push_config {
5532 #[allow(unused_imports)]
5533 use super::*;
5534
5535 /// Contains information needed for generating an
5536 /// [OpenID Connect
5537 /// token](https://developers.google.com/identity/protocols/OpenIDConnect).
5538 #[derive(Clone, Default, PartialEq)]
5539 #[non_exhaustive]
5540 pub struct OidcToken {
5541 /// Optional. [Service account
5542 /// email](https://cloud.google.com/iam/docs/service-accounts)
5543 /// used for generating the OIDC token. For more information
5544 /// on setting up authentication, see
5545 /// [Push subscriptions](https://cloud.google.com/pubsub/docs/push).
5546 pub service_account_email: std::string::String,
5547
5548 /// Optional. Audience to be used when generating OIDC token. The audience
5549 /// claim identifies the recipients that the JWT is intended for. The
5550 /// audience value is a single case-sensitive string. Having multiple values
5551 /// (array) for the audience field is not supported. More info about the OIDC
5552 /// JWT token audience here:
5553 /// <https://tools.ietf.org/html/rfc7519#section-4.1.3> Note: if not specified,
5554 /// the Push endpoint URL will be used.
5555 pub audience: std::string::String,
5556
5557 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5558 }
5559
5560 impl OidcToken {
5561 /// Creates a new default instance.
5562 pub fn new() -> Self {
5563 std::default::Default::default()
5564 }
5565
5566 /// Sets the value of [service_account_email][crate::model::push_config::OidcToken::service_account_email].
5567 ///
5568 /// # Example
5569 /// ```ignore,no_run
5570 /// # use google_cloud_pubsub::model::push_config::OidcToken;
5571 /// let x = OidcToken::new().set_service_account_email("example");
5572 /// ```
5573 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
5574 mut self,
5575 v: T,
5576 ) -> Self {
5577 self.service_account_email = v.into();
5578 self
5579 }
5580
5581 /// Sets the value of [audience][crate::model::push_config::OidcToken::audience].
5582 ///
5583 /// # Example
5584 /// ```ignore,no_run
5585 /// # use google_cloud_pubsub::model::push_config::OidcToken;
5586 /// let x = OidcToken::new().set_audience("example");
5587 /// ```
5588 pub fn set_audience<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5589 self.audience = v.into();
5590 self
5591 }
5592 }
5593
5594 impl wkt::message::Message for OidcToken {
5595 fn typename() -> &'static str {
5596 "type.googleapis.com/google.pubsub.v1.PushConfig.OidcToken"
5597 }
5598 }
5599
5600 /// The payload to the push endpoint is in the form of the JSON representation
5601 /// of a PubsubMessage
5602 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
5603 #[derive(Clone, Default, PartialEq)]
5604 #[non_exhaustive]
5605 pub struct PubsubWrapper {
5606 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5607 }
5608
5609 impl PubsubWrapper {
5610 /// Creates a new default instance.
5611 pub fn new() -> Self {
5612 std::default::Default::default()
5613 }
5614 }
5615
5616 impl wkt::message::Message for PubsubWrapper {
5617 fn typename() -> &'static str {
5618 "type.googleapis.com/google.pubsub.v1.PushConfig.PubsubWrapper"
5619 }
5620 }
5621
5622 /// Sets the `data` field as the HTTP body for delivery.
5623 #[derive(Clone, Default, PartialEq)]
5624 #[non_exhaustive]
5625 pub struct NoWrapper {
5626 /// Optional. When true, writes the Pub/Sub message metadata to
5627 /// `x-goog-pubsub-<KEY>:<VAL>` headers of the HTTP request. Writes the
5628 /// Pub/Sub message attributes to `<KEY>:<VAL>` headers of the HTTP request.
5629 pub write_metadata: bool,
5630
5631 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5632 }
5633
5634 impl NoWrapper {
5635 /// Creates a new default instance.
5636 pub fn new() -> Self {
5637 std::default::Default::default()
5638 }
5639
5640 /// Sets the value of [write_metadata][crate::model::push_config::NoWrapper::write_metadata].
5641 ///
5642 /// # Example
5643 /// ```ignore,no_run
5644 /// # use google_cloud_pubsub::model::push_config::NoWrapper;
5645 /// let x = NoWrapper::new().set_write_metadata(true);
5646 /// ```
5647 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5648 self.write_metadata = v.into();
5649 self
5650 }
5651 }
5652
5653 impl wkt::message::Message for NoWrapper {
5654 fn typename() -> &'static str {
5655 "type.googleapis.com/google.pubsub.v1.PushConfig.NoWrapper"
5656 }
5657 }
5658
5659 /// An authentication method used by push endpoints to verify the source of
5660 /// push requests. This can be used with push endpoints that are private by
5661 /// default to allow requests only from the Pub/Sub system, for example.
5662 /// This field is optional and should be set only by users interested in
5663 /// authenticated push.
5664 #[derive(Clone, Debug, PartialEq)]
5665 #[non_exhaustive]
5666 pub enum AuthenticationMethod {
5667 /// Optional. If specified, Pub/Sub will generate and attach an OIDC JWT
5668 /// token as an `Authorization` header in the HTTP request for every pushed
5669 /// message.
5670 OidcToken(std::boxed::Box<crate::model::push_config::OidcToken>),
5671 }
5672
5673 /// The format of the delivered message to the push endpoint is defined by
5674 /// the chosen wrapper. When unset, `PubsubWrapper` is used.
5675 #[derive(Clone, Debug, PartialEq)]
5676 #[non_exhaustive]
5677 pub enum Wrapper {
5678 /// Optional. When set, the payload to the push endpoint is in the form of
5679 /// the JSON representation of a PubsubMessage
5680 /// (<https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage>).
5681 PubsubWrapper(std::boxed::Box<crate::model::push_config::PubsubWrapper>),
5682 /// Optional. When set, the payload to the push endpoint is not wrapped.
5683 NoWrapper(std::boxed::Box<crate::model::push_config::NoWrapper>),
5684 }
5685}
5686
5687/// Configuration for a BigQuery subscription.
5688#[derive(Clone, Default, PartialEq)]
5689#[non_exhaustive]
5690pub struct BigQueryConfig {
5691 /// Optional. The name of the table to which to write data, of the form
5692 /// {projectId}.{datasetId}.{tableId}
5693 pub table: std::string::String,
5694
5695 /// Optional. When true, use the topic's schema as the columns to write to in
5696 /// BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be
5697 /// enabled at the same time.
5698 pub use_topic_schema: bool,
5699
5700 /// Optional. When true, write the subscription name, message_id, publish_time,
5701 /// attributes, and ordering_key to additional columns in the table. The
5702 /// subscription name, message_id, and publish_time fields are put in their own
5703 /// columns while all other message properties (other than data) are written to
5704 /// a JSON object in the attributes column.
5705 pub write_metadata: bool,
5706
5707 /// Optional. When true and use_topic_schema is true, any fields that are a
5708 /// part of the topic schema that are not part of the BigQuery table schema are
5709 /// dropped when writing to BigQuery. Otherwise, the schemas must be kept in
5710 /// sync and any messages with extra fields are not written and remain in the
5711 /// subscription's backlog.
5712 pub drop_unknown_fields: bool,
5713
5714 /// Output only. An output-only field that indicates whether or not the
5715 /// subscription can receive messages.
5716 pub state: crate::model::big_query_config::State,
5717
5718 /// Optional. When true, use the BigQuery table's schema as the columns to
5719 /// write to in BigQuery. `use_table_schema` and `use_topic_schema` cannot be
5720 /// enabled at the same time.
5721 pub use_table_schema: bool,
5722
5723 /// Optional. The service account to use to write to BigQuery. The subscription
5724 /// creator or updater that specifies this field must have
5725 /// `iam.serviceAccounts.actAs` permission on the service account. If not
5726 /// specified, the Pub/Sub [service
5727 /// agent](https://cloud.google.com/iam/docs/service-agents),
5728 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
5729 pub service_account_email: std::string::String,
5730
5731 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
5732}
5733
5734impl BigQueryConfig {
5735 /// Creates a new default instance.
5736 pub fn new() -> Self {
5737 std::default::Default::default()
5738 }
5739
5740 /// Sets the value of [table][crate::model::BigQueryConfig::table].
5741 ///
5742 /// # Example
5743 /// ```ignore,no_run
5744 /// # use google_cloud_pubsub::model::BigQueryConfig;
5745 /// let x = BigQueryConfig::new().set_table("example");
5746 /// ```
5747 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5748 self.table = v.into();
5749 self
5750 }
5751
5752 /// Sets the value of [use_topic_schema][crate::model::BigQueryConfig::use_topic_schema].
5753 ///
5754 /// # Example
5755 /// ```ignore,no_run
5756 /// # use google_cloud_pubsub::model::BigQueryConfig;
5757 /// let x = BigQueryConfig::new().set_use_topic_schema(true);
5758 /// ```
5759 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5760 self.use_topic_schema = v.into();
5761 self
5762 }
5763
5764 /// Sets the value of [write_metadata][crate::model::BigQueryConfig::write_metadata].
5765 ///
5766 /// # Example
5767 /// ```ignore,no_run
5768 /// # use google_cloud_pubsub::model::BigQueryConfig;
5769 /// let x = BigQueryConfig::new().set_write_metadata(true);
5770 /// ```
5771 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5772 self.write_metadata = v.into();
5773 self
5774 }
5775
5776 /// Sets the value of [drop_unknown_fields][crate::model::BigQueryConfig::drop_unknown_fields].
5777 ///
5778 /// # Example
5779 /// ```ignore,no_run
5780 /// # use google_cloud_pubsub::model::BigQueryConfig;
5781 /// let x = BigQueryConfig::new().set_drop_unknown_fields(true);
5782 /// ```
5783 pub fn set_drop_unknown_fields<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5784 self.drop_unknown_fields = v.into();
5785 self
5786 }
5787
5788 /// Sets the value of [state][crate::model::BigQueryConfig::state].
5789 ///
5790 /// # Example
5791 /// ```ignore,no_run
5792 /// # use google_cloud_pubsub::model::BigQueryConfig;
5793 /// use google_cloud_pubsub::model::big_query_config::State;
5794 /// let x0 = BigQueryConfig::new().set_state(State::Active);
5795 /// let x1 = BigQueryConfig::new().set_state(State::PermissionDenied);
5796 /// let x2 = BigQueryConfig::new().set_state(State::NotFound);
5797 /// ```
5798 pub fn set_state<T: std::convert::Into<crate::model::big_query_config::State>>(
5799 mut self,
5800 v: T,
5801 ) -> Self {
5802 self.state = v.into();
5803 self
5804 }
5805
5806 /// Sets the value of [use_table_schema][crate::model::BigQueryConfig::use_table_schema].
5807 ///
5808 /// # Example
5809 /// ```ignore,no_run
5810 /// # use google_cloud_pubsub::model::BigQueryConfig;
5811 /// let x = BigQueryConfig::new().set_use_table_schema(true);
5812 /// ```
5813 pub fn set_use_table_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
5814 self.use_table_schema = v.into();
5815 self
5816 }
5817
5818 /// Sets the value of [service_account_email][crate::model::BigQueryConfig::service_account_email].
5819 ///
5820 /// # Example
5821 /// ```ignore,no_run
5822 /// # use google_cloud_pubsub::model::BigQueryConfig;
5823 /// let x = BigQueryConfig::new().set_service_account_email("example");
5824 /// ```
5825 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
5826 mut self,
5827 v: T,
5828 ) -> Self {
5829 self.service_account_email = v.into();
5830 self
5831 }
5832}
5833
5834impl wkt::message::Message for BigQueryConfig {
5835 fn typename() -> &'static str {
5836 "type.googleapis.com/google.pubsub.v1.BigQueryConfig"
5837 }
5838}
5839
5840/// Defines additional types related to [BigQueryConfig].
5841pub mod big_query_config {
5842 #[allow(unused_imports)]
5843 use super::*;
5844
5845 /// Possible states for a BigQuery subscription.
5846 ///
5847 /// # Working with unknown values
5848 ///
5849 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5850 /// additional enum variants at any time. Adding new variants is not considered
5851 /// a breaking change. Applications should write their code in anticipation of:
5852 ///
5853 /// - New values appearing in future releases of the client library, **and**
5854 /// - New values received dynamically, without application changes.
5855 ///
5856 /// Please consult the [Working with enums] section in the user guide for some
5857 /// guidelines.
5858 ///
5859 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5860 #[derive(Clone, Debug, PartialEq)]
5861 #[non_exhaustive]
5862 pub enum State {
5863 /// Default value. This value is unused.
5864 Unspecified,
5865 /// The subscription can actively send messages to BigQuery
5866 Active,
5867 /// Cannot write to the BigQuery table because of permission denied errors.
5868 /// This can happen if
5869 ///
5870 /// - Pub/Sub SA has not been granted the [appropriate BigQuery IAM
5871 /// permissions](https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account)
5872 /// - bigquery.googleapis.com API is not enabled for the project
5873 /// ([instructions](https://cloud.google.com/service-usage/docs/enable-disable))
5874 PermissionDenied,
5875 /// Cannot write to the BigQuery table because it does not exist.
5876 NotFound,
5877 /// Cannot write to the BigQuery table due to a schema mismatch.
5878 SchemaMismatch,
5879 /// Cannot write to the destination because enforce_in_transit is set to true
5880 /// and the destination locations are not in the allowed regions.
5881 InTransitLocationRestriction,
5882 /// Cannot write to the BigQuery table because the table is not in the same
5883 /// location as where Vertex AI models used in `message_transform`s are
5884 /// deployed.
5885 VertexAiLocationRestriction,
5886 /// If set, the enum was initialized with an unknown value.
5887 ///
5888 /// Applications can examine the value using [State::value] or
5889 /// [State::name].
5890 UnknownValue(state::UnknownValue),
5891 }
5892
5893 #[doc(hidden)]
5894 pub mod state {
5895 #[allow(unused_imports)]
5896 use super::*;
5897 #[derive(Clone, Debug, PartialEq)]
5898 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5899 }
5900
5901 impl State {
5902 /// Gets the enum value.
5903 ///
5904 /// Returns `None` if the enum contains an unknown value deserialized from
5905 /// the string representation of enums.
5906 pub fn value(&self) -> std::option::Option<i32> {
5907 match self {
5908 Self::Unspecified => std::option::Option::Some(0),
5909 Self::Active => std::option::Option::Some(1),
5910 Self::PermissionDenied => std::option::Option::Some(2),
5911 Self::NotFound => std::option::Option::Some(3),
5912 Self::SchemaMismatch => std::option::Option::Some(4),
5913 Self::InTransitLocationRestriction => std::option::Option::Some(5),
5914 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
5915 Self::UnknownValue(u) => u.0.value(),
5916 }
5917 }
5918
5919 /// Gets the enum value as a string.
5920 ///
5921 /// Returns `None` if the enum contains an unknown value deserialized from
5922 /// the integer representation of enums.
5923 pub fn name(&self) -> std::option::Option<&str> {
5924 match self {
5925 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
5926 Self::Active => std::option::Option::Some("ACTIVE"),
5927 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
5928 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
5929 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
5930 Self::InTransitLocationRestriction => {
5931 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
5932 }
5933 Self::VertexAiLocationRestriction => {
5934 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
5935 }
5936 Self::UnknownValue(u) => u.0.name(),
5937 }
5938 }
5939 }
5940
5941 impl std::default::Default for State {
5942 fn default() -> Self {
5943 use std::convert::From;
5944 Self::from(0)
5945 }
5946 }
5947
5948 impl std::fmt::Display for State {
5949 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5950 wkt::internal::display_enum(f, self.name(), self.value())
5951 }
5952 }
5953
5954 impl std::convert::From<i32> for State {
5955 fn from(value: i32) -> Self {
5956 match value {
5957 0 => Self::Unspecified,
5958 1 => Self::Active,
5959 2 => Self::PermissionDenied,
5960 3 => Self::NotFound,
5961 4 => Self::SchemaMismatch,
5962 5 => Self::InTransitLocationRestriction,
5963 6 => Self::VertexAiLocationRestriction,
5964 _ => Self::UnknownValue(state::UnknownValue(
5965 wkt::internal::UnknownEnumValue::Integer(value),
5966 )),
5967 }
5968 }
5969 }
5970
5971 impl std::convert::From<&str> for State {
5972 fn from(value: &str) -> Self {
5973 use std::string::ToString;
5974 match value {
5975 "STATE_UNSPECIFIED" => Self::Unspecified,
5976 "ACTIVE" => Self::Active,
5977 "PERMISSION_DENIED" => Self::PermissionDenied,
5978 "NOT_FOUND" => Self::NotFound,
5979 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
5980 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
5981 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
5982 _ => Self::UnknownValue(state::UnknownValue(
5983 wkt::internal::UnknownEnumValue::String(value.to_string()),
5984 )),
5985 }
5986 }
5987 }
5988
5989 impl serde::ser::Serialize for State {
5990 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5991 where
5992 S: serde::Serializer,
5993 {
5994 match self {
5995 Self::Unspecified => serializer.serialize_i32(0),
5996 Self::Active => serializer.serialize_i32(1),
5997 Self::PermissionDenied => serializer.serialize_i32(2),
5998 Self::NotFound => serializer.serialize_i32(3),
5999 Self::SchemaMismatch => serializer.serialize_i32(4),
6000 Self::InTransitLocationRestriction => serializer.serialize_i32(5),
6001 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
6002 Self::UnknownValue(u) => u.0.serialize(serializer),
6003 }
6004 }
6005 }
6006
6007 impl<'de> serde::de::Deserialize<'de> for State {
6008 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6009 where
6010 D: serde::Deserializer<'de>,
6011 {
6012 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6013 ".google.pubsub.v1.BigQueryConfig.State",
6014 ))
6015 }
6016 }
6017}
6018
6019/// Configuration for a Bigtable subscription. The Pub/Sub message will be
6020/// written to a Bigtable row as follows:
6021///
6022/// - row key: subscription name and message ID delimited by #.
6023/// - columns: message bytes written to a single column family "data" with an
6024/// empty-string column qualifier.
6025/// - cell timestamp: the message publish timestamp.
6026#[derive(Clone, Default, PartialEq)]
6027#[non_exhaustive]
6028pub struct BigtableConfig {
6029 /// Optional. The unique name of the table to write messages to.
6030 ///
6031 /// Values are of the form
6032 /// `projects/<project>/instances/<instance>/tables/<table>`.
6033 pub table: std::string::String,
6034
6035 /// Optional. The app profile to use for the Bigtable writes. If not specified,
6036 /// the "default" application profile will be used. The app profile must use
6037 /// single-cluster routing.
6038 pub app_profile_id: std::string::String,
6039
6040 /// Optional. The service account to use to write to Bigtable. The subscription
6041 /// creator or updater that specifies this field must have
6042 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6043 /// specified, the Pub/Sub [service
6044 /// agent](https://cloud.google.com/iam/docs/service-agents),
6045 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6046 pub service_account_email: std::string::String,
6047
6048 /// Optional. When true, write the subscription name, message_id, publish_time,
6049 /// attributes, and ordering_key to additional columns in the table under the
6050 /// pubsub_metadata column family. The subscription name, message_id, and
6051 /// publish_time fields are put in their own columns while all other message
6052 /// properties (other than data) are written to a JSON object in the attributes
6053 /// column.
6054 pub write_metadata: bool,
6055
6056 /// Output only. An output-only field that indicates whether or not the
6057 /// subscription can receive messages.
6058 pub state: crate::model::bigtable_config::State,
6059
6060 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6061}
6062
6063impl BigtableConfig {
6064 /// Creates a new default instance.
6065 pub fn new() -> Self {
6066 std::default::Default::default()
6067 }
6068
6069 /// Sets the value of [table][crate::model::BigtableConfig::table].
6070 ///
6071 /// # Example
6072 /// ```ignore,no_run
6073 /// # use google_cloud_pubsub::model::BigtableConfig;
6074 /// let x = BigtableConfig::new().set_table("example");
6075 /// ```
6076 pub fn set_table<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6077 self.table = v.into();
6078 self
6079 }
6080
6081 /// Sets the value of [app_profile_id][crate::model::BigtableConfig::app_profile_id].
6082 ///
6083 /// # Example
6084 /// ```ignore,no_run
6085 /// # use google_cloud_pubsub::model::BigtableConfig;
6086 /// let x = BigtableConfig::new().set_app_profile_id("example");
6087 /// ```
6088 pub fn set_app_profile_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6089 self.app_profile_id = v.into();
6090 self
6091 }
6092
6093 /// Sets the value of [service_account_email][crate::model::BigtableConfig::service_account_email].
6094 ///
6095 /// # Example
6096 /// ```ignore,no_run
6097 /// # use google_cloud_pubsub::model::BigtableConfig;
6098 /// let x = BigtableConfig::new().set_service_account_email("example");
6099 /// ```
6100 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6101 mut self,
6102 v: T,
6103 ) -> Self {
6104 self.service_account_email = v.into();
6105 self
6106 }
6107
6108 /// Sets the value of [write_metadata][crate::model::BigtableConfig::write_metadata].
6109 ///
6110 /// # Example
6111 /// ```ignore,no_run
6112 /// # use google_cloud_pubsub::model::BigtableConfig;
6113 /// let x = BigtableConfig::new().set_write_metadata(true);
6114 /// ```
6115 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6116 self.write_metadata = v.into();
6117 self
6118 }
6119
6120 /// Sets the value of [state][crate::model::BigtableConfig::state].
6121 ///
6122 /// # Example
6123 /// ```ignore,no_run
6124 /// # use google_cloud_pubsub::model::BigtableConfig;
6125 /// use google_cloud_pubsub::model::bigtable_config::State;
6126 /// let x0 = BigtableConfig::new().set_state(State::Active);
6127 /// let x1 = BigtableConfig::new().set_state(State::NotFound);
6128 /// let x2 = BigtableConfig::new().set_state(State::AppProfileMisconfigured);
6129 /// ```
6130 pub fn set_state<T: std::convert::Into<crate::model::bigtable_config::State>>(
6131 mut self,
6132 v: T,
6133 ) -> Self {
6134 self.state = v.into();
6135 self
6136 }
6137}
6138
6139impl wkt::message::Message for BigtableConfig {
6140 fn typename() -> &'static str {
6141 "type.googleapis.com/google.pubsub.v1.BigtableConfig"
6142 }
6143}
6144
6145/// Defines additional types related to [BigtableConfig].
6146pub mod bigtable_config {
6147 #[allow(unused_imports)]
6148 use super::*;
6149
6150 /// Possible states for a Bigtable subscription.
6151 /// Note: more states could be added in the future. Please code accordingly.
6152 ///
6153 /// # Working with unknown values
6154 ///
6155 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6156 /// additional enum variants at any time. Adding new variants is not considered
6157 /// a breaking change. Applications should write their code in anticipation of:
6158 ///
6159 /// - New values appearing in future releases of the client library, **and**
6160 /// - New values received dynamically, without application changes.
6161 ///
6162 /// Please consult the [Working with enums] section in the user guide for some
6163 /// guidelines.
6164 ///
6165 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6166 #[derive(Clone, Debug, PartialEq)]
6167 #[non_exhaustive]
6168 pub enum State {
6169 /// Default value. This value is unused.
6170 Unspecified,
6171 /// The subscription can actively send messages to Bigtable.
6172 Active,
6173 /// Cannot write to Bigtable because the instance, table, or app profile
6174 /// does not exist.
6175 NotFound,
6176 /// Cannot write to Bigtable because the app profile is not configured for
6177 /// single-cluster routing.
6178 AppProfileMisconfigured,
6179 /// Cannot write to Bigtable because of permission denied errors.
6180 /// This can happen if:
6181 ///
6182 /// - The Pub/Sub service agent has not been granted the
6183 /// [appropriate Bigtable IAM permission
6184 /// bigtable.tables.mutateRows]({$universe.dns_names.final_documentation_domain}/bigtable/docs/access-control#permissions)
6185 /// - The bigtable.googleapis.com API is not enabled for the project
6186 /// ([instructions]({$universe.dns_names.final_documentation_domain}/service-usage/docs/enable-disable))
6187 PermissionDenied,
6188 /// Cannot write to Bigtable because of a missing column family ("data") or
6189 /// if there is no structured row key for the subscription name + message ID.
6190 SchemaMismatch,
6191 /// Cannot write to the destination because enforce_in_transit is set to true
6192 /// and the destination locations are not in the allowed regions.
6193 InTransitLocationRestriction,
6194 /// Cannot write to Bigtable because the table is not in the same location as
6195 /// where Vertex AI models used in `message_transform`s are deployed.
6196 VertexAiLocationRestriction,
6197 /// If set, the enum was initialized with an unknown value.
6198 ///
6199 /// Applications can examine the value using [State::value] or
6200 /// [State::name].
6201 UnknownValue(state::UnknownValue),
6202 }
6203
6204 #[doc(hidden)]
6205 pub mod state {
6206 #[allow(unused_imports)]
6207 use super::*;
6208 #[derive(Clone, Debug, PartialEq)]
6209 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6210 }
6211
6212 impl State {
6213 /// Gets the enum value.
6214 ///
6215 /// Returns `None` if the enum contains an unknown value deserialized from
6216 /// the string representation of enums.
6217 pub fn value(&self) -> std::option::Option<i32> {
6218 match self {
6219 Self::Unspecified => std::option::Option::Some(0),
6220 Self::Active => std::option::Option::Some(1),
6221 Self::NotFound => std::option::Option::Some(2),
6222 Self::AppProfileMisconfigured => std::option::Option::Some(3),
6223 Self::PermissionDenied => std::option::Option::Some(4),
6224 Self::SchemaMismatch => std::option::Option::Some(5),
6225 Self::InTransitLocationRestriction => std::option::Option::Some(6),
6226 Self::VertexAiLocationRestriction => std::option::Option::Some(7),
6227 Self::UnknownValue(u) => u.0.value(),
6228 }
6229 }
6230
6231 /// Gets the enum value as a string.
6232 ///
6233 /// Returns `None` if the enum contains an unknown value deserialized from
6234 /// the integer representation of enums.
6235 pub fn name(&self) -> std::option::Option<&str> {
6236 match self {
6237 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6238 Self::Active => std::option::Option::Some("ACTIVE"),
6239 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6240 Self::AppProfileMisconfigured => {
6241 std::option::Option::Some("APP_PROFILE_MISCONFIGURED")
6242 }
6243 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6244 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6245 Self::InTransitLocationRestriction => {
6246 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6247 }
6248 Self::VertexAiLocationRestriction => {
6249 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6250 }
6251 Self::UnknownValue(u) => u.0.name(),
6252 }
6253 }
6254 }
6255
6256 impl std::default::Default for State {
6257 fn default() -> Self {
6258 use std::convert::From;
6259 Self::from(0)
6260 }
6261 }
6262
6263 impl std::fmt::Display for State {
6264 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6265 wkt::internal::display_enum(f, self.name(), self.value())
6266 }
6267 }
6268
6269 impl std::convert::From<i32> for State {
6270 fn from(value: i32) -> Self {
6271 match value {
6272 0 => Self::Unspecified,
6273 1 => Self::Active,
6274 2 => Self::NotFound,
6275 3 => Self::AppProfileMisconfigured,
6276 4 => Self::PermissionDenied,
6277 5 => Self::SchemaMismatch,
6278 6 => Self::InTransitLocationRestriction,
6279 7 => Self::VertexAiLocationRestriction,
6280 _ => Self::UnknownValue(state::UnknownValue(
6281 wkt::internal::UnknownEnumValue::Integer(value),
6282 )),
6283 }
6284 }
6285 }
6286
6287 impl std::convert::From<&str> for State {
6288 fn from(value: &str) -> Self {
6289 use std::string::ToString;
6290 match value {
6291 "STATE_UNSPECIFIED" => Self::Unspecified,
6292 "ACTIVE" => Self::Active,
6293 "NOT_FOUND" => Self::NotFound,
6294 "APP_PROFILE_MISCONFIGURED" => Self::AppProfileMisconfigured,
6295 "PERMISSION_DENIED" => Self::PermissionDenied,
6296 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6297 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6298 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6299 _ => Self::UnknownValue(state::UnknownValue(
6300 wkt::internal::UnknownEnumValue::String(value.to_string()),
6301 )),
6302 }
6303 }
6304 }
6305
6306 impl serde::ser::Serialize for State {
6307 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6308 where
6309 S: serde::Serializer,
6310 {
6311 match self {
6312 Self::Unspecified => serializer.serialize_i32(0),
6313 Self::Active => serializer.serialize_i32(1),
6314 Self::NotFound => serializer.serialize_i32(2),
6315 Self::AppProfileMisconfigured => serializer.serialize_i32(3),
6316 Self::PermissionDenied => serializer.serialize_i32(4),
6317 Self::SchemaMismatch => serializer.serialize_i32(5),
6318 Self::InTransitLocationRestriction => serializer.serialize_i32(6),
6319 Self::VertexAiLocationRestriction => serializer.serialize_i32(7),
6320 Self::UnknownValue(u) => u.0.serialize(serializer),
6321 }
6322 }
6323 }
6324
6325 impl<'de> serde::de::Deserialize<'de> for State {
6326 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6327 where
6328 D: serde::Deserializer<'de>,
6329 {
6330 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6331 ".google.pubsub.v1.BigtableConfig.State",
6332 ))
6333 }
6334 }
6335}
6336
6337/// Configuration for a Cloud Storage subscription.
6338#[derive(Clone, Default, PartialEq)]
6339#[non_exhaustive]
6340pub struct CloudStorageConfig {
6341 /// Required. User-provided name for the Cloud Storage bucket.
6342 /// The bucket must be created by the user. The bucket name must be without
6343 /// any prefix like "gs://". See the [bucket naming
6344 /// requirements] (<https://cloud.google.com/storage/docs/buckets#naming>).
6345 pub bucket: std::string::String,
6346
6347 /// Optional. User-provided prefix for Cloud Storage filename. See the [object
6348 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6349 pub filename_prefix: std::string::String,
6350
6351 /// Optional. User-provided suffix for Cloud Storage filename. See the [object
6352 /// naming requirements](https://cloud.google.com/storage/docs/objects#naming).
6353 /// Must not end in "/".
6354 pub filename_suffix: std::string::String,
6355
6356 /// Optional. User-provided format string specifying how to represent datetimes
6357 /// in Cloud Storage filenames. See the [datetime format
6358 /// guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
6359 pub filename_datetime_format: std::string::String,
6360
6361 /// Optional. The maximum duration that can elapse before a new Cloud Storage
6362 /// file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not
6363 /// exceed the subscription's acknowledgment deadline.
6364 pub max_duration: std::option::Option<wkt::Duration>,
6365
6366 /// Optional. The maximum bytes that can be written to a Cloud Storage file
6367 /// before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may
6368 /// be exceeded in cases where messages are larger than the limit.
6369 pub max_bytes: i64,
6370
6371 /// Optional. The maximum number of messages that can be written to a Cloud
6372 /// Storage file before a new file is created. Min 1000 messages.
6373 pub max_messages: i64,
6374
6375 /// Output only. An output-only field that indicates whether or not the
6376 /// subscription can receive messages.
6377 pub state: crate::model::cloud_storage_config::State,
6378
6379 /// Optional. The service account to use to write to Cloud Storage. The
6380 /// subscription creator or updater that specifies this field must have
6381 /// `iam.serviceAccounts.actAs` permission on the service account. If not
6382 /// specified, the Pub/Sub
6383 /// [service agent](https://cloud.google.com/iam/docs/service-agents),
6384 /// service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.
6385 pub service_account_email: std::string::String,
6386
6387 /// Defaults to text format.
6388 pub output_format: std::option::Option<crate::model::cloud_storage_config::OutputFormat>,
6389
6390 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6391}
6392
6393impl CloudStorageConfig {
6394 /// Creates a new default instance.
6395 pub fn new() -> Self {
6396 std::default::Default::default()
6397 }
6398
6399 /// Sets the value of [bucket][crate::model::CloudStorageConfig::bucket].
6400 ///
6401 /// # Example
6402 /// ```ignore,no_run
6403 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6404 /// let x = CloudStorageConfig::new().set_bucket("example");
6405 /// ```
6406 pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6407 self.bucket = v.into();
6408 self
6409 }
6410
6411 /// Sets the value of [filename_prefix][crate::model::CloudStorageConfig::filename_prefix].
6412 ///
6413 /// # Example
6414 /// ```ignore,no_run
6415 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6416 /// let x = CloudStorageConfig::new().set_filename_prefix("example");
6417 /// ```
6418 pub fn set_filename_prefix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6419 self.filename_prefix = v.into();
6420 self
6421 }
6422
6423 /// Sets the value of [filename_suffix][crate::model::CloudStorageConfig::filename_suffix].
6424 ///
6425 /// # Example
6426 /// ```ignore,no_run
6427 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6428 /// let x = CloudStorageConfig::new().set_filename_suffix("example");
6429 /// ```
6430 pub fn set_filename_suffix<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6431 self.filename_suffix = v.into();
6432 self
6433 }
6434
6435 /// Sets the value of [filename_datetime_format][crate::model::CloudStorageConfig::filename_datetime_format].
6436 ///
6437 /// # Example
6438 /// ```ignore,no_run
6439 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6440 /// let x = CloudStorageConfig::new().set_filename_datetime_format("example");
6441 /// ```
6442 pub fn set_filename_datetime_format<T: std::convert::Into<std::string::String>>(
6443 mut self,
6444 v: T,
6445 ) -> Self {
6446 self.filename_datetime_format = v.into();
6447 self
6448 }
6449
6450 /// Sets the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6451 ///
6452 /// # Example
6453 /// ```ignore,no_run
6454 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6455 /// use wkt::Duration;
6456 /// let x = CloudStorageConfig::new().set_max_duration(Duration::default()/* use setters */);
6457 /// ```
6458 pub fn set_max_duration<T>(mut self, v: T) -> Self
6459 where
6460 T: std::convert::Into<wkt::Duration>,
6461 {
6462 self.max_duration = std::option::Option::Some(v.into());
6463 self
6464 }
6465
6466 /// Sets or clears the value of [max_duration][crate::model::CloudStorageConfig::max_duration].
6467 ///
6468 /// # Example
6469 /// ```ignore,no_run
6470 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6471 /// use wkt::Duration;
6472 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(Some(Duration::default()/* use setters */));
6473 /// let x = CloudStorageConfig::new().set_or_clear_max_duration(None::<Duration>);
6474 /// ```
6475 pub fn set_or_clear_max_duration<T>(mut self, v: std::option::Option<T>) -> Self
6476 where
6477 T: std::convert::Into<wkt::Duration>,
6478 {
6479 self.max_duration = v.map(|x| x.into());
6480 self
6481 }
6482
6483 /// Sets the value of [max_bytes][crate::model::CloudStorageConfig::max_bytes].
6484 ///
6485 /// # Example
6486 /// ```ignore,no_run
6487 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6488 /// let x = CloudStorageConfig::new().set_max_bytes(42);
6489 /// ```
6490 pub fn set_max_bytes<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6491 self.max_bytes = v.into();
6492 self
6493 }
6494
6495 /// Sets the value of [max_messages][crate::model::CloudStorageConfig::max_messages].
6496 ///
6497 /// # Example
6498 /// ```ignore,no_run
6499 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6500 /// let x = CloudStorageConfig::new().set_max_messages(42);
6501 /// ```
6502 pub fn set_max_messages<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
6503 self.max_messages = v.into();
6504 self
6505 }
6506
6507 /// Sets the value of [state][crate::model::CloudStorageConfig::state].
6508 ///
6509 /// # Example
6510 /// ```ignore,no_run
6511 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6512 /// use google_cloud_pubsub::model::cloud_storage_config::State;
6513 /// let x0 = CloudStorageConfig::new().set_state(State::Active);
6514 /// let x1 = CloudStorageConfig::new().set_state(State::PermissionDenied);
6515 /// let x2 = CloudStorageConfig::new().set_state(State::NotFound);
6516 /// ```
6517 pub fn set_state<T: std::convert::Into<crate::model::cloud_storage_config::State>>(
6518 mut self,
6519 v: T,
6520 ) -> Self {
6521 self.state = v.into();
6522 self
6523 }
6524
6525 /// Sets the value of [service_account_email][crate::model::CloudStorageConfig::service_account_email].
6526 ///
6527 /// # Example
6528 /// ```ignore,no_run
6529 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6530 /// let x = CloudStorageConfig::new().set_service_account_email("example");
6531 /// ```
6532 pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
6533 mut self,
6534 v: T,
6535 ) -> Self {
6536 self.service_account_email = v.into();
6537 self
6538 }
6539
6540 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format].
6541 ///
6542 /// Note that all the setters affecting `output_format` are mutually
6543 /// exclusive.
6544 ///
6545 /// # Example
6546 /// ```ignore,no_run
6547 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6548 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
6549 /// let x = CloudStorageConfig::new().set_output_format(Some(
6550 /// google_cloud_pubsub::model::cloud_storage_config::OutputFormat::TextConfig(TextConfig::default().into())));
6551 /// ```
6552 pub fn set_output_format<
6553 T: std::convert::Into<std::option::Option<crate::model::cloud_storage_config::OutputFormat>>,
6554 >(
6555 mut self,
6556 v: T,
6557 ) -> Self {
6558 self.output_format = v.into();
6559 self
6560 }
6561
6562 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
6563 /// if it holds a `TextConfig`, `None` if the field is not set or
6564 /// holds a different branch.
6565 pub fn text_config(
6566 &self,
6567 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::TextConfig>> {
6568 #[allow(unreachable_patterns)]
6569 self.output_format.as_ref().and_then(|v| match v {
6570 crate::model::cloud_storage_config::OutputFormat::TextConfig(v) => {
6571 std::option::Option::Some(v)
6572 }
6573 _ => std::option::Option::None,
6574 })
6575 }
6576
6577 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
6578 /// to hold a `TextConfig`.
6579 ///
6580 /// Note that all the setters affecting `output_format` are
6581 /// mutually exclusive.
6582 ///
6583 /// # Example
6584 /// ```ignore,no_run
6585 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6586 /// use google_cloud_pubsub::model::cloud_storage_config::TextConfig;
6587 /// let x = CloudStorageConfig::new().set_text_config(TextConfig::default()/* use setters */);
6588 /// assert!(x.text_config().is_some());
6589 /// assert!(x.avro_config().is_none());
6590 /// ```
6591 pub fn set_text_config<
6592 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::TextConfig>>,
6593 >(
6594 mut self,
6595 v: T,
6596 ) -> Self {
6597 self.output_format = std::option::Option::Some(
6598 crate::model::cloud_storage_config::OutputFormat::TextConfig(v.into()),
6599 );
6600 self
6601 }
6602
6603 /// The value of [output_format][crate::model::CloudStorageConfig::output_format]
6604 /// if it holds a `AvroConfig`, `None` if the field is not set or
6605 /// holds a different branch.
6606 pub fn avro_config(
6607 &self,
6608 ) -> std::option::Option<&std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>> {
6609 #[allow(unreachable_patterns)]
6610 self.output_format.as_ref().and_then(|v| match v {
6611 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v) => {
6612 std::option::Option::Some(v)
6613 }
6614 _ => std::option::Option::None,
6615 })
6616 }
6617
6618 /// Sets the value of [output_format][crate::model::CloudStorageConfig::output_format]
6619 /// to hold a `AvroConfig`.
6620 ///
6621 /// Note that all the setters affecting `output_format` are
6622 /// mutually exclusive.
6623 ///
6624 /// # Example
6625 /// ```ignore,no_run
6626 /// # use google_cloud_pubsub::model::CloudStorageConfig;
6627 /// use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6628 /// let x = CloudStorageConfig::new().set_avro_config(AvroConfig::default()/* use setters */);
6629 /// assert!(x.avro_config().is_some());
6630 /// assert!(x.text_config().is_none());
6631 /// ```
6632 pub fn set_avro_config<
6633 T: std::convert::Into<std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>>,
6634 >(
6635 mut self,
6636 v: T,
6637 ) -> Self {
6638 self.output_format = std::option::Option::Some(
6639 crate::model::cloud_storage_config::OutputFormat::AvroConfig(v.into()),
6640 );
6641 self
6642 }
6643}
6644
6645impl wkt::message::Message for CloudStorageConfig {
6646 fn typename() -> &'static str {
6647 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig"
6648 }
6649}
6650
6651/// Defines additional types related to [CloudStorageConfig].
6652pub mod cloud_storage_config {
6653 #[allow(unused_imports)]
6654 use super::*;
6655
6656 /// Configuration for writing message data in text format.
6657 /// Message payloads will be written to files as raw text, separated by a
6658 /// newline.
6659 #[derive(Clone, Default, PartialEq)]
6660 #[non_exhaustive]
6661 pub struct TextConfig {
6662 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6663 }
6664
6665 impl TextConfig {
6666 /// Creates a new default instance.
6667 pub fn new() -> Self {
6668 std::default::Default::default()
6669 }
6670 }
6671
6672 impl wkt::message::Message for TextConfig {
6673 fn typename() -> &'static str {
6674 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.TextConfig"
6675 }
6676 }
6677
6678 /// Configuration for writing message data in Avro format.
6679 /// Message payloads and metadata will be written to files as an Avro binary.
6680 #[derive(Clone, Default, PartialEq)]
6681 #[non_exhaustive]
6682 pub struct AvroConfig {
6683 /// Optional. When true, write the subscription name, message_id,
6684 /// publish_time, attributes, and ordering_key as additional fields in the
6685 /// output. The subscription name, message_id, and publish_time fields are
6686 /// put in their own fields while all other message properties other than
6687 /// data (for example, an ordering_key, if present) are added as entries in
6688 /// the attributes map.
6689 pub write_metadata: bool,
6690
6691 /// Optional. When true, the output Cloud Storage file will be serialized
6692 /// using the topic schema, if it exists.
6693 pub use_topic_schema: bool,
6694
6695 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6696 }
6697
6698 impl AvroConfig {
6699 /// Creates a new default instance.
6700 pub fn new() -> Self {
6701 std::default::Default::default()
6702 }
6703
6704 /// Sets the value of [write_metadata][crate::model::cloud_storage_config::AvroConfig::write_metadata].
6705 ///
6706 /// # Example
6707 /// ```ignore,no_run
6708 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6709 /// let x = AvroConfig::new().set_write_metadata(true);
6710 /// ```
6711 pub fn set_write_metadata<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6712 self.write_metadata = v.into();
6713 self
6714 }
6715
6716 /// Sets the value of [use_topic_schema][crate::model::cloud_storage_config::AvroConfig::use_topic_schema].
6717 ///
6718 /// # Example
6719 /// ```ignore,no_run
6720 /// # use google_cloud_pubsub::model::cloud_storage_config::AvroConfig;
6721 /// let x = AvroConfig::new().set_use_topic_schema(true);
6722 /// ```
6723 pub fn set_use_topic_schema<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
6724 self.use_topic_schema = v.into();
6725 self
6726 }
6727 }
6728
6729 impl wkt::message::Message for AvroConfig {
6730 fn typename() -> &'static str {
6731 "type.googleapis.com/google.pubsub.v1.CloudStorageConfig.AvroConfig"
6732 }
6733 }
6734
6735 /// Possible states for a Cloud Storage subscription.
6736 ///
6737 /// # Working with unknown values
6738 ///
6739 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
6740 /// additional enum variants at any time. Adding new variants is not considered
6741 /// a breaking change. Applications should write their code in anticipation of:
6742 ///
6743 /// - New values appearing in future releases of the client library, **and**
6744 /// - New values received dynamically, without application changes.
6745 ///
6746 /// Please consult the [Working with enums] section in the user guide for some
6747 /// guidelines.
6748 ///
6749 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
6750 #[derive(Clone, Debug, PartialEq)]
6751 #[non_exhaustive]
6752 pub enum State {
6753 /// Default value. This value is unused.
6754 Unspecified,
6755 /// The subscription can actively send messages to Cloud Storage.
6756 Active,
6757 /// Cannot write to the Cloud Storage bucket because of permission denied
6758 /// errors.
6759 PermissionDenied,
6760 /// Cannot write to the Cloud Storage bucket because it does not exist.
6761 NotFound,
6762 /// Cannot write to the destination because enforce_in_transit is set to true
6763 /// and the destination locations are not in the allowed regions.
6764 InTransitLocationRestriction,
6765 /// Cannot write to the Cloud Storage bucket due to an incompatibility
6766 /// between the topic schema and subscription settings.
6767 SchemaMismatch,
6768 /// Cannot write to the Cloud Storage bucket because the bucket is not in the
6769 /// same location as where Vertex AI models used in `message_transform`s are
6770 /// deployed.
6771 VertexAiLocationRestriction,
6772 /// If set, the enum was initialized with an unknown value.
6773 ///
6774 /// Applications can examine the value using [State::value] or
6775 /// [State::name].
6776 UnknownValue(state::UnknownValue),
6777 }
6778
6779 #[doc(hidden)]
6780 pub mod state {
6781 #[allow(unused_imports)]
6782 use super::*;
6783 #[derive(Clone, Debug, PartialEq)]
6784 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
6785 }
6786
6787 impl State {
6788 /// Gets the enum value.
6789 ///
6790 /// Returns `None` if the enum contains an unknown value deserialized from
6791 /// the string representation of enums.
6792 pub fn value(&self) -> std::option::Option<i32> {
6793 match self {
6794 Self::Unspecified => std::option::Option::Some(0),
6795 Self::Active => std::option::Option::Some(1),
6796 Self::PermissionDenied => std::option::Option::Some(2),
6797 Self::NotFound => std::option::Option::Some(3),
6798 Self::InTransitLocationRestriction => std::option::Option::Some(4),
6799 Self::SchemaMismatch => std::option::Option::Some(5),
6800 Self::VertexAiLocationRestriction => std::option::Option::Some(6),
6801 Self::UnknownValue(u) => u.0.value(),
6802 }
6803 }
6804
6805 /// Gets the enum value as a string.
6806 ///
6807 /// Returns `None` if the enum contains an unknown value deserialized from
6808 /// the integer representation of enums.
6809 pub fn name(&self) -> std::option::Option<&str> {
6810 match self {
6811 Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
6812 Self::Active => std::option::Option::Some("ACTIVE"),
6813 Self::PermissionDenied => std::option::Option::Some("PERMISSION_DENIED"),
6814 Self::NotFound => std::option::Option::Some("NOT_FOUND"),
6815 Self::InTransitLocationRestriction => {
6816 std::option::Option::Some("IN_TRANSIT_LOCATION_RESTRICTION")
6817 }
6818 Self::SchemaMismatch => std::option::Option::Some("SCHEMA_MISMATCH"),
6819 Self::VertexAiLocationRestriction => {
6820 std::option::Option::Some("VERTEX_AI_LOCATION_RESTRICTION")
6821 }
6822 Self::UnknownValue(u) => u.0.name(),
6823 }
6824 }
6825 }
6826
6827 impl std::default::Default for State {
6828 fn default() -> Self {
6829 use std::convert::From;
6830 Self::from(0)
6831 }
6832 }
6833
6834 impl std::fmt::Display for State {
6835 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
6836 wkt::internal::display_enum(f, self.name(), self.value())
6837 }
6838 }
6839
6840 impl std::convert::From<i32> for State {
6841 fn from(value: i32) -> Self {
6842 match value {
6843 0 => Self::Unspecified,
6844 1 => Self::Active,
6845 2 => Self::PermissionDenied,
6846 3 => Self::NotFound,
6847 4 => Self::InTransitLocationRestriction,
6848 5 => Self::SchemaMismatch,
6849 6 => Self::VertexAiLocationRestriction,
6850 _ => Self::UnknownValue(state::UnknownValue(
6851 wkt::internal::UnknownEnumValue::Integer(value),
6852 )),
6853 }
6854 }
6855 }
6856
6857 impl std::convert::From<&str> for State {
6858 fn from(value: &str) -> Self {
6859 use std::string::ToString;
6860 match value {
6861 "STATE_UNSPECIFIED" => Self::Unspecified,
6862 "ACTIVE" => Self::Active,
6863 "PERMISSION_DENIED" => Self::PermissionDenied,
6864 "NOT_FOUND" => Self::NotFound,
6865 "IN_TRANSIT_LOCATION_RESTRICTION" => Self::InTransitLocationRestriction,
6866 "SCHEMA_MISMATCH" => Self::SchemaMismatch,
6867 "VERTEX_AI_LOCATION_RESTRICTION" => Self::VertexAiLocationRestriction,
6868 _ => Self::UnknownValue(state::UnknownValue(
6869 wkt::internal::UnknownEnumValue::String(value.to_string()),
6870 )),
6871 }
6872 }
6873 }
6874
6875 impl serde::ser::Serialize for State {
6876 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
6877 where
6878 S: serde::Serializer,
6879 {
6880 match self {
6881 Self::Unspecified => serializer.serialize_i32(0),
6882 Self::Active => serializer.serialize_i32(1),
6883 Self::PermissionDenied => serializer.serialize_i32(2),
6884 Self::NotFound => serializer.serialize_i32(3),
6885 Self::InTransitLocationRestriction => serializer.serialize_i32(4),
6886 Self::SchemaMismatch => serializer.serialize_i32(5),
6887 Self::VertexAiLocationRestriction => serializer.serialize_i32(6),
6888 Self::UnknownValue(u) => u.0.serialize(serializer),
6889 }
6890 }
6891 }
6892
6893 impl<'de> serde::de::Deserialize<'de> for State {
6894 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
6895 where
6896 D: serde::Deserializer<'de>,
6897 {
6898 deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
6899 ".google.pubsub.v1.CloudStorageConfig.State",
6900 ))
6901 }
6902 }
6903
6904 /// Defaults to text format.
6905 #[derive(Clone, Debug, PartialEq)]
6906 #[non_exhaustive]
6907 pub enum OutputFormat {
6908 /// Optional. If set, message data will be written to Cloud Storage in text
6909 /// format.
6910 TextConfig(std::boxed::Box<crate::model::cloud_storage_config::TextConfig>),
6911 /// Optional. If set, message data will be written to Cloud Storage in Avro
6912 /// format.
6913 AvroConfig(std::boxed::Box<crate::model::cloud_storage_config::AvroConfig>),
6914 }
6915}
6916
6917/// Request for the GetSubscription method.
6918#[derive(Clone, Default, PartialEq)]
6919#[non_exhaustive]
6920pub struct GetSubscriptionRequest {
6921 /// Required. The name of the subscription to get.
6922 /// Format is `projects/{project}/subscriptions/{sub}`.
6923 pub subscription: std::string::String,
6924
6925 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6926}
6927
6928impl GetSubscriptionRequest {
6929 /// Creates a new default instance.
6930 pub fn new() -> Self {
6931 std::default::Default::default()
6932 }
6933
6934 /// Sets the value of [subscription][crate::model::GetSubscriptionRequest::subscription].
6935 ///
6936 /// # Example
6937 /// ```ignore,no_run
6938 /// # use google_cloud_pubsub::model::GetSubscriptionRequest;
6939 /// # let project_id = "project_id";
6940 /// # let subscription_id = "subscription_id";
6941 /// let x = GetSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
6942 /// ```
6943 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
6944 self.subscription = v.into();
6945 self
6946 }
6947}
6948
6949impl wkt::message::Message for GetSubscriptionRequest {
6950 fn typename() -> &'static str {
6951 "type.googleapis.com/google.pubsub.v1.GetSubscriptionRequest"
6952 }
6953}
6954
6955/// Request for the UpdateSubscription method.
6956#[derive(Clone, Default, PartialEq)]
6957#[non_exhaustive]
6958pub struct UpdateSubscriptionRequest {
6959 /// Required. The updated subscription object.
6960 pub subscription: std::option::Option<crate::model::Subscription>,
6961
6962 /// Required. Indicates which fields in the provided subscription to update.
6963 /// Must be specified and non-empty.
6964 pub update_mask: std::option::Option<wkt::FieldMask>,
6965
6966 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
6967}
6968
6969impl UpdateSubscriptionRequest {
6970 /// Creates a new default instance.
6971 pub fn new() -> Self {
6972 std::default::Default::default()
6973 }
6974
6975 /// Sets the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
6976 ///
6977 /// # Example
6978 /// ```ignore,no_run
6979 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
6980 /// use google_cloud_pubsub::model::Subscription;
6981 /// let x = UpdateSubscriptionRequest::new().set_subscription(Subscription::default()/* use setters */);
6982 /// ```
6983 pub fn set_subscription<T>(mut self, v: T) -> Self
6984 where
6985 T: std::convert::Into<crate::model::Subscription>,
6986 {
6987 self.subscription = std::option::Option::Some(v.into());
6988 self
6989 }
6990
6991 /// Sets or clears the value of [subscription][crate::model::UpdateSubscriptionRequest::subscription].
6992 ///
6993 /// # Example
6994 /// ```ignore,no_run
6995 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
6996 /// use google_cloud_pubsub::model::Subscription;
6997 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(Some(Subscription::default()/* use setters */));
6998 /// let x = UpdateSubscriptionRequest::new().set_or_clear_subscription(None::<Subscription>);
6999 /// ```
7000 pub fn set_or_clear_subscription<T>(mut self, v: std::option::Option<T>) -> Self
7001 where
7002 T: std::convert::Into<crate::model::Subscription>,
7003 {
7004 self.subscription = v.map(|x| x.into());
7005 self
7006 }
7007
7008 /// Sets the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
7009 ///
7010 /// # Example
7011 /// ```ignore,no_run
7012 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7013 /// use wkt::FieldMask;
7014 /// let x = UpdateSubscriptionRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7015 /// ```
7016 pub fn set_update_mask<T>(mut self, v: T) -> Self
7017 where
7018 T: std::convert::Into<wkt::FieldMask>,
7019 {
7020 self.update_mask = std::option::Option::Some(v.into());
7021 self
7022 }
7023
7024 /// Sets or clears the value of [update_mask][crate::model::UpdateSubscriptionRequest::update_mask].
7025 ///
7026 /// # Example
7027 /// ```ignore,no_run
7028 /// # use google_cloud_pubsub::model::UpdateSubscriptionRequest;
7029 /// use wkt::FieldMask;
7030 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7031 /// let x = UpdateSubscriptionRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7032 /// ```
7033 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7034 where
7035 T: std::convert::Into<wkt::FieldMask>,
7036 {
7037 self.update_mask = v.map(|x| x.into());
7038 self
7039 }
7040}
7041
7042impl wkt::message::Message for UpdateSubscriptionRequest {
7043 fn typename() -> &'static str {
7044 "type.googleapis.com/google.pubsub.v1.UpdateSubscriptionRequest"
7045 }
7046}
7047
7048/// Request for the `ListSubscriptions` method.
7049#[derive(Clone, Default, PartialEq)]
7050#[non_exhaustive]
7051pub struct ListSubscriptionsRequest {
7052 /// Required. The name of the project in which to list subscriptions.
7053 /// Format is `projects/{project-id}`.
7054 pub project: std::string::String,
7055
7056 /// Optional. Maximum number of subscriptions to return.
7057 pub page_size: i32,
7058
7059 /// Optional. The value returned by the last `ListSubscriptionsResponse`;
7060 /// indicates that this is a continuation of a prior `ListSubscriptions` call,
7061 /// and that the system should return the next page of data.
7062 pub page_token: std::string::String,
7063
7064 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7065}
7066
7067impl ListSubscriptionsRequest {
7068 /// Creates a new default instance.
7069 pub fn new() -> Self {
7070 std::default::Default::default()
7071 }
7072
7073 /// Sets the value of [project][crate::model::ListSubscriptionsRequest::project].
7074 ///
7075 /// # Example
7076 /// ```ignore,no_run
7077 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7078 /// let x = ListSubscriptionsRequest::new().set_project("example");
7079 /// ```
7080 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7081 self.project = v.into();
7082 self
7083 }
7084
7085 /// Sets the value of [page_size][crate::model::ListSubscriptionsRequest::page_size].
7086 ///
7087 /// # Example
7088 /// ```ignore,no_run
7089 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7090 /// let x = ListSubscriptionsRequest::new().set_page_size(42);
7091 /// ```
7092 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7093 self.page_size = v.into();
7094 self
7095 }
7096
7097 /// Sets the value of [page_token][crate::model::ListSubscriptionsRequest::page_token].
7098 ///
7099 /// # Example
7100 /// ```ignore,no_run
7101 /// # use google_cloud_pubsub::model::ListSubscriptionsRequest;
7102 /// let x = ListSubscriptionsRequest::new().set_page_token("example");
7103 /// ```
7104 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7105 self.page_token = v.into();
7106 self
7107 }
7108}
7109
7110impl wkt::message::Message for ListSubscriptionsRequest {
7111 fn typename() -> &'static str {
7112 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsRequest"
7113 }
7114}
7115
7116/// Response for the `ListSubscriptions` method.
7117#[derive(Clone, Default, PartialEq)]
7118#[non_exhaustive]
7119pub struct ListSubscriptionsResponse {
7120 /// Optional. The subscriptions that match the request.
7121 pub subscriptions: std::vec::Vec<crate::model::Subscription>,
7122
7123 /// Optional. If not empty, indicates that there may be more subscriptions that
7124 /// match the request; this value should be passed in a new
7125 /// `ListSubscriptionsRequest` to get more subscriptions.
7126 pub next_page_token: std::string::String,
7127
7128 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7129}
7130
7131impl ListSubscriptionsResponse {
7132 /// Creates a new default instance.
7133 pub fn new() -> Self {
7134 std::default::Default::default()
7135 }
7136
7137 /// Sets the value of [subscriptions][crate::model::ListSubscriptionsResponse::subscriptions].
7138 ///
7139 /// # Example
7140 /// ```ignore,no_run
7141 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7142 /// use google_cloud_pubsub::model::Subscription;
7143 /// let x = ListSubscriptionsResponse::new()
7144 /// .set_subscriptions([
7145 /// Subscription::default()/* use setters */,
7146 /// Subscription::default()/* use (different) setters */,
7147 /// ]);
7148 /// ```
7149 pub fn set_subscriptions<T, V>(mut self, v: T) -> Self
7150 where
7151 T: std::iter::IntoIterator<Item = V>,
7152 V: std::convert::Into<crate::model::Subscription>,
7153 {
7154 use std::iter::Iterator;
7155 self.subscriptions = v.into_iter().map(|i| i.into()).collect();
7156 self
7157 }
7158
7159 /// Sets the value of [next_page_token][crate::model::ListSubscriptionsResponse::next_page_token].
7160 ///
7161 /// # Example
7162 /// ```ignore,no_run
7163 /// # use google_cloud_pubsub::model::ListSubscriptionsResponse;
7164 /// let x = ListSubscriptionsResponse::new().set_next_page_token("example");
7165 /// ```
7166 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7167 self.next_page_token = v.into();
7168 self
7169 }
7170}
7171
7172impl wkt::message::Message for ListSubscriptionsResponse {
7173 fn typename() -> &'static str {
7174 "type.googleapis.com/google.pubsub.v1.ListSubscriptionsResponse"
7175 }
7176}
7177
7178#[doc(hidden)]
7179impl google_cloud_gax::paginator::internal::PageableResponse for ListSubscriptionsResponse {
7180 type PageItem = crate::model::Subscription;
7181
7182 fn items(self) -> std::vec::Vec<Self::PageItem> {
7183 self.subscriptions
7184 }
7185
7186 fn next_page_token(&self) -> std::string::String {
7187 use std::clone::Clone;
7188 self.next_page_token.clone()
7189 }
7190}
7191
7192/// Request for the DeleteSubscription method.
7193#[derive(Clone, Default, PartialEq)]
7194#[non_exhaustive]
7195pub struct DeleteSubscriptionRequest {
7196 /// Required. The subscription to delete.
7197 /// Format is `projects/{project}/subscriptions/{sub}`.
7198 pub subscription: std::string::String,
7199
7200 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7201}
7202
7203impl DeleteSubscriptionRequest {
7204 /// Creates a new default instance.
7205 pub fn new() -> Self {
7206 std::default::Default::default()
7207 }
7208
7209 /// Sets the value of [subscription][crate::model::DeleteSubscriptionRequest::subscription].
7210 ///
7211 /// # Example
7212 /// ```ignore,no_run
7213 /// # use google_cloud_pubsub::model::DeleteSubscriptionRequest;
7214 /// # let project_id = "project_id";
7215 /// # let subscription_id = "subscription_id";
7216 /// let x = DeleteSubscriptionRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7217 /// ```
7218 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7219 self.subscription = v.into();
7220 self
7221 }
7222}
7223
7224impl wkt::message::Message for DeleteSubscriptionRequest {
7225 fn typename() -> &'static str {
7226 "type.googleapis.com/google.pubsub.v1.DeleteSubscriptionRequest"
7227 }
7228}
7229
7230/// Request for the ModifyPushConfig method.
7231#[derive(Clone, Default, PartialEq)]
7232#[non_exhaustive]
7233pub struct ModifyPushConfigRequest {
7234 /// Required. The name of the subscription.
7235 /// Format is `projects/{project}/subscriptions/{sub}`.
7236 pub subscription: std::string::String,
7237
7238 /// Required. The push configuration for future deliveries.
7239 ///
7240 /// An empty `pushConfig` indicates that the Pub/Sub system should
7241 /// stop pushing messages from the given subscription and allow
7242 /// messages to be pulled and acknowledged - effectively pausing
7243 /// the subscription if `Pull` or `StreamingPull` is not called.
7244 pub push_config: std::option::Option<crate::model::PushConfig>,
7245
7246 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7247}
7248
7249impl ModifyPushConfigRequest {
7250 /// Creates a new default instance.
7251 pub fn new() -> Self {
7252 std::default::Default::default()
7253 }
7254
7255 /// Sets the value of [subscription][crate::model::ModifyPushConfigRequest::subscription].
7256 ///
7257 /// # Example
7258 /// ```ignore,no_run
7259 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7260 /// # let project_id = "project_id";
7261 /// # let subscription_id = "subscription_id";
7262 /// let x = ModifyPushConfigRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7263 /// ```
7264 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7265 self.subscription = v.into();
7266 self
7267 }
7268
7269 /// Sets the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7270 ///
7271 /// # Example
7272 /// ```ignore,no_run
7273 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7274 /// use google_cloud_pubsub::model::PushConfig;
7275 /// let x = ModifyPushConfigRequest::new().set_push_config(PushConfig::default()/* use setters */);
7276 /// ```
7277 pub fn set_push_config<T>(mut self, v: T) -> Self
7278 where
7279 T: std::convert::Into<crate::model::PushConfig>,
7280 {
7281 self.push_config = std::option::Option::Some(v.into());
7282 self
7283 }
7284
7285 /// Sets or clears the value of [push_config][crate::model::ModifyPushConfigRequest::push_config].
7286 ///
7287 /// # Example
7288 /// ```ignore,no_run
7289 /// # use google_cloud_pubsub::model::ModifyPushConfigRequest;
7290 /// use google_cloud_pubsub::model::PushConfig;
7291 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(Some(PushConfig::default()/* use setters */));
7292 /// let x = ModifyPushConfigRequest::new().set_or_clear_push_config(None::<PushConfig>);
7293 /// ```
7294 pub fn set_or_clear_push_config<T>(mut self, v: std::option::Option<T>) -> Self
7295 where
7296 T: std::convert::Into<crate::model::PushConfig>,
7297 {
7298 self.push_config = v.map(|x| x.into());
7299 self
7300 }
7301}
7302
7303impl wkt::message::Message for ModifyPushConfigRequest {
7304 fn typename() -> &'static str {
7305 "type.googleapis.com/google.pubsub.v1.ModifyPushConfigRequest"
7306 }
7307}
7308
7309/// Request for the `CreateSnapshot` method.
7310#[derive(Clone, Default, PartialEq)]
7311#[non_exhaustive]
7312pub struct CreateSnapshotRequest {
7313 /// Required. User-provided name for this snapshot. If the name is not provided
7314 /// in the request, the server will assign a random name for this snapshot on
7315 /// the same project as the subscription. Note that for REST API requests, you
7316 /// must specify a name. See the [resource name
7317 /// rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
7318 /// Format is `projects/{project}/snapshots/{snap}`.
7319 pub name: std::string::String,
7320
7321 /// Required. The subscription whose backlog the snapshot retains.
7322 /// Specifically, the created snapshot is guaranteed to retain:
7323 /// (a) The existing backlog on the subscription. More precisely, this is
7324 /// defined as the messages in the subscription's backlog that are
7325 /// unacknowledged upon the successful completion of the
7326 /// `CreateSnapshot` request; as well as:
7327 /// (b) Any messages published to the subscription's topic following the
7328 /// successful completion of the CreateSnapshot request.
7329 /// Format is `projects/{project}/subscriptions/{sub}`.
7330 pub subscription: std::string::String,
7331
7332 /// Optional. See [Creating and managing
7333 /// labels](https://cloud.google.com/pubsub/docs/labels).
7334 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7335
7336 /// Optional. Input only. Immutable. Tag keys/values directly bound to this
7337 /// resource. For example:
7338 /// "123/environment": "production",
7339 /// "123/costCenter": "marketing"
7340 /// See <https://docs.cloud.google.com/pubsub/docs/tags> for more information on
7341 /// using tags with Pub/Sub resources.
7342 pub tags: std::collections::HashMap<std::string::String, std::string::String>,
7343
7344 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7345}
7346
7347impl CreateSnapshotRequest {
7348 /// Creates a new default instance.
7349 pub fn new() -> Self {
7350 std::default::Default::default()
7351 }
7352
7353 /// Sets the value of [name][crate::model::CreateSnapshotRequest::name].
7354 ///
7355 /// # Example
7356 /// ```ignore,no_run
7357 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7358 /// # let project_id = "project_id";
7359 /// # let snapshot_id = "snapshot_id";
7360 /// let x = CreateSnapshotRequest::new().set_name(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7361 /// ```
7362 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7363 self.name = v.into();
7364 self
7365 }
7366
7367 /// Sets the value of [subscription][crate::model::CreateSnapshotRequest::subscription].
7368 ///
7369 /// # Example
7370 /// ```ignore,no_run
7371 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7372 /// # let project_id = "project_id";
7373 /// # let subscription_id = "subscription_id";
7374 /// let x = CreateSnapshotRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7375 /// ```
7376 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7377 self.subscription = v.into();
7378 self
7379 }
7380
7381 /// Sets the value of [labels][crate::model::CreateSnapshotRequest::labels].
7382 ///
7383 /// # Example
7384 /// ```ignore,no_run
7385 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7386 /// let x = CreateSnapshotRequest::new().set_labels([
7387 /// ("key0", "abc"),
7388 /// ("key1", "xyz"),
7389 /// ]);
7390 /// ```
7391 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
7392 where
7393 T: std::iter::IntoIterator<Item = (K, V)>,
7394 K: std::convert::Into<std::string::String>,
7395 V: std::convert::Into<std::string::String>,
7396 {
7397 use std::iter::Iterator;
7398 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7399 self
7400 }
7401
7402 /// Sets the value of [tags][crate::model::CreateSnapshotRequest::tags].
7403 ///
7404 /// # Example
7405 /// ```ignore,no_run
7406 /// # use google_cloud_pubsub::model::CreateSnapshotRequest;
7407 /// let x = CreateSnapshotRequest::new().set_tags([
7408 /// ("key0", "abc"),
7409 /// ("key1", "xyz"),
7410 /// ]);
7411 /// ```
7412 pub fn set_tags<T, K, V>(mut self, v: T) -> Self
7413 where
7414 T: std::iter::IntoIterator<Item = (K, V)>,
7415 K: std::convert::Into<std::string::String>,
7416 V: std::convert::Into<std::string::String>,
7417 {
7418 use std::iter::Iterator;
7419 self.tags = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7420 self
7421 }
7422}
7423
7424impl wkt::message::Message for CreateSnapshotRequest {
7425 fn typename() -> &'static str {
7426 "type.googleapis.com/google.pubsub.v1.CreateSnapshotRequest"
7427 }
7428}
7429
7430/// Request for the UpdateSnapshot method.
7431#[derive(Clone, Default, PartialEq)]
7432#[non_exhaustive]
7433pub struct UpdateSnapshotRequest {
7434 /// Required. The updated snapshot object.
7435 pub snapshot: std::option::Option<crate::model::Snapshot>,
7436
7437 /// Required. Indicates which fields in the provided snapshot to update.
7438 /// Must be specified and non-empty.
7439 pub update_mask: std::option::Option<wkt::FieldMask>,
7440
7441 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7442}
7443
7444impl UpdateSnapshotRequest {
7445 /// Creates a new default instance.
7446 pub fn new() -> Self {
7447 std::default::Default::default()
7448 }
7449
7450 /// Sets the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7451 ///
7452 /// # Example
7453 /// ```ignore,no_run
7454 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7455 /// use google_cloud_pubsub::model::Snapshot;
7456 /// let x = UpdateSnapshotRequest::new().set_snapshot(Snapshot::default()/* use setters */);
7457 /// ```
7458 pub fn set_snapshot<T>(mut self, v: T) -> Self
7459 where
7460 T: std::convert::Into<crate::model::Snapshot>,
7461 {
7462 self.snapshot = std::option::Option::Some(v.into());
7463 self
7464 }
7465
7466 /// Sets or clears the value of [snapshot][crate::model::UpdateSnapshotRequest::snapshot].
7467 ///
7468 /// # Example
7469 /// ```ignore,no_run
7470 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7471 /// use google_cloud_pubsub::model::Snapshot;
7472 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(Some(Snapshot::default()/* use setters */));
7473 /// let x = UpdateSnapshotRequest::new().set_or_clear_snapshot(None::<Snapshot>);
7474 /// ```
7475 pub fn set_or_clear_snapshot<T>(mut self, v: std::option::Option<T>) -> Self
7476 where
7477 T: std::convert::Into<crate::model::Snapshot>,
7478 {
7479 self.snapshot = v.map(|x| x.into());
7480 self
7481 }
7482
7483 /// Sets the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7484 ///
7485 /// # Example
7486 /// ```ignore,no_run
7487 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7488 /// use wkt::FieldMask;
7489 /// let x = UpdateSnapshotRequest::new().set_update_mask(FieldMask::default()/* use setters */);
7490 /// ```
7491 pub fn set_update_mask<T>(mut self, v: T) -> Self
7492 where
7493 T: std::convert::Into<wkt::FieldMask>,
7494 {
7495 self.update_mask = std::option::Option::Some(v.into());
7496 self
7497 }
7498
7499 /// Sets or clears the value of [update_mask][crate::model::UpdateSnapshotRequest::update_mask].
7500 ///
7501 /// # Example
7502 /// ```ignore,no_run
7503 /// # use google_cloud_pubsub::model::UpdateSnapshotRequest;
7504 /// use wkt::FieldMask;
7505 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
7506 /// let x = UpdateSnapshotRequest::new().set_or_clear_update_mask(None::<FieldMask>);
7507 /// ```
7508 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
7509 where
7510 T: std::convert::Into<wkt::FieldMask>,
7511 {
7512 self.update_mask = v.map(|x| x.into());
7513 self
7514 }
7515}
7516
7517impl wkt::message::Message for UpdateSnapshotRequest {
7518 fn typename() -> &'static str {
7519 "type.googleapis.com/google.pubsub.v1.UpdateSnapshotRequest"
7520 }
7521}
7522
7523/// A snapshot resource. Snapshots are used in
7524/// [Seek](https://cloud.google.com/pubsub/docs/replay-overview)
7525/// operations, which allow you to manage message acknowledgments in bulk. That
7526/// is, you can set the acknowledgment state of messages in an existing
7527/// subscription to the state captured by a snapshot.
7528#[derive(Clone, Default, PartialEq)]
7529#[non_exhaustive]
7530pub struct Snapshot {
7531 /// Optional. The name of the snapshot.
7532 pub name: std::string::String,
7533
7534 /// Optional. The name of the topic from which this snapshot is retaining
7535 /// messages.
7536 pub topic: std::string::String,
7537
7538 /// Optional. The snapshot is guaranteed to exist up until this time.
7539 /// A newly-created snapshot expires no later than 7 days from the time of its
7540 /// creation. Its exact lifetime is determined at creation by the existing
7541 /// backlog in the source subscription. Specifically, the lifetime of the
7542 /// snapshot is `7 days - (age of oldest unacked message in the subscription)`.
7543 /// For example, consider a subscription whose oldest unacked message is 3 days
7544 /// old. If a snapshot is created from this subscription, the snapshot -- which
7545 /// will always capture this 3-day-old backlog as long as the snapshot
7546 /// exists -- will expire in 4 days. The service will refuse to create a
7547 /// snapshot that would expire in less than 1 hour after creation.
7548 pub expire_time: std::option::Option<wkt::Timestamp>,
7549
7550 /// Optional. See [Creating and managing labels]
7551 /// (<https://cloud.google.com/pubsub/docs/labels>).
7552 pub labels: std::collections::HashMap<std::string::String, std::string::String>,
7553
7554 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7555}
7556
7557impl Snapshot {
7558 /// Creates a new default instance.
7559 pub fn new() -> Self {
7560 std::default::Default::default()
7561 }
7562
7563 /// Sets the value of [name][crate::model::Snapshot::name].
7564 ///
7565 /// # Example
7566 /// ```ignore,no_run
7567 /// # use google_cloud_pubsub::model::Snapshot;
7568 /// # let project_id = "project_id";
7569 /// # let snapshot_id = "snapshot_id";
7570 /// let x = Snapshot::new().set_name(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7571 /// ```
7572 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7573 self.name = v.into();
7574 self
7575 }
7576
7577 /// Sets the value of [topic][crate::model::Snapshot::topic].
7578 ///
7579 /// # Example
7580 /// ```ignore,no_run
7581 /// # use google_cloud_pubsub::model::Snapshot;
7582 /// # let project_id = "project_id";
7583 /// # let topic_id = "topic_id";
7584 /// let x = Snapshot::new().set_topic(format!("projects/{project_id}/topics/{topic_id}"));
7585 /// ```
7586 pub fn set_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7587 self.topic = v.into();
7588 self
7589 }
7590
7591 /// Sets the value of [expire_time][crate::model::Snapshot::expire_time].
7592 ///
7593 /// # Example
7594 /// ```ignore,no_run
7595 /// # use google_cloud_pubsub::model::Snapshot;
7596 /// use wkt::Timestamp;
7597 /// let x = Snapshot::new().set_expire_time(Timestamp::default()/* use setters */);
7598 /// ```
7599 pub fn set_expire_time<T>(mut self, v: T) -> Self
7600 where
7601 T: std::convert::Into<wkt::Timestamp>,
7602 {
7603 self.expire_time = std::option::Option::Some(v.into());
7604 self
7605 }
7606
7607 /// Sets or clears the value of [expire_time][crate::model::Snapshot::expire_time].
7608 ///
7609 /// # Example
7610 /// ```ignore,no_run
7611 /// # use google_cloud_pubsub::model::Snapshot;
7612 /// use wkt::Timestamp;
7613 /// let x = Snapshot::new().set_or_clear_expire_time(Some(Timestamp::default()/* use setters */));
7614 /// let x = Snapshot::new().set_or_clear_expire_time(None::<Timestamp>);
7615 /// ```
7616 pub fn set_or_clear_expire_time<T>(mut self, v: std::option::Option<T>) -> Self
7617 where
7618 T: std::convert::Into<wkt::Timestamp>,
7619 {
7620 self.expire_time = v.map(|x| x.into());
7621 self
7622 }
7623
7624 /// Sets the value of [labels][crate::model::Snapshot::labels].
7625 ///
7626 /// # Example
7627 /// ```ignore,no_run
7628 /// # use google_cloud_pubsub::model::Snapshot;
7629 /// let x = Snapshot::new().set_labels([
7630 /// ("key0", "abc"),
7631 /// ("key1", "xyz"),
7632 /// ]);
7633 /// ```
7634 pub fn set_labels<T, K, V>(mut self, v: T) -> Self
7635 where
7636 T: std::iter::IntoIterator<Item = (K, V)>,
7637 K: std::convert::Into<std::string::String>,
7638 V: std::convert::Into<std::string::String>,
7639 {
7640 use std::iter::Iterator;
7641 self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
7642 self
7643 }
7644}
7645
7646impl wkt::message::Message for Snapshot {
7647 fn typename() -> &'static str {
7648 "type.googleapis.com/google.pubsub.v1.Snapshot"
7649 }
7650}
7651
7652/// Request for the GetSnapshot method.
7653#[derive(Clone, Default, PartialEq)]
7654#[non_exhaustive]
7655pub struct GetSnapshotRequest {
7656 /// Required. The name of the snapshot to get.
7657 /// Format is `projects/{project}/snapshots/{snap}`.
7658 pub snapshot: std::string::String,
7659
7660 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7661}
7662
7663impl GetSnapshotRequest {
7664 /// Creates a new default instance.
7665 pub fn new() -> Self {
7666 std::default::Default::default()
7667 }
7668
7669 /// Sets the value of [snapshot][crate::model::GetSnapshotRequest::snapshot].
7670 ///
7671 /// # Example
7672 /// ```ignore,no_run
7673 /// # use google_cloud_pubsub::model::GetSnapshotRequest;
7674 /// # let project_id = "project_id";
7675 /// # let snapshot_id = "snapshot_id";
7676 /// let x = GetSnapshotRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7677 /// ```
7678 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7679 self.snapshot = v.into();
7680 self
7681 }
7682}
7683
7684impl wkt::message::Message for GetSnapshotRequest {
7685 fn typename() -> &'static str {
7686 "type.googleapis.com/google.pubsub.v1.GetSnapshotRequest"
7687 }
7688}
7689
7690/// Request for the `ListSnapshots` method.
7691#[derive(Clone, Default, PartialEq)]
7692#[non_exhaustive]
7693pub struct ListSnapshotsRequest {
7694 /// Required. The name of the project in which to list snapshots.
7695 /// Format is `projects/{project-id}`.
7696 pub project: std::string::String,
7697
7698 /// Optional. Maximum number of snapshots to return.
7699 pub page_size: i32,
7700
7701 /// Optional. The value returned by the last `ListSnapshotsResponse`; indicates
7702 /// that this is a continuation of a prior `ListSnapshots` call, and that the
7703 /// system should return the next page of data.
7704 pub page_token: std::string::String,
7705
7706 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7707}
7708
7709impl ListSnapshotsRequest {
7710 /// Creates a new default instance.
7711 pub fn new() -> Self {
7712 std::default::Default::default()
7713 }
7714
7715 /// Sets the value of [project][crate::model::ListSnapshotsRequest::project].
7716 ///
7717 /// # Example
7718 /// ```ignore,no_run
7719 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7720 /// let x = ListSnapshotsRequest::new().set_project("example");
7721 /// ```
7722 pub fn set_project<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7723 self.project = v.into();
7724 self
7725 }
7726
7727 /// Sets the value of [page_size][crate::model::ListSnapshotsRequest::page_size].
7728 ///
7729 /// # Example
7730 /// ```ignore,no_run
7731 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7732 /// let x = ListSnapshotsRequest::new().set_page_size(42);
7733 /// ```
7734 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
7735 self.page_size = v.into();
7736 self
7737 }
7738
7739 /// Sets the value of [page_token][crate::model::ListSnapshotsRequest::page_token].
7740 ///
7741 /// # Example
7742 /// ```ignore,no_run
7743 /// # use google_cloud_pubsub::model::ListSnapshotsRequest;
7744 /// let x = ListSnapshotsRequest::new().set_page_token("example");
7745 /// ```
7746 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7747 self.page_token = v.into();
7748 self
7749 }
7750}
7751
7752impl wkt::message::Message for ListSnapshotsRequest {
7753 fn typename() -> &'static str {
7754 "type.googleapis.com/google.pubsub.v1.ListSnapshotsRequest"
7755 }
7756}
7757
7758/// Response for the `ListSnapshots` method.
7759#[derive(Clone, Default, PartialEq)]
7760#[non_exhaustive]
7761pub struct ListSnapshotsResponse {
7762 /// Optional. The resulting snapshots.
7763 pub snapshots: std::vec::Vec<crate::model::Snapshot>,
7764
7765 /// Optional. If not empty, indicates that there may be more snapshot that
7766 /// match the request; this value should be passed in a new
7767 /// `ListSnapshotsRequest`.
7768 pub next_page_token: std::string::String,
7769
7770 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7771}
7772
7773impl ListSnapshotsResponse {
7774 /// Creates a new default instance.
7775 pub fn new() -> Self {
7776 std::default::Default::default()
7777 }
7778
7779 /// Sets the value of [snapshots][crate::model::ListSnapshotsResponse::snapshots].
7780 ///
7781 /// # Example
7782 /// ```ignore,no_run
7783 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
7784 /// use google_cloud_pubsub::model::Snapshot;
7785 /// let x = ListSnapshotsResponse::new()
7786 /// .set_snapshots([
7787 /// Snapshot::default()/* use setters */,
7788 /// Snapshot::default()/* use (different) setters */,
7789 /// ]);
7790 /// ```
7791 pub fn set_snapshots<T, V>(mut self, v: T) -> Self
7792 where
7793 T: std::iter::IntoIterator<Item = V>,
7794 V: std::convert::Into<crate::model::Snapshot>,
7795 {
7796 use std::iter::Iterator;
7797 self.snapshots = v.into_iter().map(|i| i.into()).collect();
7798 self
7799 }
7800
7801 /// Sets the value of [next_page_token][crate::model::ListSnapshotsResponse::next_page_token].
7802 ///
7803 /// # Example
7804 /// ```ignore,no_run
7805 /// # use google_cloud_pubsub::model::ListSnapshotsResponse;
7806 /// let x = ListSnapshotsResponse::new().set_next_page_token("example");
7807 /// ```
7808 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7809 self.next_page_token = v.into();
7810 self
7811 }
7812}
7813
7814impl wkt::message::Message for ListSnapshotsResponse {
7815 fn typename() -> &'static str {
7816 "type.googleapis.com/google.pubsub.v1.ListSnapshotsResponse"
7817 }
7818}
7819
7820#[doc(hidden)]
7821impl google_cloud_gax::paginator::internal::PageableResponse for ListSnapshotsResponse {
7822 type PageItem = crate::model::Snapshot;
7823
7824 fn items(self) -> std::vec::Vec<Self::PageItem> {
7825 self.snapshots
7826 }
7827
7828 fn next_page_token(&self) -> std::string::String {
7829 use std::clone::Clone;
7830 self.next_page_token.clone()
7831 }
7832}
7833
7834/// Request for the `DeleteSnapshot` method.
7835#[derive(Clone, Default, PartialEq)]
7836#[non_exhaustive]
7837pub struct DeleteSnapshotRequest {
7838 /// Required. The name of the snapshot to delete.
7839 /// Format is `projects/{project}/snapshots/{snap}`.
7840 pub snapshot: std::string::String,
7841
7842 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7843}
7844
7845impl DeleteSnapshotRequest {
7846 /// Creates a new default instance.
7847 pub fn new() -> Self {
7848 std::default::Default::default()
7849 }
7850
7851 /// Sets the value of [snapshot][crate::model::DeleteSnapshotRequest::snapshot].
7852 ///
7853 /// # Example
7854 /// ```ignore,no_run
7855 /// # use google_cloud_pubsub::model::DeleteSnapshotRequest;
7856 /// # let project_id = "project_id";
7857 /// # let snapshot_id = "snapshot_id";
7858 /// let x = DeleteSnapshotRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7859 /// ```
7860 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7861 self.snapshot = v.into();
7862 self
7863 }
7864}
7865
7866impl wkt::message::Message for DeleteSnapshotRequest {
7867 fn typename() -> &'static str {
7868 "type.googleapis.com/google.pubsub.v1.DeleteSnapshotRequest"
7869 }
7870}
7871
7872/// Request for the `Seek` method.
7873#[derive(Clone, Default, PartialEq)]
7874#[non_exhaustive]
7875pub struct SeekRequest {
7876 /// Required. The subscription to affect.
7877 pub subscription: std::string::String,
7878
7879 #[allow(missing_docs)]
7880 pub target: std::option::Option<crate::model::seek_request::Target>,
7881
7882 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
7883}
7884
7885impl SeekRequest {
7886 /// Creates a new default instance.
7887 pub fn new() -> Self {
7888 std::default::Default::default()
7889 }
7890
7891 /// Sets the value of [subscription][crate::model::SeekRequest::subscription].
7892 ///
7893 /// # Example
7894 /// ```ignore,no_run
7895 /// # use google_cloud_pubsub::model::SeekRequest;
7896 /// # let project_id = "project_id";
7897 /// # let subscription_id = "subscription_id";
7898 /// let x = SeekRequest::new().set_subscription(format!("projects/{project_id}/subscriptions/{subscription_id}"));
7899 /// ```
7900 pub fn set_subscription<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7901 self.subscription = v.into();
7902 self
7903 }
7904
7905 /// Sets the value of [target][crate::model::SeekRequest::target].
7906 ///
7907 /// Note that all the setters affecting `target` are mutually
7908 /// exclusive.
7909 ///
7910 /// # Example
7911 /// ```ignore,no_run
7912 /// # use google_cloud_pubsub::model::SeekRequest;
7913 /// use google_cloud_pubsub::model::seek_request::Target;
7914 /// let x = SeekRequest::new().set_target(Some(Target::Snapshot("example".to_string())));
7915 /// ```
7916 pub fn set_target<
7917 T: std::convert::Into<std::option::Option<crate::model::seek_request::Target>>,
7918 >(
7919 mut self,
7920 v: T,
7921 ) -> Self {
7922 self.target = v.into();
7923 self
7924 }
7925
7926 /// The value of [target][crate::model::SeekRequest::target]
7927 /// if it holds a `Time`, `None` if the field is not set or
7928 /// holds a different branch.
7929 pub fn time(&self) -> std::option::Option<&std::boxed::Box<wkt::Timestamp>> {
7930 #[allow(unreachable_patterns)]
7931 self.target.as_ref().and_then(|v| match v {
7932 crate::model::seek_request::Target::Time(v) => std::option::Option::Some(v),
7933 _ => std::option::Option::None,
7934 })
7935 }
7936
7937 /// Sets the value of [target][crate::model::SeekRequest::target]
7938 /// to hold a `Time`.
7939 ///
7940 /// Note that all the setters affecting `target` are
7941 /// mutually exclusive.
7942 ///
7943 /// # Example
7944 /// ```ignore,no_run
7945 /// # use google_cloud_pubsub::model::SeekRequest;
7946 /// use wkt::Timestamp;
7947 /// let x = SeekRequest::new().set_time(Timestamp::default()/* use setters */);
7948 /// assert!(x.time().is_some());
7949 /// assert!(x.snapshot().is_none());
7950 /// ```
7951 pub fn set_time<T: std::convert::Into<std::boxed::Box<wkt::Timestamp>>>(
7952 mut self,
7953 v: T,
7954 ) -> Self {
7955 self.target = std::option::Option::Some(crate::model::seek_request::Target::Time(v.into()));
7956 self
7957 }
7958
7959 /// The value of [target][crate::model::SeekRequest::target]
7960 /// if it holds a `Snapshot`, `None` if the field is not set or
7961 /// holds a different branch.
7962 pub fn snapshot(&self) -> std::option::Option<&std::string::String> {
7963 #[allow(unreachable_patterns)]
7964 self.target.as_ref().and_then(|v| match v {
7965 crate::model::seek_request::Target::Snapshot(v) => std::option::Option::Some(v),
7966 _ => std::option::Option::None,
7967 })
7968 }
7969
7970 /// Sets the value of [target][crate::model::SeekRequest::target]
7971 /// to hold a `Snapshot`.
7972 ///
7973 /// Note that all the setters affecting `target` are
7974 /// mutually exclusive.
7975 ///
7976 /// # Example
7977 /// ```ignore,no_run
7978 /// # use google_cloud_pubsub::model::SeekRequest;
7979 /// # let project_id = "project_id";
7980 /// # let snapshot_id = "snapshot_id";
7981 /// let x = SeekRequest::new().set_snapshot(format!("projects/{project_id}/snapshots/{snapshot_id}"));
7982 /// assert!(x.snapshot().is_some());
7983 /// assert!(x.time().is_none());
7984 /// ```
7985 pub fn set_snapshot<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
7986 self.target =
7987 std::option::Option::Some(crate::model::seek_request::Target::Snapshot(v.into()));
7988 self
7989 }
7990}
7991
7992impl wkt::message::Message for SeekRequest {
7993 fn typename() -> &'static str {
7994 "type.googleapis.com/google.pubsub.v1.SeekRequest"
7995 }
7996}
7997
7998/// Defines additional types related to [SeekRequest].
7999pub mod seek_request {
8000 #[allow(unused_imports)]
8001 use super::*;
8002
8003 #[allow(missing_docs)]
8004 #[derive(Clone, Debug, PartialEq)]
8005 #[non_exhaustive]
8006 pub enum Target {
8007 /// Optional. The time to seek to.
8008 /// Messages retained in the subscription that were published before this
8009 /// time are marked as acknowledged, and messages retained in the
8010 /// subscription that were published after this time are marked as
8011 /// unacknowledged. Note that this operation affects only those messages
8012 /// retained in the subscription (configured by the combination of
8013 /// `message_retention_duration` and `retain_acked_messages`). For example,
8014 /// if `time` corresponds to a point before the message retention
8015 /// window (or to a point before the system's notion of the subscription
8016 /// creation time), only retained messages will be marked as unacknowledged,
8017 /// and already-expunged messages will not be restored.
8018 Time(std::boxed::Box<wkt::Timestamp>),
8019 /// Optional. The snapshot to seek to. The snapshot's topic must be the same
8020 /// as that of the provided subscription. Format is
8021 /// `projects/{project}/snapshots/{snap}`.
8022 Snapshot(std::string::String),
8023 }
8024}
8025
8026/// Response for the `Seek` method (this response is empty).
8027#[derive(Clone, Default, PartialEq)]
8028#[non_exhaustive]
8029pub struct SeekResponse {
8030 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8031}
8032
8033impl SeekResponse {
8034 /// Creates a new default instance.
8035 pub fn new() -> Self {
8036 std::default::Default::default()
8037 }
8038}
8039
8040impl wkt::message::Message for SeekResponse {
8041 fn typename() -> &'static str {
8042 "type.googleapis.com/google.pubsub.v1.SeekResponse"
8043 }
8044}
8045
8046/// A schema resource.
8047#[derive(Clone, Default, PartialEq)]
8048#[non_exhaustive]
8049pub struct Schema {
8050 /// Required. Name of the schema.
8051 /// Format is `projects/{project}/schemas/{schema}`.
8052 pub name: std::string::String,
8053
8054 /// The type of the schema definition.
8055 pub r#type: crate::model::schema::Type,
8056
8057 /// The definition of the schema. This should contain a string representing
8058 /// the full definition of the schema that is a valid schema definition of
8059 /// the type specified in `type`.
8060 pub definition: std::string::String,
8061
8062 /// Output only. Immutable. The revision ID of the schema.
8063 pub revision_id: std::string::String,
8064
8065 /// Output only. The timestamp that the revision was created.
8066 pub revision_create_time: std::option::Option<wkt::Timestamp>,
8067
8068 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8069}
8070
8071impl Schema {
8072 /// Creates a new default instance.
8073 pub fn new() -> Self {
8074 std::default::Default::default()
8075 }
8076
8077 /// Sets the value of [name][crate::model::Schema::name].
8078 ///
8079 /// # Example
8080 /// ```ignore,no_run
8081 /// # use google_cloud_pubsub::model::Schema;
8082 /// # let project_id = "project_id";
8083 /// # let schema_id = "schema_id";
8084 /// let x = Schema::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8085 /// ```
8086 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8087 self.name = v.into();
8088 self
8089 }
8090
8091 /// Sets the value of [r#type][crate::model::Schema::type].
8092 ///
8093 /// # Example
8094 /// ```ignore,no_run
8095 /// # use google_cloud_pubsub::model::Schema;
8096 /// use google_cloud_pubsub::model::schema::Type;
8097 /// let x0 = Schema::new().set_type(Type::ProtocolBuffer);
8098 /// let x1 = Schema::new().set_type(Type::Avro);
8099 /// ```
8100 pub fn set_type<T: std::convert::Into<crate::model::schema::Type>>(mut self, v: T) -> Self {
8101 self.r#type = v.into();
8102 self
8103 }
8104
8105 /// Sets the value of [definition][crate::model::Schema::definition].
8106 ///
8107 /// # Example
8108 /// ```ignore,no_run
8109 /// # use google_cloud_pubsub::model::Schema;
8110 /// let x = Schema::new().set_definition("example");
8111 /// ```
8112 pub fn set_definition<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8113 self.definition = v.into();
8114 self
8115 }
8116
8117 /// Sets the value of [revision_id][crate::model::Schema::revision_id].
8118 ///
8119 /// # Example
8120 /// ```ignore,no_run
8121 /// # use google_cloud_pubsub::model::Schema;
8122 /// let x = Schema::new().set_revision_id("example");
8123 /// ```
8124 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8125 self.revision_id = v.into();
8126 self
8127 }
8128
8129 /// Sets the value of [revision_create_time][crate::model::Schema::revision_create_time].
8130 ///
8131 /// # Example
8132 /// ```ignore,no_run
8133 /// # use google_cloud_pubsub::model::Schema;
8134 /// use wkt::Timestamp;
8135 /// let x = Schema::new().set_revision_create_time(Timestamp::default()/* use setters */);
8136 /// ```
8137 pub fn set_revision_create_time<T>(mut self, v: T) -> Self
8138 where
8139 T: std::convert::Into<wkt::Timestamp>,
8140 {
8141 self.revision_create_time = std::option::Option::Some(v.into());
8142 self
8143 }
8144
8145 /// Sets or clears the value of [revision_create_time][crate::model::Schema::revision_create_time].
8146 ///
8147 /// # Example
8148 /// ```ignore,no_run
8149 /// # use google_cloud_pubsub::model::Schema;
8150 /// use wkt::Timestamp;
8151 /// let x = Schema::new().set_or_clear_revision_create_time(Some(Timestamp::default()/* use setters */));
8152 /// let x = Schema::new().set_or_clear_revision_create_time(None::<Timestamp>);
8153 /// ```
8154 pub fn set_or_clear_revision_create_time<T>(mut self, v: std::option::Option<T>) -> Self
8155 where
8156 T: std::convert::Into<wkt::Timestamp>,
8157 {
8158 self.revision_create_time = v.map(|x| x.into());
8159 self
8160 }
8161}
8162
8163impl wkt::message::Message for Schema {
8164 fn typename() -> &'static str {
8165 "type.googleapis.com/google.pubsub.v1.Schema"
8166 }
8167}
8168
8169/// Defines additional types related to [Schema].
8170pub mod schema {
8171 #[allow(unused_imports)]
8172 use super::*;
8173
8174 /// Possible schema definition types.
8175 ///
8176 /// # Working with unknown values
8177 ///
8178 /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
8179 /// additional enum variants at any time. Adding new variants is not considered
8180 /// a breaking change. Applications should write their code in anticipation of:
8181 ///
8182 /// - New values appearing in future releases of the client library, **and**
8183 /// - New values received dynamically, without application changes.
8184 ///
8185 /// Please consult the [Working with enums] section in the user guide for some
8186 /// guidelines.
8187 ///
8188 /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
8189 #[derive(Clone, Debug, PartialEq)]
8190 #[non_exhaustive]
8191 pub enum Type {
8192 /// Default value. This value is unused.
8193 Unspecified,
8194 /// A Protocol Buffer schema definition.
8195 ProtocolBuffer,
8196 /// An Avro schema definition.
8197 Avro,
8198 /// If set, the enum was initialized with an unknown value.
8199 ///
8200 /// Applications can examine the value using [Type::value] or
8201 /// [Type::name].
8202 UnknownValue(r#type::UnknownValue),
8203 }
8204
8205 #[doc(hidden)]
8206 pub mod r#type {
8207 #[allow(unused_imports)]
8208 use super::*;
8209 #[derive(Clone, Debug, PartialEq)]
8210 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
8211 }
8212
8213 impl Type {
8214 /// Gets the enum value.
8215 ///
8216 /// Returns `None` if the enum contains an unknown value deserialized from
8217 /// the string representation of enums.
8218 pub fn value(&self) -> std::option::Option<i32> {
8219 match self {
8220 Self::Unspecified => std::option::Option::Some(0),
8221 Self::ProtocolBuffer => std::option::Option::Some(1),
8222 Self::Avro => std::option::Option::Some(2),
8223 Self::UnknownValue(u) => u.0.value(),
8224 }
8225 }
8226
8227 /// Gets the enum value as a string.
8228 ///
8229 /// Returns `None` if the enum contains an unknown value deserialized from
8230 /// the integer representation of enums.
8231 pub fn name(&self) -> std::option::Option<&str> {
8232 match self {
8233 Self::Unspecified => std::option::Option::Some("TYPE_UNSPECIFIED"),
8234 Self::ProtocolBuffer => std::option::Option::Some("PROTOCOL_BUFFER"),
8235 Self::Avro => std::option::Option::Some("AVRO"),
8236 Self::UnknownValue(u) => u.0.name(),
8237 }
8238 }
8239 }
8240
8241 impl std::default::Default for Type {
8242 fn default() -> Self {
8243 use std::convert::From;
8244 Self::from(0)
8245 }
8246 }
8247
8248 impl std::fmt::Display for Type {
8249 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
8250 wkt::internal::display_enum(f, self.name(), self.value())
8251 }
8252 }
8253
8254 impl std::convert::From<i32> for Type {
8255 fn from(value: i32) -> Self {
8256 match value {
8257 0 => Self::Unspecified,
8258 1 => Self::ProtocolBuffer,
8259 2 => Self::Avro,
8260 _ => Self::UnknownValue(r#type::UnknownValue(
8261 wkt::internal::UnknownEnumValue::Integer(value),
8262 )),
8263 }
8264 }
8265 }
8266
8267 impl std::convert::From<&str> for Type {
8268 fn from(value: &str) -> Self {
8269 use std::string::ToString;
8270 match value {
8271 "TYPE_UNSPECIFIED" => Self::Unspecified,
8272 "PROTOCOL_BUFFER" => Self::ProtocolBuffer,
8273 "AVRO" => Self::Avro,
8274 _ => Self::UnknownValue(r#type::UnknownValue(
8275 wkt::internal::UnknownEnumValue::String(value.to_string()),
8276 )),
8277 }
8278 }
8279 }
8280
8281 impl serde::ser::Serialize for Type {
8282 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
8283 where
8284 S: serde::Serializer,
8285 {
8286 match self {
8287 Self::Unspecified => serializer.serialize_i32(0),
8288 Self::ProtocolBuffer => serializer.serialize_i32(1),
8289 Self::Avro => serializer.serialize_i32(2),
8290 Self::UnknownValue(u) => u.0.serialize(serializer),
8291 }
8292 }
8293 }
8294
8295 impl<'de> serde::de::Deserialize<'de> for Type {
8296 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
8297 where
8298 D: serde::Deserializer<'de>,
8299 {
8300 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Type>::new(
8301 ".google.pubsub.v1.Schema.Type",
8302 ))
8303 }
8304 }
8305}
8306
8307/// Request for the CreateSchema method.
8308#[derive(Clone, Default, PartialEq)]
8309#[non_exhaustive]
8310pub struct CreateSchemaRequest {
8311 /// Required. The name of the project in which to create the schema.
8312 /// Format is `projects/{project-id}`.
8313 pub parent: std::string::String,
8314
8315 /// Required. The schema object to create.
8316 ///
8317 /// This schema's `name` parameter is ignored. The schema object returned
8318 /// by CreateSchema will have a `name` made using the given `parent` and
8319 /// `schema_id`.
8320 pub schema: std::option::Option<crate::model::Schema>,
8321
8322 /// The ID to use for the schema, which will become the final component of
8323 /// the schema's resource name.
8324 ///
8325 /// See <https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names> for
8326 /// resource name constraints.
8327 pub schema_id: std::string::String,
8328
8329 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8330}
8331
8332impl CreateSchemaRequest {
8333 /// Creates a new default instance.
8334 pub fn new() -> Self {
8335 std::default::Default::default()
8336 }
8337
8338 /// Sets the value of [parent][crate::model::CreateSchemaRequest::parent].
8339 ///
8340 /// # Example
8341 /// ```ignore,no_run
8342 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8343 /// # let project_id = "project_id";
8344 /// let x = CreateSchemaRequest::new().set_parent(format!("projects/{project_id}"));
8345 /// ```
8346 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8347 self.parent = v.into();
8348 self
8349 }
8350
8351 /// Sets the value of [schema][crate::model::CreateSchemaRequest::schema].
8352 ///
8353 /// # Example
8354 /// ```ignore,no_run
8355 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8356 /// use google_cloud_pubsub::model::Schema;
8357 /// let x = CreateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8358 /// ```
8359 pub fn set_schema<T>(mut self, v: T) -> Self
8360 where
8361 T: std::convert::Into<crate::model::Schema>,
8362 {
8363 self.schema = std::option::Option::Some(v.into());
8364 self
8365 }
8366
8367 /// Sets or clears the value of [schema][crate::model::CreateSchemaRequest::schema].
8368 ///
8369 /// # Example
8370 /// ```ignore,no_run
8371 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8372 /// use google_cloud_pubsub::model::Schema;
8373 /// let x = CreateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
8374 /// let x = CreateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
8375 /// ```
8376 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
8377 where
8378 T: std::convert::Into<crate::model::Schema>,
8379 {
8380 self.schema = v.map(|x| x.into());
8381 self
8382 }
8383
8384 /// Sets the value of [schema_id][crate::model::CreateSchemaRequest::schema_id].
8385 ///
8386 /// # Example
8387 /// ```ignore,no_run
8388 /// # use google_cloud_pubsub::model::CreateSchemaRequest;
8389 /// let x = CreateSchemaRequest::new().set_schema_id("example");
8390 /// ```
8391 pub fn set_schema_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8392 self.schema_id = v.into();
8393 self
8394 }
8395}
8396
8397impl wkt::message::Message for CreateSchemaRequest {
8398 fn typename() -> &'static str {
8399 "type.googleapis.com/google.pubsub.v1.CreateSchemaRequest"
8400 }
8401}
8402
8403/// Request for the GetSchema method.
8404#[derive(Clone, Default, PartialEq)]
8405#[non_exhaustive]
8406pub struct GetSchemaRequest {
8407 /// Required. The name of the schema to get.
8408 /// Format is `projects/{project}/schemas/{schema}`.
8409 pub name: std::string::String,
8410
8411 /// The set of fields to return in the response. If not set, returns a Schema
8412 /// with all fields filled out. Set to `BASIC` to omit the `definition`.
8413 pub view: crate::model::SchemaView,
8414
8415 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8416}
8417
8418impl GetSchemaRequest {
8419 /// Creates a new default instance.
8420 pub fn new() -> Self {
8421 std::default::Default::default()
8422 }
8423
8424 /// Sets the value of [name][crate::model::GetSchemaRequest::name].
8425 ///
8426 /// # Example
8427 /// ```ignore,no_run
8428 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8429 /// # let project_id = "project_id";
8430 /// # let schema_id = "schema_id";
8431 /// let x = GetSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8432 /// ```
8433 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8434 self.name = v.into();
8435 self
8436 }
8437
8438 /// Sets the value of [view][crate::model::GetSchemaRequest::view].
8439 ///
8440 /// # Example
8441 /// ```ignore,no_run
8442 /// # use google_cloud_pubsub::model::GetSchemaRequest;
8443 /// use google_cloud_pubsub::model::SchemaView;
8444 /// let x0 = GetSchemaRequest::new().set_view(SchemaView::Basic);
8445 /// let x1 = GetSchemaRequest::new().set_view(SchemaView::Full);
8446 /// ```
8447 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8448 self.view = v.into();
8449 self
8450 }
8451}
8452
8453impl wkt::message::Message for GetSchemaRequest {
8454 fn typename() -> &'static str {
8455 "type.googleapis.com/google.pubsub.v1.GetSchemaRequest"
8456 }
8457}
8458
8459/// Request for the `ListSchemas` method.
8460#[derive(Clone, Default, PartialEq)]
8461#[non_exhaustive]
8462pub struct ListSchemasRequest {
8463 /// Required. The name of the project in which to list schemas.
8464 /// Format is `projects/{project-id}`.
8465 pub parent: std::string::String,
8466
8467 /// The set of Schema fields to return in the response. If not set, returns
8468 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
8469 /// retrieve all fields.
8470 pub view: crate::model::SchemaView,
8471
8472 /// Maximum number of schemas to return.
8473 pub page_size: i32,
8474
8475 /// The value returned by the last `ListSchemasResponse`; indicates that
8476 /// this is a continuation of a prior `ListSchemas` call, and that the
8477 /// system should return the next page of data.
8478 pub page_token: std::string::String,
8479
8480 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8481}
8482
8483impl ListSchemasRequest {
8484 /// Creates a new default instance.
8485 pub fn new() -> Self {
8486 std::default::Default::default()
8487 }
8488
8489 /// Sets the value of [parent][crate::model::ListSchemasRequest::parent].
8490 ///
8491 /// # Example
8492 /// ```ignore,no_run
8493 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8494 /// let x = ListSchemasRequest::new().set_parent("example");
8495 /// ```
8496 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8497 self.parent = v.into();
8498 self
8499 }
8500
8501 /// Sets the value of [view][crate::model::ListSchemasRequest::view].
8502 ///
8503 /// # Example
8504 /// ```ignore,no_run
8505 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8506 /// use google_cloud_pubsub::model::SchemaView;
8507 /// let x0 = ListSchemasRequest::new().set_view(SchemaView::Basic);
8508 /// let x1 = ListSchemasRequest::new().set_view(SchemaView::Full);
8509 /// ```
8510 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8511 self.view = v.into();
8512 self
8513 }
8514
8515 /// Sets the value of [page_size][crate::model::ListSchemasRequest::page_size].
8516 ///
8517 /// # Example
8518 /// ```ignore,no_run
8519 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8520 /// let x = ListSchemasRequest::new().set_page_size(42);
8521 /// ```
8522 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8523 self.page_size = v.into();
8524 self
8525 }
8526
8527 /// Sets the value of [page_token][crate::model::ListSchemasRequest::page_token].
8528 ///
8529 /// # Example
8530 /// ```ignore,no_run
8531 /// # use google_cloud_pubsub::model::ListSchemasRequest;
8532 /// let x = ListSchemasRequest::new().set_page_token("example");
8533 /// ```
8534 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8535 self.page_token = v.into();
8536 self
8537 }
8538}
8539
8540impl wkt::message::Message for ListSchemasRequest {
8541 fn typename() -> &'static str {
8542 "type.googleapis.com/google.pubsub.v1.ListSchemasRequest"
8543 }
8544}
8545
8546/// Response for the `ListSchemas` method.
8547#[derive(Clone, Default, PartialEq)]
8548#[non_exhaustive]
8549pub struct ListSchemasResponse {
8550 /// The resulting schemas.
8551 pub schemas: std::vec::Vec<crate::model::Schema>,
8552
8553 /// If not empty, indicates that there may be more schemas that match the
8554 /// request; this value should be passed in a new `ListSchemasRequest`.
8555 pub next_page_token: std::string::String,
8556
8557 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8558}
8559
8560impl ListSchemasResponse {
8561 /// Creates a new default instance.
8562 pub fn new() -> Self {
8563 std::default::Default::default()
8564 }
8565
8566 /// Sets the value of [schemas][crate::model::ListSchemasResponse::schemas].
8567 ///
8568 /// # Example
8569 /// ```ignore,no_run
8570 /// # use google_cloud_pubsub::model::ListSchemasResponse;
8571 /// use google_cloud_pubsub::model::Schema;
8572 /// let x = ListSchemasResponse::new()
8573 /// .set_schemas([
8574 /// Schema::default()/* use setters */,
8575 /// Schema::default()/* use (different) setters */,
8576 /// ]);
8577 /// ```
8578 pub fn set_schemas<T, V>(mut self, v: T) -> Self
8579 where
8580 T: std::iter::IntoIterator<Item = V>,
8581 V: std::convert::Into<crate::model::Schema>,
8582 {
8583 use std::iter::Iterator;
8584 self.schemas = v.into_iter().map(|i| i.into()).collect();
8585 self
8586 }
8587
8588 /// Sets the value of [next_page_token][crate::model::ListSchemasResponse::next_page_token].
8589 ///
8590 /// # Example
8591 /// ```ignore,no_run
8592 /// # use google_cloud_pubsub::model::ListSchemasResponse;
8593 /// let x = ListSchemasResponse::new().set_next_page_token("example");
8594 /// ```
8595 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8596 self.next_page_token = v.into();
8597 self
8598 }
8599}
8600
8601impl wkt::message::Message for ListSchemasResponse {
8602 fn typename() -> &'static str {
8603 "type.googleapis.com/google.pubsub.v1.ListSchemasResponse"
8604 }
8605}
8606
8607#[doc(hidden)]
8608impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemasResponse {
8609 type PageItem = crate::model::Schema;
8610
8611 fn items(self) -> std::vec::Vec<Self::PageItem> {
8612 self.schemas
8613 }
8614
8615 fn next_page_token(&self) -> std::string::String {
8616 use std::clone::Clone;
8617 self.next_page_token.clone()
8618 }
8619}
8620
8621/// Request for the `ListSchemaRevisions` method.
8622#[derive(Clone, Default, PartialEq)]
8623#[non_exhaustive]
8624pub struct ListSchemaRevisionsRequest {
8625 /// Required. The name of the schema to list revisions for.
8626 pub name: std::string::String,
8627
8628 /// The set of Schema fields to return in the response. If not set, returns
8629 /// Schemas with `name` and `type`, but not `definition`. Set to `FULL` to
8630 /// retrieve all fields.
8631 pub view: crate::model::SchemaView,
8632
8633 /// The maximum number of revisions to return per page.
8634 pub page_size: i32,
8635
8636 /// The page token, received from a previous ListSchemaRevisions call.
8637 /// Provide this to retrieve the subsequent page.
8638 pub page_token: std::string::String,
8639
8640 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8641}
8642
8643impl ListSchemaRevisionsRequest {
8644 /// Creates a new default instance.
8645 pub fn new() -> Self {
8646 std::default::Default::default()
8647 }
8648
8649 /// Sets the value of [name][crate::model::ListSchemaRevisionsRequest::name].
8650 ///
8651 /// # Example
8652 /// ```ignore,no_run
8653 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8654 /// # let project_id = "project_id";
8655 /// # let schema_id = "schema_id";
8656 /// let x = ListSchemaRevisionsRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8657 /// ```
8658 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8659 self.name = v.into();
8660 self
8661 }
8662
8663 /// Sets the value of [view][crate::model::ListSchemaRevisionsRequest::view].
8664 ///
8665 /// # Example
8666 /// ```ignore,no_run
8667 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8668 /// use google_cloud_pubsub::model::SchemaView;
8669 /// let x0 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Basic);
8670 /// let x1 = ListSchemaRevisionsRequest::new().set_view(SchemaView::Full);
8671 /// ```
8672 pub fn set_view<T: std::convert::Into<crate::model::SchemaView>>(mut self, v: T) -> Self {
8673 self.view = v.into();
8674 self
8675 }
8676
8677 /// Sets the value of [page_size][crate::model::ListSchemaRevisionsRequest::page_size].
8678 ///
8679 /// # Example
8680 /// ```ignore,no_run
8681 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8682 /// let x = ListSchemaRevisionsRequest::new().set_page_size(42);
8683 /// ```
8684 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
8685 self.page_size = v.into();
8686 self
8687 }
8688
8689 /// Sets the value of [page_token][crate::model::ListSchemaRevisionsRequest::page_token].
8690 ///
8691 /// # Example
8692 /// ```ignore,no_run
8693 /// # use google_cloud_pubsub::model::ListSchemaRevisionsRequest;
8694 /// let x = ListSchemaRevisionsRequest::new().set_page_token("example");
8695 /// ```
8696 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8697 self.page_token = v.into();
8698 self
8699 }
8700}
8701
8702impl wkt::message::Message for ListSchemaRevisionsRequest {
8703 fn typename() -> &'static str {
8704 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsRequest"
8705 }
8706}
8707
8708/// Response for the `ListSchemaRevisions` method.
8709#[derive(Clone, Default, PartialEq)]
8710#[non_exhaustive]
8711pub struct ListSchemaRevisionsResponse {
8712 /// The revisions of the schema.
8713 pub schemas: std::vec::Vec<crate::model::Schema>,
8714
8715 /// A token that can be sent as `page_token` to retrieve the next page.
8716 /// If this field is empty, there are no subsequent pages.
8717 pub next_page_token: std::string::String,
8718
8719 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8720}
8721
8722impl ListSchemaRevisionsResponse {
8723 /// Creates a new default instance.
8724 pub fn new() -> Self {
8725 std::default::Default::default()
8726 }
8727
8728 /// Sets the value of [schemas][crate::model::ListSchemaRevisionsResponse::schemas].
8729 ///
8730 /// # Example
8731 /// ```ignore,no_run
8732 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
8733 /// use google_cloud_pubsub::model::Schema;
8734 /// let x = ListSchemaRevisionsResponse::new()
8735 /// .set_schemas([
8736 /// Schema::default()/* use setters */,
8737 /// Schema::default()/* use (different) setters */,
8738 /// ]);
8739 /// ```
8740 pub fn set_schemas<T, V>(mut self, v: T) -> Self
8741 where
8742 T: std::iter::IntoIterator<Item = V>,
8743 V: std::convert::Into<crate::model::Schema>,
8744 {
8745 use std::iter::Iterator;
8746 self.schemas = v.into_iter().map(|i| i.into()).collect();
8747 self
8748 }
8749
8750 /// Sets the value of [next_page_token][crate::model::ListSchemaRevisionsResponse::next_page_token].
8751 ///
8752 /// # Example
8753 /// ```ignore,no_run
8754 /// # use google_cloud_pubsub::model::ListSchemaRevisionsResponse;
8755 /// let x = ListSchemaRevisionsResponse::new().set_next_page_token("example");
8756 /// ```
8757 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8758 self.next_page_token = v.into();
8759 self
8760 }
8761}
8762
8763impl wkt::message::Message for ListSchemaRevisionsResponse {
8764 fn typename() -> &'static str {
8765 "type.googleapis.com/google.pubsub.v1.ListSchemaRevisionsResponse"
8766 }
8767}
8768
8769#[doc(hidden)]
8770impl google_cloud_gax::paginator::internal::PageableResponse for ListSchemaRevisionsResponse {
8771 type PageItem = crate::model::Schema;
8772
8773 fn items(self) -> std::vec::Vec<Self::PageItem> {
8774 self.schemas
8775 }
8776
8777 fn next_page_token(&self) -> std::string::String {
8778 use std::clone::Clone;
8779 self.next_page_token.clone()
8780 }
8781}
8782
8783/// Request for CommitSchema method.
8784#[derive(Clone, Default, PartialEq)]
8785#[non_exhaustive]
8786pub struct CommitSchemaRequest {
8787 /// Required. The name of the schema we are revising.
8788 /// Format is `projects/{project}/schemas/{schema}`.
8789 pub name: std::string::String,
8790
8791 /// Required. The schema revision to commit.
8792 pub schema: std::option::Option<crate::model::Schema>,
8793
8794 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8795}
8796
8797impl CommitSchemaRequest {
8798 /// Creates a new default instance.
8799 pub fn new() -> Self {
8800 std::default::Default::default()
8801 }
8802
8803 /// Sets the value of [name][crate::model::CommitSchemaRequest::name].
8804 ///
8805 /// # Example
8806 /// ```ignore,no_run
8807 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8808 /// # let project_id = "project_id";
8809 /// # let schema_id = "schema_id";
8810 /// let x = CommitSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8811 /// ```
8812 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8813 self.name = v.into();
8814 self
8815 }
8816
8817 /// Sets the value of [schema][crate::model::CommitSchemaRequest::schema].
8818 ///
8819 /// # Example
8820 /// ```ignore,no_run
8821 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8822 /// use google_cloud_pubsub::model::Schema;
8823 /// let x = CommitSchemaRequest::new().set_schema(Schema::default()/* use setters */);
8824 /// ```
8825 pub fn set_schema<T>(mut self, v: T) -> Self
8826 where
8827 T: std::convert::Into<crate::model::Schema>,
8828 {
8829 self.schema = std::option::Option::Some(v.into());
8830 self
8831 }
8832
8833 /// Sets or clears the value of [schema][crate::model::CommitSchemaRequest::schema].
8834 ///
8835 /// # Example
8836 /// ```ignore,no_run
8837 /// # use google_cloud_pubsub::model::CommitSchemaRequest;
8838 /// use google_cloud_pubsub::model::Schema;
8839 /// let x = CommitSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
8840 /// let x = CommitSchemaRequest::new().set_or_clear_schema(None::<Schema>);
8841 /// ```
8842 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
8843 where
8844 T: std::convert::Into<crate::model::Schema>,
8845 {
8846 self.schema = v.map(|x| x.into());
8847 self
8848 }
8849}
8850
8851impl wkt::message::Message for CommitSchemaRequest {
8852 fn typename() -> &'static str {
8853 "type.googleapis.com/google.pubsub.v1.CommitSchemaRequest"
8854 }
8855}
8856
8857/// Request for the `RollbackSchema` method.
8858#[derive(Clone, Default, PartialEq)]
8859#[non_exhaustive]
8860pub struct RollbackSchemaRequest {
8861 /// Required. The schema being rolled back with revision id.
8862 pub name: std::string::String,
8863
8864 /// Required. The revision ID to roll back to.
8865 /// It must be a revision of the same schema.
8866 ///
8867 /// Example: c7cfa2a8
8868 pub revision_id: std::string::String,
8869
8870 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8871}
8872
8873impl RollbackSchemaRequest {
8874 /// Creates a new default instance.
8875 pub fn new() -> Self {
8876 std::default::Default::default()
8877 }
8878
8879 /// Sets the value of [name][crate::model::RollbackSchemaRequest::name].
8880 ///
8881 /// # Example
8882 /// ```ignore,no_run
8883 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
8884 /// # let project_id = "project_id";
8885 /// # let schema_id = "schema_id";
8886 /// let x = RollbackSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8887 /// ```
8888 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8889 self.name = v.into();
8890 self
8891 }
8892
8893 /// Sets the value of [revision_id][crate::model::RollbackSchemaRequest::revision_id].
8894 ///
8895 /// # Example
8896 /// ```ignore,no_run
8897 /// # use google_cloud_pubsub::model::RollbackSchemaRequest;
8898 /// let x = RollbackSchemaRequest::new().set_revision_id("example");
8899 /// ```
8900 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8901 self.revision_id = v.into();
8902 self
8903 }
8904}
8905
8906impl wkt::message::Message for RollbackSchemaRequest {
8907 fn typename() -> &'static str {
8908 "type.googleapis.com/google.pubsub.v1.RollbackSchemaRequest"
8909 }
8910}
8911
8912/// Request for the `DeleteSchemaRevision` method.
8913#[derive(Clone, Default, PartialEq)]
8914#[non_exhaustive]
8915pub struct DeleteSchemaRevisionRequest {
8916 /// Required. The name of the schema revision to be deleted, with a revision ID
8917 /// explicitly included.
8918 ///
8919 /// Example: `projects/123/schemas/my-schema@c7cfa2a8`
8920 pub name: std::string::String,
8921
8922 /// Optional. This field is deprecated and should not be used for specifying
8923 /// the revision ID. The revision ID should be specified via the `name`
8924 /// parameter.
8925 #[deprecated]
8926 pub revision_id: std::string::String,
8927
8928 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8929}
8930
8931impl DeleteSchemaRevisionRequest {
8932 /// Creates a new default instance.
8933 pub fn new() -> Self {
8934 std::default::Default::default()
8935 }
8936
8937 /// Sets the value of [name][crate::model::DeleteSchemaRevisionRequest::name].
8938 ///
8939 /// # Example
8940 /// ```ignore,no_run
8941 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
8942 /// # let project_id = "project_id";
8943 /// # let schema_id = "schema_id";
8944 /// let x = DeleteSchemaRevisionRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8945 /// ```
8946 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8947 self.name = v.into();
8948 self
8949 }
8950
8951 /// Sets the value of [revision_id][crate::model::DeleteSchemaRevisionRequest::revision_id].
8952 ///
8953 /// # Example
8954 /// ```ignore,no_run
8955 /// # use google_cloud_pubsub::model::DeleteSchemaRevisionRequest;
8956 /// let x = DeleteSchemaRevisionRequest::new().set_revision_id("example");
8957 /// ```
8958 #[deprecated]
8959 pub fn set_revision_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8960 self.revision_id = v.into();
8961 self
8962 }
8963}
8964
8965impl wkt::message::Message for DeleteSchemaRevisionRequest {
8966 fn typename() -> &'static str {
8967 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRevisionRequest"
8968 }
8969}
8970
8971/// Request for the `DeleteSchema` method.
8972#[derive(Clone, Default, PartialEq)]
8973#[non_exhaustive]
8974pub struct DeleteSchemaRequest {
8975 /// Required. Name of the schema to delete.
8976 /// Format is `projects/{project}/schemas/{schema}`.
8977 pub name: std::string::String,
8978
8979 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
8980}
8981
8982impl DeleteSchemaRequest {
8983 /// Creates a new default instance.
8984 pub fn new() -> Self {
8985 std::default::Default::default()
8986 }
8987
8988 /// Sets the value of [name][crate::model::DeleteSchemaRequest::name].
8989 ///
8990 /// # Example
8991 /// ```ignore,no_run
8992 /// # use google_cloud_pubsub::model::DeleteSchemaRequest;
8993 /// # let project_id = "project_id";
8994 /// # let schema_id = "schema_id";
8995 /// let x = DeleteSchemaRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
8996 /// ```
8997 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
8998 self.name = v.into();
8999 self
9000 }
9001}
9002
9003impl wkt::message::Message for DeleteSchemaRequest {
9004 fn typename() -> &'static str {
9005 "type.googleapis.com/google.pubsub.v1.DeleteSchemaRequest"
9006 }
9007}
9008
9009/// Request for the `ValidateSchema` method.
9010#[derive(Clone, Default, PartialEq)]
9011#[non_exhaustive]
9012pub struct ValidateSchemaRequest {
9013 /// Required. The name of the project in which to validate schemas.
9014 /// Format is `projects/{project-id}`.
9015 pub parent: std::string::String,
9016
9017 /// Required. The schema object to validate.
9018 pub schema: std::option::Option<crate::model::Schema>,
9019
9020 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9021}
9022
9023impl ValidateSchemaRequest {
9024 /// Creates a new default instance.
9025 pub fn new() -> Self {
9026 std::default::Default::default()
9027 }
9028
9029 /// Sets the value of [parent][crate::model::ValidateSchemaRequest::parent].
9030 ///
9031 /// # Example
9032 /// ```ignore,no_run
9033 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9034 /// let x = ValidateSchemaRequest::new().set_parent("example");
9035 /// ```
9036 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9037 self.parent = v.into();
9038 self
9039 }
9040
9041 /// Sets the value of [schema][crate::model::ValidateSchemaRequest::schema].
9042 ///
9043 /// # Example
9044 /// ```ignore,no_run
9045 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9046 /// use google_cloud_pubsub::model::Schema;
9047 /// let x = ValidateSchemaRequest::new().set_schema(Schema::default()/* use setters */);
9048 /// ```
9049 pub fn set_schema<T>(mut self, v: T) -> Self
9050 where
9051 T: std::convert::Into<crate::model::Schema>,
9052 {
9053 self.schema = std::option::Option::Some(v.into());
9054 self
9055 }
9056
9057 /// Sets or clears the value of [schema][crate::model::ValidateSchemaRequest::schema].
9058 ///
9059 /// # Example
9060 /// ```ignore,no_run
9061 /// # use google_cloud_pubsub::model::ValidateSchemaRequest;
9062 /// use google_cloud_pubsub::model::Schema;
9063 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(Some(Schema::default()/* use setters */));
9064 /// let x = ValidateSchemaRequest::new().set_or_clear_schema(None::<Schema>);
9065 /// ```
9066 pub fn set_or_clear_schema<T>(mut self, v: std::option::Option<T>) -> Self
9067 where
9068 T: std::convert::Into<crate::model::Schema>,
9069 {
9070 self.schema = v.map(|x| x.into());
9071 self
9072 }
9073}
9074
9075impl wkt::message::Message for ValidateSchemaRequest {
9076 fn typename() -> &'static str {
9077 "type.googleapis.com/google.pubsub.v1.ValidateSchemaRequest"
9078 }
9079}
9080
9081/// Response for the `ValidateSchema` method.
9082/// Empty for now.
9083#[derive(Clone, Default, PartialEq)]
9084#[non_exhaustive]
9085pub struct ValidateSchemaResponse {
9086 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9087}
9088
9089impl ValidateSchemaResponse {
9090 /// Creates a new default instance.
9091 pub fn new() -> Self {
9092 std::default::Default::default()
9093 }
9094}
9095
9096impl wkt::message::Message for ValidateSchemaResponse {
9097 fn typename() -> &'static str {
9098 "type.googleapis.com/google.pubsub.v1.ValidateSchemaResponse"
9099 }
9100}
9101
9102/// Request for the `ValidateMessage` method.
9103#[derive(Clone, Default, PartialEq)]
9104#[non_exhaustive]
9105pub struct ValidateMessageRequest {
9106 /// Required. The name of the project in which to validate schemas.
9107 /// Format is `projects/{project-id}`.
9108 pub parent: std::string::String,
9109
9110 /// Message to validate against the provided `schema_spec`.
9111 pub message: ::bytes::Bytes,
9112
9113 /// The encoding expected for messages
9114 pub encoding: crate::model::Encoding,
9115
9116 #[allow(missing_docs)]
9117 pub schema_spec: std::option::Option<crate::model::validate_message_request::SchemaSpec>,
9118
9119 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9120}
9121
9122impl ValidateMessageRequest {
9123 /// Creates a new default instance.
9124 pub fn new() -> Self {
9125 std::default::Default::default()
9126 }
9127
9128 /// Sets the value of [parent][crate::model::ValidateMessageRequest::parent].
9129 ///
9130 /// # Example
9131 /// ```ignore,no_run
9132 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9133 /// let x = ValidateMessageRequest::new().set_parent("example");
9134 /// ```
9135 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9136 self.parent = v.into();
9137 self
9138 }
9139
9140 /// Sets the value of [message][crate::model::ValidateMessageRequest::message].
9141 ///
9142 /// # Example
9143 /// ```ignore,no_run
9144 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9145 /// let x = ValidateMessageRequest::new().set_message(bytes::Bytes::from_static(b"example"));
9146 /// ```
9147 pub fn set_message<T: std::convert::Into<::bytes::Bytes>>(mut self, v: T) -> Self {
9148 self.message = v.into();
9149 self
9150 }
9151
9152 /// Sets the value of [encoding][crate::model::ValidateMessageRequest::encoding].
9153 ///
9154 /// # Example
9155 /// ```ignore,no_run
9156 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9157 /// use google_cloud_pubsub::model::Encoding;
9158 /// let x0 = ValidateMessageRequest::new().set_encoding(Encoding::Json);
9159 /// let x1 = ValidateMessageRequest::new().set_encoding(Encoding::Binary);
9160 /// ```
9161 pub fn set_encoding<T: std::convert::Into<crate::model::Encoding>>(mut self, v: T) -> Self {
9162 self.encoding = v.into();
9163 self
9164 }
9165
9166 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec].
9167 ///
9168 /// Note that all the setters affecting `schema_spec` are mutually
9169 /// exclusive.
9170 ///
9171 /// # Example
9172 /// ```ignore,no_run
9173 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9174 /// use google_cloud_pubsub::model::validate_message_request::SchemaSpec;
9175 /// let x = ValidateMessageRequest::new().set_schema_spec(Some(SchemaSpec::Name("example".to_string())));
9176 /// ```
9177 pub fn set_schema_spec<
9178 T: std::convert::Into<std::option::Option<crate::model::validate_message_request::SchemaSpec>>,
9179 >(
9180 mut self,
9181 v: T,
9182 ) -> Self {
9183 self.schema_spec = v.into();
9184 self
9185 }
9186
9187 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9188 /// if it holds a `Name`, `None` if the field is not set or
9189 /// holds a different branch.
9190 pub fn name(&self) -> std::option::Option<&std::string::String> {
9191 #[allow(unreachable_patterns)]
9192 self.schema_spec.as_ref().and_then(|v| match v {
9193 crate::model::validate_message_request::SchemaSpec::Name(v) => {
9194 std::option::Option::Some(v)
9195 }
9196 _ => std::option::Option::None,
9197 })
9198 }
9199
9200 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9201 /// to hold a `Name`.
9202 ///
9203 /// Note that all the setters affecting `schema_spec` are
9204 /// mutually exclusive.
9205 ///
9206 /// # Example
9207 /// ```ignore,no_run
9208 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9209 /// # let project_id = "project_id";
9210 /// # let schema_id = "schema_id";
9211 /// let x = ValidateMessageRequest::new().set_name(format!("projects/{project_id}/schemas/{schema_id}"));
9212 /// assert!(x.name().is_some());
9213 /// assert!(x.schema().is_none());
9214 /// ```
9215 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
9216 self.schema_spec = std::option::Option::Some(
9217 crate::model::validate_message_request::SchemaSpec::Name(v.into()),
9218 );
9219 self
9220 }
9221
9222 /// The value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9223 /// if it holds a `Schema`, `None` if the field is not set or
9224 /// holds a different branch.
9225 pub fn schema(&self) -> std::option::Option<&std::boxed::Box<crate::model::Schema>> {
9226 #[allow(unreachable_patterns)]
9227 self.schema_spec.as_ref().and_then(|v| match v {
9228 crate::model::validate_message_request::SchemaSpec::Schema(v) => {
9229 std::option::Option::Some(v)
9230 }
9231 _ => std::option::Option::None,
9232 })
9233 }
9234
9235 /// Sets the value of [schema_spec][crate::model::ValidateMessageRequest::schema_spec]
9236 /// to hold a `Schema`.
9237 ///
9238 /// Note that all the setters affecting `schema_spec` are
9239 /// mutually exclusive.
9240 ///
9241 /// # Example
9242 /// ```ignore,no_run
9243 /// # use google_cloud_pubsub::model::ValidateMessageRequest;
9244 /// use google_cloud_pubsub::model::Schema;
9245 /// let x = ValidateMessageRequest::new().set_schema(Schema::default()/* use setters */);
9246 /// assert!(x.schema().is_some());
9247 /// assert!(x.name().is_none());
9248 /// ```
9249 pub fn set_schema<T: std::convert::Into<std::boxed::Box<crate::model::Schema>>>(
9250 mut self,
9251 v: T,
9252 ) -> Self {
9253 self.schema_spec = std::option::Option::Some(
9254 crate::model::validate_message_request::SchemaSpec::Schema(v.into()),
9255 );
9256 self
9257 }
9258}
9259
9260impl wkt::message::Message for ValidateMessageRequest {
9261 fn typename() -> &'static str {
9262 "type.googleapis.com/google.pubsub.v1.ValidateMessageRequest"
9263 }
9264}
9265
9266/// Defines additional types related to [ValidateMessageRequest].
9267pub mod validate_message_request {
9268 #[allow(unused_imports)]
9269 use super::*;
9270
9271 #[allow(missing_docs)]
9272 #[derive(Clone, Debug, PartialEq)]
9273 #[non_exhaustive]
9274 pub enum SchemaSpec {
9275 /// Name of the schema against which to validate.
9276 ///
9277 /// Format is `projects/{project}/schemas/{schema}`.
9278 Name(std::string::String),
9279 /// Ad-hoc schema against which to validate
9280 Schema(std::boxed::Box<crate::model::Schema>),
9281 }
9282}
9283
9284/// Response for the `ValidateMessage` method.
9285/// Empty for now.
9286#[derive(Clone, Default, PartialEq)]
9287#[non_exhaustive]
9288pub struct ValidateMessageResponse {
9289 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
9290}
9291
9292impl ValidateMessageResponse {
9293 /// Creates a new default instance.
9294 pub fn new() -> Self {
9295 std::default::Default::default()
9296 }
9297}
9298
9299impl wkt::message::Message for ValidateMessageResponse {
9300 fn typename() -> &'static str {
9301 "type.googleapis.com/google.pubsub.v1.ValidateMessageResponse"
9302 }
9303}
9304
9305/// View of Schema object fields to be returned by GetSchema and ListSchemas.
9306///
9307/// # Working with unknown values
9308///
9309/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9310/// additional enum variants at any time. Adding new variants is not considered
9311/// a breaking change. Applications should write their code in anticipation of:
9312///
9313/// - New values appearing in future releases of the client library, **and**
9314/// - New values received dynamically, without application changes.
9315///
9316/// Please consult the [Working with enums] section in the user guide for some
9317/// guidelines.
9318///
9319/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9320#[derive(Clone, Debug, PartialEq)]
9321#[non_exhaustive]
9322pub enum SchemaView {
9323 /// The default / unset value.
9324 /// The API will default to the BASIC view.
9325 Unspecified,
9326 /// Include the name and type of the schema, but not the definition.
9327 Basic,
9328 /// Include all Schema object fields.
9329 Full,
9330 /// If set, the enum was initialized with an unknown value.
9331 ///
9332 /// Applications can examine the value using [SchemaView::value] or
9333 /// [SchemaView::name].
9334 UnknownValue(schema_view::UnknownValue),
9335}
9336
9337#[doc(hidden)]
9338pub mod schema_view {
9339 #[allow(unused_imports)]
9340 use super::*;
9341 #[derive(Clone, Debug, PartialEq)]
9342 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9343}
9344
9345impl SchemaView {
9346 /// Gets the enum value.
9347 ///
9348 /// Returns `None` if the enum contains an unknown value deserialized from
9349 /// the string representation of enums.
9350 pub fn value(&self) -> std::option::Option<i32> {
9351 match self {
9352 Self::Unspecified => std::option::Option::Some(0),
9353 Self::Basic => std::option::Option::Some(1),
9354 Self::Full => std::option::Option::Some(2),
9355 Self::UnknownValue(u) => u.0.value(),
9356 }
9357 }
9358
9359 /// Gets the enum value as a string.
9360 ///
9361 /// Returns `None` if the enum contains an unknown value deserialized from
9362 /// the integer representation of enums.
9363 pub fn name(&self) -> std::option::Option<&str> {
9364 match self {
9365 Self::Unspecified => std::option::Option::Some("SCHEMA_VIEW_UNSPECIFIED"),
9366 Self::Basic => std::option::Option::Some("BASIC"),
9367 Self::Full => std::option::Option::Some("FULL"),
9368 Self::UnknownValue(u) => u.0.name(),
9369 }
9370 }
9371}
9372
9373impl std::default::Default for SchemaView {
9374 fn default() -> Self {
9375 use std::convert::From;
9376 Self::from(0)
9377 }
9378}
9379
9380impl std::fmt::Display for SchemaView {
9381 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
9382 wkt::internal::display_enum(f, self.name(), self.value())
9383 }
9384}
9385
9386impl std::convert::From<i32> for SchemaView {
9387 fn from(value: i32) -> Self {
9388 match value {
9389 0 => Self::Unspecified,
9390 1 => Self::Basic,
9391 2 => Self::Full,
9392 _ => Self::UnknownValue(schema_view::UnknownValue(
9393 wkt::internal::UnknownEnumValue::Integer(value),
9394 )),
9395 }
9396 }
9397}
9398
9399impl std::convert::From<&str> for SchemaView {
9400 fn from(value: &str) -> Self {
9401 use std::string::ToString;
9402 match value {
9403 "SCHEMA_VIEW_UNSPECIFIED" => Self::Unspecified,
9404 "BASIC" => Self::Basic,
9405 "FULL" => Self::Full,
9406 _ => Self::UnknownValue(schema_view::UnknownValue(
9407 wkt::internal::UnknownEnumValue::String(value.to_string()),
9408 )),
9409 }
9410 }
9411}
9412
9413impl serde::ser::Serialize for SchemaView {
9414 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9415 where
9416 S: serde::Serializer,
9417 {
9418 match self {
9419 Self::Unspecified => serializer.serialize_i32(0),
9420 Self::Basic => serializer.serialize_i32(1),
9421 Self::Full => serializer.serialize_i32(2),
9422 Self::UnknownValue(u) => u.0.serialize(serializer),
9423 }
9424 }
9425}
9426
9427impl<'de> serde::de::Deserialize<'de> for SchemaView {
9428 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9429 where
9430 D: serde::Deserializer<'de>,
9431 {
9432 deserializer.deserialize_any(wkt::internal::EnumVisitor::<SchemaView>::new(
9433 ".google.pubsub.v1.SchemaView",
9434 ))
9435 }
9436}
9437
9438/// Possible encoding types for messages.
9439///
9440/// # Working with unknown values
9441///
9442/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
9443/// additional enum variants at any time. Adding new variants is not considered
9444/// a breaking change. Applications should write their code in anticipation of:
9445///
9446/// - New values appearing in future releases of the client library, **and**
9447/// - New values received dynamically, without application changes.
9448///
9449/// Please consult the [Working with enums] section in the user guide for some
9450/// guidelines.
9451///
9452/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
9453#[derive(Clone, Debug, PartialEq)]
9454#[non_exhaustive]
9455pub enum Encoding {
9456 /// Unspecified
9457 Unspecified,
9458 /// JSON encoding
9459 Json,
9460 /// Binary encoding, as defined by the schema type. For some schema types,
9461 /// binary encoding may not be available.
9462 Binary,
9463 /// If set, the enum was initialized with an unknown value.
9464 ///
9465 /// Applications can examine the value using [Encoding::value] or
9466 /// [Encoding::name].
9467 UnknownValue(encoding::UnknownValue),
9468}
9469
9470#[doc(hidden)]
9471pub mod encoding {
9472 #[allow(unused_imports)]
9473 use super::*;
9474 #[derive(Clone, Debug, PartialEq)]
9475 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
9476}
9477
9478impl Encoding {
9479 /// Gets the enum value.
9480 ///
9481 /// Returns `None` if the enum contains an unknown value deserialized from
9482 /// the string representation of enums.
9483 pub fn value(&self) -> std::option::Option<i32> {
9484 match self {
9485 Self::Unspecified => std::option::Option::Some(0),
9486 Self::Json => std::option::Option::Some(1),
9487 Self::Binary => std::option::Option::Some(2),
9488 Self::UnknownValue(u) => u.0.value(),
9489 }
9490 }
9491
9492 /// Gets the enum value as a string.
9493 ///
9494 /// Returns `None` if the enum contains an unknown value deserialized from
9495 /// the integer representation of enums.
9496 pub fn name(&self) -> std::option::Option<&str> {
9497 match self {
9498 Self::Unspecified => std::option::Option::Some("ENCODING_UNSPECIFIED"),
9499 Self::Json => std::option::Option::Some("JSON"),
9500 Self::Binary => std::option::Option::Some("BINARY"),
9501 Self::UnknownValue(u) => u.0.name(),
9502 }
9503 }
9504}
9505
9506impl std::default::Default for Encoding {
9507 fn default() -> Self {
9508 use std::convert::From;
9509 Self::from(0)
9510 }
9511}
9512
9513impl std::fmt::Display for Encoding {
9514 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
9515 wkt::internal::display_enum(f, self.name(), self.value())
9516 }
9517}
9518
9519impl std::convert::From<i32> for Encoding {
9520 fn from(value: i32) -> Self {
9521 match value {
9522 0 => Self::Unspecified,
9523 1 => Self::Json,
9524 2 => Self::Binary,
9525 _ => Self::UnknownValue(encoding::UnknownValue(
9526 wkt::internal::UnknownEnumValue::Integer(value),
9527 )),
9528 }
9529 }
9530}
9531
9532impl std::convert::From<&str> for Encoding {
9533 fn from(value: &str) -> Self {
9534 use std::string::ToString;
9535 match value {
9536 "ENCODING_UNSPECIFIED" => Self::Unspecified,
9537 "JSON" => Self::Json,
9538 "BINARY" => Self::Binary,
9539 _ => Self::UnknownValue(encoding::UnknownValue(
9540 wkt::internal::UnknownEnumValue::String(value.to_string()),
9541 )),
9542 }
9543 }
9544}
9545
9546impl serde::ser::Serialize for Encoding {
9547 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
9548 where
9549 S: serde::Serializer,
9550 {
9551 match self {
9552 Self::Unspecified => serializer.serialize_i32(0),
9553 Self::Json => serializer.serialize_i32(1),
9554 Self::Binary => serializer.serialize_i32(2),
9555 Self::UnknownValue(u) => u.0.serialize(serializer),
9556 }
9557 }
9558}
9559
9560impl<'de> serde::de::Deserialize<'de> for Encoding {
9561 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
9562 where
9563 D: serde::Deserializer<'de>,
9564 {
9565 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Encoding>::new(
9566 ".google.pubsub.v1.Encoding",
9567 ))
9568 }
9569}