Skip to main content

google_cloud_functions_v2/
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#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_iam_v1;
25extern crate google_cloud_location;
26extern crate google_cloud_longrunning;
27extern crate google_cloud_lro;
28extern crate google_cloud_type;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36mod debug;
37mod deserialize;
38mod serialize;
39
40/// Describes a Cloud Function that contains user computation executed in
41/// response to an event. It encapsulates function and trigger configurations.
42#[derive(Clone, Default, PartialEq)]
43#[non_exhaustive]
44pub struct Function {
45    /// A user-defined name of the function. Function names must be unique
46    /// globally and match pattern `projects/*/locations/*/functions/*`
47    pub name: std::string::String,
48
49    /// User-provided description of a function.
50    pub description: std::string::String,
51
52    /// Describes the Build step of the function that builds a container from the
53    /// given source.
54    pub build_config: std::option::Option<crate::model::BuildConfig>,
55
56    /// Describes the Service being deployed. Currently deploys services to Cloud
57    /// Run (fully managed).
58    pub service_config: std::option::Option<crate::model::ServiceConfig>,
59
60    /// An Eventarc trigger managed by Google Cloud Functions that fires events in
61    /// response to a condition in another service.
62    pub event_trigger: std::option::Option<crate::model::EventTrigger>,
63
64    /// Output only. State of the function.
65    pub state: crate::model::function::State,
66
67    /// Output only. The last update timestamp of a Cloud Function.
68    pub update_time: std::option::Option<wkt::Timestamp>,
69
70    /// Labels associated with this Cloud Function.
71    pub labels: std::collections::HashMap<std::string::String, std::string::String>,
72
73    /// Output only. State Messages for this Cloud Function.
74    pub state_messages: std::vec::Vec<crate::model::StateMessage>,
75
76    /// Describe whether the function is 1st Gen or 2nd Gen.
77    pub environment: crate::model::Environment,
78
79    /// Output only. The deployed url for the function.
80    pub url: std::string::String,
81
82    /// Resource name of a KMS crypto key (managed by the user) used to
83    /// encrypt/decrypt function resources.
84    ///
85    /// It must match the pattern
86    /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
87    pub kms_key_name: std::string::String,
88
89    /// Output only. Reserved for future use.
90    pub satisfies_pzs: bool,
91
92    /// Output only. The create timestamp of a Cloud Function. This is only
93    /// applicable to 2nd Gen functions.
94    pub create_time: std::option::Option<wkt::Timestamp>,
95
96    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
97}
98
99impl Function {
100    pub fn new() -> Self {
101        std::default::Default::default()
102    }
103
104    /// Sets the value of [name][crate::model::Function::name].
105    ///
106    /// # Example
107    /// ```ignore,no_run
108    /// # use google_cloud_functions_v2::model::Function;
109    /// let x = Function::new().set_name("example");
110    /// ```
111    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
112        self.name = v.into();
113        self
114    }
115
116    /// Sets the value of [description][crate::model::Function::description].
117    ///
118    /// # Example
119    /// ```ignore,no_run
120    /// # use google_cloud_functions_v2::model::Function;
121    /// let x = Function::new().set_description("example");
122    /// ```
123    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
124        self.description = v.into();
125        self
126    }
127
128    /// Sets the value of [build_config][crate::model::Function::build_config].
129    ///
130    /// # Example
131    /// ```ignore,no_run
132    /// # use google_cloud_functions_v2::model::Function;
133    /// use google_cloud_functions_v2::model::BuildConfig;
134    /// let x = Function::new().set_build_config(BuildConfig::default()/* use setters */);
135    /// ```
136    pub fn set_build_config<T>(mut self, v: T) -> Self
137    where
138        T: std::convert::Into<crate::model::BuildConfig>,
139    {
140        self.build_config = std::option::Option::Some(v.into());
141        self
142    }
143
144    /// Sets or clears the value of [build_config][crate::model::Function::build_config].
145    ///
146    /// # Example
147    /// ```ignore,no_run
148    /// # use google_cloud_functions_v2::model::Function;
149    /// use google_cloud_functions_v2::model::BuildConfig;
150    /// let x = Function::new().set_or_clear_build_config(Some(BuildConfig::default()/* use setters */));
151    /// let x = Function::new().set_or_clear_build_config(None::<BuildConfig>);
152    /// ```
153    pub fn set_or_clear_build_config<T>(mut self, v: std::option::Option<T>) -> Self
154    where
155        T: std::convert::Into<crate::model::BuildConfig>,
156    {
157        self.build_config = v.map(|x| x.into());
158        self
159    }
160
161    /// Sets the value of [service_config][crate::model::Function::service_config].
162    ///
163    /// # Example
164    /// ```ignore,no_run
165    /// # use google_cloud_functions_v2::model::Function;
166    /// use google_cloud_functions_v2::model::ServiceConfig;
167    /// let x = Function::new().set_service_config(ServiceConfig::default()/* use setters */);
168    /// ```
169    pub fn set_service_config<T>(mut self, v: T) -> Self
170    where
171        T: std::convert::Into<crate::model::ServiceConfig>,
172    {
173        self.service_config = std::option::Option::Some(v.into());
174        self
175    }
176
177    /// Sets or clears the value of [service_config][crate::model::Function::service_config].
178    ///
179    /// # Example
180    /// ```ignore,no_run
181    /// # use google_cloud_functions_v2::model::Function;
182    /// use google_cloud_functions_v2::model::ServiceConfig;
183    /// let x = Function::new().set_or_clear_service_config(Some(ServiceConfig::default()/* use setters */));
184    /// let x = Function::new().set_or_clear_service_config(None::<ServiceConfig>);
185    /// ```
186    pub fn set_or_clear_service_config<T>(mut self, v: std::option::Option<T>) -> Self
187    where
188        T: std::convert::Into<crate::model::ServiceConfig>,
189    {
190        self.service_config = v.map(|x| x.into());
191        self
192    }
193
194    /// Sets the value of [event_trigger][crate::model::Function::event_trigger].
195    ///
196    /// # Example
197    /// ```ignore,no_run
198    /// # use google_cloud_functions_v2::model::Function;
199    /// use google_cloud_functions_v2::model::EventTrigger;
200    /// let x = Function::new().set_event_trigger(EventTrigger::default()/* use setters */);
201    /// ```
202    pub fn set_event_trigger<T>(mut self, v: T) -> Self
203    where
204        T: std::convert::Into<crate::model::EventTrigger>,
205    {
206        self.event_trigger = std::option::Option::Some(v.into());
207        self
208    }
209
210    /// Sets or clears the value of [event_trigger][crate::model::Function::event_trigger].
211    ///
212    /// # Example
213    /// ```ignore,no_run
214    /// # use google_cloud_functions_v2::model::Function;
215    /// use google_cloud_functions_v2::model::EventTrigger;
216    /// let x = Function::new().set_or_clear_event_trigger(Some(EventTrigger::default()/* use setters */));
217    /// let x = Function::new().set_or_clear_event_trigger(None::<EventTrigger>);
218    /// ```
219    pub fn set_or_clear_event_trigger<T>(mut self, v: std::option::Option<T>) -> Self
220    where
221        T: std::convert::Into<crate::model::EventTrigger>,
222    {
223        self.event_trigger = v.map(|x| x.into());
224        self
225    }
226
227    /// Sets the value of [state][crate::model::Function::state].
228    ///
229    /// # Example
230    /// ```ignore,no_run
231    /// # use google_cloud_functions_v2::model::Function;
232    /// use google_cloud_functions_v2::model::function::State;
233    /// let x0 = Function::new().set_state(State::Active);
234    /// let x1 = Function::new().set_state(State::Failed);
235    /// let x2 = Function::new().set_state(State::Deploying);
236    /// ```
237    pub fn set_state<T: std::convert::Into<crate::model::function::State>>(mut self, v: T) -> Self {
238        self.state = v.into();
239        self
240    }
241
242    /// Sets the value of [update_time][crate::model::Function::update_time].
243    ///
244    /// # Example
245    /// ```ignore,no_run
246    /// # use google_cloud_functions_v2::model::Function;
247    /// use wkt::Timestamp;
248    /// let x = Function::new().set_update_time(Timestamp::default()/* use setters */);
249    /// ```
250    pub fn set_update_time<T>(mut self, v: T) -> Self
251    where
252        T: std::convert::Into<wkt::Timestamp>,
253    {
254        self.update_time = std::option::Option::Some(v.into());
255        self
256    }
257
258    /// Sets or clears the value of [update_time][crate::model::Function::update_time].
259    ///
260    /// # Example
261    /// ```ignore,no_run
262    /// # use google_cloud_functions_v2::model::Function;
263    /// use wkt::Timestamp;
264    /// let x = Function::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
265    /// let x = Function::new().set_or_clear_update_time(None::<Timestamp>);
266    /// ```
267    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
268    where
269        T: std::convert::Into<wkt::Timestamp>,
270    {
271        self.update_time = v.map(|x| x.into());
272        self
273    }
274
275    /// Sets the value of [labels][crate::model::Function::labels].
276    ///
277    /// # Example
278    /// ```ignore,no_run
279    /// # use google_cloud_functions_v2::model::Function;
280    /// let x = Function::new().set_labels([
281    ///     ("key0", "abc"),
282    ///     ("key1", "xyz"),
283    /// ]);
284    /// ```
285    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
286    where
287        T: std::iter::IntoIterator<Item = (K, V)>,
288        K: std::convert::Into<std::string::String>,
289        V: std::convert::Into<std::string::String>,
290    {
291        use std::iter::Iterator;
292        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
293        self
294    }
295
296    /// Sets the value of [state_messages][crate::model::Function::state_messages].
297    ///
298    /// # Example
299    /// ```ignore,no_run
300    /// # use google_cloud_functions_v2::model::Function;
301    /// use google_cloud_functions_v2::model::StateMessage;
302    /// let x = Function::new()
303    ///     .set_state_messages([
304    ///         StateMessage::default()/* use setters */,
305    ///         StateMessage::default()/* use (different) setters */,
306    ///     ]);
307    /// ```
308    pub fn set_state_messages<T, V>(mut self, v: T) -> Self
309    where
310        T: std::iter::IntoIterator<Item = V>,
311        V: std::convert::Into<crate::model::StateMessage>,
312    {
313        use std::iter::Iterator;
314        self.state_messages = v.into_iter().map(|i| i.into()).collect();
315        self
316    }
317
318    /// Sets the value of [environment][crate::model::Function::environment].
319    ///
320    /// # Example
321    /// ```ignore,no_run
322    /// # use google_cloud_functions_v2::model::Function;
323    /// use google_cloud_functions_v2::model::Environment;
324    /// let x0 = Function::new().set_environment(Environment::Gen1);
325    /// let x1 = Function::new().set_environment(Environment::Gen2);
326    /// ```
327    pub fn set_environment<T: std::convert::Into<crate::model::Environment>>(
328        mut self,
329        v: T,
330    ) -> Self {
331        self.environment = v.into();
332        self
333    }
334
335    /// Sets the value of [url][crate::model::Function::url].
336    ///
337    /// # Example
338    /// ```ignore,no_run
339    /// # use google_cloud_functions_v2::model::Function;
340    /// let x = Function::new().set_url("example");
341    /// ```
342    pub fn set_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
343        self.url = v.into();
344        self
345    }
346
347    /// Sets the value of [kms_key_name][crate::model::Function::kms_key_name].
348    ///
349    /// # Example
350    /// ```ignore,no_run
351    /// # use google_cloud_functions_v2::model::Function;
352    /// let x = Function::new().set_kms_key_name("example");
353    /// ```
354    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
355        self.kms_key_name = v.into();
356        self
357    }
358
359    /// Sets the value of [satisfies_pzs][crate::model::Function::satisfies_pzs].
360    ///
361    /// # Example
362    /// ```ignore,no_run
363    /// # use google_cloud_functions_v2::model::Function;
364    /// let x = Function::new().set_satisfies_pzs(true);
365    /// ```
366    pub fn set_satisfies_pzs<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
367        self.satisfies_pzs = v.into();
368        self
369    }
370
371    /// Sets the value of [create_time][crate::model::Function::create_time].
372    ///
373    /// # Example
374    /// ```ignore,no_run
375    /// # use google_cloud_functions_v2::model::Function;
376    /// use wkt::Timestamp;
377    /// let x = Function::new().set_create_time(Timestamp::default()/* use setters */);
378    /// ```
379    pub fn set_create_time<T>(mut self, v: T) -> Self
380    where
381        T: std::convert::Into<wkt::Timestamp>,
382    {
383        self.create_time = std::option::Option::Some(v.into());
384        self
385    }
386
387    /// Sets or clears the value of [create_time][crate::model::Function::create_time].
388    ///
389    /// # Example
390    /// ```ignore,no_run
391    /// # use google_cloud_functions_v2::model::Function;
392    /// use wkt::Timestamp;
393    /// let x = Function::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
394    /// let x = Function::new().set_or_clear_create_time(None::<Timestamp>);
395    /// ```
396    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
397    where
398        T: std::convert::Into<wkt::Timestamp>,
399    {
400        self.create_time = v.map(|x| x.into());
401        self
402    }
403}
404
405impl wkt::message::Message for Function {
406    fn typename() -> &'static str {
407        "type.googleapis.com/google.cloud.functions.v2.Function"
408    }
409}
410
411/// Defines additional types related to [Function].
412pub mod function {
413    #[allow(unused_imports)]
414    use super::*;
415
416    /// Describes the current state of the function.
417    ///
418    /// # Working with unknown values
419    ///
420    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
421    /// additional enum variants at any time. Adding new variants is not considered
422    /// a breaking change. Applications should write their code in anticipation of:
423    ///
424    /// - New values appearing in future releases of the client library, **and**
425    /// - New values received dynamically, without application changes.
426    ///
427    /// Please consult the [Working with enums] section in the user guide for some
428    /// guidelines.
429    ///
430    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
431    #[derive(Clone, Debug, PartialEq)]
432    #[non_exhaustive]
433    pub enum State {
434        /// Not specified. Invalid state.
435        Unspecified,
436        /// Function has been successfully deployed and is serving.
437        Active,
438        /// Function deployment failed and the function is not serving.
439        Failed,
440        /// Function is being created or updated.
441        Deploying,
442        /// Function is being deleted.
443        Deleting,
444        /// Function deployment failed and the function serving state is undefined.
445        /// The function should be updated or deleted to move it out of this state.
446        Unknown,
447        /// If set, the enum was initialized with an unknown value.
448        ///
449        /// Applications can examine the value using [State::value] or
450        /// [State::name].
451        UnknownValue(state::UnknownValue),
452    }
453
454    #[doc(hidden)]
455    pub mod state {
456        #[allow(unused_imports)]
457        use super::*;
458        #[derive(Clone, Debug, PartialEq)]
459        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
460    }
461
462    impl State {
463        /// Gets the enum value.
464        ///
465        /// Returns `None` if the enum contains an unknown value deserialized from
466        /// the string representation of enums.
467        pub fn value(&self) -> std::option::Option<i32> {
468            match self {
469                Self::Unspecified => std::option::Option::Some(0),
470                Self::Active => std::option::Option::Some(1),
471                Self::Failed => std::option::Option::Some(2),
472                Self::Deploying => std::option::Option::Some(3),
473                Self::Deleting => std::option::Option::Some(4),
474                Self::Unknown => std::option::Option::Some(5),
475                Self::UnknownValue(u) => u.0.value(),
476            }
477        }
478
479        /// Gets the enum value as a string.
480        ///
481        /// Returns `None` if the enum contains an unknown value deserialized from
482        /// the integer representation of enums.
483        pub fn name(&self) -> std::option::Option<&str> {
484            match self {
485                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
486                Self::Active => std::option::Option::Some("ACTIVE"),
487                Self::Failed => std::option::Option::Some("FAILED"),
488                Self::Deploying => std::option::Option::Some("DEPLOYING"),
489                Self::Deleting => std::option::Option::Some("DELETING"),
490                Self::Unknown => std::option::Option::Some("UNKNOWN"),
491                Self::UnknownValue(u) => u.0.name(),
492            }
493        }
494    }
495
496    impl std::default::Default for State {
497        fn default() -> Self {
498            use std::convert::From;
499            Self::from(0)
500        }
501    }
502
503    impl std::fmt::Display for State {
504        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
505            wkt::internal::display_enum(f, self.name(), self.value())
506        }
507    }
508
509    impl std::convert::From<i32> for State {
510        fn from(value: i32) -> Self {
511            match value {
512                0 => Self::Unspecified,
513                1 => Self::Active,
514                2 => Self::Failed,
515                3 => Self::Deploying,
516                4 => Self::Deleting,
517                5 => Self::Unknown,
518                _ => Self::UnknownValue(state::UnknownValue(
519                    wkt::internal::UnknownEnumValue::Integer(value),
520                )),
521            }
522        }
523    }
524
525    impl std::convert::From<&str> for State {
526        fn from(value: &str) -> Self {
527            use std::string::ToString;
528            match value {
529                "STATE_UNSPECIFIED" => Self::Unspecified,
530                "ACTIVE" => Self::Active,
531                "FAILED" => Self::Failed,
532                "DEPLOYING" => Self::Deploying,
533                "DELETING" => Self::Deleting,
534                "UNKNOWN" => Self::Unknown,
535                _ => Self::UnknownValue(state::UnknownValue(
536                    wkt::internal::UnknownEnumValue::String(value.to_string()),
537                )),
538            }
539        }
540    }
541
542    impl serde::ser::Serialize for State {
543        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
544        where
545            S: serde::Serializer,
546        {
547            match self {
548                Self::Unspecified => serializer.serialize_i32(0),
549                Self::Active => serializer.serialize_i32(1),
550                Self::Failed => serializer.serialize_i32(2),
551                Self::Deploying => serializer.serialize_i32(3),
552                Self::Deleting => serializer.serialize_i32(4),
553                Self::Unknown => serializer.serialize_i32(5),
554                Self::UnknownValue(u) => u.0.serialize(serializer),
555            }
556        }
557    }
558
559    impl<'de> serde::de::Deserialize<'de> for State {
560        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
561        where
562            D: serde::Deserializer<'de>,
563        {
564            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
565                ".google.cloud.functions.v2.Function.State",
566            ))
567        }
568    }
569}
570
571/// Informational messages about the state of the Cloud Function or Operation.
572#[derive(Clone, Default, PartialEq)]
573#[non_exhaustive]
574pub struct StateMessage {
575    /// Severity of the state message.
576    pub severity: crate::model::state_message::Severity,
577
578    /// One-word CamelCase type of the state message.
579    pub r#type: std::string::String,
580
581    /// The message.
582    pub message: std::string::String,
583
584    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
585}
586
587impl StateMessage {
588    pub fn new() -> Self {
589        std::default::Default::default()
590    }
591
592    /// Sets the value of [severity][crate::model::StateMessage::severity].
593    ///
594    /// # Example
595    /// ```ignore,no_run
596    /// # use google_cloud_functions_v2::model::StateMessage;
597    /// use google_cloud_functions_v2::model::state_message::Severity;
598    /// let x0 = StateMessage::new().set_severity(Severity::Error);
599    /// let x1 = StateMessage::new().set_severity(Severity::Warning);
600    /// let x2 = StateMessage::new().set_severity(Severity::Info);
601    /// ```
602    pub fn set_severity<T: std::convert::Into<crate::model::state_message::Severity>>(
603        mut self,
604        v: T,
605    ) -> Self {
606        self.severity = v.into();
607        self
608    }
609
610    /// Sets the value of [r#type][crate::model::StateMessage::type].
611    ///
612    /// # Example
613    /// ```ignore,no_run
614    /// # use google_cloud_functions_v2::model::StateMessage;
615    /// let x = StateMessage::new().set_type("example");
616    /// ```
617    pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
618        self.r#type = v.into();
619        self
620    }
621
622    /// Sets the value of [message][crate::model::StateMessage::message].
623    ///
624    /// # Example
625    /// ```ignore,no_run
626    /// # use google_cloud_functions_v2::model::StateMessage;
627    /// let x = StateMessage::new().set_message("example");
628    /// ```
629    pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
630        self.message = v.into();
631        self
632    }
633}
634
635impl wkt::message::Message for StateMessage {
636    fn typename() -> &'static str {
637        "type.googleapis.com/google.cloud.functions.v2.StateMessage"
638    }
639}
640
641/// Defines additional types related to [StateMessage].
642pub mod state_message {
643    #[allow(unused_imports)]
644    use super::*;
645
646    /// Severity of the state message.
647    ///
648    /// # Working with unknown values
649    ///
650    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
651    /// additional enum variants at any time. Adding new variants is not considered
652    /// a breaking change. Applications should write their code in anticipation of:
653    ///
654    /// - New values appearing in future releases of the client library, **and**
655    /// - New values received dynamically, without application changes.
656    ///
657    /// Please consult the [Working with enums] section in the user guide for some
658    /// guidelines.
659    ///
660    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
661    #[derive(Clone, Debug, PartialEq)]
662    #[non_exhaustive]
663    pub enum Severity {
664        /// Not specified. Invalid severity.
665        Unspecified,
666        /// ERROR-level severity.
667        Error,
668        /// WARNING-level severity.
669        Warning,
670        /// INFO-level severity.
671        Info,
672        /// If set, the enum was initialized with an unknown value.
673        ///
674        /// Applications can examine the value using [Severity::value] or
675        /// [Severity::name].
676        UnknownValue(severity::UnknownValue),
677    }
678
679    #[doc(hidden)]
680    pub mod severity {
681        #[allow(unused_imports)]
682        use super::*;
683        #[derive(Clone, Debug, PartialEq)]
684        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
685    }
686
687    impl Severity {
688        /// Gets the enum value.
689        ///
690        /// Returns `None` if the enum contains an unknown value deserialized from
691        /// the string representation of enums.
692        pub fn value(&self) -> std::option::Option<i32> {
693            match self {
694                Self::Unspecified => std::option::Option::Some(0),
695                Self::Error => std::option::Option::Some(1),
696                Self::Warning => std::option::Option::Some(2),
697                Self::Info => std::option::Option::Some(3),
698                Self::UnknownValue(u) => u.0.value(),
699            }
700        }
701
702        /// Gets the enum value as a string.
703        ///
704        /// Returns `None` if the enum contains an unknown value deserialized from
705        /// the integer representation of enums.
706        pub fn name(&self) -> std::option::Option<&str> {
707            match self {
708                Self::Unspecified => std::option::Option::Some("SEVERITY_UNSPECIFIED"),
709                Self::Error => std::option::Option::Some("ERROR"),
710                Self::Warning => std::option::Option::Some("WARNING"),
711                Self::Info => std::option::Option::Some("INFO"),
712                Self::UnknownValue(u) => u.0.name(),
713            }
714        }
715    }
716
717    impl std::default::Default for Severity {
718        fn default() -> Self {
719            use std::convert::From;
720            Self::from(0)
721        }
722    }
723
724    impl std::fmt::Display for Severity {
725        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
726            wkt::internal::display_enum(f, self.name(), self.value())
727        }
728    }
729
730    impl std::convert::From<i32> for Severity {
731        fn from(value: i32) -> Self {
732            match value {
733                0 => Self::Unspecified,
734                1 => Self::Error,
735                2 => Self::Warning,
736                3 => Self::Info,
737                _ => Self::UnknownValue(severity::UnknownValue(
738                    wkt::internal::UnknownEnumValue::Integer(value),
739                )),
740            }
741        }
742    }
743
744    impl std::convert::From<&str> for Severity {
745        fn from(value: &str) -> Self {
746            use std::string::ToString;
747            match value {
748                "SEVERITY_UNSPECIFIED" => Self::Unspecified,
749                "ERROR" => Self::Error,
750                "WARNING" => Self::Warning,
751                "INFO" => Self::Info,
752                _ => Self::UnknownValue(severity::UnknownValue(
753                    wkt::internal::UnknownEnumValue::String(value.to_string()),
754                )),
755            }
756        }
757    }
758
759    impl serde::ser::Serialize for Severity {
760        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
761        where
762            S: serde::Serializer,
763        {
764            match self {
765                Self::Unspecified => serializer.serialize_i32(0),
766                Self::Error => serializer.serialize_i32(1),
767                Self::Warning => serializer.serialize_i32(2),
768                Self::Info => serializer.serialize_i32(3),
769                Self::UnknownValue(u) => u.0.serialize(serializer),
770            }
771        }
772    }
773
774    impl<'de> serde::de::Deserialize<'de> for Severity {
775        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
776        where
777            D: serde::Deserializer<'de>,
778        {
779            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Severity>::new(
780                ".google.cloud.functions.v2.StateMessage.Severity",
781            ))
782        }
783    }
784}
785
786/// Location of the source in an archive file in Google Cloud Storage.
787#[derive(Clone, Default, PartialEq)]
788#[non_exhaustive]
789pub struct StorageSource {
790    /// Google Cloud Storage bucket containing the source (see
791    /// [Bucket Name
792    /// Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
793    pub bucket: std::string::String,
794
795    /// Google Cloud Storage object containing the source.
796    ///
797    /// This object must be a gzipped archive file (`.tar.gz`) containing source to
798    /// build.
799    pub object: std::string::String,
800
801    /// Google Cloud Storage generation for the object. If the generation is
802    /// omitted, the latest generation will be used.
803    pub generation: i64,
804
805    /// When the specified storage bucket is a 1st gen function uploard url bucket,
806    /// this field should be set as the generated upload url for 1st gen
807    /// deployment.
808    pub source_upload_url: std::string::String,
809
810    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
811}
812
813impl StorageSource {
814    pub fn new() -> Self {
815        std::default::Default::default()
816    }
817
818    /// Sets the value of [bucket][crate::model::StorageSource::bucket].
819    ///
820    /// # Example
821    /// ```ignore,no_run
822    /// # use google_cloud_functions_v2::model::StorageSource;
823    /// let x = StorageSource::new().set_bucket("example");
824    /// ```
825    pub fn set_bucket<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
826        self.bucket = v.into();
827        self
828    }
829
830    /// Sets the value of [object][crate::model::StorageSource::object].
831    ///
832    /// # Example
833    /// ```ignore,no_run
834    /// # use google_cloud_functions_v2::model::StorageSource;
835    /// let x = StorageSource::new().set_object("example");
836    /// ```
837    pub fn set_object<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
838        self.object = v.into();
839        self
840    }
841
842    /// Sets the value of [generation][crate::model::StorageSource::generation].
843    ///
844    /// # Example
845    /// ```ignore,no_run
846    /// # use google_cloud_functions_v2::model::StorageSource;
847    /// let x = StorageSource::new().set_generation(42);
848    /// ```
849    pub fn set_generation<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
850        self.generation = v.into();
851        self
852    }
853
854    /// Sets the value of [source_upload_url][crate::model::StorageSource::source_upload_url].
855    ///
856    /// # Example
857    /// ```ignore,no_run
858    /// # use google_cloud_functions_v2::model::StorageSource;
859    /// let x = StorageSource::new().set_source_upload_url("example");
860    /// ```
861    pub fn set_source_upload_url<T: std::convert::Into<std::string::String>>(
862        mut self,
863        v: T,
864    ) -> Self {
865        self.source_upload_url = v.into();
866        self
867    }
868}
869
870impl wkt::message::Message for StorageSource {
871    fn typename() -> &'static str {
872        "type.googleapis.com/google.cloud.functions.v2.StorageSource"
873    }
874}
875
876/// Location of the source in a Google Cloud Source Repository.
877#[derive(Clone, Default, PartialEq)]
878#[non_exhaustive]
879pub struct RepoSource {
880    /// ID of the project that owns the Cloud Source Repository. If omitted, the
881    /// project ID requesting the build is assumed.
882    pub project_id: std::string::String,
883
884    /// Name of the Cloud Source Repository.
885    pub repo_name: std::string::String,
886
887    /// Directory, relative to the source root, in which to run the build.
888    ///
889    /// This must be a relative path. If a step's `dir` is specified and is an
890    /// absolute path, this value is ignored for that step's execution.
891    /// eg. helloworld (no leading slash allowed)
892    pub dir: std::string::String,
893
894    /// Only trigger a build if the revision regex does NOT match the revision
895    /// regex.
896    pub invert_regex: bool,
897
898    /// A revision within the Cloud Source Repository must be specified in
899    /// one of these ways.
900    pub revision: std::option::Option<crate::model::repo_source::Revision>,
901
902    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
903}
904
905impl RepoSource {
906    pub fn new() -> Self {
907        std::default::Default::default()
908    }
909
910    /// Sets the value of [project_id][crate::model::RepoSource::project_id].
911    ///
912    /// # Example
913    /// ```ignore,no_run
914    /// # use google_cloud_functions_v2::model::RepoSource;
915    /// let x = RepoSource::new().set_project_id("example");
916    /// ```
917    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
918        self.project_id = v.into();
919        self
920    }
921
922    /// Sets the value of [repo_name][crate::model::RepoSource::repo_name].
923    ///
924    /// # Example
925    /// ```ignore,no_run
926    /// # use google_cloud_functions_v2::model::RepoSource;
927    /// let x = RepoSource::new().set_repo_name("example");
928    /// ```
929    pub fn set_repo_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
930        self.repo_name = v.into();
931        self
932    }
933
934    /// Sets the value of [dir][crate::model::RepoSource::dir].
935    ///
936    /// # Example
937    /// ```ignore,no_run
938    /// # use google_cloud_functions_v2::model::RepoSource;
939    /// let x = RepoSource::new().set_dir("example");
940    /// ```
941    pub fn set_dir<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
942        self.dir = v.into();
943        self
944    }
945
946    /// Sets the value of [invert_regex][crate::model::RepoSource::invert_regex].
947    ///
948    /// # Example
949    /// ```ignore,no_run
950    /// # use google_cloud_functions_v2::model::RepoSource;
951    /// let x = RepoSource::new().set_invert_regex(true);
952    /// ```
953    pub fn set_invert_regex<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
954        self.invert_regex = v.into();
955        self
956    }
957
958    /// Sets the value of [revision][crate::model::RepoSource::revision].
959    ///
960    /// Note that all the setters affecting `revision` are mutually
961    /// exclusive.
962    ///
963    /// # Example
964    /// ```ignore,no_run
965    /// # use google_cloud_functions_v2::model::RepoSource;
966    /// use google_cloud_functions_v2::model::repo_source::Revision;
967    /// let x = RepoSource::new().set_revision(Some(Revision::BranchName("example".to_string())));
968    /// ```
969    pub fn set_revision<
970        T: std::convert::Into<std::option::Option<crate::model::repo_source::Revision>>,
971    >(
972        mut self,
973        v: T,
974    ) -> Self {
975        self.revision = v.into();
976        self
977    }
978
979    /// The value of [revision][crate::model::RepoSource::revision]
980    /// if it holds a `BranchName`, `None` if the field is not set or
981    /// holds a different branch.
982    pub fn branch_name(&self) -> std::option::Option<&std::string::String> {
983        #[allow(unreachable_patterns)]
984        self.revision.as_ref().and_then(|v| match v {
985            crate::model::repo_source::Revision::BranchName(v) => std::option::Option::Some(v),
986            _ => std::option::Option::None,
987        })
988    }
989
990    /// Sets the value of [revision][crate::model::RepoSource::revision]
991    /// to hold a `BranchName`.
992    ///
993    /// Note that all the setters affecting `revision` are
994    /// mutually exclusive.
995    ///
996    /// # Example
997    /// ```ignore,no_run
998    /// # use google_cloud_functions_v2::model::RepoSource;
999    /// let x = RepoSource::new().set_branch_name("example");
1000    /// assert!(x.branch_name().is_some());
1001    /// assert!(x.tag_name().is_none());
1002    /// assert!(x.commit_sha().is_none());
1003    /// ```
1004    pub fn set_branch_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1005        self.revision =
1006            std::option::Option::Some(crate::model::repo_source::Revision::BranchName(v.into()));
1007        self
1008    }
1009
1010    /// The value of [revision][crate::model::RepoSource::revision]
1011    /// if it holds a `TagName`, `None` if the field is not set or
1012    /// holds a different branch.
1013    pub fn tag_name(&self) -> std::option::Option<&std::string::String> {
1014        #[allow(unreachable_patterns)]
1015        self.revision.as_ref().and_then(|v| match v {
1016            crate::model::repo_source::Revision::TagName(v) => std::option::Option::Some(v),
1017            _ => std::option::Option::None,
1018        })
1019    }
1020
1021    /// Sets the value of [revision][crate::model::RepoSource::revision]
1022    /// to hold a `TagName`.
1023    ///
1024    /// Note that all the setters affecting `revision` are
1025    /// mutually exclusive.
1026    ///
1027    /// # Example
1028    /// ```ignore,no_run
1029    /// # use google_cloud_functions_v2::model::RepoSource;
1030    /// let x = RepoSource::new().set_tag_name("example");
1031    /// assert!(x.tag_name().is_some());
1032    /// assert!(x.branch_name().is_none());
1033    /// assert!(x.commit_sha().is_none());
1034    /// ```
1035    pub fn set_tag_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1036        self.revision =
1037            std::option::Option::Some(crate::model::repo_source::Revision::TagName(v.into()));
1038        self
1039    }
1040
1041    /// The value of [revision][crate::model::RepoSource::revision]
1042    /// if it holds a `CommitSha`, `None` if the field is not set or
1043    /// holds a different branch.
1044    pub fn commit_sha(&self) -> std::option::Option<&std::string::String> {
1045        #[allow(unreachable_patterns)]
1046        self.revision.as_ref().and_then(|v| match v {
1047            crate::model::repo_source::Revision::CommitSha(v) => std::option::Option::Some(v),
1048            _ => std::option::Option::None,
1049        })
1050    }
1051
1052    /// Sets the value of [revision][crate::model::RepoSource::revision]
1053    /// to hold a `CommitSha`.
1054    ///
1055    /// Note that all the setters affecting `revision` are
1056    /// mutually exclusive.
1057    ///
1058    /// # Example
1059    /// ```ignore,no_run
1060    /// # use google_cloud_functions_v2::model::RepoSource;
1061    /// let x = RepoSource::new().set_commit_sha("example");
1062    /// assert!(x.commit_sha().is_some());
1063    /// assert!(x.branch_name().is_none());
1064    /// assert!(x.tag_name().is_none());
1065    /// ```
1066    pub fn set_commit_sha<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1067        self.revision =
1068            std::option::Option::Some(crate::model::repo_source::Revision::CommitSha(v.into()));
1069        self
1070    }
1071}
1072
1073impl wkt::message::Message for RepoSource {
1074    fn typename() -> &'static str {
1075        "type.googleapis.com/google.cloud.functions.v2.RepoSource"
1076    }
1077}
1078
1079/// Defines additional types related to [RepoSource].
1080pub mod repo_source {
1081    #[allow(unused_imports)]
1082    use super::*;
1083
1084    /// A revision within the Cloud Source Repository must be specified in
1085    /// one of these ways.
1086    #[derive(Clone, Debug, PartialEq)]
1087    #[non_exhaustive]
1088    pub enum Revision {
1089        /// Regex matching branches to build.
1090        ///
1091        /// The syntax of the regular expressions accepted is the syntax accepted by
1092        /// RE2 and described at <https://github.com/google/re2/wiki/Syntax>
1093        BranchName(std::string::String),
1094        /// Regex matching tags to build.
1095        ///
1096        /// The syntax of the regular expressions accepted is the syntax accepted by
1097        /// RE2 and described at <https://github.com/google/re2/wiki/Syntax>
1098        TagName(std::string::String),
1099        /// Explicit commit SHA to build.
1100        CommitSha(std::string::String),
1101    }
1102}
1103
1104/// The location of the function source code.
1105#[derive(Clone, Default, PartialEq)]
1106#[non_exhaustive]
1107pub struct Source {
1108    /// Location of the source.
1109    /// At least one source needs to be provided for the deployment to succeed.
1110    pub source: std::option::Option<crate::model::source::Source>,
1111
1112    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1113}
1114
1115impl Source {
1116    pub fn new() -> Self {
1117        std::default::Default::default()
1118    }
1119
1120    /// Sets the value of [source][crate::model::Source::source].
1121    ///
1122    /// Note that all the setters affecting `source` are mutually
1123    /// exclusive.
1124    ///
1125    /// # Example
1126    /// ```ignore,no_run
1127    /// # use google_cloud_functions_v2::model::Source;
1128    /// use google_cloud_functions_v2::model::source::Source as SourceOneOf;
1129    /// let x = Source::new().set_source(Some(SourceOneOf::GitUri("example".to_string())));
1130    /// ```
1131    pub fn set_source<T: std::convert::Into<std::option::Option<crate::model::source::Source>>>(
1132        mut self,
1133        v: T,
1134    ) -> Self {
1135        self.source = v.into();
1136        self
1137    }
1138
1139    /// The value of [source][crate::model::Source::source]
1140    /// if it holds a `StorageSource`, `None` if the field is not set or
1141    /// holds a different branch.
1142    pub fn storage_source(
1143        &self,
1144    ) -> std::option::Option<&std::boxed::Box<crate::model::StorageSource>> {
1145        #[allow(unreachable_patterns)]
1146        self.source.as_ref().and_then(|v| match v {
1147            crate::model::source::Source::StorageSource(v) => std::option::Option::Some(v),
1148            _ => std::option::Option::None,
1149        })
1150    }
1151
1152    /// Sets the value of [source][crate::model::Source::source]
1153    /// to hold a `StorageSource`.
1154    ///
1155    /// Note that all the setters affecting `source` are
1156    /// mutually exclusive.
1157    ///
1158    /// # Example
1159    /// ```ignore,no_run
1160    /// # use google_cloud_functions_v2::model::Source;
1161    /// use google_cloud_functions_v2::model::StorageSource;
1162    /// let x = Source::new().set_storage_source(StorageSource::default()/* use setters */);
1163    /// assert!(x.storage_source().is_some());
1164    /// assert!(x.repo_source().is_none());
1165    /// assert!(x.git_uri().is_none());
1166    /// ```
1167    pub fn set_storage_source<
1168        T: std::convert::Into<std::boxed::Box<crate::model::StorageSource>>,
1169    >(
1170        mut self,
1171        v: T,
1172    ) -> Self {
1173        self.source =
1174            std::option::Option::Some(crate::model::source::Source::StorageSource(v.into()));
1175        self
1176    }
1177
1178    /// The value of [source][crate::model::Source::source]
1179    /// if it holds a `RepoSource`, `None` if the field is not set or
1180    /// holds a different branch.
1181    pub fn repo_source(&self) -> std::option::Option<&std::boxed::Box<crate::model::RepoSource>> {
1182        #[allow(unreachable_patterns)]
1183        self.source.as_ref().and_then(|v| match v {
1184            crate::model::source::Source::RepoSource(v) => std::option::Option::Some(v),
1185            _ => std::option::Option::None,
1186        })
1187    }
1188
1189    /// Sets the value of [source][crate::model::Source::source]
1190    /// to hold a `RepoSource`.
1191    ///
1192    /// Note that all the setters affecting `source` are
1193    /// mutually exclusive.
1194    ///
1195    /// # Example
1196    /// ```ignore,no_run
1197    /// # use google_cloud_functions_v2::model::Source;
1198    /// use google_cloud_functions_v2::model::RepoSource;
1199    /// let x = Source::new().set_repo_source(RepoSource::default()/* use setters */);
1200    /// assert!(x.repo_source().is_some());
1201    /// assert!(x.storage_source().is_none());
1202    /// assert!(x.git_uri().is_none());
1203    /// ```
1204    pub fn set_repo_source<T: std::convert::Into<std::boxed::Box<crate::model::RepoSource>>>(
1205        mut self,
1206        v: T,
1207    ) -> Self {
1208        self.source = std::option::Option::Some(crate::model::source::Source::RepoSource(v.into()));
1209        self
1210    }
1211
1212    /// The value of [source][crate::model::Source::source]
1213    /// if it holds a `GitUri`, `None` if the field is not set or
1214    /// holds a different branch.
1215    pub fn git_uri(&self) -> std::option::Option<&std::string::String> {
1216        #[allow(unreachable_patterns)]
1217        self.source.as_ref().and_then(|v| match v {
1218            crate::model::source::Source::GitUri(v) => std::option::Option::Some(v),
1219            _ => std::option::Option::None,
1220        })
1221    }
1222
1223    /// Sets the value of [source][crate::model::Source::source]
1224    /// to hold a `GitUri`.
1225    ///
1226    /// Note that all the setters affecting `source` are
1227    /// mutually exclusive.
1228    ///
1229    /// # Example
1230    /// ```ignore,no_run
1231    /// # use google_cloud_functions_v2::model::Source;
1232    /// let x = Source::new().set_git_uri("example");
1233    /// assert!(x.git_uri().is_some());
1234    /// assert!(x.storage_source().is_none());
1235    /// assert!(x.repo_source().is_none());
1236    /// ```
1237    pub fn set_git_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1238        self.source = std::option::Option::Some(crate::model::source::Source::GitUri(v.into()));
1239        self
1240    }
1241}
1242
1243impl wkt::message::Message for Source {
1244    fn typename() -> &'static str {
1245        "type.googleapis.com/google.cloud.functions.v2.Source"
1246    }
1247}
1248
1249/// Defines additional types related to [Source].
1250pub mod source {
1251    #[allow(unused_imports)]
1252    use super::*;
1253
1254    /// Location of the source.
1255    /// At least one source needs to be provided for the deployment to succeed.
1256    #[derive(Clone, Debug, PartialEq)]
1257    #[non_exhaustive]
1258    pub enum Source {
1259        /// If provided, get the source from this location in Google Cloud Storage.
1260        StorageSource(std::boxed::Box<crate::model::StorageSource>),
1261        /// If provided, get the source from this location in a Cloud Source
1262        /// Repository.
1263        RepoSource(std::boxed::Box<crate::model::RepoSource>),
1264        /// If provided, get the source from GitHub repository. This option is valid
1265        /// only for GCF 1st Gen function.
1266        /// Example: <https://github.com/>\<user\>/\<repo\>/blob/\<commit\>/\<path-to-code\>
1267        GitUri(std::string::String),
1268    }
1269}
1270
1271/// Provenance of the source. Ways to find the original source, or verify that
1272/// some source was used for this build.
1273#[derive(Clone, Default, PartialEq)]
1274#[non_exhaustive]
1275pub struct SourceProvenance {
1276    /// A copy of the build's `source.storage_source`, if exists, with any
1277    /// generations resolved.
1278    pub resolved_storage_source: std::option::Option<crate::model::StorageSource>,
1279
1280    /// A copy of the build's `source.repo_source`, if exists, with any
1281    /// revisions resolved.
1282    pub resolved_repo_source: std::option::Option<crate::model::RepoSource>,
1283
1284    /// A copy of the build's `source.git_uri`, if exists, with any commits
1285    /// resolved.
1286    pub git_uri: std::string::String,
1287
1288    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1289}
1290
1291impl SourceProvenance {
1292    pub fn new() -> Self {
1293        std::default::Default::default()
1294    }
1295
1296    /// Sets the value of [resolved_storage_source][crate::model::SourceProvenance::resolved_storage_source].
1297    ///
1298    /// # Example
1299    /// ```ignore,no_run
1300    /// # use google_cloud_functions_v2::model::SourceProvenance;
1301    /// use google_cloud_functions_v2::model::StorageSource;
1302    /// let x = SourceProvenance::new().set_resolved_storage_source(StorageSource::default()/* use setters */);
1303    /// ```
1304    pub fn set_resolved_storage_source<T>(mut self, v: T) -> Self
1305    where
1306        T: std::convert::Into<crate::model::StorageSource>,
1307    {
1308        self.resolved_storage_source = std::option::Option::Some(v.into());
1309        self
1310    }
1311
1312    /// Sets or clears the value of [resolved_storage_source][crate::model::SourceProvenance::resolved_storage_source].
1313    ///
1314    /// # Example
1315    /// ```ignore,no_run
1316    /// # use google_cloud_functions_v2::model::SourceProvenance;
1317    /// use google_cloud_functions_v2::model::StorageSource;
1318    /// let x = SourceProvenance::new().set_or_clear_resolved_storage_source(Some(StorageSource::default()/* use setters */));
1319    /// let x = SourceProvenance::new().set_or_clear_resolved_storage_source(None::<StorageSource>);
1320    /// ```
1321    pub fn set_or_clear_resolved_storage_source<T>(mut self, v: std::option::Option<T>) -> Self
1322    where
1323        T: std::convert::Into<crate::model::StorageSource>,
1324    {
1325        self.resolved_storage_source = v.map(|x| x.into());
1326        self
1327    }
1328
1329    /// Sets the value of [resolved_repo_source][crate::model::SourceProvenance::resolved_repo_source].
1330    ///
1331    /// # Example
1332    /// ```ignore,no_run
1333    /// # use google_cloud_functions_v2::model::SourceProvenance;
1334    /// use google_cloud_functions_v2::model::RepoSource;
1335    /// let x = SourceProvenance::new().set_resolved_repo_source(RepoSource::default()/* use setters */);
1336    /// ```
1337    pub fn set_resolved_repo_source<T>(mut self, v: T) -> Self
1338    where
1339        T: std::convert::Into<crate::model::RepoSource>,
1340    {
1341        self.resolved_repo_source = std::option::Option::Some(v.into());
1342        self
1343    }
1344
1345    /// Sets or clears the value of [resolved_repo_source][crate::model::SourceProvenance::resolved_repo_source].
1346    ///
1347    /// # Example
1348    /// ```ignore,no_run
1349    /// # use google_cloud_functions_v2::model::SourceProvenance;
1350    /// use google_cloud_functions_v2::model::RepoSource;
1351    /// let x = SourceProvenance::new().set_or_clear_resolved_repo_source(Some(RepoSource::default()/* use setters */));
1352    /// let x = SourceProvenance::new().set_or_clear_resolved_repo_source(None::<RepoSource>);
1353    /// ```
1354    pub fn set_or_clear_resolved_repo_source<T>(mut self, v: std::option::Option<T>) -> Self
1355    where
1356        T: std::convert::Into<crate::model::RepoSource>,
1357    {
1358        self.resolved_repo_source = v.map(|x| x.into());
1359        self
1360    }
1361
1362    /// Sets the value of [git_uri][crate::model::SourceProvenance::git_uri].
1363    ///
1364    /// # Example
1365    /// ```ignore,no_run
1366    /// # use google_cloud_functions_v2::model::SourceProvenance;
1367    /// let x = SourceProvenance::new().set_git_uri("example");
1368    /// ```
1369    pub fn set_git_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1370        self.git_uri = v.into();
1371        self
1372    }
1373}
1374
1375impl wkt::message::Message for SourceProvenance {
1376    fn typename() -> &'static str {
1377        "type.googleapis.com/google.cloud.functions.v2.SourceProvenance"
1378    }
1379}
1380
1381/// Describes the Build step of the function that builds a container from the
1382/// given source.
1383#[derive(Clone, Default, PartialEq)]
1384#[non_exhaustive]
1385pub struct BuildConfig {
1386    /// Output only. The Cloud Build name of the latest successful deployment of
1387    /// the function.
1388    pub build: std::string::String,
1389
1390    /// The runtime in which to run the function. Required when deploying a new
1391    /// function, optional when updating an existing function. For a complete
1392    /// list of possible choices, see the
1393    /// [`gcloud` command
1394    /// reference](https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--runtime).
1395    pub runtime: std::string::String,
1396
1397    /// The name of the function (as defined in source code) that will be
1398    /// executed. Defaults to the resource name suffix, if not specified. For
1399    /// backward compatibility, if function with given name is not found, then the
1400    /// system will try to use function named "function".
1401    /// For Node.js this is name of a function exported by the module specified
1402    /// in `source_location`.
1403    pub entry_point: std::string::String,
1404
1405    /// The location of the function source code.
1406    pub source: std::option::Option<crate::model::Source>,
1407
1408    /// Output only. A permanent fixed identifier for source.
1409    pub source_provenance: std::option::Option<crate::model::SourceProvenance>,
1410
1411    /// Name of the Cloud Build Custom Worker Pool that should be used to build the
1412    /// function. The format of this field is
1413    /// `projects/{project}/locations/{region}/workerPools/{workerPool}` where
1414    /// {project} and {region} are the project id and region respectively where the
1415    /// worker pool is defined and {workerPool} is the short name of the worker
1416    /// pool.
1417    ///
1418    /// If the project id is not the same as the function, then the Cloud
1419    /// Functions Service Agent
1420    /// (service-<project_number>@gcf-admin-robot.iam.gserviceaccount.com) must be
1421    /// granted the role Cloud Build Custom Workers Builder
1422    /// (roles/cloudbuild.customworkers.builder) in the project.
1423    pub worker_pool: std::string::String,
1424
1425    /// User-provided build-time environment variables for the function
1426    pub environment_variables: std::collections::HashMap<std::string::String, std::string::String>,
1427
1428    /// Docker Registry to use for this deployment. This configuration is only
1429    /// applicable to 1st Gen functions, 2nd Gen functions can only use Artifact
1430    /// Registry.
1431    /// Deprecated: As of March 2025, `CONTAINER_REGISTRY` option is no longer
1432    /// available in response to Container Registry's deprecation:
1433    /// <https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr>
1434    /// Please use Artifact Registry instead, which is the default choice.
1435    ///
1436    /// If unspecified, it defaults to `ARTIFACT_REGISTRY`.
1437    /// If `docker_repository` field is specified, this field should either be left
1438    /// unspecified or set to `ARTIFACT_REGISTRY`.
1439    #[deprecated]
1440    pub docker_registry: crate::model::build_config::DockerRegistry,
1441
1442    /// Repository in Artifact Registry to which the function docker image will be
1443    /// pushed after it is built by Cloud Build. If specified by user, it is
1444    /// created and managed by user with a customer managed encryption key.
1445    /// Otherwise, GCF will create and use a repository named 'gcf-artifacts'
1446    /// for every deployed region.
1447    ///
1448    /// It must match the pattern
1449    /// `projects/{project}/locations/{location}/repositories/{repository}`.
1450    /// Repository format must be 'DOCKER'.
1451    pub docker_repository: std::string::String,
1452
1453    /// Service account to be used for building the container. The format of this
1454    /// field is `projects/{projectId}/serviceAccounts/{serviceAccountEmail}`.
1455    pub service_account: std::string::String,
1456
1457    /// This controls when security patches are applied to the runtime environment.
1458    pub runtime_update_policy: std::option::Option<crate::model::build_config::RuntimeUpdatePolicy>,
1459
1460    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1461}
1462
1463impl BuildConfig {
1464    pub fn new() -> Self {
1465        std::default::Default::default()
1466    }
1467
1468    /// Sets the value of [build][crate::model::BuildConfig::build].
1469    ///
1470    /// # Example
1471    /// ```ignore,no_run
1472    /// # use google_cloud_functions_v2::model::BuildConfig;
1473    /// let x = BuildConfig::new().set_build("example");
1474    /// ```
1475    pub fn set_build<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1476        self.build = v.into();
1477        self
1478    }
1479
1480    /// Sets the value of [runtime][crate::model::BuildConfig::runtime].
1481    ///
1482    /// # Example
1483    /// ```ignore,no_run
1484    /// # use google_cloud_functions_v2::model::BuildConfig;
1485    /// let x = BuildConfig::new().set_runtime("example");
1486    /// ```
1487    pub fn set_runtime<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1488        self.runtime = v.into();
1489        self
1490    }
1491
1492    /// Sets the value of [entry_point][crate::model::BuildConfig::entry_point].
1493    ///
1494    /// # Example
1495    /// ```ignore,no_run
1496    /// # use google_cloud_functions_v2::model::BuildConfig;
1497    /// let x = BuildConfig::new().set_entry_point("example");
1498    /// ```
1499    pub fn set_entry_point<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1500        self.entry_point = v.into();
1501        self
1502    }
1503
1504    /// Sets the value of [source][crate::model::BuildConfig::source].
1505    ///
1506    /// # Example
1507    /// ```ignore,no_run
1508    /// # use google_cloud_functions_v2::model::BuildConfig;
1509    /// use google_cloud_functions_v2::model::Source;
1510    /// let x = BuildConfig::new().set_source(Source::default()/* use setters */);
1511    /// ```
1512    pub fn set_source<T>(mut self, v: T) -> Self
1513    where
1514        T: std::convert::Into<crate::model::Source>,
1515    {
1516        self.source = std::option::Option::Some(v.into());
1517        self
1518    }
1519
1520    /// Sets or clears the value of [source][crate::model::BuildConfig::source].
1521    ///
1522    /// # Example
1523    /// ```ignore,no_run
1524    /// # use google_cloud_functions_v2::model::BuildConfig;
1525    /// use google_cloud_functions_v2::model::Source;
1526    /// let x = BuildConfig::new().set_or_clear_source(Some(Source::default()/* use setters */));
1527    /// let x = BuildConfig::new().set_or_clear_source(None::<Source>);
1528    /// ```
1529    pub fn set_or_clear_source<T>(mut self, v: std::option::Option<T>) -> Self
1530    where
1531        T: std::convert::Into<crate::model::Source>,
1532    {
1533        self.source = v.map(|x| x.into());
1534        self
1535    }
1536
1537    /// Sets the value of [source_provenance][crate::model::BuildConfig::source_provenance].
1538    ///
1539    /// # Example
1540    /// ```ignore,no_run
1541    /// # use google_cloud_functions_v2::model::BuildConfig;
1542    /// use google_cloud_functions_v2::model::SourceProvenance;
1543    /// let x = BuildConfig::new().set_source_provenance(SourceProvenance::default()/* use setters */);
1544    /// ```
1545    pub fn set_source_provenance<T>(mut self, v: T) -> Self
1546    where
1547        T: std::convert::Into<crate::model::SourceProvenance>,
1548    {
1549        self.source_provenance = std::option::Option::Some(v.into());
1550        self
1551    }
1552
1553    /// Sets or clears the value of [source_provenance][crate::model::BuildConfig::source_provenance].
1554    ///
1555    /// # Example
1556    /// ```ignore,no_run
1557    /// # use google_cloud_functions_v2::model::BuildConfig;
1558    /// use google_cloud_functions_v2::model::SourceProvenance;
1559    /// let x = BuildConfig::new().set_or_clear_source_provenance(Some(SourceProvenance::default()/* use setters */));
1560    /// let x = BuildConfig::new().set_or_clear_source_provenance(None::<SourceProvenance>);
1561    /// ```
1562    pub fn set_or_clear_source_provenance<T>(mut self, v: std::option::Option<T>) -> Self
1563    where
1564        T: std::convert::Into<crate::model::SourceProvenance>,
1565    {
1566        self.source_provenance = v.map(|x| x.into());
1567        self
1568    }
1569
1570    /// Sets the value of [worker_pool][crate::model::BuildConfig::worker_pool].
1571    ///
1572    /// # Example
1573    /// ```ignore,no_run
1574    /// # use google_cloud_functions_v2::model::BuildConfig;
1575    /// let x = BuildConfig::new().set_worker_pool("example");
1576    /// ```
1577    pub fn set_worker_pool<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1578        self.worker_pool = v.into();
1579        self
1580    }
1581
1582    /// Sets the value of [environment_variables][crate::model::BuildConfig::environment_variables].
1583    ///
1584    /// # Example
1585    /// ```ignore,no_run
1586    /// # use google_cloud_functions_v2::model::BuildConfig;
1587    /// let x = BuildConfig::new().set_environment_variables([
1588    ///     ("key0", "abc"),
1589    ///     ("key1", "xyz"),
1590    /// ]);
1591    /// ```
1592    pub fn set_environment_variables<T, K, V>(mut self, v: T) -> Self
1593    where
1594        T: std::iter::IntoIterator<Item = (K, V)>,
1595        K: std::convert::Into<std::string::String>,
1596        V: std::convert::Into<std::string::String>,
1597    {
1598        use std::iter::Iterator;
1599        self.environment_variables = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
1600        self
1601    }
1602
1603    /// Sets the value of [docker_registry][crate::model::BuildConfig::docker_registry].
1604    ///
1605    /// # Example
1606    /// ```ignore,no_run
1607    /// # use google_cloud_functions_v2::model::BuildConfig;
1608    /// use google_cloud_functions_v2::model::build_config::DockerRegistry;
1609    /// let x0 = BuildConfig::new().set_docker_registry(DockerRegistry::ContainerRegistry);
1610    /// let x1 = BuildConfig::new().set_docker_registry(DockerRegistry::ArtifactRegistry);
1611    /// ```
1612    #[deprecated]
1613    pub fn set_docker_registry<
1614        T: std::convert::Into<crate::model::build_config::DockerRegistry>,
1615    >(
1616        mut self,
1617        v: T,
1618    ) -> Self {
1619        self.docker_registry = v.into();
1620        self
1621    }
1622
1623    /// Sets the value of [docker_repository][crate::model::BuildConfig::docker_repository].
1624    ///
1625    /// # Example
1626    /// ```ignore,no_run
1627    /// # use google_cloud_functions_v2::model::BuildConfig;
1628    /// let x = BuildConfig::new().set_docker_repository("example");
1629    /// ```
1630    pub fn set_docker_repository<T: std::convert::Into<std::string::String>>(
1631        mut self,
1632        v: T,
1633    ) -> Self {
1634        self.docker_repository = v.into();
1635        self
1636    }
1637
1638    /// Sets the value of [service_account][crate::model::BuildConfig::service_account].
1639    ///
1640    /// # Example
1641    /// ```ignore,no_run
1642    /// # use google_cloud_functions_v2::model::BuildConfig;
1643    /// let x = BuildConfig::new().set_service_account("example");
1644    /// ```
1645    pub fn set_service_account<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1646        self.service_account = v.into();
1647        self
1648    }
1649
1650    /// Sets the value of [runtime_update_policy][crate::model::BuildConfig::runtime_update_policy].
1651    ///
1652    /// Note that all the setters affecting `runtime_update_policy` are mutually
1653    /// exclusive.
1654    ///
1655    /// # Example
1656    /// ```ignore,no_run
1657    /// # use google_cloud_functions_v2::model::BuildConfig;
1658    /// use google_cloud_functions_v2::model::AutomaticUpdatePolicy;
1659    /// let x = BuildConfig::new().set_runtime_update_policy(Some(
1660    ///     google_cloud_functions_v2::model::build_config::RuntimeUpdatePolicy::AutomaticUpdatePolicy(AutomaticUpdatePolicy::default().into())));
1661    /// ```
1662    pub fn set_runtime_update_policy<
1663        T: std::convert::Into<std::option::Option<crate::model::build_config::RuntimeUpdatePolicy>>,
1664    >(
1665        mut self,
1666        v: T,
1667    ) -> Self {
1668        self.runtime_update_policy = v.into();
1669        self
1670    }
1671
1672    /// The value of [runtime_update_policy][crate::model::BuildConfig::runtime_update_policy]
1673    /// if it holds a `AutomaticUpdatePolicy`, `None` if the field is not set or
1674    /// holds a different branch.
1675    pub fn automatic_update_policy(
1676        &self,
1677    ) -> std::option::Option<&std::boxed::Box<crate::model::AutomaticUpdatePolicy>> {
1678        #[allow(unreachable_patterns)]
1679        self.runtime_update_policy.as_ref().and_then(|v| match v {
1680            crate::model::build_config::RuntimeUpdatePolicy::AutomaticUpdatePolicy(v) => {
1681                std::option::Option::Some(v)
1682            }
1683            _ => std::option::Option::None,
1684        })
1685    }
1686
1687    /// Sets the value of [runtime_update_policy][crate::model::BuildConfig::runtime_update_policy]
1688    /// to hold a `AutomaticUpdatePolicy`.
1689    ///
1690    /// Note that all the setters affecting `runtime_update_policy` are
1691    /// mutually exclusive.
1692    ///
1693    /// # Example
1694    /// ```ignore,no_run
1695    /// # use google_cloud_functions_v2::model::BuildConfig;
1696    /// use google_cloud_functions_v2::model::AutomaticUpdatePolicy;
1697    /// let x = BuildConfig::new().set_automatic_update_policy(AutomaticUpdatePolicy::default()/* use setters */);
1698    /// assert!(x.automatic_update_policy().is_some());
1699    /// assert!(x.on_deploy_update_policy().is_none());
1700    /// ```
1701    pub fn set_automatic_update_policy<
1702        T: std::convert::Into<std::boxed::Box<crate::model::AutomaticUpdatePolicy>>,
1703    >(
1704        mut self,
1705        v: T,
1706    ) -> Self {
1707        self.runtime_update_policy = std::option::Option::Some(
1708            crate::model::build_config::RuntimeUpdatePolicy::AutomaticUpdatePolicy(v.into()),
1709        );
1710        self
1711    }
1712
1713    /// The value of [runtime_update_policy][crate::model::BuildConfig::runtime_update_policy]
1714    /// if it holds a `OnDeployUpdatePolicy`, `None` if the field is not set or
1715    /// holds a different branch.
1716    pub fn on_deploy_update_policy(
1717        &self,
1718    ) -> std::option::Option<&std::boxed::Box<crate::model::OnDeployUpdatePolicy>> {
1719        #[allow(unreachable_patterns)]
1720        self.runtime_update_policy.as_ref().and_then(|v| match v {
1721            crate::model::build_config::RuntimeUpdatePolicy::OnDeployUpdatePolicy(v) => {
1722                std::option::Option::Some(v)
1723            }
1724            _ => std::option::Option::None,
1725        })
1726    }
1727
1728    /// Sets the value of [runtime_update_policy][crate::model::BuildConfig::runtime_update_policy]
1729    /// to hold a `OnDeployUpdatePolicy`.
1730    ///
1731    /// Note that all the setters affecting `runtime_update_policy` are
1732    /// mutually exclusive.
1733    ///
1734    /// # Example
1735    /// ```ignore,no_run
1736    /// # use google_cloud_functions_v2::model::BuildConfig;
1737    /// use google_cloud_functions_v2::model::OnDeployUpdatePolicy;
1738    /// let x = BuildConfig::new().set_on_deploy_update_policy(OnDeployUpdatePolicy::default()/* use setters */);
1739    /// assert!(x.on_deploy_update_policy().is_some());
1740    /// assert!(x.automatic_update_policy().is_none());
1741    /// ```
1742    pub fn set_on_deploy_update_policy<
1743        T: std::convert::Into<std::boxed::Box<crate::model::OnDeployUpdatePolicy>>,
1744    >(
1745        mut self,
1746        v: T,
1747    ) -> Self {
1748        self.runtime_update_policy = std::option::Option::Some(
1749            crate::model::build_config::RuntimeUpdatePolicy::OnDeployUpdatePolicy(v.into()),
1750        );
1751        self
1752    }
1753}
1754
1755impl wkt::message::Message for BuildConfig {
1756    fn typename() -> &'static str {
1757        "type.googleapis.com/google.cloud.functions.v2.BuildConfig"
1758    }
1759}
1760
1761/// Defines additional types related to [BuildConfig].
1762pub mod build_config {
1763    #[allow(unused_imports)]
1764    use super::*;
1765
1766    /// Docker Registry to use for storing function Docker images.
1767    ///
1768    /// # Working with unknown values
1769    ///
1770    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1771    /// additional enum variants at any time. Adding new variants is not considered
1772    /// a breaking change. Applications should write their code in anticipation of:
1773    ///
1774    /// - New values appearing in future releases of the client library, **and**
1775    /// - New values received dynamically, without application changes.
1776    ///
1777    /// Please consult the [Working with enums] section in the user guide for some
1778    /// guidelines.
1779    ///
1780    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1781    #[derive(Clone, Debug, PartialEq)]
1782    #[non_exhaustive]
1783    pub enum DockerRegistry {
1784        /// Unspecified.
1785        Unspecified,
1786        /// Docker images will be stored in multi-regional Container Registry
1787        /// repositories named `gcf`.
1788        ContainerRegistry,
1789        /// Docker images will be stored in regional Artifact Registry repositories.
1790        /// By default, GCF will create and use repositories named `gcf-artifacts`
1791        /// in every region in which a function is deployed. But the repository to
1792        /// use can also be specified by the user using the `docker_repository`
1793        /// field.
1794        ArtifactRegistry,
1795        /// If set, the enum was initialized with an unknown value.
1796        ///
1797        /// Applications can examine the value using [DockerRegistry::value] or
1798        /// [DockerRegistry::name].
1799        UnknownValue(docker_registry::UnknownValue),
1800    }
1801
1802    #[doc(hidden)]
1803    pub mod docker_registry {
1804        #[allow(unused_imports)]
1805        use super::*;
1806        #[derive(Clone, Debug, PartialEq)]
1807        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1808    }
1809
1810    impl DockerRegistry {
1811        /// Gets the enum value.
1812        ///
1813        /// Returns `None` if the enum contains an unknown value deserialized from
1814        /// the string representation of enums.
1815        pub fn value(&self) -> std::option::Option<i32> {
1816            match self {
1817                Self::Unspecified => std::option::Option::Some(0),
1818                Self::ContainerRegistry => std::option::Option::Some(1),
1819                Self::ArtifactRegistry => std::option::Option::Some(2),
1820                Self::UnknownValue(u) => u.0.value(),
1821            }
1822        }
1823
1824        /// Gets the enum value as a string.
1825        ///
1826        /// Returns `None` if the enum contains an unknown value deserialized from
1827        /// the integer representation of enums.
1828        pub fn name(&self) -> std::option::Option<&str> {
1829            match self {
1830                Self::Unspecified => std::option::Option::Some("DOCKER_REGISTRY_UNSPECIFIED"),
1831                Self::ContainerRegistry => std::option::Option::Some("CONTAINER_REGISTRY"),
1832                Self::ArtifactRegistry => std::option::Option::Some("ARTIFACT_REGISTRY"),
1833                Self::UnknownValue(u) => u.0.name(),
1834            }
1835        }
1836    }
1837
1838    impl std::default::Default for DockerRegistry {
1839        fn default() -> Self {
1840            use std::convert::From;
1841            Self::from(0)
1842        }
1843    }
1844
1845    impl std::fmt::Display for DockerRegistry {
1846        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1847            wkt::internal::display_enum(f, self.name(), self.value())
1848        }
1849    }
1850
1851    impl std::convert::From<i32> for DockerRegistry {
1852        fn from(value: i32) -> Self {
1853            match value {
1854                0 => Self::Unspecified,
1855                1 => Self::ContainerRegistry,
1856                2 => Self::ArtifactRegistry,
1857                _ => Self::UnknownValue(docker_registry::UnknownValue(
1858                    wkt::internal::UnknownEnumValue::Integer(value),
1859                )),
1860            }
1861        }
1862    }
1863
1864    impl std::convert::From<&str> for DockerRegistry {
1865        fn from(value: &str) -> Self {
1866            use std::string::ToString;
1867            match value {
1868                "DOCKER_REGISTRY_UNSPECIFIED" => Self::Unspecified,
1869                "CONTAINER_REGISTRY" => Self::ContainerRegistry,
1870                "ARTIFACT_REGISTRY" => Self::ArtifactRegistry,
1871                _ => Self::UnknownValue(docker_registry::UnknownValue(
1872                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1873                )),
1874            }
1875        }
1876    }
1877
1878    impl serde::ser::Serialize for DockerRegistry {
1879        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1880        where
1881            S: serde::Serializer,
1882        {
1883            match self {
1884                Self::Unspecified => serializer.serialize_i32(0),
1885                Self::ContainerRegistry => serializer.serialize_i32(1),
1886                Self::ArtifactRegistry => serializer.serialize_i32(2),
1887                Self::UnknownValue(u) => u.0.serialize(serializer),
1888            }
1889        }
1890    }
1891
1892    impl<'de> serde::de::Deserialize<'de> for DockerRegistry {
1893        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1894        where
1895            D: serde::Deserializer<'de>,
1896        {
1897            deserializer.deserialize_any(wkt::internal::EnumVisitor::<DockerRegistry>::new(
1898                ".google.cloud.functions.v2.BuildConfig.DockerRegistry",
1899            ))
1900        }
1901    }
1902
1903    /// This controls when security patches are applied to the runtime environment.
1904    #[derive(Clone, Debug, PartialEq)]
1905    #[non_exhaustive]
1906    pub enum RuntimeUpdatePolicy {
1907        AutomaticUpdatePolicy(std::boxed::Box<crate::model::AutomaticUpdatePolicy>),
1908        OnDeployUpdatePolicy(std::boxed::Box<crate::model::OnDeployUpdatePolicy>),
1909    }
1910}
1911
1912/// Describes the Service being deployed.
1913/// Currently Supported : Cloud Run (fully managed).
1914#[derive(Clone, Default, PartialEq)]
1915#[non_exhaustive]
1916pub struct ServiceConfig {
1917    /// Output only. Name of the service associated with a Function.
1918    /// The format of this field is
1919    /// `projects/{project}/locations/{region}/services/{service}`
1920    pub service: std::string::String,
1921
1922    /// The function execution timeout. Execution is considered failed and
1923    /// can be terminated if the function is not completed at the end of the
1924    /// timeout period. Defaults to 60 seconds.
1925    pub timeout_seconds: i32,
1926
1927    /// The amount of memory available for a function.
1928    /// Defaults to 256M. Supported units are k, M, G, Mi, Gi. If no unit is
1929    /// supplied the value is interpreted as bytes.
1930    /// See
1931    /// <https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/api/resource/quantity.go>
1932    /// a full description.
1933    pub available_memory: std::string::String,
1934
1935    /// The number of CPUs used in a single container instance.
1936    /// Default value is calculated from available memory.
1937    /// Supports the same values as Cloud Run, see
1938    /// <https://cloud.google.com/run/docs/reference/rest/v1/Container#resourcerequirements>
1939    /// Example: "1" indicates 1 vCPU
1940    pub available_cpu: std::string::String,
1941
1942    /// Environment variables that shall be available during function execution.
1943    pub environment_variables: std::collections::HashMap<std::string::String, std::string::String>,
1944
1945    /// The limit on the maximum number of function instances that may coexist at a
1946    /// given time.
1947    ///
1948    /// In some cases, such as rapid traffic surges, Cloud Functions may, for a
1949    /// short period of time, create more instances than the specified max
1950    /// instances limit. If your function cannot tolerate this temporary behavior,
1951    /// you may want to factor in a safety margin and set a lower max instances
1952    /// value than your function can tolerate.
1953    ///
1954    /// See the [Max
1955    /// Instances](https://cloud.google.com/functions/docs/max-instances) Guide for
1956    /// more details.
1957    pub max_instance_count: i32,
1958
1959    /// The limit on the minimum number of function instances that may coexist at a
1960    /// given time.
1961    ///
1962    /// Function instances are kept in idle state for a short period after they
1963    /// finished executing the request to reduce cold start time for subsequent
1964    /// requests. Setting a minimum instance count will ensure that the given
1965    /// number of instances are kept running in idle state always. This can help
1966    /// with cold start times when jump in incoming request count occurs after the
1967    /// idle instance would have been stopped in the default case.
1968    pub min_instance_count: i32,
1969
1970    /// The Serverless VPC Access connector that this cloud function can connect
1971    /// to. The format of this field is `projects/*/locations/*/connectors/*`.
1972    pub vpc_connector: std::string::String,
1973
1974    /// The egress settings for the connector, controlling what traffic is diverted
1975    /// through it.
1976    pub vpc_connector_egress_settings: crate::model::service_config::VpcConnectorEgressSettings,
1977
1978    /// The ingress settings for the function, controlling what traffic can reach
1979    /// it.
1980    pub ingress_settings: crate::model::service_config::IngressSettings,
1981
1982    /// Output only. URI of the Service deployed.
1983    pub uri: std::string::String,
1984
1985    /// The email of the service's service account. If empty, defaults to
1986    /// `{project_number}-compute@developer.gserviceaccount.com`.
1987    pub service_account_email: std::string::String,
1988
1989    /// Whether 100% of traffic is routed to the latest revision.
1990    /// On CreateFunction and UpdateFunction, when set to true, the revision being
1991    /// deployed will serve 100% of traffic, ignoring any traffic split settings,
1992    /// if any. On GetFunction, true will be returned if the latest revision is
1993    /// serving 100% of traffic.
1994    pub all_traffic_on_latest_revision: bool,
1995
1996    /// Secret environment variables configuration.
1997    pub secret_environment_variables: std::vec::Vec<crate::model::SecretEnvVar>,
1998
1999    /// Secret volumes configuration.
2000    pub secret_volumes: std::vec::Vec<crate::model::SecretVolume>,
2001
2002    /// Output only. The name of service revision.
2003    pub revision: std::string::String,
2004
2005    /// Sets the maximum number of concurrent requests that each instance
2006    /// can receive. Defaults to 1.
2007    pub max_instance_request_concurrency: i32,
2008
2009    /// Security level configure whether the function only accepts https.
2010    /// This configuration is only applicable to 1st Gen functions with Http
2011    /// trigger. By default https is optional for 1st Gen functions; 2nd Gen
2012    /// functions are https ONLY.
2013    pub security_level: crate::model::service_config::SecurityLevel,
2014
2015    /// Optional. The binary authorization policy to be checked when deploying the
2016    /// Cloud Run service.
2017    pub binary_authorization_policy: std::string::String,
2018
2019    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2020}
2021
2022impl ServiceConfig {
2023    pub fn new() -> Self {
2024        std::default::Default::default()
2025    }
2026
2027    /// Sets the value of [service][crate::model::ServiceConfig::service].
2028    ///
2029    /// # Example
2030    /// ```ignore,no_run
2031    /// # use google_cloud_functions_v2::model::ServiceConfig;
2032    /// let x = ServiceConfig::new().set_service("example");
2033    /// ```
2034    pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2035        self.service = v.into();
2036        self
2037    }
2038
2039    /// Sets the value of [timeout_seconds][crate::model::ServiceConfig::timeout_seconds].
2040    ///
2041    /// # Example
2042    /// ```ignore,no_run
2043    /// # use google_cloud_functions_v2::model::ServiceConfig;
2044    /// let x = ServiceConfig::new().set_timeout_seconds(42);
2045    /// ```
2046    pub fn set_timeout_seconds<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2047        self.timeout_seconds = v.into();
2048        self
2049    }
2050
2051    /// Sets the value of [available_memory][crate::model::ServiceConfig::available_memory].
2052    ///
2053    /// # Example
2054    /// ```ignore,no_run
2055    /// # use google_cloud_functions_v2::model::ServiceConfig;
2056    /// let x = ServiceConfig::new().set_available_memory("example");
2057    /// ```
2058    pub fn set_available_memory<T: std::convert::Into<std::string::String>>(
2059        mut self,
2060        v: T,
2061    ) -> Self {
2062        self.available_memory = v.into();
2063        self
2064    }
2065
2066    /// Sets the value of [available_cpu][crate::model::ServiceConfig::available_cpu].
2067    ///
2068    /// # Example
2069    /// ```ignore,no_run
2070    /// # use google_cloud_functions_v2::model::ServiceConfig;
2071    /// let x = ServiceConfig::new().set_available_cpu("example");
2072    /// ```
2073    pub fn set_available_cpu<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2074        self.available_cpu = v.into();
2075        self
2076    }
2077
2078    /// Sets the value of [environment_variables][crate::model::ServiceConfig::environment_variables].
2079    ///
2080    /// # Example
2081    /// ```ignore,no_run
2082    /// # use google_cloud_functions_v2::model::ServiceConfig;
2083    /// let x = ServiceConfig::new().set_environment_variables([
2084    ///     ("key0", "abc"),
2085    ///     ("key1", "xyz"),
2086    /// ]);
2087    /// ```
2088    pub fn set_environment_variables<T, K, V>(mut self, v: T) -> Self
2089    where
2090        T: std::iter::IntoIterator<Item = (K, V)>,
2091        K: std::convert::Into<std::string::String>,
2092        V: std::convert::Into<std::string::String>,
2093    {
2094        use std::iter::Iterator;
2095        self.environment_variables = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
2096        self
2097    }
2098
2099    /// Sets the value of [max_instance_count][crate::model::ServiceConfig::max_instance_count].
2100    ///
2101    /// # Example
2102    /// ```ignore,no_run
2103    /// # use google_cloud_functions_v2::model::ServiceConfig;
2104    /// let x = ServiceConfig::new().set_max_instance_count(42);
2105    /// ```
2106    pub fn set_max_instance_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2107        self.max_instance_count = v.into();
2108        self
2109    }
2110
2111    /// Sets the value of [min_instance_count][crate::model::ServiceConfig::min_instance_count].
2112    ///
2113    /// # Example
2114    /// ```ignore,no_run
2115    /// # use google_cloud_functions_v2::model::ServiceConfig;
2116    /// let x = ServiceConfig::new().set_min_instance_count(42);
2117    /// ```
2118    pub fn set_min_instance_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2119        self.min_instance_count = v.into();
2120        self
2121    }
2122
2123    /// Sets the value of [vpc_connector][crate::model::ServiceConfig::vpc_connector].
2124    ///
2125    /// # Example
2126    /// ```ignore,no_run
2127    /// # use google_cloud_functions_v2::model::ServiceConfig;
2128    /// let x = ServiceConfig::new().set_vpc_connector("example");
2129    /// ```
2130    pub fn set_vpc_connector<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2131        self.vpc_connector = v.into();
2132        self
2133    }
2134
2135    /// Sets the value of [vpc_connector_egress_settings][crate::model::ServiceConfig::vpc_connector_egress_settings].
2136    ///
2137    /// # Example
2138    /// ```ignore,no_run
2139    /// # use google_cloud_functions_v2::model::ServiceConfig;
2140    /// use google_cloud_functions_v2::model::service_config::VpcConnectorEgressSettings;
2141    /// let x0 = ServiceConfig::new().set_vpc_connector_egress_settings(VpcConnectorEgressSettings::PrivateRangesOnly);
2142    /// let x1 = ServiceConfig::new().set_vpc_connector_egress_settings(VpcConnectorEgressSettings::AllTraffic);
2143    /// ```
2144    pub fn set_vpc_connector_egress_settings<
2145        T: std::convert::Into<crate::model::service_config::VpcConnectorEgressSettings>,
2146    >(
2147        mut self,
2148        v: T,
2149    ) -> Self {
2150        self.vpc_connector_egress_settings = v.into();
2151        self
2152    }
2153
2154    /// Sets the value of [ingress_settings][crate::model::ServiceConfig::ingress_settings].
2155    ///
2156    /// # Example
2157    /// ```ignore,no_run
2158    /// # use google_cloud_functions_v2::model::ServiceConfig;
2159    /// use google_cloud_functions_v2::model::service_config::IngressSettings;
2160    /// let x0 = ServiceConfig::new().set_ingress_settings(IngressSettings::AllowAll);
2161    /// let x1 = ServiceConfig::new().set_ingress_settings(IngressSettings::AllowInternalOnly);
2162    /// let x2 = ServiceConfig::new().set_ingress_settings(IngressSettings::AllowInternalAndGclb);
2163    /// ```
2164    pub fn set_ingress_settings<
2165        T: std::convert::Into<crate::model::service_config::IngressSettings>,
2166    >(
2167        mut self,
2168        v: T,
2169    ) -> Self {
2170        self.ingress_settings = v.into();
2171        self
2172    }
2173
2174    /// Sets the value of [uri][crate::model::ServiceConfig::uri].
2175    ///
2176    /// # Example
2177    /// ```ignore,no_run
2178    /// # use google_cloud_functions_v2::model::ServiceConfig;
2179    /// let x = ServiceConfig::new().set_uri("example");
2180    /// ```
2181    pub fn set_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2182        self.uri = v.into();
2183        self
2184    }
2185
2186    /// Sets the value of [service_account_email][crate::model::ServiceConfig::service_account_email].
2187    ///
2188    /// # Example
2189    /// ```ignore,no_run
2190    /// # use google_cloud_functions_v2::model::ServiceConfig;
2191    /// let x = ServiceConfig::new().set_service_account_email("example");
2192    /// ```
2193    pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
2194        mut self,
2195        v: T,
2196    ) -> Self {
2197        self.service_account_email = v.into();
2198        self
2199    }
2200
2201    /// Sets the value of [all_traffic_on_latest_revision][crate::model::ServiceConfig::all_traffic_on_latest_revision].
2202    ///
2203    /// # Example
2204    /// ```ignore,no_run
2205    /// # use google_cloud_functions_v2::model::ServiceConfig;
2206    /// let x = ServiceConfig::new().set_all_traffic_on_latest_revision(true);
2207    /// ```
2208    pub fn set_all_traffic_on_latest_revision<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
2209        self.all_traffic_on_latest_revision = v.into();
2210        self
2211    }
2212
2213    /// Sets the value of [secret_environment_variables][crate::model::ServiceConfig::secret_environment_variables].
2214    ///
2215    /// # Example
2216    /// ```ignore,no_run
2217    /// # use google_cloud_functions_v2::model::ServiceConfig;
2218    /// use google_cloud_functions_v2::model::SecretEnvVar;
2219    /// let x = ServiceConfig::new()
2220    ///     .set_secret_environment_variables([
2221    ///         SecretEnvVar::default()/* use setters */,
2222    ///         SecretEnvVar::default()/* use (different) setters */,
2223    ///     ]);
2224    /// ```
2225    pub fn set_secret_environment_variables<T, V>(mut self, v: T) -> Self
2226    where
2227        T: std::iter::IntoIterator<Item = V>,
2228        V: std::convert::Into<crate::model::SecretEnvVar>,
2229    {
2230        use std::iter::Iterator;
2231        self.secret_environment_variables = v.into_iter().map(|i| i.into()).collect();
2232        self
2233    }
2234
2235    /// Sets the value of [secret_volumes][crate::model::ServiceConfig::secret_volumes].
2236    ///
2237    /// # Example
2238    /// ```ignore,no_run
2239    /// # use google_cloud_functions_v2::model::ServiceConfig;
2240    /// use google_cloud_functions_v2::model::SecretVolume;
2241    /// let x = ServiceConfig::new()
2242    ///     .set_secret_volumes([
2243    ///         SecretVolume::default()/* use setters */,
2244    ///         SecretVolume::default()/* use (different) setters */,
2245    ///     ]);
2246    /// ```
2247    pub fn set_secret_volumes<T, V>(mut self, v: T) -> Self
2248    where
2249        T: std::iter::IntoIterator<Item = V>,
2250        V: std::convert::Into<crate::model::SecretVolume>,
2251    {
2252        use std::iter::Iterator;
2253        self.secret_volumes = v.into_iter().map(|i| i.into()).collect();
2254        self
2255    }
2256
2257    /// Sets the value of [revision][crate::model::ServiceConfig::revision].
2258    ///
2259    /// # Example
2260    /// ```ignore,no_run
2261    /// # use google_cloud_functions_v2::model::ServiceConfig;
2262    /// let x = ServiceConfig::new().set_revision("example");
2263    /// ```
2264    pub fn set_revision<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2265        self.revision = v.into();
2266        self
2267    }
2268
2269    /// Sets the value of [max_instance_request_concurrency][crate::model::ServiceConfig::max_instance_request_concurrency].
2270    ///
2271    /// # Example
2272    /// ```ignore,no_run
2273    /// # use google_cloud_functions_v2::model::ServiceConfig;
2274    /// let x = ServiceConfig::new().set_max_instance_request_concurrency(42);
2275    /// ```
2276    pub fn set_max_instance_request_concurrency<T: std::convert::Into<i32>>(
2277        mut self,
2278        v: T,
2279    ) -> Self {
2280        self.max_instance_request_concurrency = v.into();
2281        self
2282    }
2283
2284    /// Sets the value of [security_level][crate::model::ServiceConfig::security_level].
2285    ///
2286    /// # Example
2287    /// ```ignore,no_run
2288    /// # use google_cloud_functions_v2::model::ServiceConfig;
2289    /// use google_cloud_functions_v2::model::service_config::SecurityLevel;
2290    /// let x0 = ServiceConfig::new().set_security_level(SecurityLevel::SecureAlways);
2291    /// let x1 = ServiceConfig::new().set_security_level(SecurityLevel::SecureOptional);
2292    /// ```
2293    pub fn set_security_level<
2294        T: std::convert::Into<crate::model::service_config::SecurityLevel>,
2295    >(
2296        mut self,
2297        v: T,
2298    ) -> Self {
2299        self.security_level = v.into();
2300        self
2301    }
2302
2303    /// Sets the value of [binary_authorization_policy][crate::model::ServiceConfig::binary_authorization_policy].
2304    ///
2305    /// # Example
2306    /// ```ignore,no_run
2307    /// # use google_cloud_functions_v2::model::ServiceConfig;
2308    /// let x = ServiceConfig::new().set_binary_authorization_policy("example");
2309    /// ```
2310    pub fn set_binary_authorization_policy<T: std::convert::Into<std::string::String>>(
2311        mut self,
2312        v: T,
2313    ) -> Self {
2314        self.binary_authorization_policy = v.into();
2315        self
2316    }
2317}
2318
2319impl wkt::message::Message for ServiceConfig {
2320    fn typename() -> &'static str {
2321        "type.googleapis.com/google.cloud.functions.v2.ServiceConfig"
2322    }
2323}
2324
2325/// Defines additional types related to [ServiceConfig].
2326pub mod service_config {
2327    #[allow(unused_imports)]
2328    use super::*;
2329
2330    /// Available egress settings.
2331    ///
2332    /// This controls what traffic is diverted through the VPC Access Connector
2333    /// resource. By default PRIVATE_RANGES_ONLY will be used.
2334    ///
2335    /// # Working with unknown values
2336    ///
2337    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2338    /// additional enum variants at any time. Adding new variants is not considered
2339    /// a breaking change. Applications should write their code in anticipation of:
2340    ///
2341    /// - New values appearing in future releases of the client library, **and**
2342    /// - New values received dynamically, without application changes.
2343    ///
2344    /// Please consult the [Working with enums] section in the user guide for some
2345    /// guidelines.
2346    ///
2347    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2348    #[derive(Clone, Debug, PartialEq)]
2349    #[non_exhaustive]
2350    pub enum VpcConnectorEgressSettings {
2351        /// Unspecified.
2352        Unspecified,
2353        /// Use the VPC Access Connector only for private IP space from RFC1918.
2354        PrivateRangesOnly,
2355        /// Force the use of VPC Access Connector for all egress traffic from the
2356        /// function.
2357        AllTraffic,
2358        /// If set, the enum was initialized with an unknown value.
2359        ///
2360        /// Applications can examine the value using [VpcConnectorEgressSettings::value] or
2361        /// [VpcConnectorEgressSettings::name].
2362        UnknownValue(vpc_connector_egress_settings::UnknownValue),
2363    }
2364
2365    #[doc(hidden)]
2366    pub mod vpc_connector_egress_settings {
2367        #[allow(unused_imports)]
2368        use super::*;
2369        #[derive(Clone, Debug, PartialEq)]
2370        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2371    }
2372
2373    impl VpcConnectorEgressSettings {
2374        /// Gets the enum value.
2375        ///
2376        /// Returns `None` if the enum contains an unknown value deserialized from
2377        /// the string representation of enums.
2378        pub fn value(&self) -> std::option::Option<i32> {
2379            match self {
2380                Self::Unspecified => std::option::Option::Some(0),
2381                Self::PrivateRangesOnly => std::option::Option::Some(1),
2382                Self::AllTraffic => std::option::Option::Some(2),
2383                Self::UnknownValue(u) => u.0.value(),
2384            }
2385        }
2386
2387        /// Gets the enum value as a string.
2388        ///
2389        /// Returns `None` if the enum contains an unknown value deserialized from
2390        /// the integer representation of enums.
2391        pub fn name(&self) -> std::option::Option<&str> {
2392            match self {
2393                Self::Unspecified => {
2394                    std::option::Option::Some("VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED")
2395                }
2396                Self::PrivateRangesOnly => std::option::Option::Some("PRIVATE_RANGES_ONLY"),
2397                Self::AllTraffic => std::option::Option::Some("ALL_TRAFFIC"),
2398                Self::UnknownValue(u) => u.0.name(),
2399            }
2400        }
2401    }
2402
2403    impl std::default::Default for VpcConnectorEgressSettings {
2404        fn default() -> Self {
2405            use std::convert::From;
2406            Self::from(0)
2407        }
2408    }
2409
2410    impl std::fmt::Display for VpcConnectorEgressSettings {
2411        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2412            wkt::internal::display_enum(f, self.name(), self.value())
2413        }
2414    }
2415
2416    impl std::convert::From<i32> for VpcConnectorEgressSettings {
2417        fn from(value: i32) -> Self {
2418            match value {
2419                0 => Self::Unspecified,
2420                1 => Self::PrivateRangesOnly,
2421                2 => Self::AllTraffic,
2422                _ => Self::UnknownValue(vpc_connector_egress_settings::UnknownValue(
2423                    wkt::internal::UnknownEnumValue::Integer(value),
2424                )),
2425            }
2426        }
2427    }
2428
2429    impl std::convert::From<&str> for VpcConnectorEgressSettings {
2430        fn from(value: &str) -> Self {
2431            use std::string::ToString;
2432            match value {
2433                "VPC_CONNECTOR_EGRESS_SETTINGS_UNSPECIFIED" => Self::Unspecified,
2434                "PRIVATE_RANGES_ONLY" => Self::PrivateRangesOnly,
2435                "ALL_TRAFFIC" => Self::AllTraffic,
2436                _ => Self::UnknownValue(vpc_connector_egress_settings::UnknownValue(
2437                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2438                )),
2439            }
2440        }
2441    }
2442
2443    impl serde::ser::Serialize for VpcConnectorEgressSettings {
2444        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2445        where
2446            S: serde::Serializer,
2447        {
2448            match self {
2449                Self::Unspecified => serializer.serialize_i32(0),
2450                Self::PrivateRangesOnly => serializer.serialize_i32(1),
2451                Self::AllTraffic => serializer.serialize_i32(2),
2452                Self::UnknownValue(u) => u.0.serialize(serializer),
2453            }
2454        }
2455    }
2456
2457    impl<'de> serde::de::Deserialize<'de> for VpcConnectorEgressSettings {
2458        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2459        where
2460            D: serde::Deserializer<'de>,
2461        {
2462            deserializer.deserialize_any(
2463                wkt::internal::EnumVisitor::<VpcConnectorEgressSettings>::new(
2464                    ".google.cloud.functions.v2.ServiceConfig.VpcConnectorEgressSettings",
2465                ),
2466            )
2467        }
2468    }
2469
2470    /// Available ingress settings.
2471    ///
2472    /// This controls what traffic can reach the function.
2473    ///
2474    /// If unspecified, ALLOW_ALL will be used.
2475    ///
2476    /// # Working with unknown values
2477    ///
2478    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2479    /// additional enum variants at any time. Adding new variants is not considered
2480    /// a breaking change. Applications should write their code in anticipation of:
2481    ///
2482    /// - New values appearing in future releases of the client library, **and**
2483    /// - New values received dynamically, without application changes.
2484    ///
2485    /// Please consult the [Working with enums] section in the user guide for some
2486    /// guidelines.
2487    ///
2488    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2489    #[derive(Clone, Debug, PartialEq)]
2490    #[non_exhaustive]
2491    pub enum IngressSettings {
2492        /// Unspecified.
2493        Unspecified,
2494        /// Allow HTTP traffic from public and private sources.
2495        AllowAll,
2496        /// Allow HTTP traffic from only private VPC sources.
2497        AllowInternalOnly,
2498        /// Allow HTTP traffic from private VPC sources and through GCLB.
2499        AllowInternalAndGclb,
2500        /// If set, the enum was initialized with an unknown value.
2501        ///
2502        /// Applications can examine the value using [IngressSettings::value] or
2503        /// [IngressSettings::name].
2504        UnknownValue(ingress_settings::UnknownValue),
2505    }
2506
2507    #[doc(hidden)]
2508    pub mod ingress_settings {
2509        #[allow(unused_imports)]
2510        use super::*;
2511        #[derive(Clone, Debug, PartialEq)]
2512        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2513    }
2514
2515    impl IngressSettings {
2516        /// Gets the enum value.
2517        ///
2518        /// Returns `None` if the enum contains an unknown value deserialized from
2519        /// the string representation of enums.
2520        pub fn value(&self) -> std::option::Option<i32> {
2521            match self {
2522                Self::Unspecified => std::option::Option::Some(0),
2523                Self::AllowAll => std::option::Option::Some(1),
2524                Self::AllowInternalOnly => std::option::Option::Some(2),
2525                Self::AllowInternalAndGclb => std::option::Option::Some(3),
2526                Self::UnknownValue(u) => u.0.value(),
2527            }
2528        }
2529
2530        /// Gets the enum value as a string.
2531        ///
2532        /// Returns `None` if the enum contains an unknown value deserialized from
2533        /// the integer representation of enums.
2534        pub fn name(&self) -> std::option::Option<&str> {
2535            match self {
2536                Self::Unspecified => std::option::Option::Some("INGRESS_SETTINGS_UNSPECIFIED"),
2537                Self::AllowAll => std::option::Option::Some("ALLOW_ALL"),
2538                Self::AllowInternalOnly => std::option::Option::Some("ALLOW_INTERNAL_ONLY"),
2539                Self::AllowInternalAndGclb => std::option::Option::Some("ALLOW_INTERNAL_AND_GCLB"),
2540                Self::UnknownValue(u) => u.0.name(),
2541            }
2542        }
2543    }
2544
2545    impl std::default::Default for IngressSettings {
2546        fn default() -> Self {
2547            use std::convert::From;
2548            Self::from(0)
2549        }
2550    }
2551
2552    impl std::fmt::Display for IngressSettings {
2553        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2554            wkt::internal::display_enum(f, self.name(), self.value())
2555        }
2556    }
2557
2558    impl std::convert::From<i32> for IngressSettings {
2559        fn from(value: i32) -> Self {
2560            match value {
2561                0 => Self::Unspecified,
2562                1 => Self::AllowAll,
2563                2 => Self::AllowInternalOnly,
2564                3 => Self::AllowInternalAndGclb,
2565                _ => Self::UnknownValue(ingress_settings::UnknownValue(
2566                    wkt::internal::UnknownEnumValue::Integer(value),
2567                )),
2568            }
2569        }
2570    }
2571
2572    impl std::convert::From<&str> for IngressSettings {
2573        fn from(value: &str) -> Self {
2574            use std::string::ToString;
2575            match value {
2576                "INGRESS_SETTINGS_UNSPECIFIED" => Self::Unspecified,
2577                "ALLOW_ALL" => Self::AllowAll,
2578                "ALLOW_INTERNAL_ONLY" => Self::AllowInternalOnly,
2579                "ALLOW_INTERNAL_AND_GCLB" => Self::AllowInternalAndGclb,
2580                _ => Self::UnknownValue(ingress_settings::UnknownValue(
2581                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2582                )),
2583            }
2584        }
2585    }
2586
2587    impl serde::ser::Serialize for IngressSettings {
2588        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2589        where
2590            S: serde::Serializer,
2591        {
2592            match self {
2593                Self::Unspecified => serializer.serialize_i32(0),
2594                Self::AllowAll => serializer.serialize_i32(1),
2595                Self::AllowInternalOnly => serializer.serialize_i32(2),
2596                Self::AllowInternalAndGclb => serializer.serialize_i32(3),
2597                Self::UnknownValue(u) => u.0.serialize(serializer),
2598            }
2599        }
2600    }
2601
2602    impl<'de> serde::de::Deserialize<'de> for IngressSettings {
2603        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2604        where
2605            D: serde::Deserializer<'de>,
2606        {
2607            deserializer.deserialize_any(wkt::internal::EnumVisitor::<IngressSettings>::new(
2608                ".google.cloud.functions.v2.ServiceConfig.IngressSettings",
2609            ))
2610        }
2611    }
2612
2613    /// Available security level settings.
2614    ///
2615    /// This enforces security protocol on function URL.
2616    ///
2617    /// Security level is only configurable for 1st Gen functions, If unspecified,
2618    /// SECURE_OPTIONAL will be used. 2nd Gen functions are SECURE_ALWAYS ONLY.
2619    ///
2620    /// # Working with unknown values
2621    ///
2622    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2623    /// additional enum variants at any time. Adding new variants is not considered
2624    /// a breaking change. Applications should write their code in anticipation of:
2625    ///
2626    /// - New values appearing in future releases of the client library, **and**
2627    /// - New values received dynamically, without application changes.
2628    ///
2629    /// Please consult the [Working with enums] section in the user guide for some
2630    /// guidelines.
2631    ///
2632    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2633    #[derive(Clone, Debug, PartialEq)]
2634    #[non_exhaustive]
2635    pub enum SecurityLevel {
2636        /// Unspecified.
2637        Unspecified,
2638        /// Requests for a URL that match this handler that do not use HTTPS are
2639        /// automatically redirected to the HTTPS URL with the same path. Query
2640        /// parameters are reserved for the redirect.
2641        SecureAlways,
2642        /// Both HTTP and HTTPS requests with URLs that match the handler succeed
2643        /// without redirects. The application can examine the request to determine
2644        /// which protocol was used and respond accordingly.
2645        SecureOptional,
2646        /// If set, the enum was initialized with an unknown value.
2647        ///
2648        /// Applications can examine the value using [SecurityLevel::value] or
2649        /// [SecurityLevel::name].
2650        UnknownValue(security_level::UnknownValue),
2651    }
2652
2653    #[doc(hidden)]
2654    pub mod security_level {
2655        #[allow(unused_imports)]
2656        use super::*;
2657        #[derive(Clone, Debug, PartialEq)]
2658        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2659    }
2660
2661    impl SecurityLevel {
2662        /// Gets the enum value.
2663        ///
2664        /// Returns `None` if the enum contains an unknown value deserialized from
2665        /// the string representation of enums.
2666        pub fn value(&self) -> std::option::Option<i32> {
2667            match self {
2668                Self::Unspecified => std::option::Option::Some(0),
2669                Self::SecureAlways => std::option::Option::Some(1),
2670                Self::SecureOptional => std::option::Option::Some(2),
2671                Self::UnknownValue(u) => u.0.value(),
2672            }
2673        }
2674
2675        /// Gets the enum value as a string.
2676        ///
2677        /// Returns `None` if the enum contains an unknown value deserialized from
2678        /// the integer representation of enums.
2679        pub fn name(&self) -> std::option::Option<&str> {
2680            match self {
2681                Self::Unspecified => std::option::Option::Some("SECURITY_LEVEL_UNSPECIFIED"),
2682                Self::SecureAlways => std::option::Option::Some("SECURE_ALWAYS"),
2683                Self::SecureOptional => std::option::Option::Some("SECURE_OPTIONAL"),
2684                Self::UnknownValue(u) => u.0.name(),
2685            }
2686        }
2687    }
2688
2689    impl std::default::Default for SecurityLevel {
2690        fn default() -> Self {
2691            use std::convert::From;
2692            Self::from(0)
2693        }
2694    }
2695
2696    impl std::fmt::Display for SecurityLevel {
2697        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2698            wkt::internal::display_enum(f, self.name(), self.value())
2699        }
2700    }
2701
2702    impl std::convert::From<i32> for SecurityLevel {
2703        fn from(value: i32) -> Self {
2704            match value {
2705                0 => Self::Unspecified,
2706                1 => Self::SecureAlways,
2707                2 => Self::SecureOptional,
2708                _ => Self::UnknownValue(security_level::UnknownValue(
2709                    wkt::internal::UnknownEnumValue::Integer(value),
2710                )),
2711            }
2712        }
2713    }
2714
2715    impl std::convert::From<&str> for SecurityLevel {
2716        fn from(value: &str) -> Self {
2717            use std::string::ToString;
2718            match value {
2719                "SECURITY_LEVEL_UNSPECIFIED" => Self::Unspecified,
2720                "SECURE_ALWAYS" => Self::SecureAlways,
2721                "SECURE_OPTIONAL" => Self::SecureOptional,
2722                _ => Self::UnknownValue(security_level::UnknownValue(
2723                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2724                )),
2725            }
2726        }
2727    }
2728
2729    impl serde::ser::Serialize for SecurityLevel {
2730        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2731        where
2732            S: serde::Serializer,
2733        {
2734            match self {
2735                Self::Unspecified => serializer.serialize_i32(0),
2736                Self::SecureAlways => serializer.serialize_i32(1),
2737                Self::SecureOptional => serializer.serialize_i32(2),
2738                Self::UnknownValue(u) => u.0.serialize(serializer),
2739            }
2740        }
2741    }
2742
2743    impl<'de> serde::de::Deserialize<'de> for SecurityLevel {
2744        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2745        where
2746            D: serde::Deserializer<'de>,
2747        {
2748            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SecurityLevel>::new(
2749                ".google.cloud.functions.v2.ServiceConfig.SecurityLevel",
2750            ))
2751        }
2752    }
2753}
2754
2755/// Configuration for a secret environment variable. It has the information
2756/// necessary to fetch the secret value from secret manager and expose it as an
2757/// environment variable.
2758#[derive(Clone, Default, PartialEq)]
2759#[non_exhaustive]
2760pub struct SecretEnvVar {
2761    /// Name of the environment variable.
2762    pub key: std::string::String,
2763
2764    /// Project identifier (preferably project number but can also be the
2765    /// project ID) of the project that contains the secret. If not set, it is
2766    /// assumed that the secret is in the same project as the function.
2767    pub project_id: std::string::String,
2768
2769    /// Name of the secret in secret manager (not the full resource name).
2770    pub secret: std::string::String,
2771
2772    /// Version of the secret (version number or the string 'latest'). It is
2773    /// recommended to use a numeric version for secret environment variables as
2774    /// any updates to the secret value is not reflected until new instances
2775    /// start.
2776    pub version: std::string::String,
2777
2778    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2779}
2780
2781impl SecretEnvVar {
2782    pub fn new() -> Self {
2783        std::default::Default::default()
2784    }
2785
2786    /// Sets the value of [key][crate::model::SecretEnvVar::key].
2787    ///
2788    /// # Example
2789    /// ```ignore,no_run
2790    /// # use google_cloud_functions_v2::model::SecretEnvVar;
2791    /// let x = SecretEnvVar::new().set_key("example");
2792    /// ```
2793    pub fn set_key<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2794        self.key = v.into();
2795        self
2796    }
2797
2798    /// Sets the value of [project_id][crate::model::SecretEnvVar::project_id].
2799    ///
2800    /// # Example
2801    /// ```ignore,no_run
2802    /// # use google_cloud_functions_v2::model::SecretEnvVar;
2803    /// let x = SecretEnvVar::new().set_project_id("example");
2804    /// ```
2805    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2806        self.project_id = v.into();
2807        self
2808    }
2809
2810    /// Sets the value of [secret][crate::model::SecretEnvVar::secret].
2811    ///
2812    /// # Example
2813    /// ```ignore,no_run
2814    /// # use google_cloud_functions_v2::model::SecretEnvVar;
2815    /// let x = SecretEnvVar::new().set_secret("example");
2816    /// ```
2817    pub fn set_secret<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2818        self.secret = v.into();
2819        self
2820    }
2821
2822    /// Sets the value of [version][crate::model::SecretEnvVar::version].
2823    ///
2824    /// # Example
2825    /// ```ignore,no_run
2826    /// # use google_cloud_functions_v2::model::SecretEnvVar;
2827    /// let x = SecretEnvVar::new().set_version("example");
2828    /// ```
2829    pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2830        self.version = v.into();
2831        self
2832    }
2833}
2834
2835impl wkt::message::Message for SecretEnvVar {
2836    fn typename() -> &'static str {
2837        "type.googleapis.com/google.cloud.functions.v2.SecretEnvVar"
2838    }
2839}
2840
2841/// Configuration for a secret volume. It has the information necessary to fetch
2842/// the secret value from secret manager and make it available as files mounted
2843/// at the requested paths within the application container.
2844#[derive(Clone, Default, PartialEq)]
2845#[non_exhaustive]
2846pub struct SecretVolume {
2847    /// The path within the container to mount the secret volume. For example,
2848    /// setting the mount_path as `/etc/secrets` would mount the secret value files
2849    /// under the `/etc/secrets` directory. This directory will also be completely
2850    /// shadowed and unavailable to mount any other secrets.
2851    /// Recommended mount path: /etc/secrets
2852    pub mount_path: std::string::String,
2853
2854    /// Project identifier (preferably project number but can also be the project
2855    /// ID) of the project that contains the secret. If not set, it is
2856    /// assumed that the secret is in the same project as the function.
2857    pub project_id: std::string::String,
2858
2859    /// Name of the secret in secret manager (not the full resource name).
2860    pub secret: std::string::String,
2861
2862    /// List of secret versions to mount for this secret. If empty, the `latest`
2863    /// version of the secret will be made available in a file named after the
2864    /// secret under the mount point.
2865    pub versions: std::vec::Vec<crate::model::secret_volume::SecretVersion>,
2866
2867    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2868}
2869
2870impl SecretVolume {
2871    pub fn new() -> Self {
2872        std::default::Default::default()
2873    }
2874
2875    /// Sets the value of [mount_path][crate::model::SecretVolume::mount_path].
2876    ///
2877    /// # Example
2878    /// ```ignore,no_run
2879    /// # use google_cloud_functions_v2::model::SecretVolume;
2880    /// let x = SecretVolume::new().set_mount_path("example");
2881    /// ```
2882    pub fn set_mount_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2883        self.mount_path = v.into();
2884        self
2885    }
2886
2887    /// Sets the value of [project_id][crate::model::SecretVolume::project_id].
2888    ///
2889    /// # Example
2890    /// ```ignore,no_run
2891    /// # use google_cloud_functions_v2::model::SecretVolume;
2892    /// let x = SecretVolume::new().set_project_id("example");
2893    /// ```
2894    pub fn set_project_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2895        self.project_id = v.into();
2896        self
2897    }
2898
2899    /// Sets the value of [secret][crate::model::SecretVolume::secret].
2900    ///
2901    /// # Example
2902    /// ```ignore,no_run
2903    /// # use google_cloud_functions_v2::model::SecretVolume;
2904    /// let x = SecretVolume::new().set_secret("example");
2905    /// ```
2906    pub fn set_secret<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2907        self.secret = v.into();
2908        self
2909    }
2910
2911    /// Sets the value of [versions][crate::model::SecretVolume::versions].
2912    ///
2913    /// # Example
2914    /// ```ignore,no_run
2915    /// # use google_cloud_functions_v2::model::SecretVolume;
2916    /// use google_cloud_functions_v2::model::secret_volume::SecretVersion;
2917    /// let x = SecretVolume::new()
2918    ///     .set_versions([
2919    ///         SecretVersion::default()/* use setters */,
2920    ///         SecretVersion::default()/* use (different) setters */,
2921    ///     ]);
2922    /// ```
2923    pub fn set_versions<T, V>(mut self, v: T) -> Self
2924    where
2925        T: std::iter::IntoIterator<Item = V>,
2926        V: std::convert::Into<crate::model::secret_volume::SecretVersion>,
2927    {
2928        use std::iter::Iterator;
2929        self.versions = v.into_iter().map(|i| i.into()).collect();
2930        self
2931    }
2932}
2933
2934impl wkt::message::Message for SecretVolume {
2935    fn typename() -> &'static str {
2936        "type.googleapis.com/google.cloud.functions.v2.SecretVolume"
2937    }
2938}
2939
2940/// Defines additional types related to [SecretVolume].
2941pub mod secret_volume {
2942    #[allow(unused_imports)]
2943    use super::*;
2944
2945    /// Configuration for a single version.
2946    #[derive(Clone, Default, PartialEq)]
2947    #[non_exhaustive]
2948    pub struct SecretVersion {
2949        /// Version of the secret (version number or the string 'latest'). It is
2950        /// preferable to use `latest` version with secret volumes as secret value
2951        /// changes are reflected immediately.
2952        pub version: std::string::String,
2953
2954        /// Relative path of the file under the mount path where the secret value for
2955        /// this version will be fetched and made available. For example, setting the
2956        /// mount_path as '/etc/secrets' and path as `secret_foo` would mount the
2957        /// secret value file at `/etc/secrets/secret_foo`.
2958        pub path: std::string::String,
2959
2960        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2961    }
2962
2963    impl SecretVersion {
2964        pub fn new() -> Self {
2965            std::default::Default::default()
2966        }
2967
2968        /// Sets the value of [version][crate::model::secret_volume::SecretVersion::version].
2969        ///
2970        /// # Example
2971        /// ```ignore,no_run
2972        /// # use google_cloud_functions_v2::model::secret_volume::SecretVersion;
2973        /// let x = SecretVersion::new().set_version("example");
2974        /// ```
2975        pub fn set_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2976            self.version = v.into();
2977            self
2978        }
2979
2980        /// Sets the value of [path][crate::model::secret_volume::SecretVersion::path].
2981        ///
2982        /// # Example
2983        /// ```ignore,no_run
2984        /// # use google_cloud_functions_v2::model::secret_volume::SecretVersion;
2985        /// let x = SecretVersion::new().set_path("example");
2986        /// ```
2987        pub fn set_path<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2988            self.path = v.into();
2989            self
2990        }
2991    }
2992
2993    impl wkt::message::Message for SecretVersion {
2994        fn typename() -> &'static str {
2995            "type.googleapis.com/google.cloud.functions.v2.SecretVolume.SecretVersion"
2996        }
2997    }
2998}
2999
3000/// Describes EventTrigger, used to request events to be sent from another
3001/// service.
3002#[derive(Clone, Default, PartialEq)]
3003#[non_exhaustive]
3004pub struct EventTrigger {
3005    /// Output only. The resource name of the Eventarc trigger. The format of this
3006    /// field is `projects/{project}/locations/{region}/triggers/{trigger}`.
3007    pub trigger: std::string::String,
3008
3009    /// The region that the trigger will be in. The trigger will only receive
3010    /// events originating in this region. It can be the same
3011    /// region as the function, a different region or multi-region, or the global
3012    /// region. If not provided, defaults to the same region as the function.
3013    pub trigger_region: std::string::String,
3014
3015    /// Required. The type of event to observe. For example:
3016    /// `google.cloud.audit.log.v1.written` or
3017    /// `google.cloud.pubsub.topic.v1.messagePublished`.
3018    pub event_type: std::string::String,
3019
3020    /// Criteria used to filter events.
3021    pub event_filters: std::vec::Vec<crate::model::EventFilter>,
3022
3023    /// Optional. The name of a Pub/Sub topic in the same project that will be used
3024    /// as the transport topic for the event delivery. Format:
3025    /// `projects/{project}/topics/{topic}`.
3026    ///
3027    /// This is only valid for events of type
3028    /// `google.cloud.pubsub.topic.v1.messagePublished`. The topic provided here
3029    /// will not be deleted at function deletion.
3030    pub pubsub_topic: std::string::String,
3031
3032    /// Optional. The email of the trigger's service account. The service account
3033    /// must have permission to invoke Cloud Run services, the permission is
3034    /// `run.routes.invoke`.
3035    /// If empty, defaults to the Compute Engine default service account:
3036    /// `{project_number}-compute@developer.gserviceaccount.com`.
3037    pub service_account_email: std::string::String,
3038
3039    /// Optional. If unset, then defaults to ignoring failures (i.e. not retrying
3040    /// them).
3041    pub retry_policy: crate::model::event_trigger::RetryPolicy,
3042
3043    /// Optional. The name of the channel associated with the trigger in
3044    /// `projects/{project}/locations/{location}/channels/{channel}` format.
3045    /// You must provide a channel to receive events from Eventarc SaaS partners.
3046    pub channel: std::string::String,
3047
3048    /// Optional. The hostname of the service that 1st Gen function should be
3049    /// observed.
3050    ///
3051    /// If no string is provided, the default service implementing the API will
3052    /// be used. For example, `storage.googleapis.com` is the default for all
3053    /// event types in the `google.storage` namespace.
3054    ///
3055    /// The field is only applicable to 1st Gen functions.
3056    pub service: std::string::String,
3057
3058    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3059}
3060
3061impl EventTrigger {
3062    pub fn new() -> Self {
3063        std::default::Default::default()
3064    }
3065
3066    /// Sets the value of [trigger][crate::model::EventTrigger::trigger].
3067    ///
3068    /// # Example
3069    /// ```ignore,no_run
3070    /// # use google_cloud_functions_v2::model::EventTrigger;
3071    /// let x = EventTrigger::new().set_trigger("example");
3072    /// ```
3073    pub fn set_trigger<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3074        self.trigger = v.into();
3075        self
3076    }
3077
3078    /// Sets the value of [trigger_region][crate::model::EventTrigger::trigger_region].
3079    ///
3080    /// # Example
3081    /// ```ignore,no_run
3082    /// # use google_cloud_functions_v2::model::EventTrigger;
3083    /// let x = EventTrigger::new().set_trigger_region("example");
3084    /// ```
3085    pub fn set_trigger_region<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3086        self.trigger_region = v.into();
3087        self
3088    }
3089
3090    /// Sets the value of [event_type][crate::model::EventTrigger::event_type].
3091    ///
3092    /// # Example
3093    /// ```ignore,no_run
3094    /// # use google_cloud_functions_v2::model::EventTrigger;
3095    /// let x = EventTrigger::new().set_event_type("example");
3096    /// ```
3097    pub fn set_event_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3098        self.event_type = v.into();
3099        self
3100    }
3101
3102    /// Sets the value of [event_filters][crate::model::EventTrigger::event_filters].
3103    ///
3104    /// # Example
3105    /// ```ignore,no_run
3106    /// # use google_cloud_functions_v2::model::EventTrigger;
3107    /// use google_cloud_functions_v2::model::EventFilter;
3108    /// let x = EventTrigger::new()
3109    ///     .set_event_filters([
3110    ///         EventFilter::default()/* use setters */,
3111    ///         EventFilter::default()/* use (different) setters */,
3112    ///     ]);
3113    /// ```
3114    pub fn set_event_filters<T, V>(mut self, v: T) -> Self
3115    where
3116        T: std::iter::IntoIterator<Item = V>,
3117        V: std::convert::Into<crate::model::EventFilter>,
3118    {
3119        use std::iter::Iterator;
3120        self.event_filters = v.into_iter().map(|i| i.into()).collect();
3121        self
3122    }
3123
3124    /// Sets the value of [pubsub_topic][crate::model::EventTrigger::pubsub_topic].
3125    ///
3126    /// # Example
3127    /// ```ignore,no_run
3128    /// # use google_cloud_functions_v2::model::EventTrigger;
3129    /// let x = EventTrigger::new().set_pubsub_topic("example");
3130    /// ```
3131    pub fn set_pubsub_topic<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3132        self.pubsub_topic = v.into();
3133        self
3134    }
3135
3136    /// Sets the value of [service_account_email][crate::model::EventTrigger::service_account_email].
3137    ///
3138    /// # Example
3139    /// ```ignore,no_run
3140    /// # use google_cloud_functions_v2::model::EventTrigger;
3141    /// let x = EventTrigger::new().set_service_account_email("example");
3142    /// ```
3143    pub fn set_service_account_email<T: std::convert::Into<std::string::String>>(
3144        mut self,
3145        v: T,
3146    ) -> Self {
3147        self.service_account_email = v.into();
3148        self
3149    }
3150
3151    /// Sets the value of [retry_policy][crate::model::EventTrigger::retry_policy].
3152    ///
3153    /// # Example
3154    /// ```ignore,no_run
3155    /// # use google_cloud_functions_v2::model::EventTrigger;
3156    /// use google_cloud_functions_v2::model::event_trigger::RetryPolicy;
3157    /// let x0 = EventTrigger::new().set_retry_policy(RetryPolicy::DoNotRetry);
3158    /// let x1 = EventTrigger::new().set_retry_policy(RetryPolicy::Retry);
3159    /// ```
3160    pub fn set_retry_policy<T: std::convert::Into<crate::model::event_trigger::RetryPolicy>>(
3161        mut self,
3162        v: T,
3163    ) -> Self {
3164        self.retry_policy = v.into();
3165        self
3166    }
3167
3168    /// Sets the value of [channel][crate::model::EventTrigger::channel].
3169    ///
3170    /// # Example
3171    /// ```ignore,no_run
3172    /// # use google_cloud_functions_v2::model::EventTrigger;
3173    /// let x = EventTrigger::new().set_channel("example");
3174    /// ```
3175    pub fn set_channel<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3176        self.channel = v.into();
3177        self
3178    }
3179
3180    /// Sets the value of [service][crate::model::EventTrigger::service].
3181    ///
3182    /// # Example
3183    /// ```ignore,no_run
3184    /// # use google_cloud_functions_v2::model::EventTrigger;
3185    /// let x = EventTrigger::new().set_service("example");
3186    /// ```
3187    pub fn set_service<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3188        self.service = v.into();
3189        self
3190    }
3191}
3192
3193impl wkt::message::Message for EventTrigger {
3194    fn typename() -> &'static str {
3195        "type.googleapis.com/google.cloud.functions.v2.EventTrigger"
3196    }
3197}
3198
3199/// Defines additional types related to [EventTrigger].
3200pub mod event_trigger {
3201    #[allow(unused_imports)]
3202    use super::*;
3203
3204    /// Describes the retry policy in case of function's execution failure.
3205    /// Retried execution is charged as any other execution.
3206    ///
3207    /// # Working with unknown values
3208    ///
3209    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
3210    /// additional enum variants at any time. Adding new variants is not considered
3211    /// a breaking change. Applications should write their code in anticipation of:
3212    ///
3213    /// - New values appearing in future releases of the client library, **and**
3214    /// - New values received dynamically, without application changes.
3215    ///
3216    /// Please consult the [Working with enums] section in the user guide for some
3217    /// guidelines.
3218    ///
3219    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
3220    #[derive(Clone, Debug, PartialEq)]
3221    #[non_exhaustive]
3222    pub enum RetryPolicy {
3223        /// Not specified.
3224        Unspecified,
3225        /// Do not retry.
3226        DoNotRetry,
3227        /// Retry on any failure, retry up to 7 days with an exponential backoff
3228        /// (capped at 10 seconds).
3229        Retry,
3230        /// If set, the enum was initialized with an unknown value.
3231        ///
3232        /// Applications can examine the value using [RetryPolicy::value] or
3233        /// [RetryPolicy::name].
3234        UnknownValue(retry_policy::UnknownValue),
3235    }
3236
3237    #[doc(hidden)]
3238    pub mod retry_policy {
3239        #[allow(unused_imports)]
3240        use super::*;
3241        #[derive(Clone, Debug, PartialEq)]
3242        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
3243    }
3244
3245    impl RetryPolicy {
3246        /// Gets the enum value.
3247        ///
3248        /// Returns `None` if the enum contains an unknown value deserialized from
3249        /// the string representation of enums.
3250        pub fn value(&self) -> std::option::Option<i32> {
3251            match self {
3252                Self::Unspecified => std::option::Option::Some(0),
3253                Self::DoNotRetry => std::option::Option::Some(1),
3254                Self::Retry => std::option::Option::Some(2),
3255                Self::UnknownValue(u) => u.0.value(),
3256            }
3257        }
3258
3259        /// Gets the enum value as a string.
3260        ///
3261        /// Returns `None` if the enum contains an unknown value deserialized from
3262        /// the integer representation of enums.
3263        pub fn name(&self) -> std::option::Option<&str> {
3264            match self {
3265                Self::Unspecified => std::option::Option::Some("RETRY_POLICY_UNSPECIFIED"),
3266                Self::DoNotRetry => std::option::Option::Some("RETRY_POLICY_DO_NOT_RETRY"),
3267                Self::Retry => std::option::Option::Some("RETRY_POLICY_RETRY"),
3268                Self::UnknownValue(u) => u.0.name(),
3269            }
3270        }
3271    }
3272
3273    impl std::default::Default for RetryPolicy {
3274        fn default() -> Self {
3275            use std::convert::From;
3276            Self::from(0)
3277        }
3278    }
3279
3280    impl std::fmt::Display for RetryPolicy {
3281        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
3282            wkt::internal::display_enum(f, self.name(), self.value())
3283        }
3284    }
3285
3286    impl std::convert::From<i32> for RetryPolicy {
3287        fn from(value: i32) -> Self {
3288            match value {
3289                0 => Self::Unspecified,
3290                1 => Self::DoNotRetry,
3291                2 => Self::Retry,
3292                _ => Self::UnknownValue(retry_policy::UnknownValue(
3293                    wkt::internal::UnknownEnumValue::Integer(value),
3294                )),
3295            }
3296        }
3297    }
3298
3299    impl std::convert::From<&str> for RetryPolicy {
3300        fn from(value: &str) -> Self {
3301            use std::string::ToString;
3302            match value {
3303                "RETRY_POLICY_UNSPECIFIED" => Self::Unspecified,
3304                "RETRY_POLICY_DO_NOT_RETRY" => Self::DoNotRetry,
3305                "RETRY_POLICY_RETRY" => Self::Retry,
3306                _ => Self::UnknownValue(retry_policy::UnknownValue(
3307                    wkt::internal::UnknownEnumValue::String(value.to_string()),
3308                )),
3309            }
3310        }
3311    }
3312
3313    impl serde::ser::Serialize for RetryPolicy {
3314        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3315        where
3316            S: serde::Serializer,
3317        {
3318            match self {
3319                Self::Unspecified => serializer.serialize_i32(0),
3320                Self::DoNotRetry => serializer.serialize_i32(1),
3321                Self::Retry => serializer.serialize_i32(2),
3322                Self::UnknownValue(u) => u.0.serialize(serializer),
3323            }
3324        }
3325    }
3326
3327    impl<'de> serde::de::Deserialize<'de> for RetryPolicy {
3328        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3329        where
3330            D: serde::Deserializer<'de>,
3331        {
3332            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RetryPolicy>::new(
3333                ".google.cloud.functions.v2.EventTrigger.RetryPolicy",
3334            ))
3335        }
3336    }
3337}
3338
3339/// Filters events based on exact matches on the CloudEvents attributes.
3340#[derive(Clone, Default, PartialEq)]
3341#[non_exhaustive]
3342pub struct EventFilter {
3343    /// Required. The name of a CloudEvents attribute.
3344    pub attribute: std::string::String,
3345
3346    /// Required. The value for the attribute.
3347    pub value: std::string::String,
3348
3349    /// Optional. The operator used for matching the events with the value of the
3350    /// filter. If not specified, only events that have an exact key-value pair
3351    /// specified in the filter are matched. The only allowed value is
3352    /// `match-path-pattern`.
3353    pub operator: std::string::String,
3354
3355    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3356}
3357
3358impl EventFilter {
3359    pub fn new() -> Self {
3360        std::default::Default::default()
3361    }
3362
3363    /// Sets the value of [attribute][crate::model::EventFilter::attribute].
3364    ///
3365    /// # Example
3366    /// ```ignore,no_run
3367    /// # use google_cloud_functions_v2::model::EventFilter;
3368    /// let x = EventFilter::new().set_attribute("example");
3369    /// ```
3370    pub fn set_attribute<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3371        self.attribute = v.into();
3372        self
3373    }
3374
3375    /// Sets the value of [value][crate::model::EventFilter::value].
3376    ///
3377    /// # Example
3378    /// ```ignore,no_run
3379    /// # use google_cloud_functions_v2::model::EventFilter;
3380    /// let x = EventFilter::new().set_value("example");
3381    /// ```
3382    pub fn set_value<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3383        self.value = v.into();
3384        self
3385    }
3386
3387    /// Sets the value of [operator][crate::model::EventFilter::operator].
3388    ///
3389    /// # Example
3390    /// ```ignore,no_run
3391    /// # use google_cloud_functions_v2::model::EventFilter;
3392    /// let x = EventFilter::new().set_operator("example");
3393    /// ```
3394    pub fn set_operator<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3395        self.operator = v.into();
3396        self
3397    }
3398}
3399
3400impl wkt::message::Message for EventFilter {
3401    fn typename() -> &'static str {
3402        "type.googleapis.com/google.cloud.functions.v2.EventFilter"
3403    }
3404}
3405
3406/// Request for the `GetFunction` method.
3407#[derive(Clone, Default, PartialEq)]
3408#[non_exhaustive]
3409pub struct GetFunctionRequest {
3410    /// Required. The name of the function which details should be obtained.
3411    pub name: std::string::String,
3412
3413    /// Optional. The optional version of the 1st gen function whose details should
3414    /// be obtained. The version of a 1st gen function is an integer that starts
3415    /// from 1 and gets incremented on redeployments. GCF may keep historical
3416    /// configs for old versions of 1st gen function. This field can be specified
3417    /// to fetch the historical configs. This field is valid only for GCF 1st gen
3418    /// function.
3419    pub revision: std::string::String,
3420
3421    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3422}
3423
3424impl GetFunctionRequest {
3425    pub fn new() -> Self {
3426        std::default::Default::default()
3427    }
3428
3429    /// Sets the value of [name][crate::model::GetFunctionRequest::name].
3430    ///
3431    /// # Example
3432    /// ```ignore,no_run
3433    /// # use google_cloud_functions_v2::model::GetFunctionRequest;
3434    /// let x = GetFunctionRequest::new().set_name("example");
3435    /// ```
3436    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3437        self.name = v.into();
3438        self
3439    }
3440
3441    /// Sets the value of [revision][crate::model::GetFunctionRequest::revision].
3442    ///
3443    /// # Example
3444    /// ```ignore,no_run
3445    /// # use google_cloud_functions_v2::model::GetFunctionRequest;
3446    /// let x = GetFunctionRequest::new().set_revision("example");
3447    /// ```
3448    pub fn set_revision<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3449        self.revision = v.into();
3450        self
3451    }
3452}
3453
3454impl wkt::message::Message for GetFunctionRequest {
3455    fn typename() -> &'static str {
3456        "type.googleapis.com/google.cloud.functions.v2.GetFunctionRequest"
3457    }
3458}
3459
3460/// Request for the `ListFunctions` method.
3461#[derive(Clone, Default, PartialEq)]
3462#[non_exhaustive]
3463pub struct ListFunctionsRequest {
3464    /// Required. The project and location from which the function should be
3465    /// listed, specified in the format `projects/*/locations/*` If you want to
3466    /// list functions in all locations, use "-" in place of a location. When
3467    /// listing functions in all locations, if one or more location(s) are
3468    /// unreachable, the response will contain functions from all reachable
3469    /// locations along with the names of any unreachable locations.
3470    pub parent: std::string::String,
3471
3472    /// Maximum number of functions to return per call. The largest allowed
3473    /// page_size is 1,000, if the page_size is omitted or specified as greater
3474    /// than 1,000 then it will be replaced as 1,000. The size of the list
3475    /// response can be less than specified when used with filters.
3476    pub page_size: i32,
3477
3478    /// The value returned by the last
3479    /// `ListFunctionsResponse`; indicates that
3480    /// this is a continuation of a prior `ListFunctions` call, and that the
3481    /// system should return the next page of data.
3482    pub page_token: std::string::String,
3483
3484    /// The filter for Functions that match the filter expression,
3485    /// following the syntax outlined in <https://google.aip.dev/160>.
3486    pub filter: std::string::String,
3487
3488    /// The sorting order of the resources returned. Value should be a comma
3489    /// separated list of fields. The default sorting order is ascending.
3490    /// See <https://google.aip.dev/132#ordering>.
3491    pub order_by: std::string::String,
3492
3493    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3494}
3495
3496impl ListFunctionsRequest {
3497    pub fn new() -> Self {
3498        std::default::Default::default()
3499    }
3500
3501    /// Sets the value of [parent][crate::model::ListFunctionsRequest::parent].
3502    ///
3503    /// # Example
3504    /// ```ignore,no_run
3505    /// # use google_cloud_functions_v2::model::ListFunctionsRequest;
3506    /// let x = ListFunctionsRequest::new().set_parent("example");
3507    /// ```
3508    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3509        self.parent = v.into();
3510        self
3511    }
3512
3513    /// Sets the value of [page_size][crate::model::ListFunctionsRequest::page_size].
3514    ///
3515    /// # Example
3516    /// ```ignore,no_run
3517    /// # use google_cloud_functions_v2::model::ListFunctionsRequest;
3518    /// let x = ListFunctionsRequest::new().set_page_size(42);
3519    /// ```
3520    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3521        self.page_size = v.into();
3522        self
3523    }
3524
3525    /// Sets the value of [page_token][crate::model::ListFunctionsRequest::page_token].
3526    ///
3527    /// # Example
3528    /// ```ignore,no_run
3529    /// # use google_cloud_functions_v2::model::ListFunctionsRequest;
3530    /// let x = ListFunctionsRequest::new().set_page_token("example");
3531    /// ```
3532    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3533        self.page_token = v.into();
3534        self
3535    }
3536
3537    /// Sets the value of [filter][crate::model::ListFunctionsRequest::filter].
3538    ///
3539    /// # Example
3540    /// ```ignore,no_run
3541    /// # use google_cloud_functions_v2::model::ListFunctionsRequest;
3542    /// let x = ListFunctionsRequest::new().set_filter("example");
3543    /// ```
3544    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3545        self.filter = v.into();
3546        self
3547    }
3548
3549    /// Sets the value of [order_by][crate::model::ListFunctionsRequest::order_by].
3550    ///
3551    /// # Example
3552    /// ```ignore,no_run
3553    /// # use google_cloud_functions_v2::model::ListFunctionsRequest;
3554    /// let x = ListFunctionsRequest::new().set_order_by("example");
3555    /// ```
3556    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3557        self.order_by = v.into();
3558        self
3559    }
3560}
3561
3562impl wkt::message::Message for ListFunctionsRequest {
3563    fn typename() -> &'static str {
3564        "type.googleapis.com/google.cloud.functions.v2.ListFunctionsRequest"
3565    }
3566}
3567
3568/// Response for the `ListFunctions` method.
3569#[derive(Clone, Default, PartialEq)]
3570#[non_exhaustive]
3571pub struct ListFunctionsResponse {
3572    /// The functions that match the request.
3573    pub functions: std::vec::Vec<crate::model::Function>,
3574
3575    /// A token, which can be sent as `page_token` to retrieve the next page.
3576    /// If this field is omitted, there are no subsequent pages.
3577    pub next_page_token: std::string::String,
3578
3579    /// Locations that could not be reached. The response does not include any
3580    /// functions from these locations.
3581    pub unreachable: std::vec::Vec<std::string::String>,
3582
3583    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3584}
3585
3586impl ListFunctionsResponse {
3587    pub fn new() -> Self {
3588        std::default::Default::default()
3589    }
3590
3591    /// Sets the value of [functions][crate::model::ListFunctionsResponse::functions].
3592    ///
3593    /// # Example
3594    /// ```ignore,no_run
3595    /// # use google_cloud_functions_v2::model::ListFunctionsResponse;
3596    /// use google_cloud_functions_v2::model::Function;
3597    /// let x = ListFunctionsResponse::new()
3598    ///     .set_functions([
3599    ///         Function::default()/* use setters */,
3600    ///         Function::default()/* use (different) setters */,
3601    ///     ]);
3602    /// ```
3603    pub fn set_functions<T, V>(mut self, v: T) -> Self
3604    where
3605        T: std::iter::IntoIterator<Item = V>,
3606        V: std::convert::Into<crate::model::Function>,
3607    {
3608        use std::iter::Iterator;
3609        self.functions = v.into_iter().map(|i| i.into()).collect();
3610        self
3611    }
3612
3613    /// Sets the value of [next_page_token][crate::model::ListFunctionsResponse::next_page_token].
3614    ///
3615    /// # Example
3616    /// ```ignore,no_run
3617    /// # use google_cloud_functions_v2::model::ListFunctionsResponse;
3618    /// let x = ListFunctionsResponse::new().set_next_page_token("example");
3619    /// ```
3620    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3621        self.next_page_token = v.into();
3622        self
3623    }
3624
3625    /// Sets the value of [unreachable][crate::model::ListFunctionsResponse::unreachable].
3626    ///
3627    /// # Example
3628    /// ```ignore,no_run
3629    /// # use google_cloud_functions_v2::model::ListFunctionsResponse;
3630    /// let x = ListFunctionsResponse::new().set_unreachable(["a", "b", "c"]);
3631    /// ```
3632    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
3633    where
3634        T: std::iter::IntoIterator<Item = V>,
3635        V: std::convert::Into<std::string::String>,
3636    {
3637        use std::iter::Iterator;
3638        self.unreachable = v.into_iter().map(|i| i.into()).collect();
3639        self
3640    }
3641}
3642
3643impl wkt::message::Message for ListFunctionsResponse {
3644    fn typename() -> &'static str {
3645        "type.googleapis.com/google.cloud.functions.v2.ListFunctionsResponse"
3646    }
3647}
3648
3649#[doc(hidden)]
3650impl google_cloud_gax::paginator::internal::PageableResponse for ListFunctionsResponse {
3651    type PageItem = crate::model::Function;
3652
3653    fn items(self) -> std::vec::Vec<Self::PageItem> {
3654        self.functions
3655    }
3656
3657    fn next_page_token(&self) -> std::string::String {
3658        use std::clone::Clone;
3659        self.next_page_token.clone()
3660    }
3661}
3662
3663/// Request for the `CreateFunction` method.
3664#[derive(Clone, Default, PartialEq)]
3665#[non_exhaustive]
3666pub struct CreateFunctionRequest {
3667    /// Required. The project and location in which the function should be created,
3668    /// specified in the format `projects/*/locations/*`
3669    pub parent: std::string::String,
3670
3671    /// Required. Function to be created.
3672    pub function: std::option::Option<crate::model::Function>,
3673
3674    /// The ID to use for the function, which will become the final component of
3675    /// the function's resource name.
3676    ///
3677    /// This value should be 4-63 characters, and valid characters
3678    /// are /[a-z][0-9]-/.
3679    pub function_id: std::string::String,
3680
3681    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3682}
3683
3684impl CreateFunctionRequest {
3685    pub fn new() -> Self {
3686        std::default::Default::default()
3687    }
3688
3689    /// Sets the value of [parent][crate::model::CreateFunctionRequest::parent].
3690    ///
3691    /// # Example
3692    /// ```ignore,no_run
3693    /// # use google_cloud_functions_v2::model::CreateFunctionRequest;
3694    /// let x = CreateFunctionRequest::new().set_parent("example");
3695    /// ```
3696    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3697        self.parent = v.into();
3698        self
3699    }
3700
3701    /// Sets the value of [function][crate::model::CreateFunctionRequest::function].
3702    ///
3703    /// # Example
3704    /// ```ignore,no_run
3705    /// # use google_cloud_functions_v2::model::CreateFunctionRequest;
3706    /// use google_cloud_functions_v2::model::Function;
3707    /// let x = CreateFunctionRequest::new().set_function(Function::default()/* use setters */);
3708    /// ```
3709    pub fn set_function<T>(mut self, v: T) -> Self
3710    where
3711        T: std::convert::Into<crate::model::Function>,
3712    {
3713        self.function = std::option::Option::Some(v.into());
3714        self
3715    }
3716
3717    /// Sets or clears the value of [function][crate::model::CreateFunctionRequest::function].
3718    ///
3719    /// # Example
3720    /// ```ignore,no_run
3721    /// # use google_cloud_functions_v2::model::CreateFunctionRequest;
3722    /// use google_cloud_functions_v2::model::Function;
3723    /// let x = CreateFunctionRequest::new().set_or_clear_function(Some(Function::default()/* use setters */));
3724    /// let x = CreateFunctionRequest::new().set_or_clear_function(None::<Function>);
3725    /// ```
3726    pub fn set_or_clear_function<T>(mut self, v: std::option::Option<T>) -> Self
3727    where
3728        T: std::convert::Into<crate::model::Function>,
3729    {
3730        self.function = v.map(|x| x.into());
3731        self
3732    }
3733
3734    /// Sets the value of [function_id][crate::model::CreateFunctionRequest::function_id].
3735    ///
3736    /// # Example
3737    /// ```ignore,no_run
3738    /// # use google_cloud_functions_v2::model::CreateFunctionRequest;
3739    /// let x = CreateFunctionRequest::new().set_function_id("example");
3740    /// ```
3741    pub fn set_function_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3742        self.function_id = v.into();
3743        self
3744    }
3745}
3746
3747impl wkt::message::Message for CreateFunctionRequest {
3748    fn typename() -> &'static str {
3749        "type.googleapis.com/google.cloud.functions.v2.CreateFunctionRequest"
3750    }
3751}
3752
3753/// Request for the `UpdateFunction` method.
3754#[derive(Clone, Default, PartialEq)]
3755#[non_exhaustive]
3756pub struct UpdateFunctionRequest {
3757    /// Required. New version of the function.
3758    pub function: std::option::Option<crate::model::Function>,
3759
3760    /// The list of fields to be updated.
3761    /// If no field mask is provided, all fields will be updated.
3762    pub update_mask: std::option::Option<wkt::FieldMask>,
3763
3764    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3765}
3766
3767impl UpdateFunctionRequest {
3768    pub fn new() -> Self {
3769        std::default::Default::default()
3770    }
3771
3772    /// Sets the value of [function][crate::model::UpdateFunctionRequest::function].
3773    ///
3774    /// # Example
3775    /// ```ignore,no_run
3776    /// # use google_cloud_functions_v2::model::UpdateFunctionRequest;
3777    /// use google_cloud_functions_v2::model::Function;
3778    /// let x = UpdateFunctionRequest::new().set_function(Function::default()/* use setters */);
3779    /// ```
3780    pub fn set_function<T>(mut self, v: T) -> Self
3781    where
3782        T: std::convert::Into<crate::model::Function>,
3783    {
3784        self.function = std::option::Option::Some(v.into());
3785        self
3786    }
3787
3788    /// Sets or clears the value of [function][crate::model::UpdateFunctionRequest::function].
3789    ///
3790    /// # Example
3791    /// ```ignore,no_run
3792    /// # use google_cloud_functions_v2::model::UpdateFunctionRequest;
3793    /// use google_cloud_functions_v2::model::Function;
3794    /// let x = UpdateFunctionRequest::new().set_or_clear_function(Some(Function::default()/* use setters */));
3795    /// let x = UpdateFunctionRequest::new().set_or_clear_function(None::<Function>);
3796    /// ```
3797    pub fn set_or_clear_function<T>(mut self, v: std::option::Option<T>) -> Self
3798    where
3799        T: std::convert::Into<crate::model::Function>,
3800    {
3801        self.function = v.map(|x| x.into());
3802        self
3803    }
3804
3805    /// Sets the value of [update_mask][crate::model::UpdateFunctionRequest::update_mask].
3806    ///
3807    /// # Example
3808    /// ```ignore,no_run
3809    /// # use google_cloud_functions_v2::model::UpdateFunctionRequest;
3810    /// use wkt::FieldMask;
3811    /// let x = UpdateFunctionRequest::new().set_update_mask(FieldMask::default()/* use setters */);
3812    /// ```
3813    pub fn set_update_mask<T>(mut self, v: T) -> Self
3814    where
3815        T: std::convert::Into<wkt::FieldMask>,
3816    {
3817        self.update_mask = std::option::Option::Some(v.into());
3818        self
3819    }
3820
3821    /// Sets or clears the value of [update_mask][crate::model::UpdateFunctionRequest::update_mask].
3822    ///
3823    /// # Example
3824    /// ```ignore,no_run
3825    /// # use google_cloud_functions_v2::model::UpdateFunctionRequest;
3826    /// use wkt::FieldMask;
3827    /// let x = UpdateFunctionRequest::new().set_or_clear_update_mask(Some(FieldMask::default()/* use setters */));
3828    /// let x = UpdateFunctionRequest::new().set_or_clear_update_mask(None::<FieldMask>);
3829    /// ```
3830    pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
3831    where
3832        T: std::convert::Into<wkt::FieldMask>,
3833    {
3834        self.update_mask = v.map(|x| x.into());
3835        self
3836    }
3837}
3838
3839impl wkt::message::Message for UpdateFunctionRequest {
3840    fn typename() -> &'static str {
3841        "type.googleapis.com/google.cloud.functions.v2.UpdateFunctionRequest"
3842    }
3843}
3844
3845/// Request for the `DeleteFunction` method.
3846#[derive(Clone, Default, PartialEq)]
3847#[non_exhaustive]
3848pub struct DeleteFunctionRequest {
3849    /// Required. The name of the function which should be deleted.
3850    pub name: std::string::String,
3851
3852    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3853}
3854
3855impl DeleteFunctionRequest {
3856    pub fn new() -> Self {
3857        std::default::Default::default()
3858    }
3859
3860    /// Sets the value of [name][crate::model::DeleteFunctionRequest::name].
3861    ///
3862    /// # Example
3863    /// ```ignore,no_run
3864    /// # use google_cloud_functions_v2::model::DeleteFunctionRequest;
3865    /// let x = DeleteFunctionRequest::new().set_name("example");
3866    /// ```
3867    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3868        self.name = v.into();
3869        self
3870    }
3871}
3872
3873impl wkt::message::Message for DeleteFunctionRequest {
3874    fn typename() -> &'static str {
3875        "type.googleapis.com/google.cloud.functions.v2.DeleteFunctionRequest"
3876    }
3877}
3878
3879/// Request of `GenerateSourceUploadUrl` method.
3880#[derive(Clone, Default, PartialEq)]
3881#[non_exhaustive]
3882pub struct GenerateUploadUrlRequest {
3883    /// Required. The project and location in which the Google Cloud Storage signed
3884    /// URL should be generated, specified in the format `projects/*/locations/*`.
3885    pub parent: std::string::String,
3886
3887    /// Resource name of a KMS crypto key (managed by the user) used to
3888    /// encrypt/decrypt function source code objects in intermediate Cloud Storage
3889    /// buckets. When you generate an upload url and upload your source code, it
3890    /// gets copied to an intermediate Cloud Storage bucket. The source code is
3891    /// then copied to a versioned directory in the sources bucket in the consumer
3892    /// project during the function deployment.
3893    ///
3894    /// It must match the pattern
3895    /// `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
3896    ///
3897    /// The Google Cloud Functions service account
3898    /// (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) must be
3899    /// granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter
3900    /// (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the
3901    /// Key/KeyRing/Project/Organization (least access preferred).
3902    pub kms_key_name: std::string::String,
3903
3904    /// The function environment the generated upload url will be used for.
3905    /// The upload url for 2nd Gen functions can also be used for 1st gen
3906    /// functions, but not vice versa. If not specified, 2nd generation-style
3907    /// upload URLs are generated.
3908    pub environment: crate::model::Environment,
3909
3910    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3911}
3912
3913impl GenerateUploadUrlRequest {
3914    pub fn new() -> Self {
3915        std::default::Default::default()
3916    }
3917
3918    /// Sets the value of [parent][crate::model::GenerateUploadUrlRequest::parent].
3919    ///
3920    /// # Example
3921    /// ```ignore,no_run
3922    /// # use google_cloud_functions_v2::model::GenerateUploadUrlRequest;
3923    /// let x = GenerateUploadUrlRequest::new().set_parent("example");
3924    /// ```
3925    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3926        self.parent = v.into();
3927        self
3928    }
3929
3930    /// Sets the value of [kms_key_name][crate::model::GenerateUploadUrlRequest::kms_key_name].
3931    ///
3932    /// # Example
3933    /// ```ignore,no_run
3934    /// # use google_cloud_functions_v2::model::GenerateUploadUrlRequest;
3935    /// let x = GenerateUploadUrlRequest::new().set_kms_key_name("example");
3936    /// ```
3937    pub fn set_kms_key_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3938        self.kms_key_name = v.into();
3939        self
3940    }
3941
3942    /// Sets the value of [environment][crate::model::GenerateUploadUrlRequest::environment].
3943    ///
3944    /// # Example
3945    /// ```ignore,no_run
3946    /// # use google_cloud_functions_v2::model::GenerateUploadUrlRequest;
3947    /// use google_cloud_functions_v2::model::Environment;
3948    /// let x0 = GenerateUploadUrlRequest::new().set_environment(Environment::Gen1);
3949    /// let x1 = GenerateUploadUrlRequest::new().set_environment(Environment::Gen2);
3950    /// ```
3951    pub fn set_environment<T: std::convert::Into<crate::model::Environment>>(
3952        mut self,
3953        v: T,
3954    ) -> Self {
3955        self.environment = v.into();
3956        self
3957    }
3958}
3959
3960impl wkt::message::Message for GenerateUploadUrlRequest {
3961    fn typename() -> &'static str {
3962        "type.googleapis.com/google.cloud.functions.v2.GenerateUploadUrlRequest"
3963    }
3964}
3965
3966/// Response of `GenerateSourceUploadUrl` method.
3967#[derive(Clone, Default, PartialEq)]
3968#[non_exhaustive]
3969pub struct GenerateUploadUrlResponse {
3970    /// The generated Google Cloud Storage signed URL that should be used for a
3971    /// function source code upload. The uploaded file should be a zip archive
3972    /// which contains a function.
3973    pub upload_url: std::string::String,
3974
3975    /// The location of the source code in the upload bucket.
3976    ///
3977    /// Once the archive is uploaded using the `upload_url` use this field to
3978    /// set the `function.build_config.source.storage_source`
3979    /// during CreateFunction and UpdateFunction.
3980    ///
3981    /// Generation defaults to 0, as Cloud Storage provides a new generation only
3982    /// upon uploading a new object or version of an object.
3983    pub storage_source: std::option::Option<crate::model::StorageSource>,
3984
3985    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3986}
3987
3988impl GenerateUploadUrlResponse {
3989    pub fn new() -> Self {
3990        std::default::Default::default()
3991    }
3992
3993    /// Sets the value of [upload_url][crate::model::GenerateUploadUrlResponse::upload_url].
3994    ///
3995    /// # Example
3996    /// ```ignore,no_run
3997    /// # use google_cloud_functions_v2::model::GenerateUploadUrlResponse;
3998    /// let x = GenerateUploadUrlResponse::new().set_upload_url("example");
3999    /// ```
4000    pub fn set_upload_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4001        self.upload_url = v.into();
4002        self
4003    }
4004
4005    /// Sets the value of [storage_source][crate::model::GenerateUploadUrlResponse::storage_source].
4006    ///
4007    /// # Example
4008    /// ```ignore,no_run
4009    /// # use google_cloud_functions_v2::model::GenerateUploadUrlResponse;
4010    /// use google_cloud_functions_v2::model::StorageSource;
4011    /// let x = GenerateUploadUrlResponse::new().set_storage_source(StorageSource::default()/* use setters */);
4012    /// ```
4013    pub fn set_storage_source<T>(mut self, v: T) -> Self
4014    where
4015        T: std::convert::Into<crate::model::StorageSource>,
4016    {
4017        self.storage_source = std::option::Option::Some(v.into());
4018        self
4019    }
4020
4021    /// Sets or clears the value of [storage_source][crate::model::GenerateUploadUrlResponse::storage_source].
4022    ///
4023    /// # Example
4024    /// ```ignore,no_run
4025    /// # use google_cloud_functions_v2::model::GenerateUploadUrlResponse;
4026    /// use google_cloud_functions_v2::model::StorageSource;
4027    /// let x = GenerateUploadUrlResponse::new().set_or_clear_storage_source(Some(StorageSource::default()/* use setters */));
4028    /// let x = GenerateUploadUrlResponse::new().set_or_clear_storage_source(None::<StorageSource>);
4029    /// ```
4030    pub fn set_or_clear_storage_source<T>(mut self, v: std::option::Option<T>) -> Self
4031    where
4032        T: std::convert::Into<crate::model::StorageSource>,
4033    {
4034        self.storage_source = v.map(|x| x.into());
4035        self
4036    }
4037}
4038
4039impl wkt::message::Message for GenerateUploadUrlResponse {
4040    fn typename() -> &'static str {
4041        "type.googleapis.com/google.cloud.functions.v2.GenerateUploadUrlResponse"
4042    }
4043}
4044
4045/// Request of `GenerateDownloadUrl` method.
4046#[derive(Clone, Default, PartialEq)]
4047#[non_exhaustive]
4048pub struct GenerateDownloadUrlRequest {
4049    /// Required. The name of function for which source code Google Cloud Storage
4050    /// signed URL should be generated.
4051    pub name: std::string::String,
4052
4053    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4054}
4055
4056impl GenerateDownloadUrlRequest {
4057    pub fn new() -> Self {
4058        std::default::Default::default()
4059    }
4060
4061    /// Sets the value of [name][crate::model::GenerateDownloadUrlRequest::name].
4062    ///
4063    /// # Example
4064    /// ```ignore,no_run
4065    /// # use google_cloud_functions_v2::model::GenerateDownloadUrlRequest;
4066    /// let x = GenerateDownloadUrlRequest::new().set_name("example");
4067    /// ```
4068    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4069        self.name = v.into();
4070        self
4071    }
4072}
4073
4074impl wkt::message::Message for GenerateDownloadUrlRequest {
4075    fn typename() -> &'static str {
4076        "type.googleapis.com/google.cloud.functions.v2.GenerateDownloadUrlRequest"
4077    }
4078}
4079
4080/// Response of `GenerateDownloadUrl` method.
4081#[derive(Clone, Default, PartialEq)]
4082#[non_exhaustive]
4083pub struct GenerateDownloadUrlResponse {
4084    /// The generated Google Cloud Storage signed URL that should be used for
4085    /// function source code download.
4086    pub download_url: std::string::String,
4087
4088    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4089}
4090
4091impl GenerateDownloadUrlResponse {
4092    pub fn new() -> Self {
4093        std::default::Default::default()
4094    }
4095
4096    /// Sets the value of [download_url][crate::model::GenerateDownloadUrlResponse::download_url].
4097    ///
4098    /// # Example
4099    /// ```ignore,no_run
4100    /// # use google_cloud_functions_v2::model::GenerateDownloadUrlResponse;
4101    /// let x = GenerateDownloadUrlResponse::new().set_download_url("example");
4102    /// ```
4103    pub fn set_download_url<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4104        self.download_url = v.into();
4105        self
4106    }
4107}
4108
4109impl wkt::message::Message for GenerateDownloadUrlResponse {
4110    fn typename() -> &'static str {
4111        "type.googleapis.com/google.cloud.functions.v2.GenerateDownloadUrlResponse"
4112    }
4113}
4114
4115/// Request for the `ListRuntimes` method.
4116#[derive(Clone, Default, PartialEq)]
4117#[non_exhaustive]
4118pub struct ListRuntimesRequest {
4119    /// Required. The project and location from which the runtimes should be
4120    /// listed, specified in the format `projects/*/locations/*`
4121    pub parent: std::string::String,
4122
4123    /// The filter for Runtimes that match the filter expression,
4124    /// following the syntax outlined in <https://google.aip.dev/160>.
4125    pub filter: std::string::String,
4126
4127    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4128}
4129
4130impl ListRuntimesRequest {
4131    pub fn new() -> Self {
4132        std::default::Default::default()
4133    }
4134
4135    /// Sets the value of [parent][crate::model::ListRuntimesRequest::parent].
4136    ///
4137    /// # Example
4138    /// ```ignore,no_run
4139    /// # use google_cloud_functions_v2::model::ListRuntimesRequest;
4140    /// let x = ListRuntimesRequest::new().set_parent("example");
4141    /// ```
4142    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4143        self.parent = v.into();
4144        self
4145    }
4146
4147    /// Sets the value of [filter][crate::model::ListRuntimesRequest::filter].
4148    ///
4149    /// # Example
4150    /// ```ignore,no_run
4151    /// # use google_cloud_functions_v2::model::ListRuntimesRequest;
4152    /// let x = ListRuntimesRequest::new().set_filter("example");
4153    /// ```
4154    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4155        self.filter = v.into();
4156        self
4157    }
4158}
4159
4160impl wkt::message::Message for ListRuntimesRequest {
4161    fn typename() -> &'static str {
4162        "type.googleapis.com/google.cloud.functions.v2.ListRuntimesRequest"
4163    }
4164}
4165
4166/// Response for the `ListRuntimes` method.
4167#[derive(Clone, Default, PartialEq)]
4168#[non_exhaustive]
4169pub struct ListRuntimesResponse {
4170    /// The runtimes that match the request.
4171    pub runtimes: std::vec::Vec<crate::model::list_runtimes_response::Runtime>,
4172
4173    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4174}
4175
4176impl ListRuntimesResponse {
4177    pub fn new() -> Self {
4178        std::default::Default::default()
4179    }
4180
4181    /// Sets the value of [runtimes][crate::model::ListRuntimesResponse::runtimes].
4182    ///
4183    /// # Example
4184    /// ```ignore,no_run
4185    /// # use google_cloud_functions_v2::model::ListRuntimesResponse;
4186    /// use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4187    /// let x = ListRuntimesResponse::new()
4188    ///     .set_runtimes([
4189    ///         Runtime::default()/* use setters */,
4190    ///         Runtime::default()/* use (different) setters */,
4191    ///     ]);
4192    /// ```
4193    pub fn set_runtimes<T, V>(mut self, v: T) -> Self
4194    where
4195        T: std::iter::IntoIterator<Item = V>,
4196        V: std::convert::Into<crate::model::list_runtimes_response::Runtime>,
4197    {
4198        use std::iter::Iterator;
4199        self.runtimes = v.into_iter().map(|i| i.into()).collect();
4200        self
4201    }
4202}
4203
4204impl wkt::message::Message for ListRuntimesResponse {
4205    fn typename() -> &'static str {
4206        "type.googleapis.com/google.cloud.functions.v2.ListRuntimesResponse"
4207    }
4208}
4209
4210/// Defines additional types related to [ListRuntimesResponse].
4211pub mod list_runtimes_response {
4212    #[allow(unused_imports)]
4213    use super::*;
4214
4215    /// Describes a runtime and any special information (e.g., deprecation status)
4216    /// related to it.
4217    #[derive(Clone, Default, PartialEq)]
4218    #[non_exhaustive]
4219    pub struct Runtime {
4220        /// The name of the runtime, e.g., 'go113', 'nodejs12', etc.
4221        pub name: std::string::String,
4222
4223        /// The user facing name, eg 'Go 1.13', 'Node.js 12', etc.
4224        pub display_name: std::string::String,
4225
4226        /// The stage of life this runtime is in, e.g., BETA, GA, etc.
4227        pub stage: crate::model::list_runtimes_response::RuntimeStage,
4228
4229        /// Warning messages, e.g., a deprecation warning.
4230        pub warnings: std::vec::Vec<std::string::String>,
4231
4232        /// The environment for the runtime.
4233        pub environment: crate::model::Environment,
4234
4235        /// Deprecation date for the runtime.
4236        pub deprecation_date: std::option::Option<google_cloud_type::model::Date>,
4237
4238        /// Decommission date for the runtime.
4239        pub decommission_date: std::option::Option<google_cloud_type::model::Date>,
4240
4241        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4242    }
4243
4244    impl Runtime {
4245        pub fn new() -> Self {
4246            std::default::Default::default()
4247        }
4248
4249        /// Sets the value of [name][crate::model::list_runtimes_response::Runtime::name].
4250        ///
4251        /// # Example
4252        /// ```ignore,no_run
4253        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4254        /// let x = Runtime::new().set_name("example");
4255        /// ```
4256        pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4257            self.name = v.into();
4258            self
4259        }
4260
4261        /// Sets the value of [display_name][crate::model::list_runtimes_response::Runtime::display_name].
4262        ///
4263        /// # Example
4264        /// ```ignore,no_run
4265        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4266        /// let x = Runtime::new().set_display_name("example");
4267        /// ```
4268        pub fn set_display_name<T: std::convert::Into<std::string::String>>(
4269            mut self,
4270            v: T,
4271        ) -> Self {
4272            self.display_name = v.into();
4273            self
4274        }
4275
4276        /// Sets the value of [stage][crate::model::list_runtimes_response::Runtime::stage].
4277        ///
4278        /// # Example
4279        /// ```ignore,no_run
4280        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4281        /// use google_cloud_functions_v2::model::list_runtimes_response::RuntimeStage;
4282        /// let x0 = Runtime::new().set_stage(RuntimeStage::Development);
4283        /// let x1 = Runtime::new().set_stage(RuntimeStage::Alpha);
4284        /// let x2 = Runtime::new().set_stage(RuntimeStage::Beta);
4285        /// ```
4286        pub fn set_stage<
4287            T: std::convert::Into<crate::model::list_runtimes_response::RuntimeStage>,
4288        >(
4289            mut self,
4290            v: T,
4291        ) -> Self {
4292            self.stage = v.into();
4293            self
4294        }
4295
4296        /// Sets the value of [warnings][crate::model::list_runtimes_response::Runtime::warnings].
4297        ///
4298        /// # Example
4299        /// ```ignore,no_run
4300        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4301        /// let x = Runtime::new().set_warnings(["a", "b", "c"]);
4302        /// ```
4303        pub fn set_warnings<T, V>(mut self, v: T) -> Self
4304        where
4305            T: std::iter::IntoIterator<Item = V>,
4306            V: std::convert::Into<std::string::String>,
4307        {
4308            use std::iter::Iterator;
4309            self.warnings = v.into_iter().map(|i| i.into()).collect();
4310            self
4311        }
4312
4313        /// Sets the value of [environment][crate::model::list_runtimes_response::Runtime::environment].
4314        ///
4315        /// # Example
4316        /// ```ignore,no_run
4317        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4318        /// use google_cloud_functions_v2::model::Environment;
4319        /// let x0 = Runtime::new().set_environment(Environment::Gen1);
4320        /// let x1 = Runtime::new().set_environment(Environment::Gen2);
4321        /// ```
4322        pub fn set_environment<T: std::convert::Into<crate::model::Environment>>(
4323            mut self,
4324            v: T,
4325        ) -> Self {
4326            self.environment = v.into();
4327            self
4328        }
4329
4330        /// Sets the value of [deprecation_date][crate::model::list_runtimes_response::Runtime::deprecation_date].
4331        ///
4332        /// # Example
4333        /// ```ignore,no_run
4334        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4335        /// use google_cloud_type::model::Date;
4336        /// let x = Runtime::new().set_deprecation_date(Date::default()/* use setters */);
4337        /// ```
4338        pub fn set_deprecation_date<T>(mut self, v: T) -> Self
4339        where
4340            T: std::convert::Into<google_cloud_type::model::Date>,
4341        {
4342            self.deprecation_date = std::option::Option::Some(v.into());
4343            self
4344        }
4345
4346        /// Sets or clears the value of [deprecation_date][crate::model::list_runtimes_response::Runtime::deprecation_date].
4347        ///
4348        /// # Example
4349        /// ```ignore,no_run
4350        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4351        /// use google_cloud_type::model::Date;
4352        /// let x = Runtime::new().set_or_clear_deprecation_date(Some(Date::default()/* use setters */));
4353        /// let x = Runtime::new().set_or_clear_deprecation_date(None::<Date>);
4354        /// ```
4355        pub fn set_or_clear_deprecation_date<T>(mut self, v: std::option::Option<T>) -> Self
4356        where
4357            T: std::convert::Into<google_cloud_type::model::Date>,
4358        {
4359            self.deprecation_date = v.map(|x| x.into());
4360            self
4361        }
4362
4363        /// Sets the value of [decommission_date][crate::model::list_runtimes_response::Runtime::decommission_date].
4364        ///
4365        /// # Example
4366        /// ```ignore,no_run
4367        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4368        /// use google_cloud_type::model::Date;
4369        /// let x = Runtime::new().set_decommission_date(Date::default()/* use setters */);
4370        /// ```
4371        pub fn set_decommission_date<T>(mut self, v: T) -> Self
4372        where
4373            T: std::convert::Into<google_cloud_type::model::Date>,
4374        {
4375            self.decommission_date = std::option::Option::Some(v.into());
4376            self
4377        }
4378
4379        /// Sets or clears the value of [decommission_date][crate::model::list_runtimes_response::Runtime::decommission_date].
4380        ///
4381        /// # Example
4382        /// ```ignore,no_run
4383        /// # use google_cloud_functions_v2::model::list_runtimes_response::Runtime;
4384        /// use google_cloud_type::model::Date;
4385        /// let x = Runtime::new().set_or_clear_decommission_date(Some(Date::default()/* use setters */));
4386        /// let x = Runtime::new().set_or_clear_decommission_date(None::<Date>);
4387        /// ```
4388        pub fn set_or_clear_decommission_date<T>(mut self, v: std::option::Option<T>) -> Self
4389        where
4390            T: std::convert::Into<google_cloud_type::model::Date>,
4391        {
4392            self.decommission_date = v.map(|x| x.into());
4393            self
4394        }
4395    }
4396
4397    impl wkt::message::Message for Runtime {
4398        fn typename() -> &'static str {
4399            "type.googleapis.com/google.cloud.functions.v2.ListRuntimesResponse.Runtime"
4400        }
4401    }
4402
4403    /// The various stages that a runtime can be in.
4404    ///
4405    /// # Working with unknown values
4406    ///
4407    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4408    /// additional enum variants at any time. Adding new variants is not considered
4409    /// a breaking change. Applications should write their code in anticipation of:
4410    ///
4411    /// - New values appearing in future releases of the client library, **and**
4412    /// - New values received dynamically, without application changes.
4413    ///
4414    /// Please consult the [Working with enums] section in the user guide for some
4415    /// guidelines.
4416    ///
4417    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
4418    #[derive(Clone, Debug, PartialEq)]
4419    #[non_exhaustive]
4420    pub enum RuntimeStage {
4421        /// Not specified.
4422        Unspecified,
4423        /// The runtime is in development.
4424        Development,
4425        /// The runtime is in the Alpha stage.
4426        Alpha,
4427        /// The runtime is in the Beta stage.
4428        Beta,
4429        /// The runtime is generally available.
4430        Ga,
4431        /// The runtime is deprecated.
4432        Deprecated,
4433        /// The runtime is no longer supported.
4434        Decommissioned,
4435        /// If set, the enum was initialized with an unknown value.
4436        ///
4437        /// Applications can examine the value using [RuntimeStage::value] or
4438        /// [RuntimeStage::name].
4439        UnknownValue(runtime_stage::UnknownValue),
4440    }
4441
4442    #[doc(hidden)]
4443    pub mod runtime_stage {
4444        #[allow(unused_imports)]
4445        use super::*;
4446        #[derive(Clone, Debug, PartialEq)]
4447        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4448    }
4449
4450    impl RuntimeStage {
4451        /// Gets the enum value.
4452        ///
4453        /// Returns `None` if the enum contains an unknown value deserialized from
4454        /// the string representation of enums.
4455        pub fn value(&self) -> std::option::Option<i32> {
4456            match self {
4457                Self::Unspecified => std::option::Option::Some(0),
4458                Self::Development => std::option::Option::Some(1),
4459                Self::Alpha => std::option::Option::Some(2),
4460                Self::Beta => std::option::Option::Some(3),
4461                Self::Ga => std::option::Option::Some(4),
4462                Self::Deprecated => std::option::Option::Some(5),
4463                Self::Decommissioned => std::option::Option::Some(6),
4464                Self::UnknownValue(u) => u.0.value(),
4465            }
4466        }
4467
4468        /// Gets the enum value as a string.
4469        ///
4470        /// Returns `None` if the enum contains an unknown value deserialized from
4471        /// the integer representation of enums.
4472        pub fn name(&self) -> std::option::Option<&str> {
4473            match self {
4474                Self::Unspecified => std::option::Option::Some("RUNTIME_STAGE_UNSPECIFIED"),
4475                Self::Development => std::option::Option::Some("DEVELOPMENT"),
4476                Self::Alpha => std::option::Option::Some("ALPHA"),
4477                Self::Beta => std::option::Option::Some("BETA"),
4478                Self::Ga => std::option::Option::Some("GA"),
4479                Self::Deprecated => std::option::Option::Some("DEPRECATED"),
4480                Self::Decommissioned => std::option::Option::Some("DECOMMISSIONED"),
4481                Self::UnknownValue(u) => u.0.name(),
4482            }
4483        }
4484    }
4485
4486    impl std::default::Default for RuntimeStage {
4487        fn default() -> Self {
4488            use std::convert::From;
4489            Self::from(0)
4490        }
4491    }
4492
4493    impl std::fmt::Display for RuntimeStage {
4494        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4495            wkt::internal::display_enum(f, self.name(), self.value())
4496        }
4497    }
4498
4499    impl std::convert::From<i32> for RuntimeStage {
4500        fn from(value: i32) -> Self {
4501            match value {
4502                0 => Self::Unspecified,
4503                1 => Self::Development,
4504                2 => Self::Alpha,
4505                3 => Self::Beta,
4506                4 => Self::Ga,
4507                5 => Self::Deprecated,
4508                6 => Self::Decommissioned,
4509                _ => Self::UnknownValue(runtime_stage::UnknownValue(
4510                    wkt::internal::UnknownEnumValue::Integer(value),
4511                )),
4512            }
4513        }
4514    }
4515
4516    impl std::convert::From<&str> for RuntimeStage {
4517        fn from(value: &str) -> Self {
4518            use std::string::ToString;
4519            match value {
4520                "RUNTIME_STAGE_UNSPECIFIED" => Self::Unspecified,
4521                "DEVELOPMENT" => Self::Development,
4522                "ALPHA" => Self::Alpha,
4523                "BETA" => Self::Beta,
4524                "GA" => Self::Ga,
4525                "DEPRECATED" => Self::Deprecated,
4526                "DECOMMISSIONED" => Self::Decommissioned,
4527                _ => Self::UnknownValue(runtime_stage::UnknownValue(
4528                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4529                )),
4530            }
4531        }
4532    }
4533
4534    impl serde::ser::Serialize for RuntimeStage {
4535        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4536        where
4537            S: serde::Serializer,
4538        {
4539            match self {
4540                Self::Unspecified => serializer.serialize_i32(0),
4541                Self::Development => serializer.serialize_i32(1),
4542                Self::Alpha => serializer.serialize_i32(2),
4543                Self::Beta => serializer.serialize_i32(3),
4544                Self::Ga => serializer.serialize_i32(4),
4545                Self::Deprecated => serializer.serialize_i32(5),
4546                Self::Decommissioned => serializer.serialize_i32(6),
4547                Self::UnknownValue(u) => u.0.serialize(serializer),
4548            }
4549        }
4550    }
4551
4552    impl<'de> serde::de::Deserialize<'de> for RuntimeStage {
4553        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4554        where
4555            D: serde::Deserializer<'de>,
4556        {
4557            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RuntimeStage>::new(
4558                ".google.cloud.functions.v2.ListRuntimesResponse.RuntimeStage",
4559            ))
4560        }
4561    }
4562}
4563
4564/// Security patches are applied automatically to the runtime without requiring
4565/// the function to be redeployed.
4566#[derive(Clone, Default, PartialEq)]
4567#[non_exhaustive]
4568pub struct AutomaticUpdatePolicy {
4569    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4570}
4571
4572impl AutomaticUpdatePolicy {
4573    pub fn new() -> Self {
4574        std::default::Default::default()
4575    }
4576}
4577
4578impl wkt::message::Message for AutomaticUpdatePolicy {
4579    fn typename() -> &'static str {
4580        "type.googleapis.com/google.cloud.functions.v2.AutomaticUpdatePolicy"
4581    }
4582}
4583
4584/// Security patches are only applied when a function is redeployed.
4585#[derive(Clone, Default, PartialEq)]
4586#[non_exhaustive]
4587pub struct OnDeployUpdatePolicy {
4588    /// Output only. contains the runtime version which was used during latest
4589    /// function deployment.
4590    pub runtime_version: std::string::String,
4591
4592    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4593}
4594
4595impl OnDeployUpdatePolicy {
4596    pub fn new() -> Self {
4597        std::default::Default::default()
4598    }
4599
4600    /// Sets the value of [runtime_version][crate::model::OnDeployUpdatePolicy::runtime_version].
4601    ///
4602    /// # Example
4603    /// ```ignore,no_run
4604    /// # use google_cloud_functions_v2::model::OnDeployUpdatePolicy;
4605    /// let x = OnDeployUpdatePolicy::new().set_runtime_version("example");
4606    /// ```
4607    pub fn set_runtime_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4608        self.runtime_version = v.into();
4609        self
4610    }
4611}
4612
4613impl wkt::message::Message for OnDeployUpdatePolicy {
4614    fn typename() -> &'static str {
4615        "type.googleapis.com/google.cloud.functions.v2.OnDeployUpdatePolicy"
4616    }
4617}
4618
4619/// Represents the metadata of the long-running operation.
4620#[derive(Clone, Default, PartialEq)]
4621#[non_exhaustive]
4622pub struct OperationMetadata {
4623    /// The time the operation was created.
4624    pub create_time: std::option::Option<wkt::Timestamp>,
4625
4626    /// The time the operation finished running.
4627    pub end_time: std::option::Option<wkt::Timestamp>,
4628
4629    /// Server-defined resource path for the target of the operation.
4630    pub target: std::string::String,
4631
4632    /// Name of the verb executed by the operation.
4633    pub verb: std::string::String,
4634
4635    /// Human-readable status of the operation, if any.
4636    pub status_detail: std::string::String,
4637
4638    /// Identifies whether the user has requested cancellation
4639    /// of the operation. Operations that have successfully been cancelled
4640    /// have
4641    /// [google.longrunning.Operation.error][google.longrunning.Operation.error]
4642    /// value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
4643    /// corresponding to `Code.CANCELLED`.
4644    ///
4645    /// [google.longrunning.Operation.error]: google_cloud_longrunning::model::Operation::result
4646    /// [google.rpc.Status.code]: google_cloud_rpc::model::Status::code
4647    pub cancel_requested: bool,
4648
4649    /// API version used to start the operation.
4650    pub api_version: std::string::String,
4651
4652    /// The original request that started the operation.
4653    pub request_resource: std::option::Option<wkt::Any>,
4654
4655    /// Mechanism for reporting in-progress stages
4656    pub stages: std::vec::Vec<crate::model::Stage>,
4657
4658    /// An identifier for Firebase function sources. Disclaimer: This field is only
4659    /// supported for Firebase function deployments.
4660    pub source_token: std::string::String,
4661
4662    /// The build name of the function for create and update operations.
4663    pub build_name: std::string::String,
4664
4665    /// The operation type.
4666    pub operation_type: crate::model::OperationType,
4667
4668    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4669}
4670
4671impl OperationMetadata {
4672    pub fn new() -> Self {
4673        std::default::Default::default()
4674    }
4675
4676    /// Sets the value of [create_time][crate::model::OperationMetadata::create_time].
4677    ///
4678    /// # Example
4679    /// ```ignore,no_run
4680    /// # use google_cloud_functions_v2::model::OperationMetadata;
4681    /// use wkt::Timestamp;
4682    /// let x = OperationMetadata::new().set_create_time(Timestamp::default()/* use setters */);
4683    /// ```
4684    pub fn set_create_time<T>(mut self, v: T) -> Self
4685    where
4686        T: std::convert::Into<wkt::Timestamp>,
4687    {
4688        self.create_time = std::option::Option::Some(v.into());
4689        self
4690    }
4691
4692    /// Sets or clears the value of [create_time][crate::model::OperationMetadata::create_time].
4693    ///
4694    /// # Example
4695    /// ```ignore,no_run
4696    /// # use google_cloud_functions_v2::model::OperationMetadata;
4697    /// use wkt::Timestamp;
4698    /// let x = OperationMetadata::new().set_or_clear_create_time(Some(Timestamp::default()/* use setters */));
4699    /// let x = OperationMetadata::new().set_or_clear_create_time(None::<Timestamp>);
4700    /// ```
4701    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
4702    where
4703        T: std::convert::Into<wkt::Timestamp>,
4704    {
4705        self.create_time = v.map(|x| x.into());
4706        self
4707    }
4708
4709    /// Sets the value of [end_time][crate::model::OperationMetadata::end_time].
4710    ///
4711    /// # Example
4712    /// ```ignore,no_run
4713    /// # use google_cloud_functions_v2::model::OperationMetadata;
4714    /// use wkt::Timestamp;
4715    /// let x = OperationMetadata::new().set_end_time(Timestamp::default()/* use setters */);
4716    /// ```
4717    pub fn set_end_time<T>(mut self, v: T) -> Self
4718    where
4719        T: std::convert::Into<wkt::Timestamp>,
4720    {
4721        self.end_time = std::option::Option::Some(v.into());
4722        self
4723    }
4724
4725    /// Sets or clears the value of [end_time][crate::model::OperationMetadata::end_time].
4726    ///
4727    /// # Example
4728    /// ```ignore,no_run
4729    /// # use google_cloud_functions_v2::model::OperationMetadata;
4730    /// use wkt::Timestamp;
4731    /// let x = OperationMetadata::new().set_or_clear_end_time(Some(Timestamp::default()/* use setters */));
4732    /// let x = OperationMetadata::new().set_or_clear_end_time(None::<Timestamp>);
4733    /// ```
4734    pub fn set_or_clear_end_time<T>(mut self, v: std::option::Option<T>) -> Self
4735    where
4736        T: std::convert::Into<wkt::Timestamp>,
4737    {
4738        self.end_time = v.map(|x| x.into());
4739        self
4740    }
4741
4742    /// Sets the value of [target][crate::model::OperationMetadata::target].
4743    ///
4744    /// # Example
4745    /// ```ignore,no_run
4746    /// # use google_cloud_functions_v2::model::OperationMetadata;
4747    /// let x = OperationMetadata::new().set_target("example");
4748    /// ```
4749    pub fn set_target<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4750        self.target = v.into();
4751        self
4752    }
4753
4754    /// Sets the value of [verb][crate::model::OperationMetadata::verb].
4755    ///
4756    /// # Example
4757    /// ```ignore,no_run
4758    /// # use google_cloud_functions_v2::model::OperationMetadata;
4759    /// let x = OperationMetadata::new().set_verb("example");
4760    /// ```
4761    pub fn set_verb<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4762        self.verb = v.into();
4763        self
4764    }
4765
4766    /// Sets the value of [status_detail][crate::model::OperationMetadata::status_detail].
4767    ///
4768    /// # Example
4769    /// ```ignore,no_run
4770    /// # use google_cloud_functions_v2::model::OperationMetadata;
4771    /// let x = OperationMetadata::new().set_status_detail("example");
4772    /// ```
4773    pub fn set_status_detail<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4774        self.status_detail = v.into();
4775        self
4776    }
4777
4778    /// Sets the value of [cancel_requested][crate::model::OperationMetadata::cancel_requested].
4779    ///
4780    /// # Example
4781    /// ```ignore,no_run
4782    /// # use google_cloud_functions_v2::model::OperationMetadata;
4783    /// let x = OperationMetadata::new().set_cancel_requested(true);
4784    /// ```
4785    pub fn set_cancel_requested<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
4786        self.cancel_requested = v.into();
4787        self
4788    }
4789
4790    /// Sets the value of [api_version][crate::model::OperationMetadata::api_version].
4791    ///
4792    /// # Example
4793    /// ```ignore,no_run
4794    /// # use google_cloud_functions_v2::model::OperationMetadata;
4795    /// let x = OperationMetadata::new().set_api_version("example");
4796    /// ```
4797    pub fn set_api_version<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4798        self.api_version = v.into();
4799        self
4800    }
4801
4802    /// Sets the value of [request_resource][crate::model::OperationMetadata::request_resource].
4803    ///
4804    /// # Example
4805    /// ```ignore,no_run
4806    /// # use google_cloud_functions_v2::model::OperationMetadata;
4807    /// use wkt::Any;
4808    /// let x = OperationMetadata::new().set_request_resource(Any::default()/* use setters */);
4809    /// ```
4810    pub fn set_request_resource<T>(mut self, v: T) -> Self
4811    where
4812        T: std::convert::Into<wkt::Any>,
4813    {
4814        self.request_resource = std::option::Option::Some(v.into());
4815        self
4816    }
4817
4818    /// Sets or clears the value of [request_resource][crate::model::OperationMetadata::request_resource].
4819    ///
4820    /// # Example
4821    /// ```ignore,no_run
4822    /// # use google_cloud_functions_v2::model::OperationMetadata;
4823    /// use wkt::Any;
4824    /// let x = OperationMetadata::new().set_or_clear_request_resource(Some(Any::default()/* use setters */));
4825    /// let x = OperationMetadata::new().set_or_clear_request_resource(None::<Any>);
4826    /// ```
4827    pub fn set_or_clear_request_resource<T>(mut self, v: std::option::Option<T>) -> Self
4828    where
4829        T: std::convert::Into<wkt::Any>,
4830    {
4831        self.request_resource = v.map(|x| x.into());
4832        self
4833    }
4834
4835    /// Sets the value of [stages][crate::model::OperationMetadata::stages].
4836    ///
4837    /// # Example
4838    /// ```ignore,no_run
4839    /// # use google_cloud_functions_v2::model::OperationMetadata;
4840    /// use google_cloud_functions_v2::model::Stage;
4841    /// let x = OperationMetadata::new()
4842    ///     .set_stages([
4843    ///         Stage::default()/* use setters */,
4844    ///         Stage::default()/* use (different) setters */,
4845    ///     ]);
4846    /// ```
4847    pub fn set_stages<T, V>(mut self, v: T) -> Self
4848    where
4849        T: std::iter::IntoIterator<Item = V>,
4850        V: std::convert::Into<crate::model::Stage>,
4851    {
4852        use std::iter::Iterator;
4853        self.stages = v.into_iter().map(|i| i.into()).collect();
4854        self
4855    }
4856
4857    /// Sets the value of [source_token][crate::model::OperationMetadata::source_token].
4858    ///
4859    /// # Example
4860    /// ```ignore,no_run
4861    /// # use google_cloud_functions_v2::model::OperationMetadata;
4862    /// let x = OperationMetadata::new().set_source_token("example");
4863    /// ```
4864    pub fn set_source_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4865        self.source_token = v.into();
4866        self
4867    }
4868
4869    /// Sets the value of [build_name][crate::model::OperationMetadata::build_name].
4870    ///
4871    /// # Example
4872    /// ```ignore,no_run
4873    /// # use google_cloud_functions_v2::model::OperationMetadata;
4874    /// let x = OperationMetadata::new().set_build_name("example");
4875    /// ```
4876    pub fn set_build_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4877        self.build_name = v.into();
4878        self
4879    }
4880
4881    /// Sets the value of [operation_type][crate::model::OperationMetadata::operation_type].
4882    ///
4883    /// # Example
4884    /// ```ignore,no_run
4885    /// # use google_cloud_functions_v2::model::OperationMetadata;
4886    /// use google_cloud_functions_v2::model::OperationType;
4887    /// let x0 = OperationMetadata::new().set_operation_type(OperationType::CreateFunction);
4888    /// let x1 = OperationMetadata::new().set_operation_type(OperationType::UpdateFunction);
4889    /// let x2 = OperationMetadata::new().set_operation_type(OperationType::DeleteFunction);
4890    /// ```
4891    pub fn set_operation_type<T: std::convert::Into<crate::model::OperationType>>(
4892        mut self,
4893        v: T,
4894    ) -> Self {
4895        self.operation_type = v.into();
4896        self
4897    }
4898}
4899
4900impl wkt::message::Message for OperationMetadata {
4901    fn typename() -> &'static str {
4902        "type.googleapis.com/google.cloud.functions.v2.OperationMetadata"
4903    }
4904}
4905
4906/// Extra GCF specific location information.
4907#[derive(Clone, Default, PartialEq)]
4908#[non_exhaustive]
4909pub struct LocationMetadata {
4910    /// The Cloud Function environments this location supports.
4911    pub environments: std::vec::Vec<crate::model::Environment>,
4912
4913    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4914}
4915
4916impl LocationMetadata {
4917    pub fn new() -> Self {
4918        std::default::Default::default()
4919    }
4920
4921    /// Sets the value of [environments][crate::model::LocationMetadata::environments].
4922    ///
4923    /// # Example
4924    /// ```ignore,no_run
4925    /// # use google_cloud_functions_v2::model::LocationMetadata;
4926    /// use google_cloud_functions_v2::model::Environment;
4927    /// let x = LocationMetadata::new().set_environments([
4928    ///     Environment::Gen1,
4929    ///     Environment::Gen2,
4930    /// ]);
4931    /// ```
4932    pub fn set_environments<T, V>(mut self, v: T) -> Self
4933    where
4934        T: std::iter::IntoIterator<Item = V>,
4935        V: std::convert::Into<crate::model::Environment>,
4936    {
4937        use std::iter::Iterator;
4938        self.environments = v.into_iter().map(|i| i.into()).collect();
4939        self
4940    }
4941}
4942
4943impl wkt::message::Message for LocationMetadata {
4944    fn typename() -> &'static str {
4945        "type.googleapis.com/google.cloud.functions.v2.LocationMetadata"
4946    }
4947}
4948
4949/// Each Stage of the deployment process
4950#[derive(Clone, Default, PartialEq)]
4951#[non_exhaustive]
4952pub struct Stage {
4953    /// Name of the Stage. This will be unique for each Stage.
4954    pub name: crate::model::stage::Name,
4955
4956    /// Message describing the Stage
4957    pub message: std::string::String,
4958
4959    /// Current state of the Stage
4960    pub state: crate::model::stage::State,
4961
4962    /// Resource of the Stage
4963    pub resource: std::string::String,
4964
4965    /// Link to the current Stage resource
4966    pub resource_uri: std::string::String,
4967
4968    /// State messages from the current Stage.
4969    pub state_messages: std::vec::Vec<crate::model::StateMessage>,
4970
4971    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4972}
4973
4974impl Stage {
4975    pub fn new() -> Self {
4976        std::default::Default::default()
4977    }
4978
4979    /// Sets the value of [name][crate::model::Stage::name].
4980    ///
4981    /// # Example
4982    /// ```ignore,no_run
4983    /// # use google_cloud_functions_v2::model::Stage;
4984    /// use google_cloud_functions_v2::model::stage::Name;
4985    /// let x0 = Stage::new().set_name(Name::ArtifactRegistry);
4986    /// let x1 = Stage::new().set_name(Name::Build);
4987    /// let x2 = Stage::new().set_name(Name::Service);
4988    /// ```
4989    pub fn set_name<T: std::convert::Into<crate::model::stage::Name>>(mut self, v: T) -> Self {
4990        self.name = v.into();
4991        self
4992    }
4993
4994    /// Sets the value of [message][crate::model::Stage::message].
4995    ///
4996    /// # Example
4997    /// ```ignore,no_run
4998    /// # use google_cloud_functions_v2::model::Stage;
4999    /// let x = Stage::new().set_message("example");
5000    /// ```
5001    pub fn set_message<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5002        self.message = v.into();
5003        self
5004    }
5005
5006    /// Sets the value of [state][crate::model::Stage::state].
5007    ///
5008    /// # Example
5009    /// ```ignore,no_run
5010    /// # use google_cloud_functions_v2::model::Stage;
5011    /// use google_cloud_functions_v2::model::stage::State;
5012    /// let x0 = Stage::new().set_state(State::NotStarted);
5013    /// let x1 = Stage::new().set_state(State::InProgress);
5014    /// let x2 = Stage::new().set_state(State::Complete);
5015    /// ```
5016    pub fn set_state<T: std::convert::Into<crate::model::stage::State>>(mut self, v: T) -> Self {
5017        self.state = v.into();
5018        self
5019    }
5020
5021    /// Sets the value of [resource][crate::model::Stage::resource].
5022    ///
5023    /// # Example
5024    /// ```ignore,no_run
5025    /// # use google_cloud_functions_v2::model::Stage;
5026    /// let x = Stage::new().set_resource("example");
5027    /// ```
5028    pub fn set_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5029        self.resource = v.into();
5030        self
5031    }
5032
5033    /// Sets the value of [resource_uri][crate::model::Stage::resource_uri].
5034    ///
5035    /// # Example
5036    /// ```ignore,no_run
5037    /// # use google_cloud_functions_v2::model::Stage;
5038    /// let x = Stage::new().set_resource_uri("example");
5039    /// ```
5040    pub fn set_resource_uri<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
5041        self.resource_uri = v.into();
5042        self
5043    }
5044
5045    /// Sets the value of [state_messages][crate::model::Stage::state_messages].
5046    ///
5047    /// # Example
5048    /// ```ignore,no_run
5049    /// # use google_cloud_functions_v2::model::Stage;
5050    /// use google_cloud_functions_v2::model::StateMessage;
5051    /// let x = Stage::new()
5052    ///     .set_state_messages([
5053    ///         StateMessage::default()/* use setters */,
5054    ///         StateMessage::default()/* use (different) setters */,
5055    ///     ]);
5056    /// ```
5057    pub fn set_state_messages<T, V>(mut self, v: T) -> Self
5058    where
5059        T: std::iter::IntoIterator<Item = V>,
5060        V: std::convert::Into<crate::model::StateMessage>,
5061    {
5062        use std::iter::Iterator;
5063        self.state_messages = v.into_iter().map(|i| i.into()).collect();
5064        self
5065    }
5066}
5067
5068impl wkt::message::Message for Stage {
5069    fn typename() -> &'static str {
5070        "type.googleapis.com/google.cloud.functions.v2.Stage"
5071    }
5072}
5073
5074/// Defines additional types related to [Stage].
5075pub mod stage {
5076    #[allow(unused_imports)]
5077    use super::*;
5078
5079    /// Possible names for a Stage
5080    ///
5081    /// # Working with unknown values
5082    ///
5083    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5084    /// additional enum variants at any time. Adding new variants is not considered
5085    /// a breaking change. Applications should write their code in anticipation of:
5086    ///
5087    /// - New values appearing in future releases of the client library, **and**
5088    /// - New values received dynamically, without application changes.
5089    ///
5090    /// Please consult the [Working with enums] section in the user guide for some
5091    /// guidelines.
5092    ///
5093    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5094    #[derive(Clone, Debug, PartialEq)]
5095    #[non_exhaustive]
5096    pub enum Name {
5097        /// Not specified. Invalid name.
5098        Unspecified,
5099        /// Artifact Registry Stage
5100        ArtifactRegistry,
5101        /// Build Stage
5102        Build,
5103        /// Service Stage
5104        Service,
5105        /// Trigger Stage
5106        Trigger,
5107        /// Service Rollback Stage
5108        ServiceRollback,
5109        /// Trigger Rollback Stage
5110        TriggerRollback,
5111        /// If set, the enum was initialized with an unknown value.
5112        ///
5113        /// Applications can examine the value using [Name::value] or
5114        /// [Name::name].
5115        UnknownValue(name::UnknownValue),
5116    }
5117
5118    #[doc(hidden)]
5119    pub mod name {
5120        #[allow(unused_imports)]
5121        use super::*;
5122        #[derive(Clone, Debug, PartialEq)]
5123        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5124    }
5125
5126    impl Name {
5127        /// Gets the enum value.
5128        ///
5129        /// Returns `None` if the enum contains an unknown value deserialized from
5130        /// the string representation of enums.
5131        pub fn value(&self) -> std::option::Option<i32> {
5132            match self {
5133                Self::Unspecified => std::option::Option::Some(0),
5134                Self::ArtifactRegistry => std::option::Option::Some(1),
5135                Self::Build => std::option::Option::Some(2),
5136                Self::Service => std::option::Option::Some(3),
5137                Self::Trigger => std::option::Option::Some(4),
5138                Self::ServiceRollback => std::option::Option::Some(5),
5139                Self::TriggerRollback => std::option::Option::Some(6),
5140                Self::UnknownValue(u) => u.0.value(),
5141            }
5142        }
5143
5144        /// Gets the enum value as a string.
5145        ///
5146        /// Returns `None` if the enum contains an unknown value deserialized from
5147        /// the integer representation of enums.
5148        pub fn name(&self) -> std::option::Option<&str> {
5149            match self {
5150                Self::Unspecified => std::option::Option::Some("NAME_UNSPECIFIED"),
5151                Self::ArtifactRegistry => std::option::Option::Some("ARTIFACT_REGISTRY"),
5152                Self::Build => std::option::Option::Some("BUILD"),
5153                Self::Service => std::option::Option::Some("SERVICE"),
5154                Self::Trigger => std::option::Option::Some("TRIGGER"),
5155                Self::ServiceRollback => std::option::Option::Some("SERVICE_ROLLBACK"),
5156                Self::TriggerRollback => std::option::Option::Some("TRIGGER_ROLLBACK"),
5157                Self::UnknownValue(u) => u.0.name(),
5158            }
5159        }
5160    }
5161
5162    impl std::default::Default for Name {
5163        fn default() -> Self {
5164            use std::convert::From;
5165            Self::from(0)
5166        }
5167    }
5168
5169    impl std::fmt::Display for Name {
5170        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5171            wkt::internal::display_enum(f, self.name(), self.value())
5172        }
5173    }
5174
5175    impl std::convert::From<i32> for Name {
5176        fn from(value: i32) -> Self {
5177            match value {
5178                0 => Self::Unspecified,
5179                1 => Self::ArtifactRegistry,
5180                2 => Self::Build,
5181                3 => Self::Service,
5182                4 => Self::Trigger,
5183                5 => Self::ServiceRollback,
5184                6 => Self::TriggerRollback,
5185                _ => Self::UnknownValue(name::UnknownValue(
5186                    wkt::internal::UnknownEnumValue::Integer(value),
5187                )),
5188            }
5189        }
5190    }
5191
5192    impl std::convert::From<&str> for Name {
5193        fn from(value: &str) -> Self {
5194            use std::string::ToString;
5195            match value {
5196                "NAME_UNSPECIFIED" => Self::Unspecified,
5197                "ARTIFACT_REGISTRY" => Self::ArtifactRegistry,
5198                "BUILD" => Self::Build,
5199                "SERVICE" => Self::Service,
5200                "TRIGGER" => Self::Trigger,
5201                "SERVICE_ROLLBACK" => Self::ServiceRollback,
5202                "TRIGGER_ROLLBACK" => Self::TriggerRollback,
5203                _ => Self::UnknownValue(name::UnknownValue(
5204                    wkt::internal::UnknownEnumValue::String(value.to_string()),
5205                )),
5206            }
5207        }
5208    }
5209
5210    impl serde::ser::Serialize for Name {
5211        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5212        where
5213            S: serde::Serializer,
5214        {
5215            match self {
5216                Self::Unspecified => serializer.serialize_i32(0),
5217                Self::ArtifactRegistry => serializer.serialize_i32(1),
5218                Self::Build => serializer.serialize_i32(2),
5219                Self::Service => serializer.serialize_i32(3),
5220                Self::Trigger => serializer.serialize_i32(4),
5221                Self::ServiceRollback => serializer.serialize_i32(5),
5222                Self::TriggerRollback => serializer.serialize_i32(6),
5223                Self::UnknownValue(u) => u.0.serialize(serializer),
5224            }
5225        }
5226    }
5227
5228    impl<'de> serde::de::Deserialize<'de> for Name {
5229        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5230        where
5231            D: serde::Deserializer<'de>,
5232        {
5233            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Name>::new(
5234                ".google.cloud.functions.v2.Stage.Name",
5235            ))
5236        }
5237    }
5238
5239    /// Possible states for a Stage
5240    ///
5241    /// # Working with unknown values
5242    ///
5243    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5244    /// additional enum variants at any time. Adding new variants is not considered
5245    /// a breaking change. Applications should write their code in anticipation of:
5246    ///
5247    /// - New values appearing in future releases of the client library, **and**
5248    /// - New values received dynamically, without application changes.
5249    ///
5250    /// Please consult the [Working with enums] section in the user guide for some
5251    /// guidelines.
5252    ///
5253    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5254    #[derive(Clone, Debug, PartialEq)]
5255    #[non_exhaustive]
5256    pub enum State {
5257        /// Not specified. Invalid state.
5258        Unspecified,
5259        /// Stage has not started.
5260        NotStarted,
5261        /// Stage is in progress.
5262        InProgress,
5263        /// Stage has completed.
5264        Complete,
5265        /// If set, the enum was initialized with an unknown value.
5266        ///
5267        /// Applications can examine the value using [State::value] or
5268        /// [State::name].
5269        UnknownValue(state::UnknownValue),
5270    }
5271
5272    #[doc(hidden)]
5273    pub mod state {
5274        #[allow(unused_imports)]
5275        use super::*;
5276        #[derive(Clone, Debug, PartialEq)]
5277        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5278    }
5279
5280    impl State {
5281        /// Gets the enum value.
5282        ///
5283        /// Returns `None` if the enum contains an unknown value deserialized from
5284        /// the string representation of enums.
5285        pub fn value(&self) -> std::option::Option<i32> {
5286            match self {
5287                Self::Unspecified => std::option::Option::Some(0),
5288                Self::NotStarted => std::option::Option::Some(1),
5289                Self::InProgress => std::option::Option::Some(2),
5290                Self::Complete => std::option::Option::Some(3),
5291                Self::UnknownValue(u) => u.0.value(),
5292            }
5293        }
5294
5295        /// Gets the enum value as a string.
5296        ///
5297        /// Returns `None` if the enum contains an unknown value deserialized from
5298        /// the integer representation of enums.
5299        pub fn name(&self) -> std::option::Option<&str> {
5300            match self {
5301                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
5302                Self::NotStarted => std::option::Option::Some("NOT_STARTED"),
5303                Self::InProgress => std::option::Option::Some("IN_PROGRESS"),
5304                Self::Complete => std::option::Option::Some("COMPLETE"),
5305                Self::UnknownValue(u) => u.0.name(),
5306            }
5307        }
5308    }
5309
5310    impl std::default::Default for State {
5311        fn default() -> Self {
5312            use std::convert::From;
5313            Self::from(0)
5314        }
5315    }
5316
5317    impl std::fmt::Display for State {
5318        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5319            wkt::internal::display_enum(f, self.name(), self.value())
5320        }
5321    }
5322
5323    impl std::convert::From<i32> for State {
5324        fn from(value: i32) -> Self {
5325            match value {
5326                0 => Self::Unspecified,
5327                1 => Self::NotStarted,
5328                2 => Self::InProgress,
5329                3 => Self::Complete,
5330                _ => Self::UnknownValue(state::UnknownValue(
5331                    wkt::internal::UnknownEnumValue::Integer(value),
5332                )),
5333            }
5334        }
5335    }
5336
5337    impl std::convert::From<&str> for State {
5338        fn from(value: &str) -> Self {
5339            use std::string::ToString;
5340            match value {
5341                "STATE_UNSPECIFIED" => Self::Unspecified,
5342                "NOT_STARTED" => Self::NotStarted,
5343                "IN_PROGRESS" => Self::InProgress,
5344                "COMPLETE" => Self::Complete,
5345                _ => Self::UnknownValue(state::UnknownValue(
5346                    wkt::internal::UnknownEnumValue::String(value.to_string()),
5347                )),
5348            }
5349        }
5350    }
5351
5352    impl serde::ser::Serialize for State {
5353        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5354        where
5355            S: serde::Serializer,
5356        {
5357            match self {
5358                Self::Unspecified => serializer.serialize_i32(0),
5359                Self::NotStarted => serializer.serialize_i32(1),
5360                Self::InProgress => serializer.serialize_i32(2),
5361                Self::Complete => serializer.serialize_i32(3),
5362                Self::UnknownValue(u) => u.0.serialize(serializer),
5363            }
5364        }
5365    }
5366
5367    impl<'de> serde::de::Deserialize<'de> for State {
5368        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5369        where
5370            D: serde::Deserializer<'de>,
5371        {
5372            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
5373                ".google.cloud.functions.v2.Stage.State",
5374            ))
5375        }
5376    }
5377}
5378
5379/// The type of the long running operation.
5380///
5381/// # Working with unknown values
5382///
5383/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5384/// additional enum variants at any time. Adding new variants is not considered
5385/// a breaking change. Applications should write their code in anticipation of:
5386///
5387/// - New values appearing in future releases of the client library, **and**
5388/// - New values received dynamically, without application changes.
5389///
5390/// Please consult the [Working with enums] section in the user guide for some
5391/// guidelines.
5392///
5393/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5394#[derive(Clone, Debug, PartialEq)]
5395#[non_exhaustive]
5396pub enum OperationType {
5397    /// Unspecified
5398    OperationtypeUnspecified,
5399    /// CreateFunction
5400    CreateFunction,
5401    /// UpdateFunction
5402    UpdateFunction,
5403    /// DeleteFunction
5404    DeleteFunction,
5405    /// If set, the enum was initialized with an unknown value.
5406    ///
5407    /// Applications can examine the value using [OperationType::value] or
5408    /// [OperationType::name].
5409    UnknownValue(operation_type::UnknownValue),
5410}
5411
5412#[doc(hidden)]
5413pub mod operation_type {
5414    #[allow(unused_imports)]
5415    use super::*;
5416    #[derive(Clone, Debug, PartialEq)]
5417    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5418}
5419
5420impl OperationType {
5421    /// Gets the enum value.
5422    ///
5423    /// Returns `None` if the enum contains an unknown value deserialized from
5424    /// the string representation of enums.
5425    pub fn value(&self) -> std::option::Option<i32> {
5426        match self {
5427            Self::OperationtypeUnspecified => std::option::Option::Some(0),
5428            Self::CreateFunction => std::option::Option::Some(1),
5429            Self::UpdateFunction => std::option::Option::Some(2),
5430            Self::DeleteFunction => std::option::Option::Some(3),
5431            Self::UnknownValue(u) => u.0.value(),
5432        }
5433    }
5434
5435    /// Gets the enum value as a string.
5436    ///
5437    /// Returns `None` if the enum contains an unknown value deserialized from
5438    /// the integer representation of enums.
5439    pub fn name(&self) -> std::option::Option<&str> {
5440        match self {
5441            Self::OperationtypeUnspecified => {
5442                std::option::Option::Some("OPERATIONTYPE_UNSPECIFIED")
5443            }
5444            Self::CreateFunction => std::option::Option::Some("CREATE_FUNCTION"),
5445            Self::UpdateFunction => std::option::Option::Some("UPDATE_FUNCTION"),
5446            Self::DeleteFunction => std::option::Option::Some("DELETE_FUNCTION"),
5447            Self::UnknownValue(u) => u.0.name(),
5448        }
5449    }
5450}
5451
5452impl std::default::Default for OperationType {
5453    fn default() -> Self {
5454        use std::convert::From;
5455        Self::from(0)
5456    }
5457}
5458
5459impl std::fmt::Display for OperationType {
5460    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5461        wkt::internal::display_enum(f, self.name(), self.value())
5462    }
5463}
5464
5465impl std::convert::From<i32> for OperationType {
5466    fn from(value: i32) -> Self {
5467        match value {
5468            0 => Self::OperationtypeUnspecified,
5469            1 => Self::CreateFunction,
5470            2 => Self::UpdateFunction,
5471            3 => Self::DeleteFunction,
5472            _ => Self::UnknownValue(operation_type::UnknownValue(
5473                wkt::internal::UnknownEnumValue::Integer(value),
5474            )),
5475        }
5476    }
5477}
5478
5479impl std::convert::From<&str> for OperationType {
5480    fn from(value: &str) -> Self {
5481        use std::string::ToString;
5482        match value {
5483            "OPERATIONTYPE_UNSPECIFIED" => Self::OperationtypeUnspecified,
5484            "CREATE_FUNCTION" => Self::CreateFunction,
5485            "UPDATE_FUNCTION" => Self::UpdateFunction,
5486            "DELETE_FUNCTION" => Self::DeleteFunction,
5487            _ => Self::UnknownValue(operation_type::UnknownValue(
5488                wkt::internal::UnknownEnumValue::String(value.to_string()),
5489            )),
5490        }
5491    }
5492}
5493
5494impl serde::ser::Serialize for OperationType {
5495    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5496    where
5497        S: serde::Serializer,
5498    {
5499        match self {
5500            Self::OperationtypeUnspecified => serializer.serialize_i32(0),
5501            Self::CreateFunction => serializer.serialize_i32(1),
5502            Self::UpdateFunction => serializer.serialize_i32(2),
5503            Self::DeleteFunction => serializer.serialize_i32(3),
5504            Self::UnknownValue(u) => u.0.serialize(serializer),
5505        }
5506    }
5507}
5508
5509impl<'de> serde::de::Deserialize<'de> for OperationType {
5510    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5511    where
5512        D: serde::Deserializer<'de>,
5513    {
5514        deserializer.deserialize_any(wkt::internal::EnumVisitor::<OperationType>::new(
5515            ".google.cloud.functions.v2.OperationType",
5516        ))
5517    }
5518}
5519
5520/// The environment the function is hosted on.
5521///
5522/// # Working with unknown values
5523///
5524/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
5525/// additional enum variants at any time. Adding new variants is not considered
5526/// a breaking change. Applications should write their code in anticipation of:
5527///
5528/// - New values appearing in future releases of the client library, **and**
5529/// - New values received dynamically, without application changes.
5530///
5531/// Please consult the [Working with enums] section in the user guide for some
5532/// guidelines.
5533///
5534/// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
5535#[derive(Clone, Debug, PartialEq)]
5536#[non_exhaustive]
5537pub enum Environment {
5538    /// Unspecified
5539    Unspecified,
5540    /// Gen 1
5541    Gen1,
5542    /// Gen 2
5543    Gen2,
5544    /// If set, the enum was initialized with an unknown value.
5545    ///
5546    /// Applications can examine the value using [Environment::value] or
5547    /// [Environment::name].
5548    UnknownValue(environment::UnknownValue),
5549}
5550
5551#[doc(hidden)]
5552pub mod environment {
5553    #[allow(unused_imports)]
5554    use super::*;
5555    #[derive(Clone, Debug, PartialEq)]
5556    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
5557}
5558
5559impl Environment {
5560    /// Gets the enum value.
5561    ///
5562    /// Returns `None` if the enum contains an unknown value deserialized from
5563    /// the string representation of enums.
5564    pub fn value(&self) -> std::option::Option<i32> {
5565        match self {
5566            Self::Unspecified => std::option::Option::Some(0),
5567            Self::Gen1 => std::option::Option::Some(1),
5568            Self::Gen2 => std::option::Option::Some(2),
5569            Self::UnknownValue(u) => u.0.value(),
5570        }
5571    }
5572
5573    /// Gets the enum value as a string.
5574    ///
5575    /// Returns `None` if the enum contains an unknown value deserialized from
5576    /// the integer representation of enums.
5577    pub fn name(&self) -> std::option::Option<&str> {
5578        match self {
5579            Self::Unspecified => std::option::Option::Some("ENVIRONMENT_UNSPECIFIED"),
5580            Self::Gen1 => std::option::Option::Some("GEN_1"),
5581            Self::Gen2 => std::option::Option::Some("GEN_2"),
5582            Self::UnknownValue(u) => u.0.name(),
5583        }
5584    }
5585}
5586
5587impl std::default::Default for Environment {
5588    fn default() -> Self {
5589        use std::convert::From;
5590        Self::from(0)
5591    }
5592}
5593
5594impl std::fmt::Display for Environment {
5595    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
5596        wkt::internal::display_enum(f, self.name(), self.value())
5597    }
5598}
5599
5600impl std::convert::From<i32> for Environment {
5601    fn from(value: i32) -> Self {
5602        match value {
5603            0 => Self::Unspecified,
5604            1 => Self::Gen1,
5605            2 => Self::Gen2,
5606            _ => Self::UnknownValue(environment::UnknownValue(
5607                wkt::internal::UnknownEnumValue::Integer(value),
5608            )),
5609        }
5610    }
5611}
5612
5613impl std::convert::From<&str> for Environment {
5614    fn from(value: &str) -> Self {
5615        use std::string::ToString;
5616        match value {
5617            "ENVIRONMENT_UNSPECIFIED" => Self::Unspecified,
5618            "GEN_1" => Self::Gen1,
5619            "GEN_2" => Self::Gen2,
5620            _ => Self::UnknownValue(environment::UnknownValue(
5621                wkt::internal::UnknownEnumValue::String(value.to_string()),
5622            )),
5623        }
5624    }
5625}
5626
5627impl serde::ser::Serialize for Environment {
5628    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
5629    where
5630        S: serde::Serializer,
5631    {
5632        match self {
5633            Self::Unspecified => serializer.serialize_i32(0),
5634            Self::Gen1 => serializer.serialize_i32(1),
5635            Self::Gen2 => serializer.serialize_i32(2),
5636            Self::UnknownValue(u) => u.0.serialize(serializer),
5637        }
5638    }
5639}
5640
5641impl<'de> serde::de::Deserialize<'de> for Environment {
5642    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
5643    where
5644        D: serde::Deserializer<'de>,
5645    {
5646        deserializer.deserialize_any(wkt::internal::EnumVisitor::<Environment>::new(
5647            ".google.cloud.functions.v2.Environment",
5648        ))
5649    }
5650}