google-cloud-apps-script-type-gmail 1.6.0

Google Cloud Client Libraries for Rust - Google Apps Script Types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate bytes;
extern crate google_cloud_apps_script_type;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Properties customizing the appearance and execution of a Gmail add-on.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GmailAddOnManifest {
    /// Defines an endpoint that will be executed in contexts that don't
    /// match a declared contextual trigger. Any cards generated by this function
    /// will always be available to the user, but may be eclipsed by contextual
    /// content when this add-on declares more targeted triggers.
    ///
    /// If present, this overrides the configuration from
    /// `addOns.common.homepageTrigger`.
    pub homepage_trigger:
        std::option::Option<google_cloud_apps_script_type::model::HomepageExtensionPoint>,

    /// Defines the set of conditions that trigger the add-on.
    pub contextual_triggers: std::vec::Vec<crate::model::ContextualTrigger>,

    /// Defines set of [universal
    /// actions](/gmail/add-ons/how-tos/universal-actions) for the add-on. The user
    /// triggers universal actions from the add-on toolbar menu.
    pub universal_actions: std::vec::Vec<crate::model::UniversalAction>,

    /// Defines the compose time trigger for a compose time add-on. This is the
    /// trigger that causes an add-on to take action when the user is composing an
    /// email.
    /// All compose time addons are required to have the
    /// gmail.addons.current.action.compose scope even though it might not edit the
    /// draft.
    pub compose_trigger: std::option::Option<crate::model::ComposeTrigger>,

    /// The name of an endpoint that verifies that the add-on has
    /// all the required third-party authorizations, by probing the third-party
    /// APIs. If the probe fails, the function should throw an exception to
    /// initiate the authorization flow. This function is called before each
    /// invocation of the add-on, in order to ensure a smooth user experience.
    pub authorization_check_function: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GmailAddOnManifest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [homepage_trigger][crate::model::GmailAddOnManifest::homepage_trigger].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type::model::HomepageExtensionPoint;
    /// let x = GmailAddOnManifest::new().set_homepage_trigger(HomepageExtensionPoint::default()/* use setters */);
    /// ```
    pub fn set_homepage_trigger<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<google_cloud_apps_script_type::model::HomepageExtensionPoint>,
    {
        self.homepage_trigger = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [homepage_trigger][crate::model::GmailAddOnManifest::homepage_trigger].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type::model::HomepageExtensionPoint;
    /// let x = GmailAddOnManifest::new().set_or_clear_homepage_trigger(Some(HomepageExtensionPoint::default()/* use setters */));
    /// let x = GmailAddOnManifest::new().set_or_clear_homepage_trigger(None::<HomepageExtensionPoint>);
    /// ```
    pub fn set_or_clear_homepage_trigger<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<google_cloud_apps_script_type::model::HomepageExtensionPoint>,
    {
        self.homepage_trigger = v.map(|x| x.into());
        self
    }

    /// Sets the value of [contextual_triggers][crate::model::GmailAddOnManifest::contextual_triggers].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type_gmail::model::ContextualTrigger;
    /// let x = GmailAddOnManifest::new()
    ///     .set_contextual_triggers([
    ///         ContextualTrigger::default()/* use setters */,
    ///         ContextualTrigger::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_contextual_triggers<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ContextualTrigger>,
    {
        use std::iter::Iterator;
        self.contextual_triggers = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [universal_actions][crate::model::GmailAddOnManifest::universal_actions].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type_gmail::model::UniversalAction;
    /// let x = GmailAddOnManifest::new()
    ///     .set_universal_actions([
    ///         UniversalAction::default()/* use setters */,
    ///         UniversalAction::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_universal_actions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::UniversalAction>,
    {
        use std::iter::Iterator;
        self.universal_actions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [compose_trigger][crate::model::GmailAddOnManifest::compose_trigger].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type_gmail::model::ComposeTrigger;
    /// let x = GmailAddOnManifest::new().set_compose_trigger(ComposeTrigger::default()/* use setters */);
    /// ```
    pub fn set_compose_trigger<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ComposeTrigger>,
    {
        self.compose_trigger = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [compose_trigger][crate::model::GmailAddOnManifest::compose_trigger].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// use google_cloud_apps_script_type_gmail::model::ComposeTrigger;
    /// let x = GmailAddOnManifest::new().set_or_clear_compose_trigger(Some(ComposeTrigger::default()/* use setters */));
    /// let x = GmailAddOnManifest::new().set_or_clear_compose_trigger(None::<ComposeTrigger>);
    /// ```
    pub fn set_or_clear_compose_trigger<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ComposeTrigger>,
    {
        self.compose_trigger = v.map(|x| x.into());
        self
    }

    /// Sets the value of [authorization_check_function][crate::model::GmailAddOnManifest::authorization_check_function].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::GmailAddOnManifest;
    /// let x = GmailAddOnManifest::new().set_authorization_check_function("example");
    /// ```
    pub fn set_authorization_check_function<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.authorization_check_function = v.into();
        self
    }
}

impl wkt::message::Message for GmailAddOnManifest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.gmail.GmailAddOnManifest"
    }
}

/// An action that is always available in the add-on toolbar menu regardless of
/// message context.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UniversalAction {
    /// Required. User-visible text describing the action, for example, "Add a new
    /// contact."
    pub text: std::string::String,

    /// The type of the action determines the behavior of Gmail when the user
    /// invokes the action.
    pub action_type: std::option::Option<crate::model::universal_action::ActionType>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UniversalAction {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [text][crate::model::UniversalAction::text].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::UniversalAction;
    /// let x = UniversalAction::new().set_text("example");
    /// ```
    pub fn set_text<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.text = v.into();
        self
    }

    /// Sets the value of [action_type][crate::model::UniversalAction::action_type].
    ///
    /// Note that all the setters affecting `action_type` are mutually
    /// exclusive.
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::UniversalAction;
    /// use google_cloud_apps_script_type_gmail::model::universal_action::ActionType;
    /// let x = UniversalAction::new().set_action_type(Some(ActionType::OpenLink("example".to_string())));
    /// ```
    pub fn set_action_type<
        T: std::convert::Into<std::option::Option<crate::model::universal_action::ActionType>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.action_type = v.into();
        self
    }

    /// The value of [action_type][crate::model::UniversalAction::action_type]
    /// if it holds a `OpenLink`, `None` if the field is not set or
    /// holds a different branch.
    pub fn open_link(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.action_type.as_ref().and_then(|v| match v {
            crate::model::universal_action::ActionType::OpenLink(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [action_type][crate::model::UniversalAction::action_type]
    /// to hold a `OpenLink`.
    ///
    /// Note that all the setters affecting `action_type` are
    /// mutually exclusive.
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::UniversalAction;
    /// let x = UniversalAction::new().set_open_link("example");
    /// assert!(x.open_link().is_some());
    /// assert!(x.run_function().is_none());
    /// ```
    pub fn set_open_link<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.action_type = std::option::Option::Some(
            crate::model::universal_action::ActionType::OpenLink(v.into()),
        );
        self
    }

    /// The value of [action_type][crate::model::UniversalAction::action_type]
    /// if it holds a `RunFunction`, `None` if the field is not set or
    /// holds a different branch.
    pub fn run_function(&self) -> std::option::Option<&std::string::String> {
        #[allow(unreachable_patterns)]
        self.action_type.as_ref().and_then(|v| match v {
            crate::model::universal_action::ActionType::RunFunction(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [action_type][crate::model::UniversalAction::action_type]
    /// to hold a `RunFunction`.
    ///
    /// Note that all the setters affecting `action_type` are
    /// mutually exclusive.
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::UniversalAction;
    /// let x = UniversalAction::new().set_run_function("example");
    /// assert!(x.run_function().is_some());
    /// assert!(x.open_link().is_none());
    /// ```
    pub fn set_run_function<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.action_type = std::option::Option::Some(
            crate::model::universal_action::ActionType::RunFunction(v.into()),
        );
        self
    }
}

impl wkt::message::Message for UniversalAction {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.gmail.UniversalAction"
    }
}

/// Defines additional types related to [UniversalAction].
pub mod universal_action {
    #[allow(unused_imports)]
    use super::*;

    /// The type of the action determines the behavior of Gmail when the user
    /// invokes the action.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum ActionType {
        /// A link that is opened by Gmail when the user triggers the action.
        OpenLink(std::string::String),
        /// An endpoint that is called when the user triggers the
        /// action. See the [universal actions
        /// guide](/gmail/add-ons/how-tos/universal-actions) for details.
        RunFunction(std::string::String),
    }
}

/// A trigger that activates when user is composing an email.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ComposeTrigger {
    /// Defines the set of actions for compose time add-on. These are actions
    /// that user can trigger on a compose time addon.
    pub actions: std::vec::Vec<google_cloud_apps_script_type::model::MenuItemExtensionPoint>,

    /// Define the level of data access when a compose time addon is triggered.
    pub draft_access: crate::model::compose_trigger::DraftAccess,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ComposeTrigger {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [actions][crate::model::ComposeTrigger::actions].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::ComposeTrigger;
    /// use google_cloud_apps_script_type::model::MenuItemExtensionPoint;
    /// let x = ComposeTrigger::new()
    ///     .set_actions([
    ///         MenuItemExtensionPoint::default()/* use setters */,
    ///         MenuItemExtensionPoint::default()/* use (different) setters */,
    ///     ]);
    /// ```
    pub fn set_actions<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<google_cloud_apps_script_type::model::MenuItemExtensionPoint>,
    {
        use std::iter::Iterator;
        self.actions = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [draft_access][crate::model::ComposeTrigger::draft_access].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::ComposeTrigger;
    /// use google_cloud_apps_script_type_gmail::model::compose_trigger::DraftAccess;
    /// let x0 = ComposeTrigger::new().set_draft_access(DraftAccess::None);
    /// let x1 = ComposeTrigger::new().set_draft_access(DraftAccess::Metadata);
    /// ```
    pub fn set_draft_access<T: std::convert::Into<crate::model::compose_trigger::DraftAccess>>(
        mut self,
        v: T,
    ) -> Self {
        self.draft_access = v.into();
        self
    }
}

impl wkt::message::Message for ComposeTrigger {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.gmail.ComposeTrigger"
    }
}

/// Defines additional types related to [ComposeTrigger].
pub mod compose_trigger {
    #[allow(unused_imports)]
    use super::*;

    /// An enum defining the level of data access this compose trigger requires.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum DraftAccess {
        /// Default value when nothing is set for DraftAccess.
        Unspecified,
        /// NONE means compose trigger won't be able to access any data of the draft
        /// when a compose addon is triggered.
        None,
        /// METADATA gives compose trigger the permission to access the metadata of
        /// the draft when a compose addon is triggered. This includes the audience
        /// list (To/cc list) of a draft message.
        Metadata,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [DraftAccess::value] or
        /// [DraftAccess::name].
        UnknownValue(draft_access::UnknownValue),
    }

    #[doc(hidden)]
    pub mod draft_access {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl DraftAccess {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::None => std::option::Option::Some(1),
                Self::Metadata => std::option::Option::Some(2),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("UNSPECIFIED"),
                Self::None => std::option::Option::Some("NONE"),
                Self::Metadata => std::option::Option::Some("METADATA"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for DraftAccess {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for DraftAccess {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for DraftAccess {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::None,
                2 => Self::Metadata,
                _ => Self::UnknownValue(draft_access::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for DraftAccess {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "UNSPECIFIED" => Self::Unspecified,
                "NONE" => Self::None,
                "METADATA" => Self::Metadata,
                _ => Self::UnknownValue(draft_access::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for DraftAccess {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::None => serializer.serialize_i32(1),
                Self::Metadata => serializer.serialize_i32(2),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for DraftAccess {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DraftAccess>::new(
                ".google.apps.script.type.gmail.ComposeTrigger.DraftAccess",
            ))
        }
    }
}

/// Defines a trigger that fires when the open email meets a specific criteria.
/// When the trigger fires, it executes a specific endpoint, usually
/// in order to create new cards and update the UI.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ContextualTrigger {
    /// Required. The name of the endpoint to call when a message matches the
    /// trigger.
    pub on_trigger_function: std::string::String,

    /// The type of trigger determines the conditions Gmail uses to show the
    /// add-on.
    pub trigger: std::option::Option<crate::model::contextual_trigger::Trigger>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ContextualTrigger {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [on_trigger_function][crate::model::ContextualTrigger::on_trigger_function].
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::ContextualTrigger;
    /// let x = ContextualTrigger::new().set_on_trigger_function("example");
    /// ```
    pub fn set_on_trigger_function<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.on_trigger_function = v.into();
        self
    }

    /// Sets the value of [trigger][crate::model::ContextualTrigger::trigger].
    ///
    /// Note that all the setters affecting `trigger` are mutually
    /// exclusive.
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::ContextualTrigger;
    /// use google_cloud_apps_script_type_gmail::model::UnconditionalTrigger;
    /// let x = ContextualTrigger::new().set_trigger(Some(
    ///     google_cloud_apps_script_type_gmail::model::contextual_trigger::Trigger::Unconditional(UnconditionalTrigger::default().into())));
    /// ```
    pub fn set_trigger<
        T: std::convert::Into<std::option::Option<crate::model::contextual_trigger::Trigger>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.trigger = v.into();
        self
    }

    /// The value of [trigger][crate::model::ContextualTrigger::trigger]
    /// if it holds a `Unconditional`, `None` if the field is not set or
    /// holds a different branch.
    pub fn unconditional(
        &self,
    ) -> std::option::Option<&std::boxed::Box<crate::model::UnconditionalTrigger>> {
        #[allow(unreachable_patterns)]
        self.trigger.as_ref().and_then(|v| match v {
            crate::model::contextual_trigger::Trigger::Unconditional(v) => {
                std::option::Option::Some(v)
            }
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [trigger][crate::model::ContextualTrigger::trigger]
    /// to hold a `Unconditional`.
    ///
    /// Note that all the setters affecting `trigger` are
    /// mutually exclusive.
    ///
    /// # Example
    /// ```ignore,no_run
    /// # use google_cloud_apps_script_type_gmail::model::ContextualTrigger;
    /// use google_cloud_apps_script_type_gmail::model::UnconditionalTrigger;
    /// let x = ContextualTrigger::new().set_unconditional(UnconditionalTrigger::default()/* use setters */);
    /// assert!(x.unconditional().is_some());
    /// ```
    pub fn set_unconditional<
        T: std::convert::Into<std::boxed::Box<crate::model::UnconditionalTrigger>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.trigger = std::option::Option::Some(
            crate::model::contextual_trigger::Trigger::Unconditional(v.into()),
        );
        self
    }
}

impl wkt::message::Message for ContextualTrigger {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.gmail.ContextualTrigger"
    }
}

/// Defines additional types related to [ContextualTrigger].
pub mod contextual_trigger {
    #[allow(unused_imports)]
    use super::*;

    /// The type of trigger determines the conditions Gmail uses to show the
    /// add-on.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Trigger {
        /// UnconditionalTriggers are executed when any mail message is opened.
        Unconditional(std::boxed::Box<crate::model::UnconditionalTrigger>),
    }
}

/// A trigger that fires when any email message is opened.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct UnconditionalTrigger {
    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl UnconditionalTrigger {
    pub fn new() -> Self {
        std::default::Default::default()
    }
}

impl wkt::message::Message for UnconditionalTrigger {
    fn typename() -> &'static str {
        "type.googleapis.com/google.apps.script.type.gmail.UnconditionalTrigger"
    }
}