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