google_cloud_binaryauthorization_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate grafeas;
25extern crate lazy_static;
26extern crate reqwest;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34/// A [policy][google.cloud.binaryauthorization.v1.Policy] for container image binary authorization.
35///
36/// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
37#[derive(Clone, Default, PartialEq)]
38#[non_exhaustive]
39pub struct Policy {
40    /// Output only. The resource name, in the format `projects/*/policy`. There is
41    /// at most one policy per project.
42    pub name: std::string::String,
43
44    /// Optional. A descriptive comment.
45    pub description: std::string::String,
46
47    /// Optional. Controls the evaluation of a Google-maintained global admission
48    /// policy for common system-level images. Images not covered by the global
49    /// policy will be subject to the project admission policy. This setting
50    /// has no effect when specified inside a global admission policy.
51    pub global_policy_evaluation_mode: crate::model::policy::GlobalPolicyEvaluationMode,
52
53    /// Optional. Admission policy allowlisting. A matching admission request will
54    /// always be permitted. This feature is typically used to exclude Google or
55    /// third-party infrastructure images from Binary Authorization policies.
56    pub admission_whitelist_patterns: std::vec::Vec<crate::model::AdmissionWhitelistPattern>,
57
58    /// Optional. Per-cluster admission rules. Cluster spec format:
59    /// `location.clusterId`. There can be at most one admission rule per cluster
60    /// spec.
61    /// A `location` is either a compute zone (e.g. us-central1-a) or a region
62    /// (e.g. us-central1).
63    /// For `clusterId` syntax restrictions see
64    /// <https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters>.
65    pub cluster_admission_rules:
66        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
67
68    /// Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format:
69    /// [a-z.-]+, e.g. 'some-namespace'
70    pub kubernetes_namespace_admission_rules:
71        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
72
73    /// Optional. Per-kubernetes-service-account admission rules. Service account
74    /// spec format: `namespace:serviceaccount`. e.g. 'test-ns:default'
75    pub kubernetes_service_account_admission_rules:
76        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
77
78    /// Optional. Per-istio-service-identity admission rules. Istio service
79    /// identity spec format:
80    /// spiffe://\<domain\>/ns/\<namespace\>/sa/\<serviceaccount\> or
81    /// \<domain\>/ns/\<namespace\>/sa/\<serviceaccount\>
82    /// e.g. spiffe://example.com/ns/test-ns/sa/default
83    pub istio_service_identity_admission_rules:
84        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
85
86    /// Required. Default admission rule for a cluster without a per-cluster, per-
87    /// kubernetes-service-account, or per-istio-service-identity admission rule.
88    pub default_admission_rule: std::option::Option<crate::model::AdmissionRule>,
89
90    /// Output only. Time when the policy was last updated.
91    pub update_time: std::option::Option<wkt::Timestamp>,
92
93    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
94}
95
96impl Policy {
97    pub fn new() -> Self {
98        std::default::Default::default()
99    }
100
101    /// Sets the value of [name][crate::model::Policy::name].
102    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
103        self.name = v.into();
104        self
105    }
106
107    /// Sets the value of [description][crate::model::Policy::description].
108    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
109        self.description = v.into();
110        self
111    }
112
113    /// Sets the value of [global_policy_evaluation_mode][crate::model::Policy::global_policy_evaluation_mode].
114    pub fn set_global_policy_evaluation_mode<
115        T: std::convert::Into<crate::model::policy::GlobalPolicyEvaluationMode>,
116    >(
117        mut self,
118        v: T,
119    ) -> Self {
120        self.global_policy_evaluation_mode = v.into();
121        self
122    }
123
124    /// Sets the value of [admission_whitelist_patterns][crate::model::Policy::admission_whitelist_patterns].
125    pub fn set_admission_whitelist_patterns<T, V>(mut self, v: T) -> Self
126    where
127        T: std::iter::IntoIterator<Item = V>,
128        V: std::convert::Into<crate::model::AdmissionWhitelistPattern>,
129    {
130        use std::iter::Iterator;
131        self.admission_whitelist_patterns = v.into_iter().map(|i| i.into()).collect();
132        self
133    }
134
135    /// Sets the value of [cluster_admission_rules][crate::model::Policy::cluster_admission_rules].
136    pub fn set_cluster_admission_rules<T, K, V>(mut self, v: T) -> Self
137    where
138        T: std::iter::IntoIterator<Item = (K, V)>,
139        K: std::convert::Into<std::string::String>,
140        V: std::convert::Into<crate::model::AdmissionRule>,
141    {
142        use std::iter::Iterator;
143        self.cluster_admission_rules = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
144        self
145    }
146
147    /// Sets the value of [kubernetes_namespace_admission_rules][crate::model::Policy::kubernetes_namespace_admission_rules].
148    pub fn set_kubernetes_namespace_admission_rules<T, K, V>(mut self, v: T) -> Self
149    where
150        T: std::iter::IntoIterator<Item = (K, V)>,
151        K: std::convert::Into<std::string::String>,
152        V: std::convert::Into<crate::model::AdmissionRule>,
153    {
154        use std::iter::Iterator;
155        self.kubernetes_namespace_admission_rules =
156            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
157        self
158    }
159
160    /// Sets the value of [kubernetes_service_account_admission_rules][crate::model::Policy::kubernetes_service_account_admission_rules].
161    pub fn set_kubernetes_service_account_admission_rules<T, K, V>(mut self, v: T) -> Self
162    where
163        T: std::iter::IntoIterator<Item = (K, V)>,
164        K: std::convert::Into<std::string::String>,
165        V: std::convert::Into<crate::model::AdmissionRule>,
166    {
167        use std::iter::Iterator;
168        self.kubernetes_service_account_admission_rules =
169            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
170        self
171    }
172
173    /// Sets the value of [istio_service_identity_admission_rules][crate::model::Policy::istio_service_identity_admission_rules].
174    pub fn set_istio_service_identity_admission_rules<T, K, V>(mut self, v: T) -> Self
175    where
176        T: std::iter::IntoIterator<Item = (K, V)>,
177        K: std::convert::Into<std::string::String>,
178        V: std::convert::Into<crate::model::AdmissionRule>,
179    {
180        use std::iter::Iterator;
181        self.istio_service_identity_admission_rules =
182            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
183        self
184    }
185
186    /// Sets the value of [default_admission_rule][crate::model::Policy::default_admission_rule].
187    pub fn set_default_admission_rule<T>(mut self, v: T) -> Self
188    where
189        T: std::convert::Into<crate::model::AdmissionRule>,
190    {
191        self.default_admission_rule = std::option::Option::Some(v.into());
192        self
193    }
194
195    /// Sets or clears the value of [default_admission_rule][crate::model::Policy::default_admission_rule].
196    pub fn set_or_clear_default_admission_rule<T>(mut self, v: std::option::Option<T>) -> Self
197    where
198        T: std::convert::Into<crate::model::AdmissionRule>,
199    {
200        self.default_admission_rule = v.map(|x| x.into());
201        self
202    }
203
204    /// Sets the value of [update_time][crate::model::Policy::update_time].
205    pub fn set_update_time<T>(mut self, v: T) -> Self
206    where
207        T: std::convert::Into<wkt::Timestamp>,
208    {
209        self.update_time = std::option::Option::Some(v.into());
210        self
211    }
212
213    /// Sets or clears the value of [update_time][crate::model::Policy::update_time].
214    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
215    where
216        T: std::convert::Into<wkt::Timestamp>,
217    {
218        self.update_time = v.map(|x| x.into());
219        self
220    }
221}
222
223impl wkt::message::Message for Policy {
224    fn typename() -> &'static str {
225        "type.googleapis.com/google.cloud.binaryauthorization.v1.Policy"
226    }
227}
228
229#[doc(hidden)]
230impl<'de> serde::de::Deserialize<'de> for Policy {
231    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
232    where
233        D: serde::Deserializer<'de>,
234    {
235        #[allow(non_camel_case_types)]
236        #[doc(hidden)]
237        #[derive(PartialEq, Eq, Hash)]
238        enum __FieldTag {
239            __name,
240            __description,
241            __global_policy_evaluation_mode,
242            __admission_whitelist_patterns,
243            __cluster_admission_rules,
244            __kubernetes_namespace_admission_rules,
245            __kubernetes_service_account_admission_rules,
246            __istio_service_identity_admission_rules,
247            __default_admission_rule,
248            __update_time,
249            Unknown(std::string::String),
250        }
251        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
252            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
253            where
254                D: serde::Deserializer<'de>,
255            {
256                struct Visitor;
257                impl<'de> serde::de::Visitor<'de> for Visitor {
258                    type Value = __FieldTag;
259                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
260                        formatter.write_str("a field name for Policy")
261                    }
262                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
263                    where
264                        E: serde::de::Error,
265                    {
266                        use std::result::Result::Ok;
267                        use std::string::ToString;
268                        match value {
269                            "name" => Ok(__FieldTag::__name),
270                            "description" => Ok(__FieldTag::__description),
271                            "globalPolicyEvaluationMode" => {
272                                Ok(__FieldTag::__global_policy_evaluation_mode)
273                            }
274                            "global_policy_evaluation_mode" => {
275                                Ok(__FieldTag::__global_policy_evaluation_mode)
276                            }
277                            "admissionWhitelistPatterns" => {
278                                Ok(__FieldTag::__admission_whitelist_patterns)
279                            }
280                            "admission_whitelist_patterns" => {
281                                Ok(__FieldTag::__admission_whitelist_patterns)
282                            }
283                            "clusterAdmissionRules" => Ok(__FieldTag::__cluster_admission_rules),
284                            "cluster_admission_rules" => Ok(__FieldTag::__cluster_admission_rules),
285                            "kubernetesNamespaceAdmissionRules" => {
286                                Ok(__FieldTag::__kubernetes_namespace_admission_rules)
287                            }
288                            "kubernetes_namespace_admission_rules" => {
289                                Ok(__FieldTag::__kubernetes_namespace_admission_rules)
290                            }
291                            "kubernetesServiceAccountAdmissionRules" => {
292                                Ok(__FieldTag::__kubernetes_service_account_admission_rules)
293                            }
294                            "kubernetes_service_account_admission_rules" => {
295                                Ok(__FieldTag::__kubernetes_service_account_admission_rules)
296                            }
297                            "istioServiceIdentityAdmissionRules" => {
298                                Ok(__FieldTag::__istio_service_identity_admission_rules)
299                            }
300                            "istio_service_identity_admission_rules" => {
301                                Ok(__FieldTag::__istio_service_identity_admission_rules)
302                            }
303                            "defaultAdmissionRule" => Ok(__FieldTag::__default_admission_rule),
304                            "default_admission_rule" => Ok(__FieldTag::__default_admission_rule),
305                            "updateTime" => Ok(__FieldTag::__update_time),
306                            "update_time" => Ok(__FieldTag::__update_time),
307                            _ => Ok(__FieldTag::Unknown(value.to_string())),
308                        }
309                    }
310                }
311                deserializer.deserialize_identifier(Visitor)
312            }
313        }
314        struct Visitor;
315        impl<'de> serde::de::Visitor<'de> for Visitor {
316            type Value = Policy;
317            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
318                formatter.write_str("struct Policy")
319            }
320            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
321            where
322                A: serde::de::MapAccess<'de>,
323            {
324                #[allow(unused_imports)]
325                use serde::de::Error;
326                use std::option::Option::Some;
327                let mut fields = std::collections::HashSet::new();
328                let mut result = Self::Value::new();
329                while let Some(tag) = map.next_key::<__FieldTag>()? {
330                    #[allow(clippy::match_single_binding)]
331                    match tag {
332                        __FieldTag::__name => {
333                            if !fields.insert(__FieldTag::__name) {
334                                return std::result::Result::Err(A::Error::duplicate_field(
335                                    "multiple values for name",
336                                ));
337                            }
338                            result.name = map
339                                .next_value::<std::option::Option<std::string::String>>()?
340                                .unwrap_or_default();
341                        }
342                        __FieldTag::__description => {
343                            if !fields.insert(__FieldTag::__description) {
344                                return std::result::Result::Err(A::Error::duplicate_field(
345                                    "multiple values for description",
346                                ));
347                            }
348                            result.description = map
349                                .next_value::<std::option::Option<std::string::String>>()?
350                                .unwrap_or_default();
351                        }
352                        __FieldTag::__global_policy_evaluation_mode => {
353                            if !fields.insert(__FieldTag::__global_policy_evaluation_mode) {
354                                return std::result::Result::Err(A::Error::duplicate_field(
355                                    "multiple values for global_policy_evaluation_mode",
356                                ));
357                            }
358                            result.global_policy_evaluation_mode = map
359                                .next_value::<std::option::Option<
360                                    crate::model::policy::GlobalPolicyEvaluationMode,
361                                >>()?
362                                .unwrap_or_default();
363                        }
364                        __FieldTag::__admission_whitelist_patterns => {
365                            if !fields.insert(__FieldTag::__admission_whitelist_patterns) {
366                                return std::result::Result::Err(A::Error::duplicate_field(
367                                    "multiple values for admission_whitelist_patterns",
368                                ));
369                            }
370                            result.admission_whitelist_patterns = map
371                                .next_value::<std::option::Option<
372                                    std::vec::Vec<crate::model::AdmissionWhitelistPattern>,
373                                >>()?
374                                .unwrap_or_default();
375                        }
376                        __FieldTag::__cluster_admission_rules => {
377                            if !fields.insert(__FieldTag::__cluster_admission_rules) {
378                                return std::result::Result::Err(A::Error::duplicate_field(
379                                    "multiple values for cluster_admission_rules",
380                                ));
381                            }
382                            result.cluster_admission_rules = map
383                                .next_value::<std::option::Option<
384                                    std::collections::HashMap<
385                                        std::string::String,
386                                        crate::model::AdmissionRule,
387                                    >,
388                                >>()?
389                                .unwrap_or_default();
390                        }
391                        __FieldTag::__kubernetes_namespace_admission_rules => {
392                            if !fields.insert(__FieldTag::__kubernetes_namespace_admission_rules) {
393                                return std::result::Result::Err(A::Error::duplicate_field(
394                                    "multiple values for kubernetes_namespace_admission_rules",
395                                ));
396                            }
397                            result.kubernetes_namespace_admission_rules = map
398                                .next_value::<std::option::Option<
399                                    std::collections::HashMap<
400                                        std::string::String,
401                                        crate::model::AdmissionRule,
402                                    >,
403                                >>()?
404                                .unwrap_or_default();
405                        }
406                        __FieldTag::__kubernetes_service_account_admission_rules => {
407                            if !fields
408                                .insert(__FieldTag::__kubernetes_service_account_admission_rules)
409                            {
410                                return std::result::Result::Err(A::Error::duplicate_field(
411                                    "multiple values for kubernetes_service_account_admission_rules",
412                                ));
413                            }
414                            result.kubernetes_service_account_admission_rules = map
415                                .next_value::<std::option::Option<
416                                    std::collections::HashMap<
417                                        std::string::String,
418                                        crate::model::AdmissionRule,
419                                    >,
420                                >>()?
421                                .unwrap_or_default();
422                        }
423                        __FieldTag::__istio_service_identity_admission_rules => {
424                            if !fields.insert(__FieldTag::__istio_service_identity_admission_rules)
425                            {
426                                return std::result::Result::Err(A::Error::duplicate_field(
427                                    "multiple values for istio_service_identity_admission_rules",
428                                ));
429                            }
430                            result.istio_service_identity_admission_rules = map
431                                .next_value::<std::option::Option<
432                                    std::collections::HashMap<
433                                        std::string::String,
434                                        crate::model::AdmissionRule,
435                                    >,
436                                >>()?
437                                .unwrap_or_default();
438                        }
439                        __FieldTag::__default_admission_rule => {
440                            if !fields.insert(__FieldTag::__default_admission_rule) {
441                                return std::result::Result::Err(A::Error::duplicate_field(
442                                    "multiple values for default_admission_rule",
443                                ));
444                            }
445                            result.default_admission_rule = map
446                                .next_value::<std::option::Option<crate::model::AdmissionRule>>()?;
447                        }
448                        __FieldTag::__update_time => {
449                            if !fields.insert(__FieldTag::__update_time) {
450                                return std::result::Result::Err(A::Error::duplicate_field(
451                                    "multiple values for update_time",
452                                ));
453                            }
454                            result.update_time =
455                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
456                        }
457                        __FieldTag::Unknown(key) => {
458                            let value = map.next_value::<serde_json::Value>()?;
459                            result._unknown_fields.insert(key, value);
460                        }
461                    }
462                }
463                std::result::Result::Ok(result)
464            }
465        }
466        deserializer.deserialize_any(Visitor)
467    }
468}
469
470#[doc(hidden)]
471impl serde::ser::Serialize for Policy {
472    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
473    where
474        S: serde::ser::Serializer,
475    {
476        use serde::ser::SerializeMap;
477        #[allow(unused_imports)]
478        use std::option::Option::Some;
479        let mut state = serializer.serialize_map(std::option::Option::None)?;
480        if !self.name.is_empty() {
481            state.serialize_entry("name", &self.name)?;
482        }
483        if !self.description.is_empty() {
484            state.serialize_entry("description", &self.description)?;
485        }
486        if !wkt::internal::is_default(&self.global_policy_evaluation_mode) {
487            state.serialize_entry(
488                "globalPolicyEvaluationMode",
489                &self.global_policy_evaluation_mode,
490            )?;
491        }
492        if !self.admission_whitelist_patterns.is_empty() {
493            state.serialize_entry(
494                "admissionWhitelistPatterns",
495                &self.admission_whitelist_patterns,
496            )?;
497        }
498        if !self.cluster_admission_rules.is_empty() {
499            state.serialize_entry("clusterAdmissionRules", &self.cluster_admission_rules)?;
500        }
501        if !self.kubernetes_namespace_admission_rules.is_empty() {
502            state.serialize_entry(
503                "kubernetesNamespaceAdmissionRules",
504                &self.kubernetes_namespace_admission_rules,
505            )?;
506        }
507        if !self.kubernetes_service_account_admission_rules.is_empty() {
508            state.serialize_entry(
509                "kubernetesServiceAccountAdmissionRules",
510                &self.kubernetes_service_account_admission_rules,
511            )?;
512        }
513        if !self.istio_service_identity_admission_rules.is_empty() {
514            state.serialize_entry(
515                "istioServiceIdentityAdmissionRules",
516                &self.istio_service_identity_admission_rules,
517            )?;
518        }
519        if self.default_admission_rule.is_some() {
520            state.serialize_entry("defaultAdmissionRule", &self.default_admission_rule)?;
521        }
522        if self.update_time.is_some() {
523            state.serialize_entry("updateTime", &self.update_time)?;
524        }
525        if !self._unknown_fields.is_empty() {
526            for (key, value) in self._unknown_fields.iter() {
527                state.serialize_entry(key, &value)?;
528            }
529        }
530        state.end()
531    }
532}
533
534impl std::fmt::Debug for Policy {
535    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
536        let mut debug_struct = f.debug_struct("Policy");
537        debug_struct.field("name", &self.name);
538        debug_struct.field("description", &self.description);
539        debug_struct.field(
540            "global_policy_evaluation_mode",
541            &self.global_policy_evaluation_mode,
542        );
543        debug_struct.field(
544            "admission_whitelist_patterns",
545            &self.admission_whitelist_patterns,
546        );
547        debug_struct.field("cluster_admission_rules", &self.cluster_admission_rules);
548        debug_struct.field(
549            "kubernetes_namespace_admission_rules",
550            &self.kubernetes_namespace_admission_rules,
551        );
552        debug_struct.field(
553            "kubernetes_service_account_admission_rules",
554            &self.kubernetes_service_account_admission_rules,
555        );
556        debug_struct.field(
557            "istio_service_identity_admission_rules",
558            &self.istio_service_identity_admission_rules,
559        );
560        debug_struct.field("default_admission_rule", &self.default_admission_rule);
561        debug_struct.field("update_time", &self.update_time);
562        if !self._unknown_fields.is_empty() {
563            debug_struct.field("_unknown_fields", &self._unknown_fields);
564        }
565        debug_struct.finish()
566    }
567}
568
569/// Defines additional types related to [Policy].
570pub mod policy {
571    #[allow(unused_imports)]
572    use super::*;
573
574    ///
575    /// # Working with unknown values
576    ///
577    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
578    /// additional enum variants at any time. Adding new variants is not considered
579    /// a breaking change. Applications should write their code in anticipation of:
580    ///
581    /// - New values appearing in future releases of the client library, **and**
582    /// - New values received dynamically, without application changes.
583    ///
584    /// Please consult the [Working with enums] section in the user guide for some
585    /// guidelines.
586    ///
587    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
588    #[derive(Clone, Debug, PartialEq)]
589    #[non_exhaustive]
590    pub enum GlobalPolicyEvaluationMode {
591        /// Not specified: DISABLE is assumed.
592        Unspecified,
593        /// Enables system policy evaluation.
594        Enable,
595        /// Disables system policy evaluation.
596        Disable,
597        /// If set, the enum was initialized with an unknown value.
598        ///
599        /// Applications can examine the value using [GlobalPolicyEvaluationMode::value] or
600        /// [GlobalPolicyEvaluationMode::name].
601        UnknownValue(global_policy_evaluation_mode::UnknownValue),
602    }
603
604    #[doc(hidden)]
605    pub mod global_policy_evaluation_mode {
606        #[allow(unused_imports)]
607        use super::*;
608        #[derive(Clone, Debug, PartialEq)]
609        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
610    }
611
612    impl GlobalPolicyEvaluationMode {
613        /// Gets the enum value.
614        ///
615        /// Returns `None` if the enum contains an unknown value deserialized from
616        /// the string representation of enums.
617        pub fn value(&self) -> std::option::Option<i32> {
618            match self {
619                Self::Unspecified => std::option::Option::Some(0),
620                Self::Enable => std::option::Option::Some(1),
621                Self::Disable => std::option::Option::Some(2),
622                Self::UnknownValue(u) => u.0.value(),
623            }
624        }
625
626        /// Gets the enum value as a string.
627        ///
628        /// Returns `None` if the enum contains an unknown value deserialized from
629        /// the integer representation of enums.
630        pub fn name(&self) -> std::option::Option<&str> {
631            match self {
632                Self::Unspecified => {
633                    std::option::Option::Some("GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED")
634                }
635                Self::Enable => std::option::Option::Some("ENABLE"),
636                Self::Disable => std::option::Option::Some("DISABLE"),
637                Self::UnknownValue(u) => u.0.name(),
638            }
639        }
640    }
641
642    impl std::default::Default for GlobalPolicyEvaluationMode {
643        fn default() -> Self {
644            use std::convert::From;
645            Self::from(0)
646        }
647    }
648
649    impl std::fmt::Display for GlobalPolicyEvaluationMode {
650        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
651            wkt::internal::display_enum(f, self.name(), self.value())
652        }
653    }
654
655    impl std::convert::From<i32> for GlobalPolicyEvaluationMode {
656        fn from(value: i32) -> Self {
657            match value {
658                0 => Self::Unspecified,
659                1 => Self::Enable,
660                2 => Self::Disable,
661                _ => Self::UnknownValue(global_policy_evaluation_mode::UnknownValue(
662                    wkt::internal::UnknownEnumValue::Integer(value),
663                )),
664            }
665        }
666    }
667
668    impl std::convert::From<&str> for GlobalPolicyEvaluationMode {
669        fn from(value: &str) -> Self {
670            use std::string::ToString;
671            match value {
672                "GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED" => Self::Unspecified,
673                "ENABLE" => Self::Enable,
674                "DISABLE" => Self::Disable,
675                _ => Self::UnknownValue(global_policy_evaluation_mode::UnknownValue(
676                    wkt::internal::UnknownEnumValue::String(value.to_string()),
677                )),
678            }
679        }
680    }
681
682    impl serde::ser::Serialize for GlobalPolicyEvaluationMode {
683        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
684        where
685            S: serde::Serializer,
686        {
687            match self {
688                Self::Unspecified => serializer.serialize_i32(0),
689                Self::Enable => serializer.serialize_i32(1),
690                Self::Disable => serializer.serialize_i32(2),
691                Self::UnknownValue(u) => u.0.serialize(serializer),
692            }
693        }
694    }
695
696    impl<'de> serde::de::Deserialize<'de> for GlobalPolicyEvaluationMode {
697        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
698        where
699            D: serde::Deserializer<'de>,
700        {
701            deserializer.deserialize_any(
702                wkt::internal::EnumVisitor::<GlobalPolicyEvaluationMode>::new(
703                    ".google.cloud.binaryauthorization.v1.Policy.GlobalPolicyEvaluationMode",
704                ),
705            )
706        }
707    }
708}
709
710/// An [admission allowlist pattern][google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern] exempts images
711/// from checks by [admission rules][google.cloud.binaryauthorization.v1.AdmissionRule].
712///
713/// [google.cloud.binaryauthorization.v1.AdmissionRule]: crate::model::AdmissionRule
714/// [google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]: crate::model::AdmissionWhitelistPattern
715#[derive(Clone, Default, PartialEq)]
716#[non_exhaustive]
717pub struct AdmissionWhitelistPattern {
718    /// An image name pattern to allowlist, in the form `registry/path/to/image`.
719    /// This supports a trailing `*` wildcard, but this is allowed only in
720    /// text after the `registry/` part. This also supports a trailing `**`
721    /// wildcard which matches subdirectories of a given entry.
722    pub name_pattern: std::string::String,
723
724    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
725}
726
727impl AdmissionWhitelistPattern {
728    pub fn new() -> Self {
729        std::default::Default::default()
730    }
731
732    /// Sets the value of [name_pattern][crate::model::AdmissionWhitelistPattern::name_pattern].
733    pub fn set_name_pattern<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
734        self.name_pattern = v.into();
735        self
736    }
737}
738
739impl wkt::message::Message for AdmissionWhitelistPattern {
740    fn typename() -> &'static str {
741        "type.googleapis.com/google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern"
742    }
743}
744
745#[doc(hidden)]
746impl<'de> serde::de::Deserialize<'de> for AdmissionWhitelistPattern {
747    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
748    where
749        D: serde::Deserializer<'de>,
750    {
751        #[allow(non_camel_case_types)]
752        #[doc(hidden)]
753        #[derive(PartialEq, Eq, Hash)]
754        enum __FieldTag {
755            __name_pattern,
756            Unknown(std::string::String),
757        }
758        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
759            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
760            where
761                D: serde::Deserializer<'de>,
762            {
763                struct Visitor;
764                impl<'de> serde::de::Visitor<'de> for Visitor {
765                    type Value = __FieldTag;
766                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
767                        formatter.write_str("a field name for AdmissionWhitelistPattern")
768                    }
769                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
770                    where
771                        E: serde::de::Error,
772                    {
773                        use std::result::Result::Ok;
774                        use std::string::ToString;
775                        match value {
776                            "namePattern" => Ok(__FieldTag::__name_pattern),
777                            "name_pattern" => Ok(__FieldTag::__name_pattern),
778                            _ => Ok(__FieldTag::Unknown(value.to_string())),
779                        }
780                    }
781                }
782                deserializer.deserialize_identifier(Visitor)
783            }
784        }
785        struct Visitor;
786        impl<'de> serde::de::Visitor<'de> for Visitor {
787            type Value = AdmissionWhitelistPattern;
788            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
789                formatter.write_str("struct AdmissionWhitelistPattern")
790            }
791            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
792            where
793                A: serde::de::MapAccess<'de>,
794            {
795                #[allow(unused_imports)]
796                use serde::de::Error;
797                use std::option::Option::Some;
798                let mut fields = std::collections::HashSet::new();
799                let mut result = Self::Value::new();
800                while let Some(tag) = map.next_key::<__FieldTag>()? {
801                    #[allow(clippy::match_single_binding)]
802                    match tag {
803                        __FieldTag::__name_pattern => {
804                            if !fields.insert(__FieldTag::__name_pattern) {
805                                return std::result::Result::Err(A::Error::duplicate_field(
806                                    "multiple values for name_pattern",
807                                ));
808                            }
809                            result.name_pattern = map
810                                .next_value::<std::option::Option<std::string::String>>()?
811                                .unwrap_or_default();
812                        }
813                        __FieldTag::Unknown(key) => {
814                            let value = map.next_value::<serde_json::Value>()?;
815                            result._unknown_fields.insert(key, value);
816                        }
817                    }
818                }
819                std::result::Result::Ok(result)
820            }
821        }
822        deserializer.deserialize_any(Visitor)
823    }
824}
825
826#[doc(hidden)]
827impl serde::ser::Serialize for AdmissionWhitelistPattern {
828    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
829    where
830        S: serde::ser::Serializer,
831    {
832        use serde::ser::SerializeMap;
833        #[allow(unused_imports)]
834        use std::option::Option::Some;
835        let mut state = serializer.serialize_map(std::option::Option::None)?;
836        if !self.name_pattern.is_empty() {
837            state.serialize_entry("namePattern", &self.name_pattern)?;
838        }
839        if !self._unknown_fields.is_empty() {
840            for (key, value) in self._unknown_fields.iter() {
841                state.serialize_entry(key, &value)?;
842            }
843        }
844        state.end()
845    }
846}
847
848impl std::fmt::Debug for AdmissionWhitelistPattern {
849    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
850        let mut debug_struct = f.debug_struct("AdmissionWhitelistPattern");
851        debug_struct.field("name_pattern", &self.name_pattern);
852        if !self._unknown_fields.is_empty() {
853            debug_struct.field("_unknown_fields", &self._unknown_fields);
854        }
855        debug_struct.finish()
856    }
857}
858
859/// An [admission rule][google.cloud.binaryauthorization.v1.AdmissionRule] specifies either that all container images
860/// used in a pod creation request must be attested to by one or more
861/// [attestors][google.cloud.binaryauthorization.v1.Attestor], that all pod creations will be allowed, or that all
862/// pod creations will be denied.
863///
864/// Images matching an [admission allowlist pattern][google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]
865/// are exempted from admission rules and will never block a pod creation.
866///
867/// [google.cloud.binaryauthorization.v1.AdmissionRule]: crate::model::AdmissionRule
868/// [google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]: crate::model::AdmissionWhitelistPattern
869/// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
870#[derive(Clone, Default, PartialEq)]
871#[non_exhaustive]
872pub struct AdmissionRule {
873    /// Required. How this admission rule will be evaluated.
874    pub evaluation_mode: crate::model::admission_rule::EvaluationMode,
875
876    /// Optional. The resource names of the attestors that must attest to
877    /// a container image, in the format `projects/*/attestors/*`. Each
878    /// attestor must exist before a policy can reference it.  To add an attestor
879    /// to a policy the principal issuing the policy change request must be able
880    /// to read the attestor resource.
881    ///
882    /// Note: this field must be non-empty when the evaluation_mode field specifies
883    /// REQUIRE_ATTESTATION, otherwise it must be empty.
884    pub require_attestations_by: std::vec::Vec<std::string::String>,
885
886    /// Required. The action when a pod creation is denied by the admission rule.
887    pub enforcement_mode: crate::model::admission_rule::EnforcementMode,
888
889    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
890}
891
892impl AdmissionRule {
893    pub fn new() -> Self {
894        std::default::Default::default()
895    }
896
897    /// Sets the value of [evaluation_mode][crate::model::AdmissionRule::evaluation_mode].
898    pub fn set_evaluation_mode<
899        T: std::convert::Into<crate::model::admission_rule::EvaluationMode>,
900    >(
901        mut self,
902        v: T,
903    ) -> Self {
904        self.evaluation_mode = v.into();
905        self
906    }
907
908    /// Sets the value of [require_attestations_by][crate::model::AdmissionRule::require_attestations_by].
909    pub fn set_require_attestations_by<T, V>(mut self, v: T) -> Self
910    where
911        T: std::iter::IntoIterator<Item = V>,
912        V: std::convert::Into<std::string::String>,
913    {
914        use std::iter::Iterator;
915        self.require_attestations_by = v.into_iter().map(|i| i.into()).collect();
916        self
917    }
918
919    /// Sets the value of [enforcement_mode][crate::model::AdmissionRule::enforcement_mode].
920    pub fn set_enforcement_mode<
921        T: std::convert::Into<crate::model::admission_rule::EnforcementMode>,
922    >(
923        mut self,
924        v: T,
925    ) -> Self {
926        self.enforcement_mode = v.into();
927        self
928    }
929}
930
931impl wkt::message::Message for AdmissionRule {
932    fn typename() -> &'static str {
933        "type.googleapis.com/google.cloud.binaryauthorization.v1.AdmissionRule"
934    }
935}
936
937#[doc(hidden)]
938impl<'de> serde::de::Deserialize<'de> for AdmissionRule {
939    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
940    where
941        D: serde::Deserializer<'de>,
942    {
943        #[allow(non_camel_case_types)]
944        #[doc(hidden)]
945        #[derive(PartialEq, Eq, Hash)]
946        enum __FieldTag {
947            __evaluation_mode,
948            __require_attestations_by,
949            __enforcement_mode,
950            Unknown(std::string::String),
951        }
952        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
953            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
954            where
955                D: serde::Deserializer<'de>,
956            {
957                struct Visitor;
958                impl<'de> serde::de::Visitor<'de> for Visitor {
959                    type Value = __FieldTag;
960                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
961                        formatter.write_str("a field name for AdmissionRule")
962                    }
963                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
964                    where
965                        E: serde::de::Error,
966                    {
967                        use std::result::Result::Ok;
968                        use std::string::ToString;
969                        match value {
970                            "evaluationMode" => Ok(__FieldTag::__evaluation_mode),
971                            "evaluation_mode" => Ok(__FieldTag::__evaluation_mode),
972                            "requireAttestationsBy" => Ok(__FieldTag::__require_attestations_by),
973                            "require_attestations_by" => Ok(__FieldTag::__require_attestations_by),
974                            "enforcementMode" => Ok(__FieldTag::__enforcement_mode),
975                            "enforcement_mode" => Ok(__FieldTag::__enforcement_mode),
976                            _ => Ok(__FieldTag::Unknown(value.to_string())),
977                        }
978                    }
979                }
980                deserializer.deserialize_identifier(Visitor)
981            }
982        }
983        struct Visitor;
984        impl<'de> serde::de::Visitor<'de> for Visitor {
985            type Value = AdmissionRule;
986            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
987                formatter.write_str("struct AdmissionRule")
988            }
989            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
990            where
991                A: serde::de::MapAccess<'de>,
992            {
993                #[allow(unused_imports)]
994                use serde::de::Error;
995                use std::option::Option::Some;
996                let mut fields = std::collections::HashSet::new();
997                let mut result = Self::Value::new();
998                while let Some(tag) = map.next_key::<__FieldTag>()? {
999                    #[allow(clippy::match_single_binding)]
1000                    match tag {
1001                        __FieldTag::__evaluation_mode => {
1002                            if !fields.insert(__FieldTag::__evaluation_mode) {
1003                                return std::result::Result::Err(A::Error::duplicate_field(
1004                                    "multiple values for evaluation_mode",
1005                                ));
1006                            }
1007                            result.evaluation_mode =
1008                                map.next_value::<std::option::Option<
1009                                    crate::model::admission_rule::EvaluationMode,
1010                                >>()?
1011                                .unwrap_or_default();
1012                        }
1013                        __FieldTag::__require_attestations_by => {
1014                            if !fields.insert(__FieldTag::__require_attestations_by) {
1015                                return std::result::Result::Err(A::Error::duplicate_field(
1016                                    "multiple values for require_attestations_by",
1017                                ));
1018                            }
1019                            result.require_attestations_by = map.next_value::<std::option::Option<std::vec::Vec<std::string::String>>>()?.unwrap_or_default();
1020                        }
1021                        __FieldTag::__enforcement_mode => {
1022                            if !fields.insert(__FieldTag::__enforcement_mode) {
1023                                return std::result::Result::Err(A::Error::duplicate_field(
1024                                    "multiple values for enforcement_mode",
1025                                ));
1026                            }
1027                            result.enforcement_mode =
1028                                map.next_value::<std::option::Option<
1029                                    crate::model::admission_rule::EnforcementMode,
1030                                >>()?
1031                                .unwrap_or_default();
1032                        }
1033                        __FieldTag::Unknown(key) => {
1034                            let value = map.next_value::<serde_json::Value>()?;
1035                            result._unknown_fields.insert(key, value);
1036                        }
1037                    }
1038                }
1039                std::result::Result::Ok(result)
1040            }
1041        }
1042        deserializer.deserialize_any(Visitor)
1043    }
1044}
1045
1046#[doc(hidden)]
1047impl serde::ser::Serialize for AdmissionRule {
1048    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1049    where
1050        S: serde::ser::Serializer,
1051    {
1052        use serde::ser::SerializeMap;
1053        #[allow(unused_imports)]
1054        use std::option::Option::Some;
1055        let mut state = serializer.serialize_map(std::option::Option::None)?;
1056        if !wkt::internal::is_default(&self.evaluation_mode) {
1057            state.serialize_entry("evaluationMode", &self.evaluation_mode)?;
1058        }
1059        if !self.require_attestations_by.is_empty() {
1060            state.serialize_entry("requireAttestationsBy", &self.require_attestations_by)?;
1061        }
1062        if !wkt::internal::is_default(&self.enforcement_mode) {
1063            state.serialize_entry("enforcementMode", &self.enforcement_mode)?;
1064        }
1065        if !self._unknown_fields.is_empty() {
1066            for (key, value) in self._unknown_fields.iter() {
1067                state.serialize_entry(key, &value)?;
1068            }
1069        }
1070        state.end()
1071    }
1072}
1073
1074impl std::fmt::Debug for AdmissionRule {
1075    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1076        let mut debug_struct = f.debug_struct("AdmissionRule");
1077        debug_struct.field("evaluation_mode", &self.evaluation_mode);
1078        debug_struct.field("require_attestations_by", &self.require_attestations_by);
1079        debug_struct.field("enforcement_mode", &self.enforcement_mode);
1080        if !self._unknown_fields.is_empty() {
1081            debug_struct.field("_unknown_fields", &self._unknown_fields);
1082        }
1083        debug_struct.finish()
1084    }
1085}
1086
1087/// Defines additional types related to [AdmissionRule].
1088pub mod admission_rule {
1089    #[allow(unused_imports)]
1090    use super::*;
1091
1092    ///
1093    /// # Working with unknown values
1094    ///
1095    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1096    /// additional enum variants at any time. Adding new variants is not considered
1097    /// a breaking change. Applications should write their code in anticipation of:
1098    ///
1099    /// - New values appearing in future releases of the client library, **and**
1100    /// - New values received dynamically, without application changes.
1101    ///
1102    /// Please consult the [Working with enums] section in the user guide for some
1103    /// guidelines.
1104    ///
1105    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1106    #[derive(Clone, Debug, PartialEq)]
1107    #[non_exhaustive]
1108    pub enum EvaluationMode {
1109        /// Do not use.
1110        Unspecified,
1111        /// This rule allows all all pod creations.
1112        AlwaysAllow,
1113        /// This rule allows a pod creation if all the attestors listed in
1114        /// 'require_attestations_by' have valid attestations for all of the
1115        /// images in the pod spec.
1116        RequireAttestation,
1117        /// This rule denies all pod creations.
1118        AlwaysDeny,
1119        /// If set, the enum was initialized with an unknown value.
1120        ///
1121        /// Applications can examine the value using [EvaluationMode::value] or
1122        /// [EvaluationMode::name].
1123        UnknownValue(evaluation_mode::UnknownValue),
1124    }
1125
1126    #[doc(hidden)]
1127    pub mod evaluation_mode {
1128        #[allow(unused_imports)]
1129        use super::*;
1130        #[derive(Clone, Debug, PartialEq)]
1131        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1132    }
1133
1134    impl EvaluationMode {
1135        /// Gets the enum value.
1136        ///
1137        /// Returns `None` if the enum contains an unknown value deserialized from
1138        /// the string representation of enums.
1139        pub fn value(&self) -> std::option::Option<i32> {
1140            match self {
1141                Self::Unspecified => std::option::Option::Some(0),
1142                Self::AlwaysAllow => std::option::Option::Some(1),
1143                Self::RequireAttestation => std::option::Option::Some(2),
1144                Self::AlwaysDeny => std::option::Option::Some(3),
1145                Self::UnknownValue(u) => u.0.value(),
1146            }
1147        }
1148
1149        /// Gets the enum value as a string.
1150        ///
1151        /// Returns `None` if the enum contains an unknown value deserialized from
1152        /// the integer representation of enums.
1153        pub fn name(&self) -> std::option::Option<&str> {
1154            match self {
1155                Self::Unspecified => std::option::Option::Some("EVALUATION_MODE_UNSPECIFIED"),
1156                Self::AlwaysAllow => std::option::Option::Some("ALWAYS_ALLOW"),
1157                Self::RequireAttestation => std::option::Option::Some("REQUIRE_ATTESTATION"),
1158                Self::AlwaysDeny => std::option::Option::Some("ALWAYS_DENY"),
1159                Self::UnknownValue(u) => u.0.name(),
1160            }
1161        }
1162    }
1163
1164    impl std::default::Default for EvaluationMode {
1165        fn default() -> Self {
1166            use std::convert::From;
1167            Self::from(0)
1168        }
1169    }
1170
1171    impl std::fmt::Display for EvaluationMode {
1172        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1173            wkt::internal::display_enum(f, self.name(), self.value())
1174        }
1175    }
1176
1177    impl std::convert::From<i32> for EvaluationMode {
1178        fn from(value: i32) -> Self {
1179            match value {
1180                0 => Self::Unspecified,
1181                1 => Self::AlwaysAllow,
1182                2 => Self::RequireAttestation,
1183                3 => Self::AlwaysDeny,
1184                _ => Self::UnknownValue(evaluation_mode::UnknownValue(
1185                    wkt::internal::UnknownEnumValue::Integer(value),
1186                )),
1187            }
1188        }
1189    }
1190
1191    impl std::convert::From<&str> for EvaluationMode {
1192        fn from(value: &str) -> Self {
1193            use std::string::ToString;
1194            match value {
1195                "EVALUATION_MODE_UNSPECIFIED" => Self::Unspecified,
1196                "ALWAYS_ALLOW" => Self::AlwaysAllow,
1197                "REQUIRE_ATTESTATION" => Self::RequireAttestation,
1198                "ALWAYS_DENY" => Self::AlwaysDeny,
1199                _ => Self::UnknownValue(evaluation_mode::UnknownValue(
1200                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1201                )),
1202            }
1203        }
1204    }
1205
1206    impl serde::ser::Serialize for EvaluationMode {
1207        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1208        where
1209            S: serde::Serializer,
1210        {
1211            match self {
1212                Self::Unspecified => serializer.serialize_i32(0),
1213                Self::AlwaysAllow => serializer.serialize_i32(1),
1214                Self::RequireAttestation => serializer.serialize_i32(2),
1215                Self::AlwaysDeny => serializer.serialize_i32(3),
1216                Self::UnknownValue(u) => u.0.serialize(serializer),
1217            }
1218        }
1219    }
1220
1221    impl<'de> serde::de::Deserialize<'de> for EvaluationMode {
1222        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1223        where
1224            D: serde::Deserializer<'de>,
1225        {
1226            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EvaluationMode>::new(
1227                ".google.cloud.binaryauthorization.v1.AdmissionRule.EvaluationMode",
1228            ))
1229        }
1230    }
1231
1232    /// Defines the possible actions when a pod creation is denied by an admission
1233    /// rule.
1234    ///
1235    /// # Working with unknown values
1236    ///
1237    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1238    /// additional enum variants at any time. Adding new variants is not considered
1239    /// a breaking change. Applications should write their code in anticipation of:
1240    ///
1241    /// - New values appearing in future releases of the client library, **and**
1242    /// - New values received dynamically, without application changes.
1243    ///
1244    /// Please consult the [Working with enums] section in the user guide for some
1245    /// guidelines.
1246    ///
1247    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1248    #[derive(Clone, Debug, PartialEq)]
1249    #[non_exhaustive]
1250    pub enum EnforcementMode {
1251        /// Do not use.
1252        Unspecified,
1253        /// Enforce the admission rule by blocking the pod creation.
1254        EnforcedBlockAndAuditLog,
1255        /// Dryrun mode: Audit logging only.  This will allow the pod creation as if
1256        /// the admission request had specified break-glass.
1257        DryrunAuditLogOnly,
1258        /// If set, the enum was initialized with an unknown value.
1259        ///
1260        /// Applications can examine the value using [EnforcementMode::value] or
1261        /// [EnforcementMode::name].
1262        UnknownValue(enforcement_mode::UnknownValue),
1263    }
1264
1265    #[doc(hidden)]
1266    pub mod enforcement_mode {
1267        #[allow(unused_imports)]
1268        use super::*;
1269        #[derive(Clone, Debug, PartialEq)]
1270        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1271    }
1272
1273    impl EnforcementMode {
1274        /// Gets the enum value.
1275        ///
1276        /// Returns `None` if the enum contains an unknown value deserialized from
1277        /// the string representation of enums.
1278        pub fn value(&self) -> std::option::Option<i32> {
1279            match self {
1280                Self::Unspecified => std::option::Option::Some(0),
1281                Self::EnforcedBlockAndAuditLog => std::option::Option::Some(1),
1282                Self::DryrunAuditLogOnly => std::option::Option::Some(2),
1283                Self::UnknownValue(u) => u.0.value(),
1284            }
1285        }
1286
1287        /// Gets the enum value as a string.
1288        ///
1289        /// Returns `None` if the enum contains an unknown value deserialized from
1290        /// the integer representation of enums.
1291        pub fn name(&self) -> std::option::Option<&str> {
1292            match self {
1293                Self::Unspecified => std::option::Option::Some("ENFORCEMENT_MODE_UNSPECIFIED"),
1294                Self::EnforcedBlockAndAuditLog => {
1295                    std::option::Option::Some("ENFORCED_BLOCK_AND_AUDIT_LOG")
1296                }
1297                Self::DryrunAuditLogOnly => std::option::Option::Some("DRYRUN_AUDIT_LOG_ONLY"),
1298                Self::UnknownValue(u) => u.0.name(),
1299            }
1300        }
1301    }
1302
1303    impl std::default::Default for EnforcementMode {
1304        fn default() -> Self {
1305            use std::convert::From;
1306            Self::from(0)
1307        }
1308    }
1309
1310    impl std::fmt::Display for EnforcementMode {
1311        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1312            wkt::internal::display_enum(f, self.name(), self.value())
1313        }
1314    }
1315
1316    impl std::convert::From<i32> for EnforcementMode {
1317        fn from(value: i32) -> Self {
1318            match value {
1319                0 => Self::Unspecified,
1320                1 => Self::EnforcedBlockAndAuditLog,
1321                2 => Self::DryrunAuditLogOnly,
1322                _ => Self::UnknownValue(enforcement_mode::UnknownValue(
1323                    wkt::internal::UnknownEnumValue::Integer(value),
1324                )),
1325            }
1326        }
1327    }
1328
1329    impl std::convert::From<&str> for EnforcementMode {
1330        fn from(value: &str) -> Self {
1331            use std::string::ToString;
1332            match value {
1333                "ENFORCEMENT_MODE_UNSPECIFIED" => Self::Unspecified,
1334                "ENFORCED_BLOCK_AND_AUDIT_LOG" => Self::EnforcedBlockAndAuditLog,
1335                "DRYRUN_AUDIT_LOG_ONLY" => Self::DryrunAuditLogOnly,
1336                _ => Self::UnknownValue(enforcement_mode::UnknownValue(
1337                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1338                )),
1339            }
1340        }
1341    }
1342
1343    impl serde::ser::Serialize for EnforcementMode {
1344        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1345        where
1346            S: serde::Serializer,
1347        {
1348            match self {
1349                Self::Unspecified => serializer.serialize_i32(0),
1350                Self::EnforcedBlockAndAuditLog => serializer.serialize_i32(1),
1351                Self::DryrunAuditLogOnly => serializer.serialize_i32(2),
1352                Self::UnknownValue(u) => u.0.serialize(serializer),
1353            }
1354        }
1355    }
1356
1357    impl<'de> serde::de::Deserialize<'de> for EnforcementMode {
1358        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1359        where
1360            D: serde::Deserializer<'de>,
1361        {
1362            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EnforcementMode>::new(
1363                ".google.cloud.binaryauthorization.v1.AdmissionRule.EnforcementMode",
1364            ))
1365        }
1366    }
1367}
1368
1369/// An [attestor][google.cloud.binaryauthorization.v1.Attestor] that attests to container image
1370/// artifacts. An existing attestor cannot be modified except where
1371/// indicated.
1372///
1373/// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1374#[derive(Clone, Default, PartialEq)]
1375#[non_exhaustive]
1376pub struct Attestor {
1377    /// Required. The resource name, in the format:
1378    /// `projects/*/attestors/*`. This field may not be updated.
1379    pub name: std::string::String,
1380
1381    /// Optional. A descriptive comment.  This field may be updated.
1382    /// The field may be displayed in chooser dialogs.
1383    pub description: std::string::String,
1384
1385    /// Output only. Time when the attestor was last updated.
1386    pub update_time: std::option::Option<wkt::Timestamp>,
1387
1388    pub attestor_type: std::option::Option<crate::model::attestor::AttestorType>,
1389
1390    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1391}
1392
1393impl Attestor {
1394    pub fn new() -> Self {
1395        std::default::Default::default()
1396    }
1397
1398    /// Sets the value of [name][crate::model::Attestor::name].
1399    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1400        self.name = v.into();
1401        self
1402    }
1403
1404    /// Sets the value of [description][crate::model::Attestor::description].
1405    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1406        self.description = v.into();
1407        self
1408    }
1409
1410    /// Sets the value of [update_time][crate::model::Attestor::update_time].
1411    pub fn set_update_time<T>(mut self, v: T) -> Self
1412    where
1413        T: std::convert::Into<wkt::Timestamp>,
1414    {
1415        self.update_time = std::option::Option::Some(v.into());
1416        self
1417    }
1418
1419    /// Sets or clears the value of [update_time][crate::model::Attestor::update_time].
1420    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
1421    where
1422        T: std::convert::Into<wkt::Timestamp>,
1423    {
1424        self.update_time = v.map(|x| x.into());
1425        self
1426    }
1427
1428    /// Sets the value of [attestor_type][crate::model::Attestor::attestor_type].
1429    ///
1430    /// Note that all the setters affecting `attestor_type` are mutually
1431    /// exclusive.
1432    pub fn set_attestor_type<
1433        T: std::convert::Into<std::option::Option<crate::model::attestor::AttestorType>>,
1434    >(
1435        mut self,
1436        v: T,
1437    ) -> Self {
1438        self.attestor_type = v.into();
1439        self
1440    }
1441
1442    /// The value of [attestor_type][crate::model::Attestor::attestor_type]
1443    /// if it holds a `UserOwnedGrafeasNote`, `None` if the field is not set or
1444    /// holds a different branch.
1445    pub fn user_owned_grafeas_note(
1446        &self,
1447    ) -> std::option::Option<&std::boxed::Box<crate::model::UserOwnedGrafeasNote>> {
1448        #[allow(unreachable_patterns)]
1449        self.attestor_type.as_ref().and_then(|v| match v {
1450            crate::model::attestor::AttestorType::UserOwnedGrafeasNote(v) => {
1451                std::option::Option::Some(v)
1452            }
1453            _ => std::option::Option::None,
1454        })
1455    }
1456
1457    /// Sets the value of [attestor_type][crate::model::Attestor::attestor_type]
1458    /// to hold a `UserOwnedGrafeasNote`.
1459    ///
1460    /// Note that all the setters affecting `attestor_type` are
1461    /// mutually exclusive.
1462    pub fn set_user_owned_grafeas_note<
1463        T: std::convert::Into<std::boxed::Box<crate::model::UserOwnedGrafeasNote>>,
1464    >(
1465        mut self,
1466        v: T,
1467    ) -> Self {
1468        self.attestor_type = std::option::Option::Some(
1469            crate::model::attestor::AttestorType::UserOwnedGrafeasNote(v.into()),
1470        );
1471        self
1472    }
1473}
1474
1475impl wkt::message::Message for Attestor {
1476    fn typename() -> &'static str {
1477        "type.googleapis.com/google.cloud.binaryauthorization.v1.Attestor"
1478    }
1479}
1480
1481#[doc(hidden)]
1482impl<'de> serde::de::Deserialize<'de> for Attestor {
1483    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1484    where
1485        D: serde::Deserializer<'de>,
1486    {
1487        #[allow(non_camel_case_types)]
1488        #[doc(hidden)]
1489        #[derive(PartialEq, Eq, Hash)]
1490        enum __FieldTag {
1491            __name,
1492            __description,
1493            __user_owned_grafeas_note,
1494            __update_time,
1495            Unknown(std::string::String),
1496        }
1497        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1498            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1499            where
1500                D: serde::Deserializer<'de>,
1501            {
1502                struct Visitor;
1503                impl<'de> serde::de::Visitor<'de> for Visitor {
1504                    type Value = __FieldTag;
1505                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1506                        formatter.write_str("a field name for Attestor")
1507                    }
1508                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1509                    where
1510                        E: serde::de::Error,
1511                    {
1512                        use std::result::Result::Ok;
1513                        use std::string::ToString;
1514                        match value {
1515                            "name" => Ok(__FieldTag::__name),
1516                            "description" => Ok(__FieldTag::__description),
1517                            "userOwnedGrafeasNote" => Ok(__FieldTag::__user_owned_grafeas_note),
1518                            "user_owned_grafeas_note" => Ok(__FieldTag::__user_owned_grafeas_note),
1519                            "updateTime" => Ok(__FieldTag::__update_time),
1520                            "update_time" => Ok(__FieldTag::__update_time),
1521                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1522                        }
1523                    }
1524                }
1525                deserializer.deserialize_identifier(Visitor)
1526            }
1527        }
1528        struct Visitor;
1529        impl<'de> serde::de::Visitor<'de> for Visitor {
1530            type Value = Attestor;
1531            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1532                formatter.write_str("struct Attestor")
1533            }
1534            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1535            where
1536                A: serde::de::MapAccess<'de>,
1537            {
1538                #[allow(unused_imports)]
1539                use serde::de::Error;
1540                use std::option::Option::Some;
1541                let mut fields = std::collections::HashSet::new();
1542                let mut result = Self::Value::new();
1543                while let Some(tag) = map.next_key::<__FieldTag>()? {
1544                    #[allow(clippy::match_single_binding)]
1545                    match tag {
1546                        __FieldTag::__name => {
1547                            if !fields.insert(__FieldTag::__name) {
1548                                return std::result::Result::Err(A::Error::duplicate_field(
1549                                    "multiple values for name",
1550                                ));
1551                            }
1552                            result.name = map
1553                                .next_value::<std::option::Option<std::string::String>>()?
1554                                .unwrap_or_default();
1555                        }
1556                        __FieldTag::__description => {
1557                            if !fields.insert(__FieldTag::__description) {
1558                                return std::result::Result::Err(A::Error::duplicate_field(
1559                                    "multiple values for description",
1560                                ));
1561                            }
1562                            result.description = map
1563                                .next_value::<std::option::Option<std::string::String>>()?
1564                                .unwrap_or_default();
1565                        }
1566                        __FieldTag::__user_owned_grafeas_note => {
1567                            if !fields.insert(__FieldTag::__user_owned_grafeas_note) {
1568                                return std::result::Result::Err(A::Error::duplicate_field(
1569                                    "multiple values for user_owned_grafeas_note",
1570                                ));
1571                            }
1572                            if result.attestor_type.is_some() {
1573                                return std::result::Result::Err(A::Error::duplicate_field(
1574                                    "multiple values for `attestor_type`, a oneof with full ID .google.cloud.binaryauthorization.v1.Attestor.user_owned_grafeas_note, latest field was userOwnedGrafeasNote",
1575                                ));
1576                            }
1577                            result.attestor_type = std::option::Option::Some(
1578                                crate::model::attestor::AttestorType::UserOwnedGrafeasNote(
1579                                    map.next_value::<std::option::Option<
1580                                        std::boxed::Box<crate::model::UserOwnedGrafeasNote>,
1581                                    >>()?
1582                                    .unwrap_or_default(),
1583                                ),
1584                            );
1585                        }
1586                        __FieldTag::__update_time => {
1587                            if !fields.insert(__FieldTag::__update_time) {
1588                                return std::result::Result::Err(A::Error::duplicate_field(
1589                                    "multiple values for update_time",
1590                                ));
1591                            }
1592                            result.update_time =
1593                                map.next_value::<std::option::Option<wkt::Timestamp>>()?;
1594                        }
1595                        __FieldTag::Unknown(key) => {
1596                            let value = map.next_value::<serde_json::Value>()?;
1597                            result._unknown_fields.insert(key, value);
1598                        }
1599                    }
1600                }
1601                std::result::Result::Ok(result)
1602            }
1603        }
1604        deserializer.deserialize_any(Visitor)
1605    }
1606}
1607
1608#[doc(hidden)]
1609impl serde::ser::Serialize for Attestor {
1610    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1611    where
1612        S: serde::ser::Serializer,
1613    {
1614        use serde::ser::SerializeMap;
1615        #[allow(unused_imports)]
1616        use std::option::Option::Some;
1617        let mut state = serializer.serialize_map(std::option::Option::None)?;
1618        if !self.name.is_empty() {
1619            state.serialize_entry("name", &self.name)?;
1620        }
1621        if !self.description.is_empty() {
1622            state.serialize_entry("description", &self.description)?;
1623        }
1624        if let Some(value) = self.user_owned_grafeas_note() {
1625            state.serialize_entry("userOwnedGrafeasNote", value)?;
1626        }
1627        if self.update_time.is_some() {
1628            state.serialize_entry("updateTime", &self.update_time)?;
1629        }
1630        if !self._unknown_fields.is_empty() {
1631            for (key, value) in self._unknown_fields.iter() {
1632                state.serialize_entry(key, &value)?;
1633            }
1634        }
1635        state.end()
1636    }
1637}
1638
1639impl std::fmt::Debug for Attestor {
1640    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1641        let mut debug_struct = f.debug_struct("Attestor");
1642        debug_struct.field("name", &self.name);
1643        debug_struct.field("description", &self.description);
1644        debug_struct.field("update_time", &self.update_time);
1645        debug_struct.field("attestor_type", &self.attestor_type);
1646        if !self._unknown_fields.is_empty() {
1647            debug_struct.field("_unknown_fields", &self._unknown_fields);
1648        }
1649        debug_struct.finish()
1650    }
1651}
1652
1653/// Defines additional types related to [Attestor].
1654pub mod attestor {
1655    #[allow(unused_imports)]
1656    use super::*;
1657
1658    #[derive(Clone, Debug, PartialEq)]
1659    #[non_exhaustive]
1660    pub enum AttestorType {
1661        /// This specifies how an attestation will be read, and how it will be used
1662        /// during policy enforcement.
1663        UserOwnedGrafeasNote(std::boxed::Box<crate::model::UserOwnedGrafeasNote>),
1664    }
1665}
1666
1667/// An [user owned Grafeas note][google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote] references a Grafeas
1668/// Attestation.Authority Note created by the user.
1669///
1670/// [google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote]: crate::model::UserOwnedGrafeasNote
1671#[derive(Clone, Default, PartialEq)]
1672#[non_exhaustive]
1673pub struct UserOwnedGrafeasNote {
1674    /// Required. The Grafeas resource name of a Attestation.Authority Note,
1675    /// created by the user, in the format: `projects/*/notes/*`. This field may
1676    /// not be updated.
1677    ///
1678    /// An attestation by this attestor is stored as a Grafeas
1679    /// Attestation.Authority Occurrence that names a container image and that
1680    /// links to this Note. Grafeas is an external dependency.
1681    pub note_reference: std::string::String,
1682
1683    /// Optional. Public keys that verify attestations signed by this
1684    /// attestor.  This field may be updated.
1685    ///
1686    /// If this field is non-empty, one of the specified public keys must
1687    /// verify that an attestation was signed by this attestor for the
1688    /// image specified in the admission request.
1689    ///
1690    /// If this field is empty, this attestor always returns that no
1691    /// valid attestations exist.
1692    pub public_keys: std::vec::Vec<crate::model::AttestorPublicKey>,
1693
1694    /// Output only. This field will contain the service account email address
1695    /// that this Attestor will use as the principal when querying Container
1696    /// Analysis. Attestor administrators must grant this service account the
1697    /// IAM role needed to read attestations from the [note_reference][Note] in
1698    /// Container Analysis (`containeranalysis.notes.occurrences.viewer`).
1699    ///
1700    /// This email address is fixed for the lifetime of the Attestor, but callers
1701    /// should not make any other assumptions about the service account email;
1702    /// future versions may use an email based on a different naming pattern.
1703    pub delegation_service_account_email: std::string::String,
1704
1705    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1706}
1707
1708impl UserOwnedGrafeasNote {
1709    pub fn new() -> Self {
1710        std::default::Default::default()
1711    }
1712
1713    /// Sets the value of [note_reference][crate::model::UserOwnedGrafeasNote::note_reference].
1714    pub fn set_note_reference<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1715        self.note_reference = v.into();
1716        self
1717    }
1718
1719    /// Sets the value of [public_keys][crate::model::UserOwnedGrafeasNote::public_keys].
1720    pub fn set_public_keys<T, V>(mut self, v: T) -> Self
1721    where
1722        T: std::iter::IntoIterator<Item = V>,
1723        V: std::convert::Into<crate::model::AttestorPublicKey>,
1724    {
1725        use std::iter::Iterator;
1726        self.public_keys = v.into_iter().map(|i| i.into()).collect();
1727        self
1728    }
1729
1730    /// Sets the value of [delegation_service_account_email][crate::model::UserOwnedGrafeasNote::delegation_service_account_email].
1731    pub fn set_delegation_service_account_email<T: std::convert::Into<std::string::String>>(
1732        mut self,
1733        v: T,
1734    ) -> Self {
1735        self.delegation_service_account_email = v.into();
1736        self
1737    }
1738}
1739
1740impl wkt::message::Message for UserOwnedGrafeasNote {
1741    fn typename() -> &'static str {
1742        "type.googleapis.com/google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote"
1743    }
1744}
1745
1746#[doc(hidden)]
1747impl<'de> serde::de::Deserialize<'de> for UserOwnedGrafeasNote {
1748    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1749    where
1750        D: serde::Deserializer<'de>,
1751    {
1752        #[allow(non_camel_case_types)]
1753        #[doc(hidden)]
1754        #[derive(PartialEq, Eq, Hash)]
1755        enum __FieldTag {
1756            __note_reference,
1757            __public_keys,
1758            __delegation_service_account_email,
1759            Unknown(std::string::String),
1760        }
1761        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1762            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1763            where
1764                D: serde::Deserializer<'de>,
1765            {
1766                struct Visitor;
1767                impl<'de> serde::de::Visitor<'de> for Visitor {
1768                    type Value = __FieldTag;
1769                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1770                        formatter.write_str("a field name for UserOwnedGrafeasNote")
1771                    }
1772                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1773                    where
1774                        E: serde::de::Error,
1775                    {
1776                        use std::result::Result::Ok;
1777                        use std::string::ToString;
1778                        match value {
1779                            "noteReference" => Ok(__FieldTag::__note_reference),
1780                            "note_reference" => Ok(__FieldTag::__note_reference),
1781                            "publicKeys" => Ok(__FieldTag::__public_keys),
1782                            "public_keys" => Ok(__FieldTag::__public_keys),
1783                            "delegationServiceAccountEmail" => {
1784                                Ok(__FieldTag::__delegation_service_account_email)
1785                            }
1786                            "delegation_service_account_email" => {
1787                                Ok(__FieldTag::__delegation_service_account_email)
1788                            }
1789                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1790                        }
1791                    }
1792                }
1793                deserializer.deserialize_identifier(Visitor)
1794            }
1795        }
1796        struct Visitor;
1797        impl<'de> serde::de::Visitor<'de> for Visitor {
1798            type Value = UserOwnedGrafeasNote;
1799            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1800                formatter.write_str("struct UserOwnedGrafeasNote")
1801            }
1802            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
1803            where
1804                A: serde::de::MapAccess<'de>,
1805            {
1806                #[allow(unused_imports)]
1807                use serde::de::Error;
1808                use std::option::Option::Some;
1809                let mut fields = std::collections::HashSet::new();
1810                let mut result = Self::Value::new();
1811                while let Some(tag) = map.next_key::<__FieldTag>()? {
1812                    #[allow(clippy::match_single_binding)]
1813                    match tag {
1814                        __FieldTag::__note_reference => {
1815                            if !fields.insert(__FieldTag::__note_reference) {
1816                                return std::result::Result::Err(A::Error::duplicate_field(
1817                                    "multiple values for note_reference",
1818                                ));
1819                            }
1820                            result.note_reference = map
1821                                .next_value::<std::option::Option<std::string::String>>()?
1822                                .unwrap_or_default();
1823                        }
1824                        __FieldTag::__public_keys => {
1825                            if !fields.insert(__FieldTag::__public_keys) {
1826                                return std::result::Result::Err(A::Error::duplicate_field(
1827                                    "multiple values for public_keys",
1828                                ));
1829                            }
1830                            result.public_keys =
1831                                map.next_value::<std::option::Option<
1832                                    std::vec::Vec<crate::model::AttestorPublicKey>,
1833                                >>()?
1834                                .unwrap_or_default();
1835                        }
1836                        __FieldTag::__delegation_service_account_email => {
1837                            if !fields.insert(__FieldTag::__delegation_service_account_email) {
1838                                return std::result::Result::Err(A::Error::duplicate_field(
1839                                    "multiple values for delegation_service_account_email",
1840                                ));
1841                            }
1842                            result.delegation_service_account_email = map
1843                                .next_value::<std::option::Option<std::string::String>>()?
1844                                .unwrap_or_default();
1845                        }
1846                        __FieldTag::Unknown(key) => {
1847                            let value = map.next_value::<serde_json::Value>()?;
1848                            result._unknown_fields.insert(key, value);
1849                        }
1850                    }
1851                }
1852                std::result::Result::Ok(result)
1853            }
1854        }
1855        deserializer.deserialize_any(Visitor)
1856    }
1857}
1858
1859#[doc(hidden)]
1860impl serde::ser::Serialize for UserOwnedGrafeasNote {
1861    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1862    where
1863        S: serde::ser::Serializer,
1864    {
1865        use serde::ser::SerializeMap;
1866        #[allow(unused_imports)]
1867        use std::option::Option::Some;
1868        let mut state = serializer.serialize_map(std::option::Option::None)?;
1869        if !self.note_reference.is_empty() {
1870            state.serialize_entry("noteReference", &self.note_reference)?;
1871        }
1872        if !self.public_keys.is_empty() {
1873            state.serialize_entry("publicKeys", &self.public_keys)?;
1874        }
1875        if !self.delegation_service_account_email.is_empty() {
1876            state.serialize_entry(
1877                "delegationServiceAccountEmail",
1878                &self.delegation_service_account_email,
1879            )?;
1880        }
1881        if !self._unknown_fields.is_empty() {
1882            for (key, value) in self._unknown_fields.iter() {
1883                state.serialize_entry(key, &value)?;
1884            }
1885        }
1886        state.end()
1887    }
1888}
1889
1890impl std::fmt::Debug for UserOwnedGrafeasNote {
1891    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1892        let mut debug_struct = f.debug_struct("UserOwnedGrafeasNote");
1893        debug_struct.field("note_reference", &self.note_reference);
1894        debug_struct.field("public_keys", &self.public_keys);
1895        debug_struct.field(
1896            "delegation_service_account_email",
1897            &self.delegation_service_account_email,
1898        );
1899        if !self._unknown_fields.is_empty() {
1900            debug_struct.field("_unknown_fields", &self._unknown_fields);
1901        }
1902        debug_struct.finish()
1903    }
1904}
1905
1906/// A public key in the PkixPublicKey format (see
1907/// <https://tools.ietf.org/html/rfc5280#section-4.1.2.7> for details).
1908/// Public keys of this type are typically textually encoded using the PEM
1909/// format.
1910#[derive(Clone, Default, PartialEq)]
1911#[non_exhaustive]
1912pub struct PkixPublicKey {
1913    /// A PEM-encoded public key, as described in
1914    /// <https://tools.ietf.org/html/rfc7468#section-13>
1915    pub public_key_pem: std::string::String,
1916
1917    /// The signature algorithm used to verify a message against a signature using
1918    /// this key.
1919    /// These signature algorithm must match the structure and any object
1920    /// identifiers encoded in `public_key_pem` (i.e. this algorithm must match
1921    /// that of the public key).
1922    pub signature_algorithm: crate::model::pkix_public_key::SignatureAlgorithm,
1923
1924    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1925}
1926
1927impl PkixPublicKey {
1928    pub fn new() -> Self {
1929        std::default::Default::default()
1930    }
1931
1932    /// Sets the value of [public_key_pem][crate::model::PkixPublicKey::public_key_pem].
1933    pub fn set_public_key_pem<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1934        self.public_key_pem = v.into();
1935        self
1936    }
1937
1938    /// Sets the value of [signature_algorithm][crate::model::PkixPublicKey::signature_algorithm].
1939    pub fn set_signature_algorithm<
1940        T: std::convert::Into<crate::model::pkix_public_key::SignatureAlgorithm>,
1941    >(
1942        mut self,
1943        v: T,
1944    ) -> Self {
1945        self.signature_algorithm = v.into();
1946        self
1947    }
1948}
1949
1950impl wkt::message::Message for PkixPublicKey {
1951    fn typename() -> &'static str {
1952        "type.googleapis.com/google.cloud.binaryauthorization.v1.PkixPublicKey"
1953    }
1954}
1955
1956#[doc(hidden)]
1957impl<'de> serde::de::Deserialize<'de> for PkixPublicKey {
1958    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1959    where
1960        D: serde::Deserializer<'de>,
1961    {
1962        #[allow(non_camel_case_types)]
1963        #[doc(hidden)]
1964        #[derive(PartialEq, Eq, Hash)]
1965        enum __FieldTag {
1966            __public_key_pem,
1967            __signature_algorithm,
1968            Unknown(std::string::String),
1969        }
1970        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
1971            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1972            where
1973                D: serde::Deserializer<'de>,
1974            {
1975                struct Visitor;
1976                impl<'de> serde::de::Visitor<'de> for Visitor {
1977                    type Value = __FieldTag;
1978                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
1979                        formatter.write_str("a field name for PkixPublicKey")
1980                    }
1981                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
1982                    where
1983                        E: serde::de::Error,
1984                    {
1985                        use std::result::Result::Ok;
1986                        use std::string::ToString;
1987                        match value {
1988                            "publicKeyPem" => Ok(__FieldTag::__public_key_pem),
1989                            "public_key_pem" => Ok(__FieldTag::__public_key_pem),
1990                            "signatureAlgorithm" => Ok(__FieldTag::__signature_algorithm),
1991                            "signature_algorithm" => Ok(__FieldTag::__signature_algorithm),
1992                            _ => Ok(__FieldTag::Unknown(value.to_string())),
1993                        }
1994                    }
1995                }
1996                deserializer.deserialize_identifier(Visitor)
1997            }
1998        }
1999        struct Visitor;
2000        impl<'de> serde::de::Visitor<'de> for Visitor {
2001            type Value = PkixPublicKey;
2002            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2003                formatter.write_str("struct PkixPublicKey")
2004            }
2005            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2006            where
2007                A: serde::de::MapAccess<'de>,
2008            {
2009                #[allow(unused_imports)]
2010                use serde::de::Error;
2011                use std::option::Option::Some;
2012                let mut fields = std::collections::HashSet::new();
2013                let mut result = Self::Value::new();
2014                while let Some(tag) = map.next_key::<__FieldTag>()? {
2015                    #[allow(clippy::match_single_binding)]
2016                    match tag {
2017                        __FieldTag::__public_key_pem => {
2018                            if !fields.insert(__FieldTag::__public_key_pem) {
2019                                return std::result::Result::Err(A::Error::duplicate_field(
2020                                    "multiple values for public_key_pem",
2021                                ));
2022                            }
2023                            result.public_key_pem = map
2024                                .next_value::<std::option::Option<std::string::String>>()?
2025                                .unwrap_or_default();
2026                        }
2027                        __FieldTag::__signature_algorithm => {
2028                            if !fields.insert(__FieldTag::__signature_algorithm) {
2029                                return std::result::Result::Err(A::Error::duplicate_field(
2030                                    "multiple values for signature_algorithm",
2031                                ));
2032                            }
2033                            result.signature_algorithm = map
2034                                .next_value::<std::option::Option<
2035                                    crate::model::pkix_public_key::SignatureAlgorithm,
2036                                >>()?
2037                                .unwrap_or_default();
2038                        }
2039                        __FieldTag::Unknown(key) => {
2040                            let value = map.next_value::<serde_json::Value>()?;
2041                            result._unknown_fields.insert(key, value);
2042                        }
2043                    }
2044                }
2045                std::result::Result::Ok(result)
2046            }
2047        }
2048        deserializer.deserialize_any(Visitor)
2049    }
2050}
2051
2052#[doc(hidden)]
2053impl serde::ser::Serialize for PkixPublicKey {
2054    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2055    where
2056        S: serde::ser::Serializer,
2057    {
2058        use serde::ser::SerializeMap;
2059        #[allow(unused_imports)]
2060        use std::option::Option::Some;
2061        let mut state = serializer.serialize_map(std::option::Option::None)?;
2062        if !self.public_key_pem.is_empty() {
2063            state.serialize_entry("publicKeyPem", &self.public_key_pem)?;
2064        }
2065        if !wkt::internal::is_default(&self.signature_algorithm) {
2066            state.serialize_entry("signatureAlgorithm", &self.signature_algorithm)?;
2067        }
2068        if !self._unknown_fields.is_empty() {
2069            for (key, value) in self._unknown_fields.iter() {
2070                state.serialize_entry(key, &value)?;
2071            }
2072        }
2073        state.end()
2074    }
2075}
2076
2077impl std::fmt::Debug for PkixPublicKey {
2078    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2079        let mut debug_struct = f.debug_struct("PkixPublicKey");
2080        debug_struct.field("public_key_pem", &self.public_key_pem);
2081        debug_struct.field("signature_algorithm", &self.signature_algorithm);
2082        if !self._unknown_fields.is_empty() {
2083            debug_struct.field("_unknown_fields", &self._unknown_fields);
2084        }
2085        debug_struct.finish()
2086    }
2087}
2088
2089/// Defines additional types related to [PkixPublicKey].
2090pub mod pkix_public_key {
2091    #[allow(unused_imports)]
2092    use super::*;
2093
2094    /// Represents a signature algorithm and other information necessary to verify
2095    /// signatures with a given public key.
2096    /// This is based primarily on the public key types supported by Tink's
2097    /// PemKeyType, which is in turn based on KMS's supported signing algorithms.
2098    /// See <https://cloud.google.com/kms/docs/algorithms>. In the future, BinAuthz
2099    /// might support additional public key types independently of Tink and/or KMS.
2100    ///
2101    /// # Working with unknown values
2102    ///
2103    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2104    /// additional enum variants at any time. Adding new variants is not considered
2105    /// a breaking change. Applications should write their code in anticipation of:
2106    ///
2107    /// - New values appearing in future releases of the client library, **and**
2108    /// - New values received dynamically, without application changes.
2109    ///
2110    /// Please consult the [Working with enums] section in the user guide for some
2111    /// guidelines.
2112    ///
2113    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
2114    #[derive(Clone, Debug, PartialEq)]
2115    #[non_exhaustive]
2116    pub enum SignatureAlgorithm {
2117        /// Not specified.
2118        Unspecified,
2119        /// RSASSA-PSS 2048 bit key with a SHA256 digest.
2120        RsaPss2048Sha256,
2121        /// RSASSA-PSS 3072 bit key with a SHA256 digest.
2122        RsaPss3072Sha256,
2123        /// RSASSA-PSS 4096 bit key with a SHA256 digest.
2124        RsaPss4096Sha256,
2125        /// RSASSA-PSS 4096 bit key with a SHA512 digest.
2126        RsaPss4096Sha512,
2127        /// RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest.
2128        RsaSignPkcs12048Sha256,
2129        /// RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest.
2130        RsaSignPkcs13072Sha256,
2131        /// RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest.
2132        RsaSignPkcs14096Sha256,
2133        /// RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest.
2134        RsaSignPkcs14096Sha512,
2135        /// ECDSA on the NIST P-256 curve with a SHA256 digest.
2136        EcdsaP256Sha256,
2137        /// ECDSA on the NIST P-256 curve with a SHA256 digest.
2138        EcSignP256Sha256,
2139        /// ECDSA on the NIST P-384 curve with a SHA384 digest.
2140        EcdsaP384Sha384,
2141        /// ECDSA on the NIST P-384 curve with a SHA384 digest.
2142        EcSignP384Sha384,
2143        /// ECDSA on the NIST P-521 curve with a SHA512 digest.
2144        EcdsaP521Sha512,
2145        /// ECDSA on the NIST P-521 curve with a SHA512 digest.
2146        EcSignP521Sha512,
2147        /// If set, the enum was initialized with an unknown value.
2148        ///
2149        /// Applications can examine the value using [SignatureAlgorithm::value] or
2150        /// [SignatureAlgorithm::name].
2151        UnknownValue(signature_algorithm::UnknownValue),
2152    }
2153
2154    #[doc(hidden)]
2155    pub mod signature_algorithm {
2156        #[allow(unused_imports)]
2157        use super::*;
2158        #[derive(Clone, Debug, PartialEq)]
2159        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2160    }
2161
2162    impl SignatureAlgorithm {
2163        /// Gets the enum value.
2164        ///
2165        /// Returns `None` if the enum contains an unknown value deserialized from
2166        /// the string representation of enums.
2167        pub fn value(&self) -> std::option::Option<i32> {
2168            match self {
2169                Self::Unspecified => std::option::Option::Some(0),
2170                Self::RsaPss2048Sha256 => std::option::Option::Some(1),
2171                Self::RsaPss3072Sha256 => std::option::Option::Some(2),
2172                Self::RsaPss4096Sha256 => std::option::Option::Some(3),
2173                Self::RsaPss4096Sha512 => std::option::Option::Some(4),
2174                Self::RsaSignPkcs12048Sha256 => std::option::Option::Some(5),
2175                Self::RsaSignPkcs13072Sha256 => std::option::Option::Some(6),
2176                Self::RsaSignPkcs14096Sha256 => std::option::Option::Some(7),
2177                Self::RsaSignPkcs14096Sha512 => std::option::Option::Some(8),
2178                Self::EcdsaP256Sha256 => std::option::Option::Some(9),
2179                Self::EcSignP256Sha256 => std::option::Option::Some(9),
2180                Self::EcdsaP384Sha384 => std::option::Option::Some(10),
2181                Self::EcSignP384Sha384 => std::option::Option::Some(10),
2182                Self::EcdsaP521Sha512 => std::option::Option::Some(11),
2183                Self::EcSignP521Sha512 => std::option::Option::Some(11),
2184                Self::UnknownValue(u) => u.0.value(),
2185            }
2186        }
2187
2188        /// Gets the enum value as a string.
2189        ///
2190        /// Returns `None` if the enum contains an unknown value deserialized from
2191        /// the integer representation of enums.
2192        pub fn name(&self) -> std::option::Option<&str> {
2193            match self {
2194                Self::Unspecified => std::option::Option::Some("SIGNATURE_ALGORITHM_UNSPECIFIED"),
2195                Self::RsaPss2048Sha256 => std::option::Option::Some("RSA_PSS_2048_SHA256"),
2196                Self::RsaPss3072Sha256 => std::option::Option::Some("RSA_PSS_3072_SHA256"),
2197                Self::RsaPss4096Sha256 => std::option::Option::Some("RSA_PSS_4096_SHA256"),
2198                Self::RsaPss4096Sha512 => std::option::Option::Some("RSA_PSS_4096_SHA512"),
2199                Self::RsaSignPkcs12048Sha256 => {
2200                    std::option::Option::Some("RSA_SIGN_PKCS1_2048_SHA256")
2201                }
2202                Self::RsaSignPkcs13072Sha256 => {
2203                    std::option::Option::Some("RSA_SIGN_PKCS1_3072_SHA256")
2204                }
2205                Self::RsaSignPkcs14096Sha256 => {
2206                    std::option::Option::Some("RSA_SIGN_PKCS1_4096_SHA256")
2207                }
2208                Self::RsaSignPkcs14096Sha512 => {
2209                    std::option::Option::Some("RSA_SIGN_PKCS1_4096_SHA512")
2210                }
2211                Self::EcdsaP256Sha256 => std::option::Option::Some("ECDSA_P256_SHA256"),
2212                Self::EcSignP256Sha256 => std::option::Option::Some("EC_SIGN_P256_SHA256"),
2213                Self::EcdsaP384Sha384 => std::option::Option::Some("ECDSA_P384_SHA384"),
2214                Self::EcSignP384Sha384 => std::option::Option::Some("EC_SIGN_P384_SHA384"),
2215                Self::EcdsaP521Sha512 => std::option::Option::Some("ECDSA_P521_SHA512"),
2216                Self::EcSignP521Sha512 => std::option::Option::Some("EC_SIGN_P521_SHA512"),
2217                Self::UnknownValue(u) => u.0.name(),
2218            }
2219        }
2220    }
2221
2222    impl std::default::Default for SignatureAlgorithm {
2223        fn default() -> Self {
2224            use std::convert::From;
2225            Self::from(0)
2226        }
2227    }
2228
2229    impl std::fmt::Display for SignatureAlgorithm {
2230        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2231            wkt::internal::display_enum(f, self.name(), self.value())
2232        }
2233    }
2234
2235    impl std::convert::From<i32> for SignatureAlgorithm {
2236        fn from(value: i32) -> Self {
2237            match value {
2238                0 => Self::Unspecified,
2239                1 => Self::RsaPss2048Sha256,
2240                2 => Self::RsaPss3072Sha256,
2241                3 => Self::RsaPss4096Sha256,
2242                4 => Self::RsaPss4096Sha512,
2243                5 => Self::RsaSignPkcs12048Sha256,
2244                6 => Self::RsaSignPkcs13072Sha256,
2245                7 => Self::RsaSignPkcs14096Sha256,
2246                8 => Self::RsaSignPkcs14096Sha512,
2247                9 => Self::EcdsaP256Sha256,
2248                10 => Self::EcdsaP384Sha384,
2249                11 => Self::EcdsaP521Sha512,
2250                _ => Self::UnknownValue(signature_algorithm::UnknownValue(
2251                    wkt::internal::UnknownEnumValue::Integer(value),
2252                )),
2253            }
2254        }
2255    }
2256
2257    impl std::convert::From<&str> for SignatureAlgorithm {
2258        fn from(value: &str) -> Self {
2259            use std::string::ToString;
2260            match value {
2261                "SIGNATURE_ALGORITHM_UNSPECIFIED" => Self::Unspecified,
2262                "RSA_PSS_2048_SHA256" => Self::RsaPss2048Sha256,
2263                "RSA_PSS_3072_SHA256" => Self::RsaPss3072Sha256,
2264                "RSA_PSS_4096_SHA256" => Self::RsaPss4096Sha256,
2265                "RSA_PSS_4096_SHA512" => Self::RsaPss4096Sha512,
2266                "RSA_SIGN_PKCS1_2048_SHA256" => Self::RsaSignPkcs12048Sha256,
2267                "RSA_SIGN_PKCS1_3072_SHA256" => Self::RsaSignPkcs13072Sha256,
2268                "RSA_SIGN_PKCS1_4096_SHA256" => Self::RsaSignPkcs14096Sha256,
2269                "RSA_SIGN_PKCS1_4096_SHA512" => Self::RsaSignPkcs14096Sha512,
2270                "ECDSA_P256_SHA256" => Self::EcdsaP256Sha256,
2271                "EC_SIGN_P256_SHA256" => Self::EcSignP256Sha256,
2272                "ECDSA_P384_SHA384" => Self::EcdsaP384Sha384,
2273                "EC_SIGN_P384_SHA384" => Self::EcSignP384Sha384,
2274                "ECDSA_P521_SHA512" => Self::EcdsaP521Sha512,
2275                "EC_SIGN_P521_SHA512" => Self::EcSignP521Sha512,
2276                _ => Self::UnknownValue(signature_algorithm::UnknownValue(
2277                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2278                )),
2279            }
2280        }
2281    }
2282
2283    impl serde::ser::Serialize for SignatureAlgorithm {
2284        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2285        where
2286            S: serde::Serializer,
2287        {
2288            match self {
2289                Self::Unspecified => serializer.serialize_i32(0),
2290                Self::RsaPss2048Sha256 => serializer.serialize_i32(1),
2291                Self::RsaPss3072Sha256 => serializer.serialize_i32(2),
2292                Self::RsaPss4096Sha256 => serializer.serialize_i32(3),
2293                Self::RsaPss4096Sha512 => serializer.serialize_i32(4),
2294                Self::RsaSignPkcs12048Sha256 => serializer.serialize_i32(5),
2295                Self::RsaSignPkcs13072Sha256 => serializer.serialize_i32(6),
2296                Self::RsaSignPkcs14096Sha256 => serializer.serialize_i32(7),
2297                Self::RsaSignPkcs14096Sha512 => serializer.serialize_i32(8),
2298                Self::EcdsaP256Sha256 => serializer.serialize_i32(9),
2299                Self::EcSignP256Sha256 => serializer.serialize_i32(9),
2300                Self::EcdsaP384Sha384 => serializer.serialize_i32(10),
2301                Self::EcSignP384Sha384 => serializer.serialize_i32(10),
2302                Self::EcdsaP521Sha512 => serializer.serialize_i32(11),
2303                Self::EcSignP521Sha512 => serializer.serialize_i32(11),
2304                Self::UnknownValue(u) => u.0.serialize(serializer),
2305            }
2306        }
2307    }
2308
2309    impl<'de> serde::de::Deserialize<'de> for SignatureAlgorithm {
2310        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2311        where
2312            D: serde::Deserializer<'de>,
2313        {
2314            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SignatureAlgorithm>::new(
2315                ".google.cloud.binaryauthorization.v1.PkixPublicKey.SignatureAlgorithm",
2316            ))
2317        }
2318    }
2319}
2320
2321/// An [attestor public key][google.cloud.binaryauthorization.v1.AttestorPublicKey] that will be used to verify
2322/// attestations signed by this attestor.
2323///
2324/// [google.cloud.binaryauthorization.v1.AttestorPublicKey]: crate::model::AttestorPublicKey
2325#[derive(Clone, Default, PartialEq)]
2326#[non_exhaustive]
2327pub struct AttestorPublicKey {
2328    /// Optional. A descriptive comment. This field may be updated.
2329    pub comment: std::string::String,
2330
2331    /// The ID of this public key.
2332    /// Signatures verified by BinAuthz must include the ID of the public key that
2333    /// can be used to verify them, and that ID must match the contents of this
2334    /// field exactly.
2335    /// Additional restrictions on this field can be imposed based on which public
2336    /// key type is encapsulated. See the documentation on `public_key` cases below
2337    /// for details.
2338    pub id: std::string::String,
2339
2340    pub public_key: std::option::Option<crate::model::attestor_public_key::PublicKey>,
2341
2342    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2343}
2344
2345impl AttestorPublicKey {
2346    pub fn new() -> Self {
2347        std::default::Default::default()
2348    }
2349
2350    /// Sets the value of [comment][crate::model::AttestorPublicKey::comment].
2351    pub fn set_comment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2352        self.comment = v.into();
2353        self
2354    }
2355
2356    /// Sets the value of [id][crate::model::AttestorPublicKey::id].
2357    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2358        self.id = v.into();
2359        self
2360    }
2361
2362    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key].
2363    ///
2364    /// Note that all the setters affecting `public_key` are mutually
2365    /// exclusive.
2366    pub fn set_public_key<
2367        T: std::convert::Into<std::option::Option<crate::model::attestor_public_key::PublicKey>>,
2368    >(
2369        mut self,
2370        v: T,
2371    ) -> Self {
2372        self.public_key = v.into();
2373        self
2374    }
2375
2376    /// The value of [public_key][crate::model::AttestorPublicKey::public_key]
2377    /// if it holds a `AsciiArmoredPgpPublicKey`, `None` if the field is not set or
2378    /// holds a different branch.
2379    pub fn ascii_armored_pgp_public_key(&self) -> std::option::Option<&std::string::String> {
2380        #[allow(unreachable_patterns)]
2381        self.public_key.as_ref().and_then(|v| match v {
2382            crate::model::attestor_public_key::PublicKey::AsciiArmoredPgpPublicKey(v) => {
2383                std::option::Option::Some(v)
2384            }
2385            _ => std::option::Option::None,
2386        })
2387    }
2388
2389    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key]
2390    /// to hold a `AsciiArmoredPgpPublicKey`.
2391    ///
2392    /// Note that all the setters affecting `public_key` are
2393    /// mutually exclusive.
2394    pub fn set_ascii_armored_pgp_public_key<T: std::convert::Into<std::string::String>>(
2395        mut self,
2396        v: T,
2397    ) -> Self {
2398        self.public_key = std::option::Option::Some(
2399            crate::model::attestor_public_key::PublicKey::AsciiArmoredPgpPublicKey(v.into()),
2400        );
2401        self
2402    }
2403
2404    /// The value of [public_key][crate::model::AttestorPublicKey::public_key]
2405    /// if it holds a `PkixPublicKey`, `None` if the field is not set or
2406    /// holds a different branch.
2407    pub fn pkix_public_key(
2408        &self,
2409    ) -> std::option::Option<&std::boxed::Box<crate::model::PkixPublicKey>> {
2410        #[allow(unreachable_patterns)]
2411        self.public_key.as_ref().and_then(|v| match v {
2412            crate::model::attestor_public_key::PublicKey::PkixPublicKey(v) => {
2413                std::option::Option::Some(v)
2414            }
2415            _ => std::option::Option::None,
2416        })
2417    }
2418
2419    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key]
2420    /// to hold a `PkixPublicKey`.
2421    ///
2422    /// Note that all the setters affecting `public_key` are
2423    /// mutually exclusive.
2424    pub fn set_pkix_public_key<
2425        T: std::convert::Into<std::boxed::Box<crate::model::PkixPublicKey>>,
2426    >(
2427        mut self,
2428        v: T,
2429    ) -> Self {
2430        self.public_key = std::option::Option::Some(
2431            crate::model::attestor_public_key::PublicKey::PkixPublicKey(v.into()),
2432        );
2433        self
2434    }
2435}
2436
2437impl wkt::message::Message for AttestorPublicKey {
2438    fn typename() -> &'static str {
2439        "type.googleapis.com/google.cloud.binaryauthorization.v1.AttestorPublicKey"
2440    }
2441}
2442
2443#[doc(hidden)]
2444impl<'de> serde::de::Deserialize<'de> for AttestorPublicKey {
2445    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2446    where
2447        D: serde::Deserializer<'de>,
2448    {
2449        #[allow(non_camel_case_types)]
2450        #[doc(hidden)]
2451        #[derive(PartialEq, Eq, Hash)]
2452        enum __FieldTag {
2453            __comment,
2454            __id,
2455            __ascii_armored_pgp_public_key,
2456            __pkix_public_key,
2457            Unknown(std::string::String),
2458        }
2459        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2460            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2461            where
2462                D: serde::Deserializer<'de>,
2463            {
2464                struct Visitor;
2465                impl<'de> serde::de::Visitor<'de> for Visitor {
2466                    type Value = __FieldTag;
2467                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2468                        formatter.write_str("a field name for AttestorPublicKey")
2469                    }
2470                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2471                    where
2472                        E: serde::de::Error,
2473                    {
2474                        use std::result::Result::Ok;
2475                        use std::string::ToString;
2476                        match value {
2477                            "comment" => Ok(__FieldTag::__comment),
2478                            "id" => Ok(__FieldTag::__id),
2479                            "asciiArmoredPgpPublicKey" => {
2480                                Ok(__FieldTag::__ascii_armored_pgp_public_key)
2481                            }
2482                            "ascii_armored_pgp_public_key" => {
2483                                Ok(__FieldTag::__ascii_armored_pgp_public_key)
2484                            }
2485                            "pkixPublicKey" => Ok(__FieldTag::__pkix_public_key),
2486                            "pkix_public_key" => Ok(__FieldTag::__pkix_public_key),
2487                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2488                        }
2489                    }
2490                }
2491                deserializer.deserialize_identifier(Visitor)
2492            }
2493        }
2494        struct Visitor;
2495        impl<'de> serde::de::Visitor<'de> for Visitor {
2496            type Value = AttestorPublicKey;
2497            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2498                formatter.write_str("struct AttestorPublicKey")
2499            }
2500            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2501            where
2502                A: serde::de::MapAccess<'de>,
2503            {
2504                #[allow(unused_imports)]
2505                use serde::de::Error;
2506                use std::option::Option::Some;
2507                let mut fields = std::collections::HashSet::new();
2508                let mut result = Self::Value::new();
2509                while let Some(tag) = map.next_key::<__FieldTag>()? {
2510                    #[allow(clippy::match_single_binding)]
2511                    match tag {
2512                        __FieldTag::__comment => {
2513                            if !fields.insert(__FieldTag::__comment) {
2514                                return std::result::Result::Err(A::Error::duplicate_field(
2515                                    "multiple values for comment",
2516                                ));
2517                            }
2518                            result.comment = map
2519                                .next_value::<std::option::Option<std::string::String>>()?
2520                                .unwrap_or_default();
2521                        }
2522                        __FieldTag::__id => {
2523                            if !fields.insert(__FieldTag::__id) {
2524                                return std::result::Result::Err(A::Error::duplicate_field(
2525                                    "multiple values for id",
2526                                ));
2527                            }
2528                            result.id = map
2529                                .next_value::<std::option::Option<std::string::String>>()?
2530                                .unwrap_or_default();
2531                        }
2532                        __FieldTag::__ascii_armored_pgp_public_key => {
2533                            if !fields.insert(__FieldTag::__ascii_armored_pgp_public_key) {
2534                                return std::result::Result::Err(A::Error::duplicate_field(
2535                                    "multiple values for ascii_armored_pgp_public_key",
2536                                ));
2537                            }
2538                            if result.public_key.is_some() {
2539                                return std::result::Result::Err(A::Error::duplicate_field(
2540                                    "multiple values for `public_key`, a oneof with full ID .google.cloud.binaryauthorization.v1.AttestorPublicKey.ascii_armored_pgp_public_key, latest field was asciiArmoredPgpPublicKey",
2541                                ));
2542                            }
2543                            result.public_key = std::option::Option::Some(
2544                                crate::model::attestor_public_key::PublicKey::AsciiArmoredPgpPublicKey(
2545                                    map.next_value::<std::option::Option<std::string::String>>()?.unwrap_or_default()
2546                                ),
2547                            );
2548                        }
2549                        __FieldTag::__pkix_public_key => {
2550                            if !fields.insert(__FieldTag::__pkix_public_key) {
2551                                return std::result::Result::Err(A::Error::duplicate_field(
2552                                    "multiple values for pkix_public_key",
2553                                ));
2554                            }
2555                            if result.public_key.is_some() {
2556                                return std::result::Result::Err(A::Error::duplicate_field(
2557                                    "multiple values for `public_key`, a oneof with full ID .google.cloud.binaryauthorization.v1.AttestorPublicKey.pkix_public_key, latest field was pkixPublicKey",
2558                                ));
2559                            }
2560                            result.public_key = std::option::Option::Some(
2561                                crate::model::attestor_public_key::PublicKey::PkixPublicKey(
2562                                    map.next_value::<std::option::Option<
2563                                        std::boxed::Box<crate::model::PkixPublicKey>,
2564                                    >>()?
2565                                    .unwrap_or_default(),
2566                                ),
2567                            );
2568                        }
2569                        __FieldTag::Unknown(key) => {
2570                            let value = map.next_value::<serde_json::Value>()?;
2571                            result._unknown_fields.insert(key, value);
2572                        }
2573                    }
2574                }
2575                std::result::Result::Ok(result)
2576            }
2577        }
2578        deserializer.deserialize_any(Visitor)
2579    }
2580}
2581
2582#[doc(hidden)]
2583impl serde::ser::Serialize for AttestorPublicKey {
2584    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2585    where
2586        S: serde::ser::Serializer,
2587    {
2588        use serde::ser::SerializeMap;
2589        #[allow(unused_imports)]
2590        use std::option::Option::Some;
2591        let mut state = serializer.serialize_map(std::option::Option::None)?;
2592        if !self.comment.is_empty() {
2593            state.serialize_entry("comment", &self.comment)?;
2594        }
2595        if !self.id.is_empty() {
2596            state.serialize_entry("id", &self.id)?;
2597        }
2598        if let Some(value) = self.ascii_armored_pgp_public_key() {
2599            state.serialize_entry("asciiArmoredPgpPublicKey", value)?;
2600        }
2601        if let Some(value) = self.pkix_public_key() {
2602            state.serialize_entry("pkixPublicKey", value)?;
2603        }
2604        if !self._unknown_fields.is_empty() {
2605            for (key, value) in self._unknown_fields.iter() {
2606                state.serialize_entry(key, &value)?;
2607            }
2608        }
2609        state.end()
2610    }
2611}
2612
2613impl std::fmt::Debug for AttestorPublicKey {
2614    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2615        let mut debug_struct = f.debug_struct("AttestorPublicKey");
2616        debug_struct.field("comment", &self.comment);
2617        debug_struct.field("id", &self.id);
2618        debug_struct.field("public_key", &self.public_key);
2619        if !self._unknown_fields.is_empty() {
2620            debug_struct.field("_unknown_fields", &self._unknown_fields);
2621        }
2622        debug_struct.finish()
2623    }
2624}
2625
2626/// Defines additional types related to [AttestorPublicKey].
2627pub mod attestor_public_key {
2628    #[allow(unused_imports)]
2629    use super::*;
2630
2631    #[derive(Clone, Debug, PartialEq)]
2632    #[non_exhaustive]
2633    pub enum PublicKey {
2634        /// ASCII-armored representation of a PGP public key, as the entire output by
2635        /// the command `gpg --export --armor foo@example.com` (either LF or CRLF
2636        /// line endings).
2637        /// When using this field, `id` should be left blank.  The BinAuthz API
2638        /// handlers will calculate the ID and fill it in automatically.  BinAuthz
2639        /// computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as
2640        /// upper-case hex.  If `id` is provided by the caller, it will be
2641        /// overwritten by the API-calculated ID.
2642        AsciiArmoredPgpPublicKey(std::string::String),
2643        /// A raw PKIX SubjectPublicKeyInfo format public key.
2644        ///
2645        /// NOTE: `id` may be explicitly provided by the caller when using this
2646        /// type of public key, but it MUST be a valid RFC3986 URI. If `id` is left
2647        /// blank, a default one will be computed based on the digest of the DER
2648        /// encoding of the public key.
2649        PkixPublicKey(std::boxed::Box<crate::model::PkixPublicKey>),
2650    }
2651}
2652
2653/// Request message for [BinauthzManagementService.GetPolicy][].
2654#[derive(Clone, Default, PartialEq)]
2655#[non_exhaustive]
2656pub struct GetPolicyRequest {
2657    /// Required. The resource name of the [policy][google.cloud.binaryauthorization.v1.Policy] to retrieve,
2658    /// in the format `projects/*/policy`.
2659    ///
2660    /// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
2661    pub name: std::string::String,
2662
2663    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2664}
2665
2666impl GetPolicyRequest {
2667    pub fn new() -> Self {
2668        std::default::Default::default()
2669    }
2670
2671    /// Sets the value of [name][crate::model::GetPolicyRequest::name].
2672    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2673        self.name = v.into();
2674        self
2675    }
2676}
2677
2678impl wkt::message::Message for GetPolicyRequest {
2679    fn typename() -> &'static str {
2680        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetPolicyRequest"
2681    }
2682}
2683
2684#[doc(hidden)]
2685impl<'de> serde::de::Deserialize<'de> for GetPolicyRequest {
2686    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2687    where
2688        D: serde::Deserializer<'de>,
2689    {
2690        #[allow(non_camel_case_types)]
2691        #[doc(hidden)]
2692        #[derive(PartialEq, Eq, Hash)]
2693        enum __FieldTag {
2694            __name,
2695            Unknown(std::string::String),
2696        }
2697        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2698            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2699            where
2700                D: serde::Deserializer<'de>,
2701            {
2702                struct Visitor;
2703                impl<'de> serde::de::Visitor<'de> for Visitor {
2704                    type Value = __FieldTag;
2705                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2706                        formatter.write_str("a field name for GetPolicyRequest")
2707                    }
2708                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2709                    where
2710                        E: serde::de::Error,
2711                    {
2712                        use std::result::Result::Ok;
2713                        use std::string::ToString;
2714                        match value {
2715                            "name" => Ok(__FieldTag::__name),
2716                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2717                        }
2718                    }
2719                }
2720                deserializer.deserialize_identifier(Visitor)
2721            }
2722        }
2723        struct Visitor;
2724        impl<'de> serde::de::Visitor<'de> for Visitor {
2725            type Value = GetPolicyRequest;
2726            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2727                formatter.write_str("struct GetPolicyRequest")
2728            }
2729            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2730            where
2731                A: serde::de::MapAccess<'de>,
2732            {
2733                #[allow(unused_imports)]
2734                use serde::de::Error;
2735                use std::option::Option::Some;
2736                let mut fields = std::collections::HashSet::new();
2737                let mut result = Self::Value::new();
2738                while let Some(tag) = map.next_key::<__FieldTag>()? {
2739                    #[allow(clippy::match_single_binding)]
2740                    match tag {
2741                        __FieldTag::__name => {
2742                            if !fields.insert(__FieldTag::__name) {
2743                                return std::result::Result::Err(A::Error::duplicate_field(
2744                                    "multiple values for name",
2745                                ));
2746                            }
2747                            result.name = map
2748                                .next_value::<std::option::Option<std::string::String>>()?
2749                                .unwrap_or_default();
2750                        }
2751                        __FieldTag::Unknown(key) => {
2752                            let value = map.next_value::<serde_json::Value>()?;
2753                            result._unknown_fields.insert(key, value);
2754                        }
2755                    }
2756                }
2757                std::result::Result::Ok(result)
2758            }
2759        }
2760        deserializer.deserialize_any(Visitor)
2761    }
2762}
2763
2764#[doc(hidden)]
2765impl serde::ser::Serialize for GetPolicyRequest {
2766    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2767    where
2768        S: serde::ser::Serializer,
2769    {
2770        use serde::ser::SerializeMap;
2771        #[allow(unused_imports)]
2772        use std::option::Option::Some;
2773        let mut state = serializer.serialize_map(std::option::Option::None)?;
2774        if !self.name.is_empty() {
2775            state.serialize_entry("name", &self.name)?;
2776        }
2777        if !self._unknown_fields.is_empty() {
2778            for (key, value) in self._unknown_fields.iter() {
2779                state.serialize_entry(key, &value)?;
2780            }
2781        }
2782        state.end()
2783    }
2784}
2785
2786impl std::fmt::Debug for GetPolicyRequest {
2787    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2788        let mut debug_struct = f.debug_struct("GetPolicyRequest");
2789        debug_struct.field("name", &self.name);
2790        if !self._unknown_fields.is_empty() {
2791            debug_struct.field("_unknown_fields", &self._unknown_fields);
2792        }
2793        debug_struct.finish()
2794    }
2795}
2796
2797/// Request message for [BinauthzManagementService.UpdatePolicy][].
2798#[derive(Clone, Default, PartialEq)]
2799#[non_exhaustive]
2800pub struct UpdatePolicyRequest {
2801    /// Required. A new or updated [policy][google.cloud.binaryauthorization.v1.Policy] value. The service will
2802    /// overwrite the [policy name][google.cloud.binaryauthorization.v1.Policy.name] field with the resource name in
2803    /// the request URL, in the format `projects/*/policy`.
2804    ///
2805    /// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
2806    /// [google.cloud.binaryauthorization.v1.Policy.name]: crate::model::Policy::name
2807    pub policy: std::option::Option<crate::model::Policy>,
2808
2809    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2810}
2811
2812impl UpdatePolicyRequest {
2813    pub fn new() -> Self {
2814        std::default::Default::default()
2815    }
2816
2817    /// Sets the value of [policy][crate::model::UpdatePolicyRequest::policy].
2818    pub fn set_policy<T>(mut self, v: T) -> Self
2819    where
2820        T: std::convert::Into<crate::model::Policy>,
2821    {
2822        self.policy = std::option::Option::Some(v.into());
2823        self
2824    }
2825
2826    /// Sets or clears the value of [policy][crate::model::UpdatePolicyRequest::policy].
2827    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
2828    where
2829        T: std::convert::Into<crate::model::Policy>,
2830    {
2831        self.policy = v.map(|x| x.into());
2832        self
2833    }
2834}
2835
2836impl wkt::message::Message for UpdatePolicyRequest {
2837    fn typename() -> &'static str {
2838        "type.googleapis.com/google.cloud.binaryauthorization.v1.UpdatePolicyRequest"
2839    }
2840}
2841
2842#[doc(hidden)]
2843impl<'de> serde::de::Deserialize<'de> for UpdatePolicyRequest {
2844    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2845    where
2846        D: serde::Deserializer<'de>,
2847    {
2848        #[allow(non_camel_case_types)]
2849        #[doc(hidden)]
2850        #[derive(PartialEq, Eq, Hash)]
2851        enum __FieldTag {
2852            __policy,
2853            Unknown(std::string::String),
2854        }
2855        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
2856            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2857            where
2858                D: serde::Deserializer<'de>,
2859            {
2860                struct Visitor;
2861                impl<'de> serde::de::Visitor<'de> for Visitor {
2862                    type Value = __FieldTag;
2863                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2864                        formatter.write_str("a field name for UpdatePolicyRequest")
2865                    }
2866                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
2867                    where
2868                        E: serde::de::Error,
2869                    {
2870                        use std::result::Result::Ok;
2871                        use std::string::ToString;
2872                        match value {
2873                            "policy" => Ok(__FieldTag::__policy),
2874                            _ => Ok(__FieldTag::Unknown(value.to_string())),
2875                        }
2876                    }
2877                }
2878                deserializer.deserialize_identifier(Visitor)
2879            }
2880        }
2881        struct Visitor;
2882        impl<'de> serde::de::Visitor<'de> for Visitor {
2883            type Value = UpdatePolicyRequest;
2884            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
2885                formatter.write_str("struct UpdatePolicyRequest")
2886            }
2887            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
2888            where
2889                A: serde::de::MapAccess<'de>,
2890            {
2891                #[allow(unused_imports)]
2892                use serde::de::Error;
2893                use std::option::Option::Some;
2894                let mut fields = std::collections::HashSet::new();
2895                let mut result = Self::Value::new();
2896                while let Some(tag) = map.next_key::<__FieldTag>()? {
2897                    #[allow(clippy::match_single_binding)]
2898                    match tag {
2899                        __FieldTag::__policy => {
2900                            if !fields.insert(__FieldTag::__policy) {
2901                                return std::result::Result::Err(A::Error::duplicate_field(
2902                                    "multiple values for policy",
2903                                ));
2904                            }
2905                            result.policy =
2906                                map.next_value::<std::option::Option<crate::model::Policy>>()?;
2907                        }
2908                        __FieldTag::Unknown(key) => {
2909                            let value = map.next_value::<serde_json::Value>()?;
2910                            result._unknown_fields.insert(key, value);
2911                        }
2912                    }
2913                }
2914                std::result::Result::Ok(result)
2915            }
2916        }
2917        deserializer.deserialize_any(Visitor)
2918    }
2919}
2920
2921#[doc(hidden)]
2922impl serde::ser::Serialize for UpdatePolicyRequest {
2923    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2924    where
2925        S: serde::ser::Serializer,
2926    {
2927        use serde::ser::SerializeMap;
2928        #[allow(unused_imports)]
2929        use std::option::Option::Some;
2930        let mut state = serializer.serialize_map(std::option::Option::None)?;
2931        if self.policy.is_some() {
2932            state.serialize_entry("policy", &self.policy)?;
2933        }
2934        if !self._unknown_fields.is_empty() {
2935            for (key, value) in self._unknown_fields.iter() {
2936                state.serialize_entry(key, &value)?;
2937            }
2938        }
2939        state.end()
2940    }
2941}
2942
2943impl std::fmt::Debug for UpdatePolicyRequest {
2944    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2945        let mut debug_struct = f.debug_struct("UpdatePolicyRequest");
2946        debug_struct.field("policy", &self.policy);
2947        if !self._unknown_fields.is_empty() {
2948            debug_struct.field("_unknown_fields", &self._unknown_fields);
2949        }
2950        debug_struct.finish()
2951    }
2952}
2953
2954/// Request message for [BinauthzManagementService.CreateAttestor][].
2955#[derive(Clone, Default, PartialEq)]
2956#[non_exhaustive]
2957pub struct CreateAttestorRequest {
2958    /// Required. The parent of this [attestor][google.cloud.binaryauthorization.v1.Attestor].
2959    ///
2960    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2961    pub parent: std::string::String,
2962
2963    /// Required. The [attestors][google.cloud.binaryauthorization.v1.Attestor] ID.
2964    ///
2965    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2966    pub attestor_id: std::string::String,
2967
2968    /// Required. The initial [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will
2969    /// overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name,
2970    /// in the format `projects/*/attestors/*`.
2971    ///
2972    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2973    /// [google.cloud.binaryauthorization.v1.Attestor.name]: crate::model::Attestor::name
2974    pub attestor: std::option::Option<crate::model::Attestor>,
2975
2976    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2977}
2978
2979impl CreateAttestorRequest {
2980    pub fn new() -> Self {
2981        std::default::Default::default()
2982    }
2983
2984    /// Sets the value of [parent][crate::model::CreateAttestorRequest::parent].
2985    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2986        self.parent = v.into();
2987        self
2988    }
2989
2990    /// Sets the value of [attestor_id][crate::model::CreateAttestorRequest::attestor_id].
2991    pub fn set_attestor_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2992        self.attestor_id = v.into();
2993        self
2994    }
2995
2996    /// Sets the value of [attestor][crate::model::CreateAttestorRequest::attestor].
2997    pub fn set_attestor<T>(mut self, v: T) -> Self
2998    where
2999        T: std::convert::Into<crate::model::Attestor>,
3000    {
3001        self.attestor = std::option::Option::Some(v.into());
3002        self
3003    }
3004
3005    /// Sets or clears the value of [attestor][crate::model::CreateAttestorRequest::attestor].
3006    pub fn set_or_clear_attestor<T>(mut self, v: std::option::Option<T>) -> Self
3007    where
3008        T: std::convert::Into<crate::model::Attestor>,
3009    {
3010        self.attestor = v.map(|x| x.into());
3011        self
3012    }
3013}
3014
3015impl wkt::message::Message for CreateAttestorRequest {
3016    fn typename() -> &'static str {
3017        "type.googleapis.com/google.cloud.binaryauthorization.v1.CreateAttestorRequest"
3018    }
3019}
3020
3021#[doc(hidden)]
3022impl<'de> serde::de::Deserialize<'de> for CreateAttestorRequest {
3023    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3024    where
3025        D: serde::Deserializer<'de>,
3026    {
3027        #[allow(non_camel_case_types)]
3028        #[doc(hidden)]
3029        #[derive(PartialEq, Eq, Hash)]
3030        enum __FieldTag {
3031            __parent,
3032            __attestor_id,
3033            __attestor,
3034            Unknown(std::string::String),
3035        }
3036        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3037            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3038            where
3039                D: serde::Deserializer<'de>,
3040            {
3041                struct Visitor;
3042                impl<'de> serde::de::Visitor<'de> for Visitor {
3043                    type Value = __FieldTag;
3044                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3045                        formatter.write_str("a field name for CreateAttestorRequest")
3046                    }
3047                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3048                    where
3049                        E: serde::de::Error,
3050                    {
3051                        use std::result::Result::Ok;
3052                        use std::string::ToString;
3053                        match value {
3054                            "parent" => Ok(__FieldTag::__parent),
3055                            "attestorId" => Ok(__FieldTag::__attestor_id),
3056                            "attestor_id" => Ok(__FieldTag::__attestor_id),
3057                            "attestor" => Ok(__FieldTag::__attestor),
3058                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3059                        }
3060                    }
3061                }
3062                deserializer.deserialize_identifier(Visitor)
3063            }
3064        }
3065        struct Visitor;
3066        impl<'de> serde::de::Visitor<'de> for Visitor {
3067            type Value = CreateAttestorRequest;
3068            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3069                formatter.write_str("struct CreateAttestorRequest")
3070            }
3071            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3072            where
3073                A: serde::de::MapAccess<'de>,
3074            {
3075                #[allow(unused_imports)]
3076                use serde::de::Error;
3077                use std::option::Option::Some;
3078                let mut fields = std::collections::HashSet::new();
3079                let mut result = Self::Value::new();
3080                while let Some(tag) = map.next_key::<__FieldTag>()? {
3081                    #[allow(clippy::match_single_binding)]
3082                    match tag {
3083                        __FieldTag::__parent => {
3084                            if !fields.insert(__FieldTag::__parent) {
3085                                return std::result::Result::Err(A::Error::duplicate_field(
3086                                    "multiple values for parent",
3087                                ));
3088                            }
3089                            result.parent = map
3090                                .next_value::<std::option::Option<std::string::String>>()?
3091                                .unwrap_or_default();
3092                        }
3093                        __FieldTag::__attestor_id => {
3094                            if !fields.insert(__FieldTag::__attestor_id) {
3095                                return std::result::Result::Err(A::Error::duplicate_field(
3096                                    "multiple values for attestor_id",
3097                                ));
3098                            }
3099                            result.attestor_id = map
3100                                .next_value::<std::option::Option<std::string::String>>()?
3101                                .unwrap_or_default();
3102                        }
3103                        __FieldTag::__attestor => {
3104                            if !fields.insert(__FieldTag::__attestor) {
3105                                return std::result::Result::Err(A::Error::duplicate_field(
3106                                    "multiple values for attestor",
3107                                ));
3108                            }
3109                            result.attestor =
3110                                map.next_value::<std::option::Option<crate::model::Attestor>>()?;
3111                        }
3112                        __FieldTag::Unknown(key) => {
3113                            let value = map.next_value::<serde_json::Value>()?;
3114                            result._unknown_fields.insert(key, value);
3115                        }
3116                    }
3117                }
3118                std::result::Result::Ok(result)
3119            }
3120        }
3121        deserializer.deserialize_any(Visitor)
3122    }
3123}
3124
3125#[doc(hidden)]
3126impl serde::ser::Serialize for CreateAttestorRequest {
3127    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3128    where
3129        S: serde::ser::Serializer,
3130    {
3131        use serde::ser::SerializeMap;
3132        #[allow(unused_imports)]
3133        use std::option::Option::Some;
3134        let mut state = serializer.serialize_map(std::option::Option::None)?;
3135        if !self.parent.is_empty() {
3136            state.serialize_entry("parent", &self.parent)?;
3137        }
3138        if !self.attestor_id.is_empty() {
3139            state.serialize_entry("attestorId", &self.attestor_id)?;
3140        }
3141        if self.attestor.is_some() {
3142            state.serialize_entry("attestor", &self.attestor)?;
3143        }
3144        if !self._unknown_fields.is_empty() {
3145            for (key, value) in self._unknown_fields.iter() {
3146                state.serialize_entry(key, &value)?;
3147            }
3148        }
3149        state.end()
3150    }
3151}
3152
3153impl std::fmt::Debug for CreateAttestorRequest {
3154    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3155        let mut debug_struct = f.debug_struct("CreateAttestorRequest");
3156        debug_struct.field("parent", &self.parent);
3157        debug_struct.field("attestor_id", &self.attestor_id);
3158        debug_struct.field("attestor", &self.attestor);
3159        if !self._unknown_fields.is_empty() {
3160            debug_struct.field("_unknown_fields", &self._unknown_fields);
3161        }
3162        debug_struct.finish()
3163    }
3164}
3165
3166/// Request message for [BinauthzManagementService.GetAttestor][].
3167#[derive(Clone, Default, PartialEq)]
3168#[non_exhaustive]
3169pub struct GetAttestorRequest {
3170    /// Required. The name of the [attestor][google.cloud.binaryauthorization.v1.Attestor] to retrieve, in the format
3171    /// `projects/*/attestors/*`.
3172    ///
3173    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
3174    pub name: std::string::String,
3175
3176    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3177}
3178
3179impl GetAttestorRequest {
3180    pub fn new() -> Self {
3181        std::default::Default::default()
3182    }
3183
3184    /// Sets the value of [name][crate::model::GetAttestorRequest::name].
3185    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3186        self.name = v.into();
3187        self
3188    }
3189}
3190
3191impl wkt::message::Message for GetAttestorRequest {
3192    fn typename() -> &'static str {
3193        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetAttestorRequest"
3194    }
3195}
3196
3197#[doc(hidden)]
3198impl<'de> serde::de::Deserialize<'de> for GetAttestorRequest {
3199    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3200    where
3201        D: serde::Deserializer<'de>,
3202    {
3203        #[allow(non_camel_case_types)]
3204        #[doc(hidden)]
3205        #[derive(PartialEq, Eq, Hash)]
3206        enum __FieldTag {
3207            __name,
3208            Unknown(std::string::String),
3209        }
3210        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3211            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3212            where
3213                D: serde::Deserializer<'de>,
3214            {
3215                struct Visitor;
3216                impl<'de> serde::de::Visitor<'de> for Visitor {
3217                    type Value = __FieldTag;
3218                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3219                        formatter.write_str("a field name for GetAttestorRequest")
3220                    }
3221                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3222                    where
3223                        E: serde::de::Error,
3224                    {
3225                        use std::result::Result::Ok;
3226                        use std::string::ToString;
3227                        match value {
3228                            "name" => Ok(__FieldTag::__name),
3229                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3230                        }
3231                    }
3232                }
3233                deserializer.deserialize_identifier(Visitor)
3234            }
3235        }
3236        struct Visitor;
3237        impl<'de> serde::de::Visitor<'de> for Visitor {
3238            type Value = GetAttestorRequest;
3239            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3240                formatter.write_str("struct GetAttestorRequest")
3241            }
3242            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3243            where
3244                A: serde::de::MapAccess<'de>,
3245            {
3246                #[allow(unused_imports)]
3247                use serde::de::Error;
3248                use std::option::Option::Some;
3249                let mut fields = std::collections::HashSet::new();
3250                let mut result = Self::Value::new();
3251                while let Some(tag) = map.next_key::<__FieldTag>()? {
3252                    #[allow(clippy::match_single_binding)]
3253                    match tag {
3254                        __FieldTag::__name => {
3255                            if !fields.insert(__FieldTag::__name) {
3256                                return std::result::Result::Err(A::Error::duplicate_field(
3257                                    "multiple values for name",
3258                                ));
3259                            }
3260                            result.name = map
3261                                .next_value::<std::option::Option<std::string::String>>()?
3262                                .unwrap_or_default();
3263                        }
3264                        __FieldTag::Unknown(key) => {
3265                            let value = map.next_value::<serde_json::Value>()?;
3266                            result._unknown_fields.insert(key, value);
3267                        }
3268                    }
3269                }
3270                std::result::Result::Ok(result)
3271            }
3272        }
3273        deserializer.deserialize_any(Visitor)
3274    }
3275}
3276
3277#[doc(hidden)]
3278impl serde::ser::Serialize for GetAttestorRequest {
3279    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3280    where
3281        S: serde::ser::Serializer,
3282    {
3283        use serde::ser::SerializeMap;
3284        #[allow(unused_imports)]
3285        use std::option::Option::Some;
3286        let mut state = serializer.serialize_map(std::option::Option::None)?;
3287        if !self.name.is_empty() {
3288            state.serialize_entry("name", &self.name)?;
3289        }
3290        if !self._unknown_fields.is_empty() {
3291            for (key, value) in self._unknown_fields.iter() {
3292                state.serialize_entry(key, &value)?;
3293            }
3294        }
3295        state.end()
3296    }
3297}
3298
3299impl std::fmt::Debug for GetAttestorRequest {
3300    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3301        let mut debug_struct = f.debug_struct("GetAttestorRequest");
3302        debug_struct.field("name", &self.name);
3303        if !self._unknown_fields.is_empty() {
3304            debug_struct.field("_unknown_fields", &self._unknown_fields);
3305        }
3306        debug_struct.finish()
3307    }
3308}
3309
3310/// Request message for [BinauthzManagementService.UpdateAttestor][].
3311#[derive(Clone, Default, PartialEq)]
3312#[non_exhaustive]
3313pub struct UpdateAttestorRequest {
3314    /// Required. The updated [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will
3315    /// overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name
3316    /// in the request URL, in the format `projects/*/attestors/*`.
3317    ///
3318    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
3319    /// [google.cloud.binaryauthorization.v1.Attestor.name]: crate::model::Attestor::name
3320    pub attestor: std::option::Option<crate::model::Attestor>,
3321
3322    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3323}
3324
3325impl UpdateAttestorRequest {
3326    pub fn new() -> Self {
3327        std::default::Default::default()
3328    }
3329
3330    /// Sets the value of [attestor][crate::model::UpdateAttestorRequest::attestor].
3331    pub fn set_attestor<T>(mut self, v: T) -> Self
3332    where
3333        T: std::convert::Into<crate::model::Attestor>,
3334    {
3335        self.attestor = std::option::Option::Some(v.into());
3336        self
3337    }
3338
3339    /// Sets or clears the value of [attestor][crate::model::UpdateAttestorRequest::attestor].
3340    pub fn set_or_clear_attestor<T>(mut self, v: std::option::Option<T>) -> Self
3341    where
3342        T: std::convert::Into<crate::model::Attestor>,
3343    {
3344        self.attestor = v.map(|x| x.into());
3345        self
3346    }
3347}
3348
3349impl wkt::message::Message for UpdateAttestorRequest {
3350    fn typename() -> &'static str {
3351        "type.googleapis.com/google.cloud.binaryauthorization.v1.UpdateAttestorRequest"
3352    }
3353}
3354
3355#[doc(hidden)]
3356impl<'de> serde::de::Deserialize<'de> for UpdateAttestorRequest {
3357    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3358    where
3359        D: serde::Deserializer<'de>,
3360    {
3361        #[allow(non_camel_case_types)]
3362        #[doc(hidden)]
3363        #[derive(PartialEq, Eq, Hash)]
3364        enum __FieldTag {
3365            __attestor,
3366            Unknown(std::string::String),
3367        }
3368        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3369            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3370            where
3371                D: serde::Deserializer<'de>,
3372            {
3373                struct Visitor;
3374                impl<'de> serde::de::Visitor<'de> for Visitor {
3375                    type Value = __FieldTag;
3376                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3377                        formatter.write_str("a field name for UpdateAttestorRequest")
3378                    }
3379                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3380                    where
3381                        E: serde::de::Error,
3382                    {
3383                        use std::result::Result::Ok;
3384                        use std::string::ToString;
3385                        match value {
3386                            "attestor" => Ok(__FieldTag::__attestor),
3387                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3388                        }
3389                    }
3390                }
3391                deserializer.deserialize_identifier(Visitor)
3392            }
3393        }
3394        struct Visitor;
3395        impl<'de> serde::de::Visitor<'de> for Visitor {
3396            type Value = UpdateAttestorRequest;
3397            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3398                formatter.write_str("struct UpdateAttestorRequest")
3399            }
3400            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3401            where
3402                A: serde::de::MapAccess<'de>,
3403            {
3404                #[allow(unused_imports)]
3405                use serde::de::Error;
3406                use std::option::Option::Some;
3407                let mut fields = std::collections::HashSet::new();
3408                let mut result = Self::Value::new();
3409                while let Some(tag) = map.next_key::<__FieldTag>()? {
3410                    #[allow(clippy::match_single_binding)]
3411                    match tag {
3412                        __FieldTag::__attestor => {
3413                            if !fields.insert(__FieldTag::__attestor) {
3414                                return std::result::Result::Err(A::Error::duplicate_field(
3415                                    "multiple values for attestor",
3416                                ));
3417                            }
3418                            result.attestor =
3419                                map.next_value::<std::option::Option<crate::model::Attestor>>()?;
3420                        }
3421                        __FieldTag::Unknown(key) => {
3422                            let value = map.next_value::<serde_json::Value>()?;
3423                            result._unknown_fields.insert(key, value);
3424                        }
3425                    }
3426                }
3427                std::result::Result::Ok(result)
3428            }
3429        }
3430        deserializer.deserialize_any(Visitor)
3431    }
3432}
3433
3434#[doc(hidden)]
3435impl serde::ser::Serialize for UpdateAttestorRequest {
3436    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3437    where
3438        S: serde::ser::Serializer,
3439    {
3440        use serde::ser::SerializeMap;
3441        #[allow(unused_imports)]
3442        use std::option::Option::Some;
3443        let mut state = serializer.serialize_map(std::option::Option::None)?;
3444        if self.attestor.is_some() {
3445            state.serialize_entry("attestor", &self.attestor)?;
3446        }
3447        if !self._unknown_fields.is_empty() {
3448            for (key, value) in self._unknown_fields.iter() {
3449                state.serialize_entry(key, &value)?;
3450            }
3451        }
3452        state.end()
3453    }
3454}
3455
3456impl std::fmt::Debug for UpdateAttestorRequest {
3457    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3458        let mut debug_struct = f.debug_struct("UpdateAttestorRequest");
3459        debug_struct.field("attestor", &self.attestor);
3460        if !self._unknown_fields.is_empty() {
3461            debug_struct.field("_unknown_fields", &self._unknown_fields);
3462        }
3463        debug_struct.finish()
3464    }
3465}
3466
3467/// Request message for [BinauthzManagementService.ListAttestors][].
3468#[derive(Clone, Default, PartialEq)]
3469#[non_exhaustive]
3470pub struct ListAttestorsRequest {
3471    /// Required. The resource name of the project associated with the
3472    /// [attestors][google.cloud.binaryauthorization.v1.Attestor], in the format `projects/*`.
3473    ///
3474    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
3475    pub parent: std::string::String,
3476
3477    /// Requested page size. The server may return fewer results than requested. If
3478    /// unspecified, the server will pick an appropriate default.
3479    pub page_size: i32,
3480
3481    /// A token identifying a page of results the server should return. Typically,
3482    /// this is the value of [ListAttestorsResponse.next_page_token][google.cloud.binaryauthorization.v1.ListAttestorsResponse.next_page_token] returned
3483    /// from the previous call to the `ListAttestors` method.
3484    ///
3485    /// [google.cloud.binaryauthorization.v1.ListAttestorsResponse.next_page_token]: crate::model::ListAttestorsResponse::next_page_token
3486    pub page_token: std::string::String,
3487
3488    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3489}
3490
3491impl ListAttestorsRequest {
3492    pub fn new() -> Self {
3493        std::default::Default::default()
3494    }
3495
3496    /// Sets the value of [parent][crate::model::ListAttestorsRequest::parent].
3497    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3498        self.parent = v.into();
3499        self
3500    }
3501
3502    /// Sets the value of [page_size][crate::model::ListAttestorsRequest::page_size].
3503    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
3504        self.page_size = v.into();
3505        self
3506    }
3507
3508    /// Sets the value of [page_token][crate::model::ListAttestorsRequest::page_token].
3509    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3510        self.page_token = v.into();
3511        self
3512    }
3513}
3514
3515impl wkt::message::Message for ListAttestorsRequest {
3516    fn typename() -> &'static str {
3517        "type.googleapis.com/google.cloud.binaryauthorization.v1.ListAttestorsRequest"
3518    }
3519}
3520
3521#[doc(hidden)]
3522impl<'de> serde::de::Deserialize<'de> for ListAttestorsRequest {
3523    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3524    where
3525        D: serde::Deserializer<'de>,
3526    {
3527        #[allow(non_camel_case_types)]
3528        #[doc(hidden)]
3529        #[derive(PartialEq, Eq, Hash)]
3530        enum __FieldTag {
3531            __parent,
3532            __page_size,
3533            __page_token,
3534            Unknown(std::string::String),
3535        }
3536        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3537            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3538            where
3539                D: serde::Deserializer<'de>,
3540            {
3541                struct Visitor;
3542                impl<'de> serde::de::Visitor<'de> for Visitor {
3543                    type Value = __FieldTag;
3544                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3545                        formatter.write_str("a field name for ListAttestorsRequest")
3546                    }
3547                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3548                    where
3549                        E: serde::de::Error,
3550                    {
3551                        use std::result::Result::Ok;
3552                        use std::string::ToString;
3553                        match value {
3554                            "parent" => Ok(__FieldTag::__parent),
3555                            "pageSize" => Ok(__FieldTag::__page_size),
3556                            "page_size" => Ok(__FieldTag::__page_size),
3557                            "pageToken" => Ok(__FieldTag::__page_token),
3558                            "page_token" => Ok(__FieldTag::__page_token),
3559                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3560                        }
3561                    }
3562                }
3563                deserializer.deserialize_identifier(Visitor)
3564            }
3565        }
3566        struct Visitor;
3567        impl<'de> serde::de::Visitor<'de> for Visitor {
3568            type Value = ListAttestorsRequest;
3569            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3570                formatter.write_str("struct ListAttestorsRequest")
3571            }
3572            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3573            where
3574                A: serde::de::MapAccess<'de>,
3575            {
3576                #[allow(unused_imports)]
3577                use serde::de::Error;
3578                use std::option::Option::Some;
3579                let mut fields = std::collections::HashSet::new();
3580                let mut result = Self::Value::new();
3581                while let Some(tag) = map.next_key::<__FieldTag>()? {
3582                    #[allow(clippy::match_single_binding)]
3583                    match tag {
3584                        __FieldTag::__parent => {
3585                            if !fields.insert(__FieldTag::__parent) {
3586                                return std::result::Result::Err(A::Error::duplicate_field(
3587                                    "multiple values for parent",
3588                                ));
3589                            }
3590                            result.parent = map
3591                                .next_value::<std::option::Option<std::string::String>>()?
3592                                .unwrap_or_default();
3593                        }
3594                        __FieldTag::__page_size => {
3595                            if !fields.insert(__FieldTag::__page_size) {
3596                                return std::result::Result::Err(A::Error::duplicate_field(
3597                                    "multiple values for page_size",
3598                                ));
3599                            }
3600                            struct __With(std::option::Option<i32>);
3601                            impl<'de> serde::de::Deserialize<'de> for __With {
3602                                fn deserialize<D>(
3603                                    deserializer: D,
3604                                ) -> std::result::Result<Self, D::Error>
3605                                where
3606                                    D: serde::de::Deserializer<'de>,
3607                                {
3608                                    serde_with::As::< std::option::Option<wkt::internal::I32> >::deserialize(deserializer).map(__With)
3609                                }
3610                            }
3611                            result.page_size = map.next_value::<__With>()?.0.unwrap_or_default();
3612                        }
3613                        __FieldTag::__page_token => {
3614                            if !fields.insert(__FieldTag::__page_token) {
3615                                return std::result::Result::Err(A::Error::duplicate_field(
3616                                    "multiple values for page_token",
3617                                ));
3618                            }
3619                            result.page_token = map
3620                                .next_value::<std::option::Option<std::string::String>>()?
3621                                .unwrap_or_default();
3622                        }
3623                        __FieldTag::Unknown(key) => {
3624                            let value = map.next_value::<serde_json::Value>()?;
3625                            result._unknown_fields.insert(key, value);
3626                        }
3627                    }
3628                }
3629                std::result::Result::Ok(result)
3630            }
3631        }
3632        deserializer.deserialize_any(Visitor)
3633    }
3634}
3635
3636#[doc(hidden)]
3637impl serde::ser::Serialize for ListAttestorsRequest {
3638    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3639    where
3640        S: serde::ser::Serializer,
3641    {
3642        use serde::ser::SerializeMap;
3643        #[allow(unused_imports)]
3644        use std::option::Option::Some;
3645        let mut state = serializer.serialize_map(std::option::Option::None)?;
3646        if !self.parent.is_empty() {
3647            state.serialize_entry("parent", &self.parent)?;
3648        }
3649        if !wkt::internal::is_default(&self.page_size) {
3650            struct __With<'a>(&'a i32);
3651            impl<'a> serde::ser::Serialize for __With<'a> {
3652                fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3653                where
3654                    S: serde::ser::Serializer,
3655                {
3656                    serde_with::As::<wkt::internal::I32>::serialize(self.0, serializer)
3657                }
3658            }
3659            state.serialize_entry("pageSize", &__With(&self.page_size))?;
3660        }
3661        if !self.page_token.is_empty() {
3662            state.serialize_entry("pageToken", &self.page_token)?;
3663        }
3664        if !self._unknown_fields.is_empty() {
3665            for (key, value) in self._unknown_fields.iter() {
3666                state.serialize_entry(key, &value)?;
3667            }
3668        }
3669        state.end()
3670    }
3671}
3672
3673impl std::fmt::Debug for ListAttestorsRequest {
3674    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3675        let mut debug_struct = f.debug_struct("ListAttestorsRequest");
3676        debug_struct.field("parent", &self.parent);
3677        debug_struct.field("page_size", &self.page_size);
3678        debug_struct.field("page_token", &self.page_token);
3679        if !self._unknown_fields.is_empty() {
3680            debug_struct.field("_unknown_fields", &self._unknown_fields);
3681        }
3682        debug_struct.finish()
3683    }
3684}
3685
3686/// Response message for [BinauthzManagementService.ListAttestors][].
3687#[derive(Clone, Default, PartialEq)]
3688#[non_exhaustive]
3689pub struct ListAttestorsResponse {
3690    /// The list of [attestors][google.cloud.binaryauthorization.v1.Attestor].
3691    ///
3692    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
3693    pub attestors: std::vec::Vec<crate::model::Attestor>,
3694
3695    /// A token to retrieve the next page of results. Pass this value in the
3696    /// [ListAttestorsRequest.page_token][google.cloud.binaryauthorization.v1.ListAttestorsRequest.page_token] field in the subsequent call to the
3697    /// `ListAttestors` method to retrieve the next page of results.
3698    ///
3699    /// [google.cloud.binaryauthorization.v1.ListAttestorsRequest.page_token]: crate::model::ListAttestorsRequest::page_token
3700    pub next_page_token: std::string::String,
3701
3702    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3703}
3704
3705impl ListAttestorsResponse {
3706    pub fn new() -> Self {
3707        std::default::Default::default()
3708    }
3709
3710    /// Sets the value of [attestors][crate::model::ListAttestorsResponse::attestors].
3711    pub fn set_attestors<T, V>(mut self, v: T) -> Self
3712    where
3713        T: std::iter::IntoIterator<Item = V>,
3714        V: std::convert::Into<crate::model::Attestor>,
3715    {
3716        use std::iter::Iterator;
3717        self.attestors = v.into_iter().map(|i| i.into()).collect();
3718        self
3719    }
3720
3721    /// Sets the value of [next_page_token][crate::model::ListAttestorsResponse::next_page_token].
3722    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3723        self.next_page_token = v.into();
3724        self
3725    }
3726}
3727
3728impl wkt::message::Message for ListAttestorsResponse {
3729    fn typename() -> &'static str {
3730        "type.googleapis.com/google.cloud.binaryauthorization.v1.ListAttestorsResponse"
3731    }
3732}
3733
3734#[doc(hidden)]
3735impl gax::paginator::internal::PageableResponse for ListAttestorsResponse {
3736    type PageItem = crate::model::Attestor;
3737
3738    fn items(self) -> std::vec::Vec<Self::PageItem> {
3739        self.attestors
3740    }
3741
3742    fn next_page_token(&self) -> std::string::String {
3743        use std::clone::Clone;
3744        self.next_page_token.clone()
3745    }
3746}
3747
3748#[doc(hidden)]
3749impl<'de> serde::de::Deserialize<'de> for ListAttestorsResponse {
3750    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3751    where
3752        D: serde::Deserializer<'de>,
3753    {
3754        #[allow(non_camel_case_types)]
3755        #[doc(hidden)]
3756        #[derive(PartialEq, Eq, Hash)]
3757        enum __FieldTag {
3758            __attestors,
3759            __next_page_token,
3760            Unknown(std::string::String),
3761        }
3762        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3763            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3764            where
3765                D: serde::Deserializer<'de>,
3766            {
3767                struct Visitor;
3768                impl<'de> serde::de::Visitor<'de> for Visitor {
3769                    type Value = __FieldTag;
3770                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3771                        formatter.write_str("a field name for ListAttestorsResponse")
3772                    }
3773                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3774                    where
3775                        E: serde::de::Error,
3776                    {
3777                        use std::result::Result::Ok;
3778                        use std::string::ToString;
3779                        match value {
3780                            "attestors" => Ok(__FieldTag::__attestors),
3781                            "nextPageToken" => Ok(__FieldTag::__next_page_token),
3782                            "next_page_token" => Ok(__FieldTag::__next_page_token),
3783                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3784                        }
3785                    }
3786                }
3787                deserializer.deserialize_identifier(Visitor)
3788            }
3789        }
3790        struct Visitor;
3791        impl<'de> serde::de::Visitor<'de> for Visitor {
3792            type Value = ListAttestorsResponse;
3793            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3794                formatter.write_str("struct ListAttestorsResponse")
3795            }
3796            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3797            where
3798                A: serde::de::MapAccess<'de>,
3799            {
3800                #[allow(unused_imports)]
3801                use serde::de::Error;
3802                use std::option::Option::Some;
3803                let mut fields = std::collections::HashSet::new();
3804                let mut result = Self::Value::new();
3805                while let Some(tag) = map.next_key::<__FieldTag>()? {
3806                    #[allow(clippy::match_single_binding)]
3807                    match tag {
3808                        __FieldTag::__attestors => {
3809                            if !fields.insert(__FieldTag::__attestors) {
3810                                return std::result::Result::Err(A::Error::duplicate_field(
3811                                    "multiple values for attestors",
3812                                ));
3813                            }
3814                            result.attestors = map.next_value::<std::option::Option<std::vec::Vec<crate::model::Attestor>>>()?.unwrap_or_default();
3815                        }
3816                        __FieldTag::__next_page_token => {
3817                            if !fields.insert(__FieldTag::__next_page_token) {
3818                                return std::result::Result::Err(A::Error::duplicate_field(
3819                                    "multiple values for next_page_token",
3820                                ));
3821                            }
3822                            result.next_page_token = map
3823                                .next_value::<std::option::Option<std::string::String>>()?
3824                                .unwrap_or_default();
3825                        }
3826                        __FieldTag::Unknown(key) => {
3827                            let value = map.next_value::<serde_json::Value>()?;
3828                            result._unknown_fields.insert(key, value);
3829                        }
3830                    }
3831                }
3832                std::result::Result::Ok(result)
3833            }
3834        }
3835        deserializer.deserialize_any(Visitor)
3836    }
3837}
3838
3839#[doc(hidden)]
3840impl serde::ser::Serialize for ListAttestorsResponse {
3841    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3842    where
3843        S: serde::ser::Serializer,
3844    {
3845        use serde::ser::SerializeMap;
3846        #[allow(unused_imports)]
3847        use std::option::Option::Some;
3848        let mut state = serializer.serialize_map(std::option::Option::None)?;
3849        if !self.attestors.is_empty() {
3850            state.serialize_entry("attestors", &self.attestors)?;
3851        }
3852        if !self.next_page_token.is_empty() {
3853            state.serialize_entry("nextPageToken", &self.next_page_token)?;
3854        }
3855        if !self._unknown_fields.is_empty() {
3856            for (key, value) in self._unknown_fields.iter() {
3857                state.serialize_entry(key, &value)?;
3858            }
3859        }
3860        state.end()
3861    }
3862}
3863
3864impl std::fmt::Debug for ListAttestorsResponse {
3865    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3866        let mut debug_struct = f.debug_struct("ListAttestorsResponse");
3867        debug_struct.field("attestors", &self.attestors);
3868        debug_struct.field("next_page_token", &self.next_page_token);
3869        if !self._unknown_fields.is_empty() {
3870            debug_struct.field("_unknown_fields", &self._unknown_fields);
3871        }
3872        debug_struct.finish()
3873    }
3874}
3875
3876/// Request message for [BinauthzManagementService.DeleteAttestor][].
3877#[derive(Clone, Default, PartialEq)]
3878#[non_exhaustive]
3879pub struct DeleteAttestorRequest {
3880    /// Required. The name of the [attestors][google.cloud.binaryauthorization.v1.Attestor] to delete, in the format
3881    /// `projects/*/attestors/*`.
3882    ///
3883    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
3884    pub name: std::string::String,
3885
3886    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
3887}
3888
3889impl DeleteAttestorRequest {
3890    pub fn new() -> Self {
3891        std::default::Default::default()
3892    }
3893
3894    /// Sets the value of [name][crate::model::DeleteAttestorRequest::name].
3895    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
3896        self.name = v.into();
3897        self
3898    }
3899}
3900
3901impl wkt::message::Message for DeleteAttestorRequest {
3902    fn typename() -> &'static str {
3903        "type.googleapis.com/google.cloud.binaryauthorization.v1.DeleteAttestorRequest"
3904    }
3905}
3906
3907#[doc(hidden)]
3908impl<'de> serde::de::Deserialize<'de> for DeleteAttestorRequest {
3909    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3910    where
3911        D: serde::Deserializer<'de>,
3912    {
3913        #[allow(non_camel_case_types)]
3914        #[doc(hidden)]
3915        #[derive(PartialEq, Eq, Hash)]
3916        enum __FieldTag {
3917            __name,
3918            Unknown(std::string::String),
3919        }
3920        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
3921            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
3922            where
3923                D: serde::Deserializer<'de>,
3924            {
3925                struct Visitor;
3926                impl<'de> serde::de::Visitor<'de> for Visitor {
3927                    type Value = __FieldTag;
3928                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3929                        formatter.write_str("a field name for DeleteAttestorRequest")
3930                    }
3931                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
3932                    where
3933                        E: serde::de::Error,
3934                    {
3935                        use std::result::Result::Ok;
3936                        use std::string::ToString;
3937                        match value {
3938                            "name" => Ok(__FieldTag::__name),
3939                            _ => Ok(__FieldTag::Unknown(value.to_string())),
3940                        }
3941                    }
3942                }
3943                deserializer.deserialize_identifier(Visitor)
3944            }
3945        }
3946        struct Visitor;
3947        impl<'de> serde::de::Visitor<'de> for Visitor {
3948            type Value = DeleteAttestorRequest;
3949            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
3950                formatter.write_str("struct DeleteAttestorRequest")
3951            }
3952            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
3953            where
3954                A: serde::de::MapAccess<'de>,
3955            {
3956                #[allow(unused_imports)]
3957                use serde::de::Error;
3958                use std::option::Option::Some;
3959                let mut fields = std::collections::HashSet::new();
3960                let mut result = Self::Value::new();
3961                while let Some(tag) = map.next_key::<__FieldTag>()? {
3962                    #[allow(clippy::match_single_binding)]
3963                    match tag {
3964                        __FieldTag::__name => {
3965                            if !fields.insert(__FieldTag::__name) {
3966                                return std::result::Result::Err(A::Error::duplicate_field(
3967                                    "multiple values for name",
3968                                ));
3969                            }
3970                            result.name = map
3971                                .next_value::<std::option::Option<std::string::String>>()?
3972                                .unwrap_or_default();
3973                        }
3974                        __FieldTag::Unknown(key) => {
3975                            let value = map.next_value::<serde_json::Value>()?;
3976                            result._unknown_fields.insert(key, value);
3977                        }
3978                    }
3979                }
3980                std::result::Result::Ok(result)
3981            }
3982        }
3983        deserializer.deserialize_any(Visitor)
3984    }
3985}
3986
3987#[doc(hidden)]
3988impl serde::ser::Serialize for DeleteAttestorRequest {
3989    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
3990    where
3991        S: serde::ser::Serializer,
3992    {
3993        use serde::ser::SerializeMap;
3994        #[allow(unused_imports)]
3995        use std::option::Option::Some;
3996        let mut state = serializer.serialize_map(std::option::Option::None)?;
3997        if !self.name.is_empty() {
3998            state.serialize_entry("name", &self.name)?;
3999        }
4000        if !self._unknown_fields.is_empty() {
4001            for (key, value) in self._unknown_fields.iter() {
4002                state.serialize_entry(key, &value)?;
4003            }
4004        }
4005        state.end()
4006    }
4007}
4008
4009impl std::fmt::Debug for DeleteAttestorRequest {
4010    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4011        let mut debug_struct = f.debug_struct("DeleteAttestorRequest");
4012        debug_struct.field("name", &self.name);
4013        if !self._unknown_fields.is_empty() {
4014            debug_struct.field("_unknown_fields", &self._unknown_fields);
4015        }
4016        debug_struct.finish()
4017    }
4018}
4019
4020/// Request to read the current system policy.
4021#[derive(Clone, Default, PartialEq)]
4022#[non_exhaustive]
4023pub struct GetSystemPolicyRequest {
4024    /// Required. The resource name, in the format `locations/*/policy`.
4025    /// Note that the system policy is not associated with a project.
4026    pub name: std::string::String,
4027
4028    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4029}
4030
4031impl GetSystemPolicyRequest {
4032    pub fn new() -> Self {
4033        std::default::Default::default()
4034    }
4035
4036    /// Sets the value of [name][crate::model::GetSystemPolicyRequest::name].
4037    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4038        self.name = v.into();
4039        self
4040    }
4041}
4042
4043impl wkt::message::Message for GetSystemPolicyRequest {
4044    fn typename() -> &'static str {
4045        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetSystemPolicyRequest"
4046    }
4047}
4048
4049#[doc(hidden)]
4050impl<'de> serde::de::Deserialize<'de> for GetSystemPolicyRequest {
4051    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4052    where
4053        D: serde::Deserializer<'de>,
4054    {
4055        #[allow(non_camel_case_types)]
4056        #[doc(hidden)]
4057        #[derive(PartialEq, Eq, Hash)]
4058        enum __FieldTag {
4059            __name,
4060            Unknown(std::string::String),
4061        }
4062        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4063            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4064            where
4065                D: serde::Deserializer<'de>,
4066            {
4067                struct Visitor;
4068                impl<'de> serde::de::Visitor<'de> for Visitor {
4069                    type Value = __FieldTag;
4070                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4071                        formatter.write_str("a field name for GetSystemPolicyRequest")
4072                    }
4073                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4074                    where
4075                        E: serde::de::Error,
4076                    {
4077                        use std::result::Result::Ok;
4078                        use std::string::ToString;
4079                        match value {
4080                            "name" => Ok(__FieldTag::__name),
4081                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4082                        }
4083                    }
4084                }
4085                deserializer.deserialize_identifier(Visitor)
4086            }
4087        }
4088        struct Visitor;
4089        impl<'de> serde::de::Visitor<'de> for Visitor {
4090            type Value = GetSystemPolicyRequest;
4091            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4092                formatter.write_str("struct GetSystemPolicyRequest")
4093            }
4094            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4095            where
4096                A: serde::de::MapAccess<'de>,
4097            {
4098                #[allow(unused_imports)]
4099                use serde::de::Error;
4100                use std::option::Option::Some;
4101                let mut fields = std::collections::HashSet::new();
4102                let mut result = Self::Value::new();
4103                while let Some(tag) = map.next_key::<__FieldTag>()? {
4104                    #[allow(clippy::match_single_binding)]
4105                    match tag {
4106                        __FieldTag::__name => {
4107                            if !fields.insert(__FieldTag::__name) {
4108                                return std::result::Result::Err(A::Error::duplicate_field(
4109                                    "multiple values for name",
4110                                ));
4111                            }
4112                            result.name = map
4113                                .next_value::<std::option::Option<std::string::String>>()?
4114                                .unwrap_or_default();
4115                        }
4116                        __FieldTag::Unknown(key) => {
4117                            let value = map.next_value::<serde_json::Value>()?;
4118                            result._unknown_fields.insert(key, value);
4119                        }
4120                    }
4121                }
4122                std::result::Result::Ok(result)
4123            }
4124        }
4125        deserializer.deserialize_any(Visitor)
4126    }
4127}
4128
4129#[doc(hidden)]
4130impl serde::ser::Serialize for GetSystemPolicyRequest {
4131    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4132    where
4133        S: serde::ser::Serializer,
4134    {
4135        use serde::ser::SerializeMap;
4136        #[allow(unused_imports)]
4137        use std::option::Option::Some;
4138        let mut state = serializer.serialize_map(std::option::Option::None)?;
4139        if !self.name.is_empty() {
4140            state.serialize_entry("name", &self.name)?;
4141        }
4142        if !self._unknown_fields.is_empty() {
4143            for (key, value) in self._unknown_fields.iter() {
4144                state.serialize_entry(key, &value)?;
4145            }
4146        }
4147        state.end()
4148    }
4149}
4150
4151impl std::fmt::Debug for GetSystemPolicyRequest {
4152    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4153        let mut debug_struct = f.debug_struct("GetSystemPolicyRequest");
4154        debug_struct.field("name", &self.name);
4155        if !self._unknown_fields.is_empty() {
4156            debug_struct.field("_unknown_fields", &self._unknown_fields);
4157        }
4158        debug_struct.finish()
4159    }
4160}
4161
4162/// Request message for
4163/// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence].
4164///
4165/// [google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]: crate::client::ValidationHelperV1::validate_attestation_occurrence
4166#[derive(Clone, Default, PartialEq)]
4167#[non_exhaustive]
4168pub struct ValidateAttestationOccurrenceRequest {
4169    /// Required. The resource name of the [Attestor][google.cloud.binaryauthorization.v1.Attestor] of the
4170    /// [occurrence][grafeas.v1.Occurrence], in the format
4171    /// `projects/*/attestors/*`.
4172    ///
4173    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
4174    pub attestor: std::string::String,
4175
4176    /// Required. An [AttestationOccurrence][grafeas.v1.AttestationOccurrence] to
4177    /// be checked that it can be verified by the Attestor. It does not have to be
4178    /// an existing entity in Container Analysis. It must otherwise be a valid
4179    /// AttestationOccurrence.
4180    ///
4181    /// [grafeas.v1.AttestationOccurrence]: grafeas::model::AttestationOccurrence
4182    pub attestation: std::option::Option<grafeas::model::AttestationOccurrence>,
4183
4184    /// Required. The resource name of the [Note][grafeas.v1.Note] to which the
4185    /// containing [Occurrence][grafeas.v1.Occurrence] is associated.
4186    pub occurrence_note: std::string::String,
4187
4188    /// Required. The URI of the artifact (e.g. container image) that is the
4189    /// subject of the containing [Occurrence][grafeas.v1.Occurrence].
4190    pub occurrence_resource_uri: std::string::String,
4191
4192    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4193}
4194
4195impl ValidateAttestationOccurrenceRequest {
4196    pub fn new() -> Self {
4197        std::default::Default::default()
4198    }
4199
4200    /// Sets the value of [attestor][crate::model::ValidateAttestationOccurrenceRequest::attestor].
4201    pub fn set_attestor<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4202        self.attestor = v.into();
4203        self
4204    }
4205
4206    /// Sets the value of [attestation][crate::model::ValidateAttestationOccurrenceRequest::attestation].
4207    pub fn set_attestation<T>(mut self, v: T) -> Self
4208    where
4209        T: std::convert::Into<grafeas::model::AttestationOccurrence>,
4210    {
4211        self.attestation = std::option::Option::Some(v.into());
4212        self
4213    }
4214
4215    /// Sets or clears the value of [attestation][crate::model::ValidateAttestationOccurrenceRequest::attestation].
4216    pub fn set_or_clear_attestation<T>(mut self, v: std::option::Option<T>) -> Self
4217    where
4218        T: std::convert::Into<grafeas::model::AttestationOccurrence>,
4219    {
4220        self.attestation = v.map(|x| x.into());
4221        self
4222    }
4223
4224    /// Sets the value of [occurrence_note][crate::model::ValidateAttestationOccurrenceRequest::occurrence_note].
4225    pub fn set_occurrence_note<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4226        self.occurrence_note = v.into();
4227        self
4228    }
4229
4230    /// Sets the value of [occurrence_resource_uri][crate::model::ValidateAttestationOccurrenceRequest::occurrence_resource_uri].
4231    pub fn set_occurrence_resource_uri<T: std::convert::Into<std::string::String>>(
4232        mut self,
4233        v: T,
4234    ) -> Self {
4235        self.occurrence_resource_uri = v.into();
4236        self
4237    }
4238}
4239
4240impl wkt::message::Message for ValidateAttestationOccurrenceRequest {
4241    fn typename() -> &'static str {
4242        "type.googleapis.com/google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceRequest"
4243    }
4244}
4245
4246#[doc(hidden)]
4247impl<'de> serde::de::Deserialize<'de> for ValidateAttestationOccurrenceRequest {
4248    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4249    where
4250        D: serde::Deserializer<'de>,
4251    {
4252        #[allow(non_camel_case_types)]
4253        #[doc(hidden)]
4254        #[derive(PartialEq, Eq, Hash)]
4255        enum __FieldTag {
4256            __attestor,
4257            __attestation,
4258            __occurrence_note,
4259            __occurrence_resource_uri,
4260            Unknown(std::string::String),
4261        }
4262        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4263            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4264            where
4265                D: serde::Deserializer<'de>,
4266            {
4267                struct Visitor;
4268                impl<'de> serde::de::Visitor<'de> for Visitor {
4269                    type Value = __FieldTag;
4270                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4271                        formatter.write_str("a field name for ValidateAttestationOccurrenceRequest")
4272                    }
4273                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4274                    where
4275                        E: serde::de::Error,
4276                    {
4277                        use std::result::Result::Ok;
4278                        use std::string::ToString;
4279                        match value {
4280                            "attestor" => Ok(__FieldTag::__attestor),
4281                            "attestation" => Ok(__FieldTag::__attestation),
4282                            "occurrenceNote" => Ok(__FieldTag::__occurrence_note),
4283                            "occurrence_note" => Ok(__FieldTag::__occurrence_note),
4284                            "occurrenceResourceUri" => Ok(__FieldTag::__occurrence_resource_uri),
4285                            "occurrence_resource_uri" => Ok(__FieldTag::__occurrence_resource_uri),
4286                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4287                        }
4288                    }
4289                }
4290                deserializer.deserialize_identifier(Visitor)
4291            }
4292        }
4293        struct Visitor;
4294        impl<'de> serde::de::Visitor<'de> for Visitor {
4295            type Value = ValidateAttestationOccurrenceRequest;
4296            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4297                formatter.write_str("struct ValidateAttestationOccurrenceRequest")
4298            }
4299            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4300            where
4301                A: serde::de::MapAccess<'de>,
4302            {
4303                #[allow(unused_imports)]
4304                use serde::de::Error;
4305                use std::option::Option::Some;
4306                let mut fields = std::collections::HashSet::new();
4307                let mut result = Self::Value::new();
4308                while let Some(tag) = map.next_key::<__FieldTag>()? {
4309                    #[allow(clippy::match_single_binding)]
4310                    match tag {
4311                        __FieldTag::__attestor => {
4312                            if !fields.insert(__FieldTag::__attestor) {
4313                                return std::result::Result::Err(A::Error::duplicate_field(
4314                                    "multiple values for attestor",
4315                                ));
4316                            }
4317                            result.attestor = map
4318                                .next_value::<std::option::Option<std::string::String>>()?
4319                                .unwrap_or_default();
4320                        }
4321                        __FieldTag::__attestation => {
4322                            if !fields.insert(__FieldTag::__attestation) {
4323                                return std::result::Result::Err(A::Error::duplicate_field(
4324                                    "multiple values for attestation",
4325                                ));
4326                            }
4327                            result.attestation = map.next_value::<std::option::Option<grafeas::model::AttestationOccurrence>>()?
4328                                ;
4329                        }
4330                        __FieldTag::__occurrence_note => {
4331                            if !fields.insert(__FieldTag::__occurrence_note) {
4332                                return std::result::Result::Err(A::Error::duplicate_field(
4333                                    "multiple values for occurrence_note",
4334                                ));
4335                            }
4336                            result.occurrence_note = map
4337                                .next_value::<std::option::Option<std::string::String>>()?
4338                                .unwrap_or_default();
4339                        }
4340                        __FieldTag::__occurrence_resource_uri => {
4341                            if !fields.insert(__FieldTag::__occurrence_resource_uri) {
4342                                return std::result::Result::Err(A::Error::duplicate_field(
4343                                    "multiple values for occurrence_resource_uri",
4344                                ));
4345                            }
4346                            result.occurrence_resource_uri = map
4347                                .next_value::<std::option::Option<std::string::String>>()?
4348                                .unwrap_or_default();
4349                        }
4350                        __FieldTag::Unknown(key) => {
4351                            let value = map.next_value::<serde_json::Value>()?;
4352                            result._unknown_fields.insert(key, value);
4353                        }
4354                    }
4355                }
4356                std::result::Result::Ok(result)
4357            }
4358        }
4359        deserializer.deserialize_any(Visitor)
4360    }
4361}
4362
4363#[doc(hidden)]
4364impl serde::ser::Serialize for ValidateAttestationOccurrenceRequest {
4365    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4366    where
4367        S: serde::ser::Serializer,
4368    {
4369        use serde::ser::SerializeMap;
4370        #[allow(unused_imports)]
4371        use std::option::Option::Some;
4372        let mut state = serializer.serialize_map(std::option::Option::None)?;
4373        if !self.attestor.is_empty() {
4374            state.serialize_entry("attestor", &self.attestor)?;
4375        }
4376        if self.attestation.is_some() {
4377            state.serialize_entry("attestation", &self.attestation)?;
4378        }
4379        if !self.occurrence_note.is_empty() {
4380            state.serialize_entry("occurrenceNote", &self.occurrence_note)?;
4381        }
4382        if !self.occurrence_resource_uri.is_empty() {
4383            state.serialize_entry("occurrenceResourceUri", &self.occurrence_resource_uri)?;
4384        }
4385        if !self._unknown_fields.is_empty() {
4386            for (key, value) in self._unknown_fields.iter() {
4387                state.serialize_entry(key, &value)?;
4388            }
4389        }
4390        state.end()
4391    }
4392}
4393
4394impl std::fmt::Debug for ValidateAttestationOccurrenceRequest {
4395    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4396        let mut debug_struct = f.debug_struct("ValidateAttestationOccurrenceRequest");
4397        debug_struct.field("attestor", &self.attestor);
4398        debug_struct.field("attestation", &self.attestation);
4399        debug_struct.field("occurrence_note", &self.occurrence_note);
4400        debug_struct.field("occurrence_resource_uri", &self.occurrence_resource_uri);
4401        if !self._unknown_fields.is_empty() {
4402            debug_struct.field("_unknown_fields", &self._unknown_fields);
4403        }
4404        debug_struct.finish()
4405    }
4406}
4407
4408/// Response message for
4409/// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence].
4410///
4411/// [google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]: crate::client::ValidationHelperV1::validate_attestation_occurrence
4412#[derive(Clone, Default, PartialEq)]
4413#[non_exhaustive]
4414pub struct ValidateAttestationOccurrenceResponse {
4415    /// The result of the Attestation validation.
4416    pub result: crate::model::validate_attestation_occurrence_response::Result,
4417
4418    /// The reason for denial if the Attestation couldn't be validated.
4419    pub denial_reason: std::string::String,
4420
4421    _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
4422}
4423
4424impl ValidateAttestationOccurrenceResponse {
4425    pub fn new() -> Self {
4426        std::default::Default::default()
4427    }
4428
4429    /// Sets the value of [result][crate::model::ValidateAttestationOccurrenceResponse::result].
4430    pub fn set_result<
4431        T: std::convert::Into<crate::model::validate_attestation_occurrence_response::Result>,
4432    >(
4433        mut self,
4434        v: T,
4435    ) -> Self {
4436        self.result = v.into();
4437        self
4438    }
4439
4440    /// Sets the value of [denial_reason][crate::model::ValidateAttestationOccurrenceResponse::denial_reason].
4441    pub fn set_denial_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
4442        self.denial_reason = v.into();
4443        self
4444    }
4445}
4446
4447impl wkt::message::Message for ValidateAttestationOccurrenceResponse {
4448    fn typename() -> &'static str {
4449        "type.googleapis.com/google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse"
4450    }
4451}
4452
4453#[doc(hidden)]
4454impl<'de> serde::de::Deserialize<'de> for ValidateAttestationOccurrenceResponse {
4455    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4456    where
4457        D: serde::Deserializer<'de>,
4458    {
4459        #[allow(non_camel_case_types)]
4460        #[doc(hidden)]
4461        #[derive(PartialEq, Eq, Hash)]
4462        enum __FieldTag {
4463            __result,
4464            __denial_reason,
4465            Unknown(std::string::String),
4466        }
4467        impl<'de> serde::de::Deserialize<'de> for __FieldTag {
4468            fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4469            where
4470                D: serde::Deserializer<'de>,
4471            {
4472                struct Visitor;
4473                impl<'de> serde::de::Visitor<'de> for Visitor {
4474                    type Value = __FieldTag;
4475                    fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4476                        formatter
4477                            .write_str("a field name for ValidateAttestationOccurrenceResponse")
4478                    }
4479                    fn visit_str<E>(self, value: &str) -> std::result::Result<Self::Value, E>
4480                    where
4481                        E: serde::de::Error,
4482                    {
4483                        use std::result::Result::Ok;
4484                        use std::string::ToString;
4485                        match value {
4486                            "result" => Ok(__FieldTag::__result),
4487                            "denialReason" => Ok(__FieldTag::__denial_reason),
4488                            "denial_reason" => Ok(__FieldTag::__denial_reason),
4489                            _ => Ok(__FieldTag::Unknown(value.to_string())),
4490                        }
4491                    }
4492                }
4493                deserializer.deserialize_identifier(Visitor)
4494            }
4495        }
4496        struct Visitor;
4497        impl<'de> serde::de::Visitor<'de> for Visitor {
4498            type Value = ValidateAttestationOccurrenceResponse;
4499            fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
4500                formatter.write_str("struct ValidateAttestationOccurrenceResponse")
4501            }
4502            fn visit_map<A>(self, mut map: A) -> std::result::Result<Self::Value, A::Error>
4503            where
4504                A: serde::de::MapAccess<'de>,
4505            {
4506                #[allow(unused_imports)]
4507                use serde::de::Error;
4508                use std::option::Option::Some;
4509                let mut fields = std::collections::HashSet::new();
4510                let mut result = Self::Value::new();
4511                while let Some(tag) = map.next_key::<__FieldTag>()? {
4512                    #[allow(clippy::match_single_binding)]
4513                    match tag {
4514                        __FieldTag::__result => {
4515                            if !fields.insert(__FieldTag::__result) {
4516                                return std::result::Result::Err(A::Error::duplicate_field(
4517                                    "multiple values for result",
4518                                ));
4519                            }
4520                            result.result = map
4521                                .next_value::<std::option::Option<
4522                                    crate::model::validate_attestation_occurrence_response::Result,
4523                                >>()?
4524                                .unwrap_or_default();
4525                        }
4526                        __FieldTag::__denial_reason => {
4527                            if !fields.insert(__FieldTag::__denial_reason) {
4528                                return std::result::Result::Err(A::Error::duplicate_field(
4529                                    "multiple values for denial_reason",
4530                                ));
4531                            }
4532                            result.denial_reason = map
4533                                .next_value::<std::option::Option<std::string::String>>()?
4534                                .unwrap_or_default();
4535                        }
4536                        __FieldTag::Unknown(key) => {
4537                            let value = map.next_value::<serde_json::Value>()?;
4538                            result._unknown_fields.insert(key, value);
4539                        }
4540                    }
4541                }
4542                std::result::Result::Ok(result)
4543            }
4544        }
4545        deserializer.deserialize_any(Visitor)
4546    }
4547}
4548
4549#[doc(hidden)]
4550impl serde::ser::Serialize for ValidateAttestationOccurrenceResponse {
4551    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4552    where
4553        S: serde::ser::Serializer,
4554    {
4555        use serde::ser::SerializeMap;
4556        #[allow(unused_imports)]
4557        use std::option::Option::Some;
4558        let mut state = serializer.serialize_map(std::option::Option::None)?;
4559        if !wkt::internal::is_default(&self.result) {
4560            state.serialize_entry("result", &self.result)?;
4561        }
4562        if !self.denial_reason.is_empty() {
4563            state.serialize_entry("denialReason", &self.denial_reason)?;
4564        }
4565        if !self._unknown_fields.is_empty() {
4566            for (key, value) in self._unknown_fields.iter() {
4567                state.serialize_entry(key, &value)?;
4568            }
4569        }
4570        state.end()
4571    }
4572}
4573
4574impl std::fmt::Debug for ValidateAttestationOccurrenceResponse {
4575    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4576        let mut debug_struct = f.debug_struct("ValidateAttestationOccurrenceResponse");
4577        debug_struct.field("result", &self.result);
4578        debug_struct.field("denial_reason", &self.denial_reason);
4579        if !self._unknown_fields.is_empty() {
4580            debug_struct.field("_unknown_fields", &self._unknown_fields);
4581        }
4582        debug_struct.finish()
4583    }
4584}
4585
4586/// Defines additional types related to [ValidateAttestationOccurrenceResponse].
4587pub mod validate_attestation_occurrence_response {
4588    #[allow(unused_imports)]
4589    use super::*;
4590
4591    /// The enum returned in the "result" field.
4592    ///
4593    /// # Working with unknown values
4594    ///
4595    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
4596    /// additional enum variants at any time. Adding new variants is not considered
4597    /// a breaking change. Applications should write their code in anticipation of:
4598    ///
4599    /// - New values appearing in future releases of the client library, **and**
4600    /// - New values received dynamically, without application changes.
4601    ///
4602    /// Please consult the [Working with enums] section in the user guide for some
4603    /// guidelines.
4604    ///
4605    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
4606    #[derive(Clone, Debug, PartialEq)]
4607    #[non_exhaustive]
4608    pub enum Result {
4609        /// Unspecified.
4610        Unspecified,
4611        /// The Attestation was able to verified by the Attestor.
4612        Verified,
4613        /// The Attestation was not able to verified by the Attestor.
4614        AttestationNotVerifiable,
4615        /// If set, the enum was initialized with an unknown value.
4616        ///
4617        /// Applications can examine the value using [Result::value] or
4618        /// [Result::name].
4619        UnknownValue(result::UnknownValue),
4620    }
4621
4622    #[doc(hidden)]
4623    pub mod result {
4624        #[allow(unused_imports)]
4625        use super::*;
4626        #[derive(Clone, Debug, PartialEq)]
4627        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
4628    }
4629
4630    impl Result {
4631        /// Gets the enum value.
4632        ///
4633        /// Returns `None` if the enum contains an unknown value deserialized from
4634        /// the string representation of enums.
4635        pub fn value(&self) -> std::option::Option<i32> {
4636            match self {
4637                Self::Unspecified => std::option::Option::Some(0),
4638                Self::Verified => std::option::Option::Some(1),
4639                Self::AttestationNotVerifiable => std::option::Option::Some(2),
4640                Self::UnknownValue(u) => u.0.value(),
4641            }
4642        }
4643
4644        /// Gets the enum value as a string.
4645        ///
4646        /// Returns `None` if the enum contains an unknown value deserialized from
4647        /// the integer representation of enums.
4648        pub fn name(&self) -> std::option::Option<&str> {
4649            match self {
4650                Self::Unspecified => std::option::Option::Some("RESULT_UNSPECIFIED"),
4651                Self::Verified => std::option::Option::Some("VERIFIED"),
4652                Self::AttestationNotVerifiable => {
4653                    std::option::Option::Some("ATTESTATION_NOT_VERIFIABLE")
4654                }
4655                Self::UnknownValue(u) => u.0.name(),
4656            }
4657        }
4658    }
4659
4660    impl std::default::Default for Result {
4661        fn default() -> Self {
4662            use std::convert::From;
4663            Self::from(0)
4664        }
4665    }
4666
4667    impl std::fmt::Display for Result {
4668        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
4669            wkt::internal::display_enum(f, self.name(), self.value())
4670        }
4671    }
4672
4673    impl std::convert::From<i32> for Result {
4674        fn from(value: i32) -> Self {
4675            match value {
4676                0 => Self::Unspecified,
4677                1 => Self::Verified,
4678                2 => Self::AttestationNotVerifiable,
4679                _ => Self::UnknownValue(result::UnknownValue(
4680                    wkt::internal::UnknownEnumValue::Integer(value),
4681                )),
4682            }
4683        }
4684    }
4685
4686    impl std::convert::From<&str> for Result {
4687        fn from(value: &str) -> Self {
4688            use std::string::ToString;
4689            match value {
4690                "RESULT_UNSPECIFIED" => Self::Unspecified,
4691                "VERIFIED" => Self::Verified,
4692                "ATTESTATION_NOT_VERIFIABLE" => Self::AttestationNotVerifiable,
4693                _ => Self::UnknownValue(result::UnknownValue(
4694                    wkt::internal::UnknownEnumValue::String(value.to_string()),
4695                )),
4696            }
4697        }
4698    }
4699
4700    impl serde::ser::Serialize for Result {
4701        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
4702        where
4703            S: serde::Serializer,
4704        {
4705            match self {
4706                Self::Unspecified => serializer.serialize_i32(0),
4707                Self::Verified => serializer.serialize_i32(1),
4708                Self::AttestationNotVerifiable => serializer.serialize_i32(2),
4709                Self::UnknownValue(u) => u.0.serialize(serializer),
4710            }
4711        }
4712    }
4713
4714    impl<'de> serde::de::Deserialize<'de> for Result {
4715        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
4716        where
4717            D: serde::Deserializer<'de>,
4718        {
4719            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Result>::new(
4720                ".google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse.Result",
4721            ))
4722        }
4723    }
4724}