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