Skip to main content

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 gaxi;
23extern crate google_cloud_gax;
24extern crate google_cloud_grafeas_v1;
25extern crate serde;
26extern crate serde_json;
27extern crate serde_with;
28extern crate std;
29extern crate tracing;
30extern crate wkt;
31
32mod debug;
33mod deserialize;
34mod serialize;
35
36/// A [policy][google.cloud.binaryauthorization.v1.Policy] for container image binary authorization.
37///
38/// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
39#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct Policy {
42    /// Output only. The resource name, in the format `projects/*/policy`. There is
43    /// at most one policy per project.
44    pub name: std::string::String,
45
46    /// Optional. A descriptive comment.
47    pub description: std::string::String,
48
49    /// Optional. Controls the evaluation of a Google-maintained global admission
50    /// policy for common system-level images. Images not covered by the global
51    /// policy will be subject to the project admission policy. This setting
52    /// has no effect when specified inside a global admission policy.
53    pub global_policy_evaluation_mode: crate::model::policy::GlobalPolicyEvaluationMode,
54
55    /// Optional. Admission policy allowlisting. A matching admission request will
56    /// always be permitted. This feature is typically used to exclude Google or
57    /// third-party infrastructure images from Binary Authorization policies.
58    pub admission_whitelist_patterns: std::vec::Vec<crate::model::AdmissionWhitelistPattern>,
59
60    /// Optional. Per-cluster admission rules. Cluster spec format:
61    /// `location.clusterId`. There can be at most one admission rule per cluster
62    /// spec.
63    /// A `location` is either a compute zone (e.g. us-central1-a) or a region
64    /// (e.g. us-central1).
65    /// For `clusterId` syntax restrictions see
66    /// <https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters>.
67    pub cluster_admission_rules:
68        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
69
70    /// Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format:
71    /// [a-z.-]+, e.g. 'some-namespace'
72    pub kubernetes_namespace_admission_rules:
73        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
74
75    /// Optional. Per-kubernetes-service-account admission rules. Service account
76    /// spec format: `namespace:serviceaccount`. e.g. 'test-ns:default'
77    pub kubernetes_service_account_admission_rules:
78        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
79
80    /// Optional. Per-istio-service-identity admission rules. Istio service
81    /// identity spec format:
82    /// spiffe://\<domain\>/ns/\<namespace\>/sa/\<serviceaccount\> or
83    /// \<domain\>/ns/\<namespace\>/sa/\<serviceaccount\>
84    /// e.g. spiffe://example.com/ns/test-ns/sa/default
85    pub istio_service_identity_admission_rules:
86        std::collections::HashMap<std::string::String, crate::model::AdmissionRule>,
87
88    /// Required. Default admission rule for a cluster without a per-cluster, per-
89    /// kubernetes-service-account, or per-istio-service-identity admission rule.
90    pub default_admission_rule: std::option::Option<crate::model::AdmissionRule>,
91
92    /// Output only. Time when the policy was last updated.
93    pub update_time: std::option::Option<wkt::Timestamp>,
94
95    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
96}
97
98impl Policy {
99    /// Creates a new default instance.
100    pub fn new() -> Self {
101        std::default::Default::default()
102    }
103
104    /// Sets the value of [name][crate::model::Policy::name].
105    ///
106    /// # Example
107    /// ```ignore,no_run
108    /// # use google_cloud_binaryauthorization_v1::model::Policy;
109    /// let x = Policy::new().set_name("example");
110    /// ```
111    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
112        self.name = v.into();
113        self
114    }
115
116    /// Sets the value of [description][crate::model::Policy::description].
117    ///
118    /// # Example
119    /// ```ignore,no_run
120    /// # use google_cloud_binaryauthorization_v1::model::Policy;
121    /// let x = Policy::new().set_description("example");
122    /// ```
123    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
124        self.description = v.into();
125        self
126    }
127
128    /// Sets the value of [global_policy_evaluation_mode][crate::model::Policy::global_policy_evaluation_mode].
129    ///
130    /// # Example
131    /// ```ignore,no_run
132    /// # use google_cloud_binaryauthorization_v1::model::Policy;
133    /// use google_cloud_binaryauthorization_v1::model::policy::GlobalPolicyEvaluationMode;
134    /// let x0 = Policy::new().set_global_policy_evaluation_mode(GlobalPolicyEvaluationMode::Enable);
135    /// let x1 = Policy::new().set_global_policy_evaluation_mode(GlobalPolicyEvaluationMode::Disable);
136    /// ```
137    pub fn set_global_policy_evaluation_mode<
138        T: std::convert::Into<crate::model::policy::GlobalPolicyEvaluationMode>,
139    >(
140        mut self,
141        v: T,
142    ) -> Self {
143        self.global_policy_evaluation_mode = v.into();
144        self
145    }
146
147    /// Sets the value of [admission_whitelist_patterns][crate::model::Policy::admission_whitelist_patterns].
148    ///
149    /// # Example
150    /// ```ignore,no_run
151    /// # use google_cloud_binaryauthorization_v1::model::Policy;
152    /// use google_cloud_binaryauthorization_v1::model::AdmissionWhitelistPattern;
153    /// let x = Policy::new()
154    ///     .set_admission_whitelist_patterns([
155    ///         AdmissionWhitelistPattern::default()/* use setters */,
156    ///         AdmissionWhitelistPattern::default()/* use (different) setters */,
157    ///     ]);
158    /// ```
159    pub fn set_admission_whitelist_patterns<T, V>(mut self, v: T) -> Self
160    where
161        T: std::iter::IntoIterator<Item = V>,
162        V: std::convert::Into<crate::model::AdmissionWhitelistPattern>,
163    {
164        use std::iter::Iterator;
165        self.admission_whitelist_patterns = v.into_iter().map(|i| i.into()).collect();
166        self
167    }
168
169    /// Sets the value of [cluster_admission_rules][crate::model::Policy::cluster_admission_rules].
170    ///
171    /// # Example
172    /// ```ignore,no_run
173    /// # use google_cloud_binaryauthorization_v1::model::Policy;
174    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
175    /// let x = Policy::new().set_cluster_admission_rules([
176    ///     ("key0", AdmissionRule::default()/* use setters */),
177    ///     ("key1", AdmissionRule::default()/* use (different) setters */),
178    /// ]);
179    /// ```
180    pub fn set_cluster_admission_rules<T, K, V>(mut self, v: T) -> Self
181    where
182        T: std::iter::IntoIterator<Item = (K, V)>,
183        K: std::convert::Into<std::string::String>,
184        V: std::convert::Into<crate::model::AdmissionRule>,
185    {
186        use std::iter::Iterator;
187        self.cluster_admission_rules = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
188        self
189    }
190
191    /// Sets the value of [kubernetes_namespace_admission_rules][crate::model::Policy::kubernetes_namespace_admission_rules].
192    ///
193    /// # Example
194    /// ```ignore,no_run
195    /// # use google_cloud_binaryauthorization_v1::model::Policy;
196    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
197    /// let x = Policy::new().set_kubernetes_namespace_admission_rules([
198    ///     ("key0", AdmissionRule::default()/* use setters */),
199    ///     ("key1", AdmissionRule::default()/* use (different) setters */),
200    /// ]);
201    /// ```
202    pub fn set_kubernetes_namespace_admission_rules<T, K, V>(mut self, v: T) -> Self
203    where
204        T: std::iter::IntoIterator<Item = (K, V)>,
205        K: std::convert::Into<std::string::String>,
206        V: std::convert::Into<crate::model::AdmissionRule>,
207    {
208        use std::iter::Iterator;
209        self.kubernetes_namespace_admission_rules =
210            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
211        self
212    }
213
214    /// Sets the value of [kubernetes_service_account_admission_rules][crate::model::Policy::kubernetes_service_account_admission_rules].
215    ///
216    /// # Example
217    /// ```ignore,no_run
218    /// # use google_cloud_binaryauthorization_v1::model::Policy;
219    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
220    /// let x = Policy::new().set_kubernetes_service_account_admission_rules([
221    ///     ("key0", AdmissionRule::default()/* use setters */),
222    ///     ("key1", AdmissionRule::default()/* use (different) setters */),
223    /// ]);
224    /// ```
225    pub fn set_kubernetes_service_account_admission_rules<T, K, V>(mut self, v: T) -> Self
226    where
227        T: std::iter::IntoIterator<Item = (K, V)>,
228        K: std::convert::Into<std::string::String>,
229        V: std::convert::Into<crate::model::AdmissionRule>,
230    {
231        use std::iter::Iterator;
232        self.kubernetes_service_account_admission_rules =
233            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
234        self
235    }
236
237    /// Sets the value of [istio_service_identity_admission_rules][crate::model::Policy::istio_service_identity_admission_rules].
238    ///
239    /// # Example
240    /// ```ignore,no_run
241    /// # use google_cloud_binaryauthorization_v1::model::Policy;
242    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
243    /// let x = Policy::new().set_istio_service_identity_admission_rules([
244    ///     ("key0", AdmissionRule::default()/* use setters */),
245    ///     ("key1", AdmissionRule::default()/* use (different) setters */),
246    /// ]);
247    /// ```
248    pub fn set_istio_service_identity_admission_rules<T, K, V>(mut self, v: T) -> Self
249    where
250        T: std::iter::IntoIterator<Item = (K, V)>,
251        K: std::convert::Into<std::string::String>,
252        V: std::convert::Into<crate::model::AdmissionRule>,
253    {
254        use std::iter::Iterator;
255        self.istio_service_identity_admission_rules =
256            v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
257        self
258    }
259
260    /// Sets the value of [default_admission_rule][crate::model::Policy::default_admission_rule].
261    ///
262    /// # Example
263    /// ```ignore,no_run
264    /// # use google_cloud_binaryauthorization_v1::model::Policy;
265    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
266    /// let x = Policy::new().set_default_admission_rule(AdmissionRule::default()/* use setters */);
267    /// ```
268    pub fn set_default_admission_rule<T>(mut self, v: T) -> Self
269    where
270        T: std::convert::Into<crate::model::AdmissionRule>,
271    {
272        self.default_admission_rule = std::option::Option::Some(v.into());
273        self
274    }
275
276    /// Sets or clears the value of [default_admission_rule][crate::model::Policy::default_admission_rule].
277    ///
278    /// # Example
279    /// ```ignore,no_run
280    /// # use google_cloud_binaryauthorization_v1::model::Policy;
281    /// use google_cloud_binaryauthorization_v1::model::AdmissionRule;
282    /// let x = Policy::new().set_or_clear_default_admission_rule(Some(AdmissionRule::default()/* use setters */));
283    /// let x = Policy::new().set_or_clear_default_admission_rule(None::<AdmissionRule>);
284    /// ```
285    pub fn set_or_clear_default_admission_rule<T>(mut self, v: std::option::Option<T>) -> Self
286    where
287        T: std::convert::Into<crate::model::AdmissionRule>,
288    {
289        self.default_admission_rule = v.map(|x| x.into());
290        self
291    }
292
293    /// Sets the value of [update_time][crate::model::Policy::update_time].
294    ///
295    /// # Example
296    /// ```ignore,no_run
297    /// # use google_cloud_binaryauthorization_v1::model::Policy;
298    /// use wkt::Timestamp;
299    /// let x = Policy::new().set_update_time(Timestamp::default()/* use setters */);
300    /// ```
301    pub fn set_update_time<T>(mut self, v: T) -> Self
302    where
303        T: std::convert::Into<wkt::Timestamp>,
304    {
305        self.update_time = std::option::Option::Some(v.into());
306        self
307    }
308
309    /// Sets or clears the value of [update_time][crate::model::Policy::update_time].
310    ///
311    /// # Example
312    /// ```ignore,no_run
313    /// # use google_cloud_binaryauthorization_v1::model::Policy;
314    /// use wkt::Timestamp;
315    /// let x = Policy::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
316    /// let x = Policy::new().set_or_clear_update_time(None::<Timestamp>);
317    /// ```
318    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
319    where
320        T: std::convert::Into<wkt::Timestamp>,
321    {
322        self.update_time = v.map(|x| x.into());
323        self
324    }
325}
326
327impl wkt::message::Message for Policy {
328    fn typename() -> &'static str {
329        "type.googleapis.com/google.cloud.binaryauthorization.v1.Policy"
330    }
331}
332
333/// Defines additional types related to [Policy].
334pub mod policy {
335    #[allow(unused_imports)]
336    use super::*;
337
338    /// Enum for [GlobalPolicyEvaluationMode].
339    ///
340    /// # Working with unknown values
341    ///
342    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
343    /// additional enum variants at any time. Adding new variants is not considered
344    /// a breaking change. Applications should write their code in anticipation of:
345    ///
346    /// - New values appearing in future releases of the client library, **and**
347    /// - New values received dynamically, without application changes.
348    ///
349    /// Please consult the [Working with enums] section in the user guide for some
350    /// guidelines.
351    ///
352    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
353    #[derive(Clone, Debug, PartialEq)]
354    #[non_exhaustive]
355    pub enum GlobalPolicyEvaluationMode {
356        /// Not specified: DISABLE is assumed.
357        Unspecified,
358        /// Enables system policy evaluation.
359        Enable,
360        /// Disables system policy evaluation.
361        Disable,
362        /// If set, the enum was initialized with an unknown value.
363        ///
364        /// Applications can examine the value using [GlobalPolicyEvaluationMode::value] or
365        /// [GlobalPolicyEvaluationMode::name].
366        UnknownValue(global_policy_evaluation_mode::UnknownValue),
367    }
368
369    #[doc(hidden)]
370    pub mod global_policy_evaluation_mode {
371        #[allow(unused_imports)]
372        use super::*;
373        #[derive(Clone, Debug, PartialEq)]
374        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
375    }
376
377    impl GlobalPolicyEvaluationMode {
378        /// Gets the enum value.
379        ///
380        /// Returns `None` if the enum contains an unknown value deserialized from
381        /// the string representation of enums.
382        pub fn value(&self) -> std::option::Option<i32> {
383            match self {
384                Self::Unspecified => std::option::Option::Some(0),
385                Self::Enable => std::option::Option::Some(1),
386                Self::Disable => std::option::Option::Some(2),
387                Self::UnknownValue(u) => u.0.value(),
388            }
389        }
390
391        /// Gets the enum value as a string.
392        ///
393        /// Returns `None` if the enum contains an unknown value deserialized from
394        /// the integer representation of enums.
395        pub fn name(&self) -> std::option::Option<&str> {
396            match self {
397                Self::Unspecified => {
398                    std::option::Option::Some("GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED")
399                }
400                Self::Enable => std::option::Option::Some("ENABLE"),
401                Self::Disable => std::option::Option::Some("DISABLE"),
402                Self::UnknownValue(u) => u.0.name(),
403            }
404        }
405    }
406
407    impl std::default::Default for GlobalPolicyEvaluationMode {
408        fn default() -> Self {
409            use std::convert::From;
410            Self::from(0)
411        }
412    }
413
414    impl std::fmt::Display for GlobalPolicyEvaluationMode {
415        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
416            wkt::internal::display_enum(f, self.name(), self.value())
417        }
418    }
419
420    impl std::convert::From<i32> for GlobalPolicyEvaluationMode {
421        fn from(value: i32) -> Self {
422            match value {
423                0 => Self::Unspecified,
424                1 => Self::Enable,
425                2 => Self::Disable,
426                _ => Self::UnknownValue(global_policy_evaluation_mode::UnknownValue(
427                    wkt::internal::UnknownEnumValue::Integer(value),
428                )),
429            }
430        }
431    }
432
433    impl std::convert::From<&str> for GlobalPolicyEvaluationMode {
434        fn from(value: &str) -> Self {
435            use std::string::ToString;
436            match value {
437                "GLOBAL_POLICY_EVALUATION_MODE_UNSPECIFIED" => Self::Unspecified,
438                "ENABLE" => Self::Enable,
439                "DISABLE" => Self::Disable,
440                _ => Self::UnknownValue(global_policy_evaluation_mode::UnknownValue(
441                    wkt::internal::UnknownEnumValue::String(value.to_string()),
442                )),
443            }
444        }
445    }
446
447    impl serde::ser::Serialize for GlobalPolicyEvaluationMode {
448        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
449        where
450            S: serde::Serializer,
451        {
452            match self {
453                Self::Unspecified => serializer.serialize_i32(0),
454                Self::Enable => serializer.serialize_i32(1),
455                Self::Disable => serializer.serialize_i32(2),
456                Self::UnknownValue(u) => u.0.serialize(serializer),
457            }
458        }
459    }
460
461    impl<'de> serde::de::Deserialize<'de> for GlobalPolicyEvaluationMode {
462        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
463        where
464            D: serde::Deserializer<'de>,
465        {
466            deserializer.deserialize_any(
467                wkt::internal::EnumVisitor::<GlobalPolicyEvaluationMode>::new(
468                    ".google.cloud.binaryauthorization.v1.Policy.GlobalPolicyEvaluationMode",
469                ),
470            )
471        }
472    }
473}
474
475/// An [admission allowlist pattern][google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern] exempts images
476/// from checks by [admission rules][google.cloud.binaryauthorization.v1.AdmissionRule].
477///
478/// [google.cloud.binaryauthorization.v1.AdmissionRule]: crate::model::AdmissionRule
479/// [google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]: crate::model::AdmissionWhitelistPattern
480#[derive(Clone, Default, PartialEq)]
481#[non_exhaustive]
482pub struct AdmissionWhitelistPattern {
483    /// An image name pattern to allowlist, in the form `registry/path/to/image`.
484    /// This supports a trailing `*` wildcard, but this is allowed only in
485    /// text after the `registry/` part. This also supports a trailing `**`
486    /// wildcard which matches subdirectories of a given entry.
487    pub name_pattern: std::string::String,
488
489    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
490}
491
492impl AdmissionWhitelistPattern {
493    /// Creates a new default instance.
494    pub fn new() -> Self {
495        std::default::Default::default()
496    }
497
498    /// Sets the value of [name_pattern][crate::model::AdmissionWhitelistPattern::name_pattern].
499    ///
500    /// # Example
501    /// ```ignore,no_run
502    /// # use google_cloud_binaryauthorization_v1::model::AdmissionWhitelistPattern;
503    /// let x = AdmissionWhitelistPattern::new().set_name_pattern("example");
504    /// ```
505    pub fn set_name_pattern<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
506        self.name_pattern = v.into();
507        self
508    }
509}
510
511impl wkt::message::Message for AdmissionWhitelistPattern {
512    fn typename() -> &'static str {
513        "type.googleapis.com/google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern"
514    }
515}
516
517/// An [admission rule][google.cloud.binaryauthorization.v1.AdmissionRule] specifies either that all container images
518/// used in a pod creation request must be attested to by one or more
519/// [attestors][google.cloud.binaryauthorization.v1.Attestor], that all pod creations will be allowed, or that all
520/// pod creations will be denied.
521///
522/// Images matching an [admission allowlist pattern][google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]
523/// are exempted from admission rules and will never block a pod creation.
524///
525/// [google.cloud.binaryauthorization.v1.AdmissionRule]: crate::model::AdmissionRule
526/// [google.cloud.binaryauthorization.v1.AdmissionWhitelistPattern]: crate::model::AdmissionWhitelistPattern
527/// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
528#[derive(Clone, Default, PartialEq)]
529#[non_exhaustive]
530pub struct AdmissionRule {
531    /// Required. How this admission rule will be evaluated.
532    pub evaluation_mode: crate::model::admission_rule::EvaluationMode,
533
534    /// Optional. The resource names of the attestors that must attest to
535    /// a container image, in the format `projects/*/attestors/*`. Each
536    /// attestor must exist before a policy can reference it.  To add an attestor
537    /// to a policy the principal issuing the policy change request must be able
538    /// to read the attestor resource.
539    ///
540    /// Note: this field must be non-empty when the evaluation_mode field specifies
541    /// REQUIRE_ATTESTATION, otherwise it must be empty.
542    pub require_attestations_by: std::vec::Vec<std::string::String>,
543
544    /// Required. The action when a pod creation is denied by the admission rule.
545    pub enforcement_mode: crate::model::admission_rule::EnforcementMode,
546
547    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
548}
549
550impl AdmissionRule {
551    /// Creates a new default instance.
552    pub fn new() -> Self {
553        std::default::Default::default()
554    }
555
556    /// Sets the value of [evaluation_mode][crate::model::AdmissionRule::evaluation_mode].
557    ///
558    /// # Example
559    /// ```ignore,no_run
560    /// # use google_cloud_binaryauthorization_v1::model::AdmissionRule;
561    /// use google_cloud_binaryauthorization_v1::model::admission_rule::EvaluationMode;
562    /// let x0 = AdmissionRule::new().set_evaluation_mode(EvaluationMode::AlwaysAllow);
563    /// let x1 = AdmissionRule::new().set_evaluation_mode(EvaluationMode::RequireAttestation);
564    /// let x2 = AdmissionRule::new().set_evaluation_mode(EvaluationMode::AlwaysDeny);
565    /// ```
566    pub fn set_evaluation_mode<
567        T: std::convert::Into<crate::model::admission_rule::EvaluationMode>,
568    >(
569        mut self,
570        v: T,
571    ) -> Self {
572        self.evaluation_mode = v.into();
573        self
574    }
575
576    /// Sets the value of [require_attestations_by][crate::model::AdmissionRule::require_attestations_by].
577    ///
578    /// # Example
579    /// ```ignore,no_run
580    /// # use google_cloud_binaryauthorization_v1::model::AdmissionRule;
581    /// let x = AdmissionRule::new().set_require_attestations_by(["a", "b", "c"]);
582    /// ```
583    pub fn set_require_attestations_by<T, V>(mut self, v: T) -> Self
584    where
585        T: std::iter::IntoIterator<Item = V>,
586        V: std::convert::Into<std::string::String>,
587    {
588        use std::iter::Iterator;
589        self.require_attestations_by = v.into_iter().map(|i| i.into()).collect();
590        self
591    }
592
593    /// Sets the value of [enforcement_mode][crate::model::AdmissionRule::enforcement_mode].
594    ///
595    /// # Example
596    /// ```ignore,no_run
597    /// # use google_cloud_binaryauthorization_v1::model::AdmissionRule;
598    /// use google_cloud_binaryauthorization_v1::model::admission_rule::EnforcementMode;
599    /// let x0 = AdmissionRule::new().set_enforcement_mode(EnforcementMode::EnforcedBlockAndAuditLog);
600    /// let x1 = AdmissionRule::new().set_enforcement_mode(EnforcementMode::DryrunAuditLogOnly);
601    /// ```
602    pub fn set_enforcement_mode<
603        T: std::convert::Into<crate::model::admission_rule::EnforcementMode>,
604    >(
605        mut self,
606        v: T,
607    ) -> Self {
608        self.enforcement_mode = v.into();
609        self
610    }
611}
612
613impl wkt::message::Message for AdmissionRule {
614    fn typename() -> &'static str {
615        "type.googleapis.com/google.cloud.binaryauthorization.v1.AdmissionRule"
616    }
617}
618
619/// Defines additional types related to [AdmissionRule].
620pub mod admission_rule {
621    #[allow(unused_imports)]
622    use super::*;
623
624    /// Enum for [EvaluationMode].
625    ///
626    /// # Working with unknown values
627    ///
628    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
629    /// additional enum variants at any time. Adding new variants is not considered
630    /// a breaking change. Applications should write their code in anticipation of:
631    ///
632    /// - New values appearing in future releases of the client library, **and**
633    /// - New values received dynamically, without application changes.
634    ///
635    /// Please consult the [Working with enums] section in the user guide for some
636    /// guidelines.
637    ///
638    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
639    #[derive(Clone, Debug, PartialEq)]
640    #[non_exhaustive]
641    pub enum EvaluationMode {
642        /// Do not use.
643        Unspecified,
644        /// This rule allows all all pod creations.
645        AlwaysAllow,
646        /// This rule allows a pod creation if all the attestors listed in
647        /// 'require_attestations_by' have valid attestations for all of the
648        /// images in the pod spec.
649        RequireAttestation,
650        /// This rule denies all pod creations.
651        AlwaysDeny,
652        /// If set, the enum was initialized with an unknown value.
653        ///
654        /// Applications can examine the value using [EvaluationMode::value] or
655        /// [EvaluationMode::name].
656        UnknownValue(evaluation_mode::UnknownValue),
657    }
658
659    #[doc(hidden)]
660    pub mod evaluation_mode {
661        #[allow(unused_imports)]
662        use super::*;
663        #[derive(Clone, Debug, PartialEq)]
664        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
665    }
666
667    impl EvaluationMode {
668        /// Gets the enum value.
669        ///
670        /// Returns `None` if the enum contains an unknown value deserialized from
671        /// the string representation of enums.
672        pub fn value(&self) -> std::option::Option<i32> {
673            match self {
674                Self::Unspecified => std::option::Option::Some(0),
675                Self::AlwaysAllow => std::option::Option::Some(1),
676                Self::RequireAttestation => std::option::Option::Some(2),
677                Self::AlwaysDeny => std::option::Option::Some(3),
678                Self::UnknownValue(u) => u.0.value(),
679            }
680        }
681
682        /// Gets the enum value as a string.
683        ///
684        /// Returns `None` if the enum contains an unknown value deserialized from
685        /// the integer representation of enums.
686        pub fn name(&self) -> std::option::Option<&str> {
687            match self {
688                Self::Unspecified => std::option::Option::Some("EVALUATION_MODE_UNSPECIFIED"),
689                Self::AlwaysAllow => std::option::Option::Some("ALWAYS_ALLOW"),
690                Self::RequireAttestation => std::option::Option::Some("REQUIRE_ATTESTATION"),
691                Self::AlwaysDeny => std::option::Option::Some("ALWAYS_DENY"),
692                Self::UnknownValue(u) => u.0.name(),
693            }
694        }
695    }
696
697    impl std::default::Default for EvaluationMode {
698        fn default() -> Self {
699            use std::convert::From;
700            Self::from(0)
701        }
702    }
703
704    impl std::fmt::Display for EvaluationMode {
705        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
706            wkt::internal::display_enum(f, self.name(), self.value())
707        }
708    }
709
710    impl std::convert::From<i32> for EvaluationMode {
711        fn from(value: i32) -> Self {
712            match value {
713                0 => Self::Unspecified,
714                1 => Self::AlwaysAllow,
715                2 => Self::RequireAttestation,
716                3 => Self::AlwaysDeny,
717                _ => Self::UnknownValue(evaluation_mode::UnknownValue(
718                    wkt::internal::UnknownEnumValue::Integer(value),
719                )),
720            }
721        }
722    }
723
724    impl std::convert::From<&str> for EvaluationMode {
725        fn from(value: &str) -> Self {
726            use std::string::ToString;
727            match value {
728                "EVALUATION_MODE_UNSPECIFIED" => Self::Unspecified,
729                "ALWAYS_ALLOW" => Self::AlwaysAllow,
730                "REQUIRE_ATTESTATION" => Self::RequireAttestation,
731                "ALWAYS_DENY" => Self::AlwaysDeny,
732                _ => Self::UnknownValue(evaluation_mode::UnknownValue(
733                    wkt::internal::UnknownEnumValue::String(value.to_string()),
734                )),
735            }
736        }
737    }
738
739    impl serde::ser::Serialize for EvaluationMode {
740        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
741        where
742            S: serde::Serializer,
743        {
744            match self {
745                Self::Unspecified => serializer.serialize_i32(0),
746                Self::AlwaysAllow => serializer.serialize_i32(1),
747                Self::RequireAttestation => serializer.serialize_i32(2),
748                Self::AlwaysDeny => serializer.serialize_i32(3),
749                Self::UnknownValue(u) => u.0.serialize(serializer),
750            }
751        }
752    }
753
754    impl<'de> serde::de::Deserialize<'de> for EvaluationMode {
755        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
756        where
757            D: serde::Deserializer<'de>,
758        {
759            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EvaluationMode>::new(
760                ".google.cloud.binaryauthorization.v1.AdmissionRule.EvaluationMode",
761            ))
762        }
763    }
764
765    /// Defines the possible actions when a pod creation is denied by an admission
766    /// rule.
767    ///
768    /// # Working with unknown values
769    ///
770    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
771    /// additional enum variants at any time. Adding new variants is not considered
772    /// a breaking change. Applications should write their code in anticipation of:
773    ///
774    /// - New values appearing in future releases of the client library, **and**
775    /// - New values received dynamically, without application changes.
776    ///
777    /// Please consult the [Working with enums] section in the user guide for some
778    /// guidelines.
779    ///
780    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
781    #[derive(Clone, Debug, PartialEq)]
782    #[non_exhaustive]
783    pub enum EnforcementMode {
784        /// Do not use.
785        Unspecified,
786        /// Enforce the admission rule by blocking the pod creation.
787        EnforcedBlockAndAuditLog,
788        /// Dryrun mode: Audit logging only.  This will allow the pod creation as if
789        /// the admission request had specified break-glass.
790        DryrunAuditLogOnly,
791        /// If set, the enum was initialized with an unknown value.
792        ///
793        /// Applications can examine the value using [EnforcementMode::value] or
794        /// [EnforcementMode::name].
795        UnknownValue(enforcement_mode::UnknownValue),
796    }
797
798    #[doc(hidden)]
799    pub mod enforcement_mode {
800        #[allow(unused_imports)]
801        use super::*;
802        #[derive(Clone, Debug, PartialEq)]
803        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
804    }
805
806    impl EnforcementMode {
807        /// Gets the enum value.
808        ///
809        /// Returns `None` if the enum contains an unknown value deserialized from
810        /// the string representation of enums.
811        pub fn value(&self) -> std::option::Option<i32> {
812            match self {
813                Self::Unspecified => std::option::Option::Some(0),
814                Self::EnforcedBlockAndAuditLog => std::option::Option::Some(1),
815                Self::DryrunAuditLogOnly => std::option::Option::Some(2),
816                Self::UnknownValue(u) => u.0.value(),
817            }
818        }
819
820        /// Gets the enum value as a string.
821        ///
822        /// Returns `None` if the enum contains an unknown value deserialized from
823        /// the integer representation of enums.
824        pub fn name(&self) -> std::option::Option<&str> {
825            match self {
826                Self::Unspecified => std::option::Option::Some("ENFORCEMENT_MODE_UNSPECIFIED"),
827                Self::EnforcedBlockAndAuditLog => {
828                    std::option::Option::Some("ENFORCED_BLOCK_AND_AUDIT_LOG")
829                }
830                Self::DryrunAuditLogOnly => std::option::Option::Some("DRYRUN_AUDIT_LOG_ONLY"),
831                Self::UnknownValue(u) => u.0.name(),
832            }
833        }
834    }
835
836    impl std::default::Default for EnforcementMode {
837        fn default() -> Self {
838            use std::convert::From;
839            Self::from(0)
840        }
841    }
842
843    impl std::fmt::Display for EnforcementMode {
844        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
845            wkt::internal::display_enum(f, self.name(), self.value())
846        }
847    }
848
849    impl std::convert::From<i32> for EnforcementMode {
850        fn from(value: i32) -> Self {
851            match value {
852                0 => Self::Unspecified,
853                1 => Self::EnforcedBlockAndAuditLog,
854                2 => Self::DryrunAuditLogOnly,
855                _ => Self::UnknownValue(enforcement_mode::UnknownValue(
856                    wkt::internal::UnknownEnumValue::Integer(value),
857                )),
858            }
859        }
860    }
861
862    impl std::convert::From<&str> for EnforcementMode {
863        fn from(value: &str) -> Self {
864            use std::string::ToString;
865            match value {
866                "ENFORCEMENT_MODE_UNSPECIFIED" => Self::Unspecified,
867                "ENFORCED_BLOCK_AND_AUDIT_LOG" => Self::EnforcedBlockAndAuditLog,
868                "DRYRUN_AUDIT_LOG_ONLY" => Self::DryrunAuditLogOnly,
869                _ => Self::UnknownValue(enforcement_mode::UnknownValue(
870                    wkt::internal::UnknownEnumValue::String(value.to_string()),
871                )),
872            }
873        }
874    }
875
876    impl serde::ser::Serialize for EnforcementMode {
877        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
878        where
879            S: serde::Serializer,
880        {
881            match self {
882                Self::Unspecified => serializer.serialize_i32(0),
883                Self::EnforcedBlockAndAuditLog => serializer.serialize_i32(1),
884                Self::DryrunAuditLogOnly => serializer.serialize_i32(2),
885                Self::UnknownValue(u) => u.0.serialize(serializer),
886            }
887        }
888    }
889
890    impl<'de> serde::de::Deserialize<'de> for EnforcementMode {
891        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
892        where
893            D: serde::Deserializer<'de>,
894        {
895            deserializer.deserialize_any(wkt::internal::EnumVisitor::<EnforcementMode>::new(
896                ".google.cloud.binaryauthorization.v1.AdmissionRule.EnforcementMode",
897            ))
898        }
899    }
900}
901
902/// An [attestor][google.cloud.binaryauthorization.v1.Attestor] that attests to container image
903/// artifacts. An existing attestor cannot be modified except where
904/// indicated.
905///
906/// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
907#[derive(Clone, Default, PartialEq)]
908#[non_exhaustive]
909pub struct Attestor {
910    /// Required. The resource name, in the format:
911    /// `projects/*/attestors/*`. This field may not be updated.
912    pub name: std::string::String,
913
914    /// Optional. A descriptive comment.  This field may be updated.
915    /// The field may be displayed in chooser dialogs.
916    pub description: std::string::String,
917
918    /// Output only. Time when the attestor was last updated.
919    pub update_time: std::option::Option<wkt::Timestamp>,
920
921    #[allow(missing_docs)]
922    pub attestor_type: std::option::Option<crate::model::attestor::AttestorType>,
923
924    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
925}
926
927impl Attestor {
928    /// Creates a new default instance.
929    pub fn new() -> Self {
930        std::default::Default::default()
931    }
932
933    /// Sets the value of [name][crate::model::Attestor::name].
934    ///
935    /// # Example
936    /// ```ignore,no_run
937    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
938    /// let x = Attestor::new().set_name("example");
939    /// ```
940    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
941        self.name = v.into();
942        self
943    }
944
945    /// Sets the value of [description][crate::model::Attestor::description].
946    ///
947    /// # Example
948    /// ```ignore,no_run
949    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
950    /// let x = Attestor::new().set_description("example");
951    /// ```
952    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
953        self.description = v.into();
954        self
955    }
956
957    /// Sets the value of [update_time][crate::model::Attestor::update_time].
958    ///
959    /// # Example
960    /// ```ignore,no_run
961    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
962    /// use wkt::Timestamp;
963    /// let x = Attestor::new().set_update_time(Timestamp::default()/* use setters */);
964    /// ```
965    pub fn set_update_time<T>(mut self, v: T) -> Self
966    where
967        T: std::convert::Into<wkt::Timestamp>,
968    {
969        self.update_time = std::option::Option::Some(v.into());
970        self
971    }
972
973    /// Sets or clears the value of [update_time][crate::model::Attestor::update_time].
974    ///
975    /// # Example
976    /// ```ignore,no_run
977    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
978    /// use wkt::Timestamp;
979    /// let x = Attestor::new().set_or_clear_update_time(Some(Timestamp::default()/* use setters */));
980    /// let x = Attestor::new().set_or_clear_update_time(None::<Timestamp>);
981    /// ```
982    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
983    where
984        T: std::convert::Into<wkt::Timestamp>,
985    {
986        self.update_time = v.map(|x| x.into());
987        self
988    }
989
990    /// Sets the value of [attestor_type][crate::model::Attestor::attestor_type].
991    ///
992    /// Note that all the setters affecting `attestor_type` are mutually
993    /// exclusive.
994    ///
995    /// # Example
996    /// ```ignore,no_run
997    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
998    /// use google_cloud_binaryauthorization_v1::model::UserOwnedGrafeasNote;
999    /// let x = Attestor::new().set_attestor_type(Some(
1000    ///     google_cloud_binaryauthorization_v1::model::attestor::AttestorType::UserOwnedGrafeasNote(UserOwnedGrafeasNote::default().into())));
1001    /// ```
1002    pub fn set_attestor_type<
1003        T: std::convert::Into<std::option::Option<crate::model::attestor::AttestorType>>,
1004    >(
1005        mut self,
1006        v: T,
1007    ) -> Self {
1008        self.attestor_type = v.into();
1009        self
1010    }
1011
1012    /// The value of [attestor_type][crate::model::Attestor::attestor_type]
1013    /// if it holds a `UserOwnedGrafeasNote`, `None` if the field is not set or
1014    /// holds a different branch.
1015    pub fn user_owned_grafeas_note(
1016        &self,
1017    ) -> std::option::Option<&std::boxed::Box<crate::model::UserOwnedGrafeasNote>> {
1018        #[allow(unreachable_patterns)]
1019        self.attestor_type.as_ref().and_then(|v| match v {
1020            crate::model::attestor::AttestorType::UserOwnedGrafeasNote(v) => {
1021                std::option::Option::Some(v)
1022            }
1023            _ => std::option::Option::None,
1024        })
1025    }
1026
1027    /// Sets the value of [attestor_type][crate::model::Attestor::attestor_type]
1028    /// to hold a `UserOwnedGrafeasNote`.
1029    ///
1030    /// Note that all the setters affecting `attestor_type` are
1031    /// mutually exclusive.
1032    ///
1033    /// # Example
1034    /// ```ignore,no_run
1035    /// # use google_cloud_binaryauthorization_v1::model::Attestor;
1036    /// use google_cloud_binaryauthorization_v1::model::UserOwnedGrafeasNote;
1037    /// let x = Attestor::new().set_user_owned_grafeas_note(UserOwnedGrafeasNote::default()/* use setters */);
1038    /// assert!(x.user_owned_grafeas_note().is_some());
1039    /// ```
1040    pub fn set_user_owned_grafeas_note<
1041        T: std::convert::Into<std::boxed::Box<crate::model::UserOwnedGrafeasNote>>,
1042    >(
1043        mut self,
1044        v: T,
1045    ) -> Self {
1046        self.attestor_type = std::option::Option::Some(
1047            crate::model::attestor::AttestorType::UserOwnedGrafeasNote(v.into()),
1048        );
1049        self
1050    }
1051}
1052
1053impl wkt::message::Message for Attestor {
1054    fn typename() -> &'static str {
1055        "type.googleapis.com/google.cloud.binaryauthorization.v1.Attestor"
1056    }
1057}
1058
1059/// Defines additional types related to [Attestor].
1060pub mod attestor {
1061    #[allow(unused_imports)]
1062    use super::*;
1063
1064    #[allow(missing_docs)]
1065    #[derive(Clone, Debug, PartialEq)]
1066    #[non_exhaustive]
1067    pub enum AttestorType {
1068        /// This specifies how an attestation will be read, and how it will be used
1069        /// during policy enforcement.
1070        UserOwnedGrafeasNote(std::boxed::Box<crate::model::UserOwnedGrafeasNote>),
1071    }
1072}
1073
1074/// An [user owned Grafeas note][google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote] references a Grafeas
1075/// Attestation.Authority Note created by the user.
1076///
1077/// [google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote]: crate::model::UserOwnedGrafeasNote
1078#[derive(Clone, Default, PartialEq)]
1079#[non_exhaustive]
1080pub struct UserOwnedGrafeasNote {
1081    /// Required. The Grafeas resource name of a Attestation.Authority Note,
1082    /// created by the user, in the format: `projects/*/notes/*`. This field may
1083    /// not be updated.
1084    ///
1085    /// An attestation by this attestor is stored as a Grafeas
1086    /// Attestation.Authority Occurrence that names a container image and that
1087    /// links to this Note. Grafeas is an external dependency.
1088    pub note_reference: std::string::String,
1089
1090    /// Optional. Public keys that verify attestations signed by this
1091    /// attestor.  This field may be updated.
1092    ///
1093    /// If this field is non-empty, one of the specified public keys must
1094    /// verify that an attestation was signed by this attestor for the
1095    /// image specified in the admission request.
1096    ///
1097    /// If this field is empty, this attestor always returns that no
1098    /// valid attestations exist.
1099    pub public_keys: std::vec::Vec<crate::model::AttestorPublicKey>,
1100
1101    /// Output only. This field will contain the service account email address
1102    /// that this Attestor will use as the principal when querying Container
1103    /// Analysis. Attestor administrators must grant this service account the
1104    /// IAM role needed to read attestations from the [note_reference][Note] in
1105    /// Container Analysis (`containeranalysis.notes.occurrences.viewer`).
1106    ///
1107    /// This email address is fixed for the lifetime of the Attestor, but callers
1108    /// should not make any other assumptions about the service account email;
1109    /// future versions may use an email based on a different naming pattern.
1110    pub delegation_service_account_email: std::string::String,
1111
1112    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1113}
1114
1115impl UserOwnedGrafeasNote {
1116    /// Creates a new default instance.
1117    pub fn new() -> Self {
1118        std::default::Default::default()
1119    }
1120
1121    /// Sets the value of [note_reference][crate::model::UserOwnedGrafeasNote::note_reference].
1122    ///
1123    /// # Example
1124    /// ```ignore,no_run
1125    /// # use google_cloud_binaryauthorization_v1::model::UserOwnedGrafeasNote;
1126    /// let x = UserOwnedGrafeasNote::new().set_note_reference("example");
1127    /// ```
1128    pub fn set_note_reference<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1129        self.note_reference = v.into();
1130        self
1131    }
1132
1133    /// Sets the value of [public_keys][crate::model::UserOwnedGrafeasNote::public_keys].
1134    ///
1135    /// # Example
1136    /// ```ignore,no_run
1137    /// # use google_cloud_binaryauthorization_v1::model::UserOwnedGrafeasNote;
1138    /// use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1139    /// let x = UserOwnedGrafeasNote::new()
1140    ///     .set_public_keys([
1141    ///         AttestorPublicKey::default()/* use setters */,
1142    ///         AttestorPublicKey::default()/* use (different) setters */,
1143    ///     ]);
1144    /// ```
1145    pub fn set_public_keys<T, V>(mut self, v: T) -> Self
1146    where
1147        T: std::iter::IntoIterator<Item = V>,
1148        V: std::convert::Into<crate::model::AttestorPublicKey>,
1149    {
1150        use std::iter::Iterator;
1151        self.public_keys = v.into_iter().map(|i| i.into()).collect();
1152        self
1153    }
1154
1155    /// Sets the value of [delegation_service_account_email][crate::model::UserOwnedGrafeasNote::delegation_service_account_email].
1156    ///
1157    /// # Example
1158    /// ```ignore,no_run
1159    /// # use google_cloud_binaryauthorization_v1::model::UserOwnedGrafeasNote;
1160    /// let x = UserOwnedGrafeasNote::new().set_delegation_service_account_email("example");
1161    /// ```
1162    pub fn set_delegation_service_account_email<T: std::convert::Into<std::string::String>>(
1163        mut self,
1164        v: T,
1165    ) -> Self {
1166        self.delegation_service_account_email = v.into();
1167        self
1168    }
1169}
1170
1171impl wkt::message::Message for UserOwnedGrafeasNote {
1172    fn typename() -> &'static str {
1173        "type.googleapis.com/google.cloud.binaryauthorization.v1.UserOwnedGrafeasNote"
1174    }
1175}
1176
1177/// A public key in the PkixPublicKey format (see
1178/// <https://tools.ietf.org/html/rfc5280#section-4.1.2.7> for details).
1179/// Public keys of this type are typically textually encoded using the PEM
1180/// format.
1181#[derive(Clone, Default, PartialEq)]
1182#[non_exhaustive]
1183pub struct PkixPublicKey {
1184    /// A PEM-encoded public key, as described in
1185    /// <https://tools.ietf.org/html/rfc7468#section-13>
1186    pub public_key_pem: std::string::String,
1187
1188    /// The signature algorithm used to verify a message against a signature using
1189    /// this key.
1190    /// These signature algorithm must match the structure and any object
1191    /// identifiers encoded in `public_key_pem` (i.e. this algorithm must match
1192    /// that of the public key).
1193    pub signature_algorithm: crate::model::pkix_public_key::SignatureAlgorithm,
1194
1195    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1196}
1197
1198impl PkixPublicKey {
1199    /// Creates a new default instance.
1200    pub fn new() -> Self {
1201        std::default::Default::default()
1202    }
1203
1204    /// Sets the value of [public_key_pem][crate::model::PkixPublicKey::public_key_pem].
1205    ///
1206    /// # Example
1207    /// ```ignore,no_run
1208    /// # use google_cloud_binaryauthorization_v1::model::PkixPublicKey;
1209    /// let x = PkixPublicKey::new().set_public_key_pem("example");
1210    /// ```
1211    pub fn set_public_key_pem<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1212        self.public_key_pem = v.into();
1213        self
1214    }
1215
1216    /// Sets the value of [signature_algorithm][crate::model::PkixPublicKey::signature_algorithm].
1217    ///
1218    /// # Example
1219    /// ```ignore,no_run
1220    /// # use google_cloud_binaryauthorization_v1::model::PkixPublicKey;
1221    /// use google_cloud_binaryauthorization_v1::model::pkix_public_key::SignatureAlgorithm;
1222    /// let x0 = PkixPublicKey::new().set_signature_algorithm(SignatureAlgorithm::RsaPss2048Sha256);
1223    /// let x1 = PkixPublicKey::new().set_signature_algorithm(SignatureAlgorithm::RsaPss3072Sha256);
1224    /// let x2 = PkixPublicKey::new().set_signature_algorithm(SignatureAlgorithm::RsaPss4096Sha256);
1225    /// ```
1226    pub fn set_signature_algorithm<
1227        T: std::convert::Into<crate::model::pkix_public_key::SignatureAlgorithm>,
1228    >(
1229        mut self,
1230        v: T,
1231    ) -> Self {
1232        self.signature_algorithm = v.into();
1233        self
1234    }
1235}
1236
1237impl wkt::message::Message for PkixPublicKey {
1238    fn typename() -> &'static str {
1239        "type.googleapis.com/google.cloud.binaryauthorization.v1.PkixPublicKey"
1240    }
1241}
1242
1243/// Defines additional types related to [PkixPublicKey].
1244pub mod pkix_public_key {
1245    #[allow(unused_imports)]
1246    use super::*;
1247
1248    /// Represents a signature algorithm and other information necessary to verify
1249    /// signatures with a given public key.
1250    /// This is based primarily on the public key types supported by Tink's
1251    /// PemKeyType, which is in turn based on KMS's supported signing algorithms.
1252    /// See <https://cloud.google.com/kms/docs/algorithms>. In the future, BinAuthz
1253    /// might support additional public key types independently of Tink and/or KMS.
1254    ///
1255    /// # Working with unknown values
1256    ///
1257    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
1258    /// additional enum variants at any time. Adding new variants is not considered
1259    /// a breaking change. Applications should write their code in anticipation of:
1260    ///
1261    /// - New values appearing in future releases of the client library, **and**
1262    /// - New values received dynamically, without application changes.
1263    ///
1264    /// Please consult the [Working with enums] section in the user guide for some
1265    /// guidelines.
1266    ///
1267    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
1268    #[derive(Clone, Debug, PartialEq)]
1269    #[non_exhaustive]
1270    pub enum SignatureAlgorithm {
1271        /// Not specified.
1272        Unspecified,
1273        /// RSASSA-PSS 2048 bit key with a SHA256 digest.
1274        RsaPss2048Sha256,
1275        /// RSASSA-PSS 3072 bit key with a SHA256 digest.
1276        RsaPss3072Sha256,
1277        /// RSASSA-PSS 4096 bit key with a SHA256 digest.
1278        RsaPss4096Sha256,
1279        /// RSASSA-PSS 4096 bit key with a SHA512 digest.
1280        RsaPss4096Sha512,
1281        /// RSASSA-PKCS1-v1_5 with a 2048 bit key and a SHA256 digest.
1282        RsaSignPkcs12048Sha256,
1283        /// RSASSA-PKCS1-v1_5 with a 3072 bit key and a SHA256 digest.
1284        RsaSignPkcs13072Sha256,
1285        /// RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA256 digest.
1286        RsaSignPkcs14096Sha256,
1287        /// RSASSA-PKCS1-v1_5 with a 4096 bit key and a SHA512 digest.
1288        RsaSignPkcs14096Sha512,
1289        /// ECDSA on the NIST P-256 curve with a SHA256 digest.
1290        EcdsaP256Sha256,
1291        /// ECDSA on the NIST P-256 curve with a SHA256 digest.
1292        EcSignP256Sha256,
1293        /// ECDSA on the NIST P-384 curve with a SHA384 digest.
1294        EcdsaP384Sha384,
1295        /// ECDSA on the NIST P-384 curve with a SHA384 digest.
1296        EcSignP384Sha384,
1297        /// ECDSA on the NIST P-521 curve with a SHA512 digest.
1298        EcdsaP521Sha512,
1299        /// ECDSA on the NIST P-521 curve with a SHA512 digest.
1300        EcSignP521Sha512,
1301        /// If set, the enum was initialized with an unknown value.
1302        ///
1303        /// Applications can examine the value using [SignatureAlgorithm::value] or
1304        /// [SignatureAlgorithm::name].
1305        UnknownValue(signature_algorithm::UnknownValue),
1306    }
1307
1308    #[doc(hidden)]
1309    pub mod signature_algorithm {
1310        #[allow(unused_imports)]
1311        use super::*;
1312        #[derive(Clone, Debug, PartialEq)]
1313        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1314    }
1315
1316    impl SignatureAlgorithm {
1317        /// Gets the enum value.
1318        ///
1319        /// Returns `None` if the enum contains an unknown value deserialized from
1320        /// the string representation of enums.
1321        pub fn value(&self) -> std::option::Option<i32> {
1322            match self {
1323                Self::Unspecified => std::option::Option::Some(0),
1324                Self::RsaPss2048Sha256 => std::option::Option::Some(1),
1325                Self::RsaPss3072Sha256 => std::option::Option::Some(2),
1326                Self::RsaPss4096Sha256 => std::option::Option::Some(3),
1327                Self::RsaPss4096Sha512 => std::option::Option::Some(4),
1328                Self::RsaSignPkcs12048Sha256 => std::option::Option::Some(5),
1329                Self::RsaSignPkcs13072Sha256 => std::option::Option::Some(6),
1330                Self::RsaSignPkcs14096Sha256 => std::option::Option::Some(7),
1331                Self::RsaSignPkcs14096Sha512 => std::option::Option::Some(8),
1332                Self::EcdsaP256Sha256 => std::option::Option::Some(9),
1333                Self::EcSignP256Sha256 => std::option::Option::Some(9),
1334                Self::EcdsaP384Sha384 => std::option::Option::Some(10),
1335                Self::EcSignP384Sha384 => std::option::Option::Some(10),
1336                Self::EcdsaP521Sha512 => std::option::Option::Some(11),
1337                Self::EcSignP521Sha512 => std::option::Option::Some(11),
1338                Self::UnknownValue(u) => u.0.value(),
1339            }
1340        }
1341
1342        /// Gets the enum value as a string.
1343        ///
1344        /// Returns `None` if the enum contains an unknown value deserialized from
1345        /// the integer representation of enums.
1346        pub fn name(&self) -> std::option::Option<&str> {
1347            match self {
1348                Self::Unspecified => std::option::Option::Some("SIGNATURE_ALGORITHM_UNSPECIFIED"),
1349                Self::RsaPss2048Sha256 => std::option::Option::Some("RSA_PSS_2048_SHA256"),
1350                Self::RsaPss3072Sha256 => std::option::Option::Some("RSA_PSS_3072_SHA256"),
1351                Self::RsaPss4096Sha256 => std::option::Option::Some("RSA_PSS_4096_SHA256"),
1352                Self::RsaPss4096Sha512 => std::option::Option::Some("RSA_PSS_4096_SHA512"),
1353                Self::RsaSignPkcs12048Sha256 => {
1354                    std::option::Option::Some("RSA_SIGN_PKCS1_2048_SHA256")
1355                }
1356                Self::RsaSignPkcs13072Sha256 => {
1357                    std::option::Option::Some("RSA_SIGN_PKCS1_3072_SHA256")
1358                }
1359                Self::RsaSignPkcs14096Sha256 => {
1360                    std::option::Option::Some("RSA_SIGN_PKCS1_4096_SHA256")
1361                }
1362                Self::RsaSignPkcs14096Sha512 => {
1363                    std::option::Option::Some("RSA_SIGN_PKCS1_4096_SHA512")
1364                }
1365                Self::EcdsaP256Sha256 => std::option::Option::Some("ECDSA_P256_SHA256"),
1366                Self::EcSignP256Sha256 => std::option::Option::Some("EC_SIGN_P256_SHA256"),
1367                Self::EcdsaP384Sha384 => std::option::Option::Some("ECDSA_P384_SHA384"),
1368                Self::EcSignP384Sha384 => std::option::Option::Some("EC_SIGN_P384_SHA384"),
1369                Self::EcdsaP521Sha512 => std::option::Option::Some("ECDSA_P521_SHA512"),
1370                Self::EcSignP521Sha512 => std::option::Option::Some("EC_SIGN_P521_SHA512"),
1371                Self::UnknownValue(u) => u.0.name(),
1372            }
1373        }
1374    }
1375
1376    impl std::default::Default for SignatureAlgorithm {
1377        fn default() -> Self {
1378            use std::convert::From;
1379            Self::from(0)
1380        }
1381    }
1382
1383    impl std::fmt::Display for SignatureAlgorithm {
1384        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1385            wkt::internal::display_enum(f, self.name(), self.value())
1386        }
1387    }
1388
1389    impl std::convert::From<i32> for SignatureAlgorithm {
1390        fn from(value: i32) -> Self {
1391            match value {
1392                0 => Self::Unspecified,
1393                1 => Self::RsaPss2048Sha256,
1394                2 => Self::RsaPss3072Sha256,
1395                3 => Self::RsaPss4096Sha256,
1396                4 => Self::RsaPss4096Sha512,
1397                5 => Self::RsaSignPkcs12048Sha256,
1398                6 => Self::RsaSignPkcs13072Sha256,
1399                7 => Self::RsaSignPkcs14096Sha256,
1400                8 => Self::RsaSignPkcs14096Sha512,
1401                9 => Self::EcdsaP256Sha256,
1402                10 => Self::EcdsaP384Sha384,
1403                11 => Self::EcdsaP521Sha512,
1404                _ => Self::UnknownValue(signature_algorithm::UnknownValue(
1405                    wkt::internal::UnknownEnumValue::Integer(value),
1406                )),
1407            }
1408        }
1409    }
1410
1411    impl std::convert::From<&str> for SignatureAlgorithm {
1412        fn from(value: &str) -> Self {
1413            use std::string::ToString;
1414            match value {
1415                "SIGNATURE_ALGORITHM_UNSPECIFIED" => Self::Unspecified,
1416                "RSA_PSS_2048_SHA256" => Self::RsaPss2048Sha256,
1417                "RSA_PSS_3072_SHA256" => Self::RsaPss3072Sha256,
1418                "RSA_PSS_4096_SHA256" => Self::RsaPss4096Sha256,
1419                "RSA_PSS_4096_SHA512" => Self::RsaPss4096Sha512,
1420                "RSA_SIGN_PKCS1_2048_SHA256" => Self::RsaSignPkcs12048Sha256,
1421                "RSA_SIGN_PKCS1_3072_SHA256" => Self::RsaSignPkcs13072Sha256,
1422                "RSA_SIGN_PKCS1_4096_SHA256" => Self::RsaSignPkcs14096Sha256,
1423                "RSA_SIGN_PKCS1_4096_SHA512" => Self::RsaSignPkcs14096Sha512,
1424                "ECDSA_P256_SHA256" => Self::EcdsaP256Sha256,
1425                "EC_SIGN_P256_SHA256" => Self::EcSignP256Sha256,
1426                "ECDSA_P384_SHA384" => Self::EcdsaP384Sha384,
1427                "EC_SIGN_P384_SHA384" => Self::EcSignP384Sha384,
1428                "ECDSA_P521_SHA512" => Self::EcdsaP521Sha512,
1429                "EC_SIGN_P521_SHA512" => Self::EcSignP521Sha512,
1430                _ => Self::UnknownValue(signature_algorithm::UnknownValue(
1431                    wkt::internal::UnknownEnumValue::String(value.to_string()),
1432                )),
1433            }
1434        }
1435    }
1436
1437    impl serde::ser::Serialize for SignatureAlgorithm {
1438        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1439        where
1440            S: serde::Serializer,
1441        {
1442            match self {
1443                Self::Unspecified => serializer.serialize_i32(0),
1444                Self::RsaPss2048Sha256 => serializer.serialize_i32(1),
1445                Self::RsaPss3072Sha256 => serializer.serialize_i32(2),
1446                Self::RsaPss4096Sha256 => serializer.serialize_i32(3),
1447                Self::RsaPss4096Sha512 => serializer.serialize_i32(4),
1448                Self::RsaSignPkcs12048Sha256 => serializer.serialize_i32(5),
1449                Self::RsaSignPkcs13072Sha256 => serializer.serialize_i32(6),
1450                Self::RsaSignPkcs14096Sha256 => serializer.serialize_i32(7),
1451                Self::RsaSignPkcs14096Sha512 => serializer.serialize_i32(8),
1452                Self::EcdsaP256Sha256 => serializer.serialize_i32(9),
1453                Self::EcSignP256Sha256 => serializer.serialize_i32(9),
1454                Self::EcdsaP384Sha384 => serializer.serialize_i32(10),
1455                Self::EcSignP384Sha384 => serializer.serialize_i32(10),
1456                Self::EcdsaP521Sha512 => serializer.serialize_i32(11),
1457                Self::EcSignP521Sha512 => serializer.serialize_i32(11),
1458                Self::UnknownValue(u) => u.0.serialize(serializer),
1459            }
1460        }
1461    }
1462
1463    impl<'de> serde::de::Deserialize<'de> for SignatureAlgorithm {
1464        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1465        where
1466            D: serde::Deserializer<'de>,
1467        {
1468            deserializer.deserialize_any(wkt::internal::EnumVisitor::<SignatureAlgorithm>::new(
1469                ".google.cloud.binaryauthorization.v1.PkixPublicKey.SignatureAlgorithm",
1470            ))
1471        }
1472    }
1473}
1474
1475/// An [attestor public key][google.cloud.binaryauthorization.v1.AttestorPublicKey] that will be used to verify
1476/// attestations signed by this attestor.
1477///
1478/// [google.cloud.binaryauthorization.v1.AttestorPublicKey]: crate::model::AttestorPublicKey
1479#[derive(Clone, Default, PartialEq)]
1480#[non_exhaustive]
1481pub struct AttestorPublicKey {
1482    /// Optional. A descriptive comment. This field may be updated.
1483    pub comment: std::string::String,
1484
1485    /// The ID of this public key.
1486    /// Signatures verified by BinAuthz must include the ID of the public key that
1487    /// can be used to verify them, and that ID must match the contents of this
1488    /// field exactly.
1489    /// Additional restrictions on this field can be imposed based on which public
1490    /// key type is encapsulated. See the documentation on `public_key` cases below
1491    /// for details.
1492    pub id: std::string::String,
1493
1494    #[allow(missing_docs)]
1495    pub public_key: std::option::Option<crate::model::attestor_public_key::PublicKey>,
1496
1497    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1498}
1499
1500impl AttestorPublicKey {
1501    /// Creates a new default instance.
1502    pub fn new() -> Self {
1503        std::default::Default::default()
1504    }
1505
1506    /// Sets the value of [comment][crate::model::AttestorPublicKey::comment].
1507    ///
1508    /// # Example
1509    /// ```ignore,no_run
1510    /// # use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1511    /// let x = AttestorPublicKey::new().set_comment("example");
1512    /// ```
1513    pub fn set_comment<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1514        self.comment = v.into();
1515        self
1516    }
1517
1518    /// Sets the value of [id][crate::model::AttestorPublicKey::id].
1519    ///
1520    /// # Example
1521    /// ```ignore,no_run
1522    /// # use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1523    /// let x = AttestorPublicKey::new().set_id("example");
1524    /// ```
1525    pub fn set_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1526        self.id = v.into();
1527        self
1528    }
1529
1530    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key].
1531    ///
1532    /// Note that all the setters affecting `public_key` are mutually
1533    /// exclusive.
1534    ///
1535    /// # Example
1536    /// ```ignore,no_run
1537    /// # use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1538    /// use google_cloud_binaryauthorization_v1::model::attestor_public_key::PublicKey;
1539    /// let x = AttestorPublicKey::new().set_public_key(Some(PublicKey::AsciiArmoredPgpPublicKey("example".to_string())));
1540    /// ```
1541    pub fn set_public_key<
1542        T: std::convert::Into<std::option::Option<crate::model::attestor_public_key::PublicKey>>,
1543    >(
1544        mut self,
1545        v: T,
1546    ) -> Self {
1547        self.public_key = v.into();
1548        self
1549    }
1550
1551    /// The value of [public_key][crate::model::AttestorPublicKey::public_key]
1552    /// if it holds a `AsciiArmoredPgpPublicKey`, `None` if the field is not set or
1553    /// holds a different branch.
1554    pub fn ascii_armored_pgp_public_key(&self) -> std::option::Option<&std::string::String> {
1555        #[allow(unreachable_patterns)]
1556        self.public_key.as_ref().and_then(|v| match v {
1557            crate::model::attestor_public_key::PublicKey::AsciiArmoredPgpPublicKey(v) => {
1558                std::option::Option::Some(v)
1559            }
1560            _ => std::option::Option::None,
1561        })
1562    }
1563
1564    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key]
1565    /// to hold a `AsciiArmoredPgpPublicKey`.
1566    ///
1567    /// Note that all the setters affecting `public_key` are
1568    /// mutually exclusive.
1569    ///
1570    /// # Example
1571    /// ```ignore,no_run
1572    /// # use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1573    /// let x = AttestorPublicKey::new().set_ascii_armored_pgp_public_key("example");
1574    /// assert!(x.ascii_armored_pgp_public_key().is_some());
1575    /// assert!(x.pkix_public_key().is_none());
1576    /// ```
1577    pub fn set_ascii_armored_pgp_public_key<T: std::convert::Into<std::string::String>>(
1578        mut self,
1579        v: T,
1580    ) -> Self {
1581        self.public_key = std::option::Option::Some(
1582            crate::model::attestor_public_key::PublicKey::AsciiArmoredPgpPublicKey(v.into()),
1583        );
1584        self
1585    }
1586
1587    /// The value of [public_key][crate::model::AttestorPublicKey::public_key]
1588    /// if it holds a `PkixPublicKey`, `None` if the field is not set or
1589    /// holds a different branch.
1590    pub fn pkix_public_key(
1591        &self,
1592    ) -> std::option::Option<&std::boxed::Box<crate::model::PkixPublicKey>> {
1593        #[allow(unreachable_patterns)]
1594        self.public_key.as_ref().and_then(|v| match v {
1595            crate::model::attestor_public_key::PublicKey::PkixPublicKey(v) => {
1596                std::option::Option::Some(v)
1597            }
1598            _ => std::option::Option::None,
1599        })
1600    }
1601
1602    /// Sets the value of [public_key][crate::model::AttestorPublicKey::public_key]
1603    /// to hold a `PkixPublicKey`.
1604    ///
1605    /// Note that all the setters affecting `public_key` are
1606    /// mutually exclusive.
1607    ///
1608    /// # Example
1609    /// ```ignore,no_run
1610    /// # use google_cloud_binaryauthorization_v1::model::AttestorPublicKey;
1611    /// use google_cloud_binaryauthorization_v1::model::PkixPublicKey;
1612    /// let x = AttestorPublicKey::new().set_pkix_public_key(PkixPublicKey::default()/* use setters */);
1613    /// assert!(x.pkix_public_key().is_some());
1614    /// assert!(x.ascii_armored_pgp_public_key().is_none());
1615    /// ```
1616    pub fn set_pkix_public_key<
1617        T: std::convert::Into<std::boxed::Box<crate::model::PkixPublicKey>>,
1618    >(
1619        mut self,
1620        v: T,
1621    ) -> Self {
1622        self.public_key = std::option::Option::Some(
1623            crate::model::attestor_public_key::PublicKey::PkixPublicKey(v.into()),
1624        );
1625        self
1626    }
1627}
1628
1629impl wkt::message::Message for AttestorPublicKey {
1630    fn typename() -> &'static str {
1631        "type.googleapis.com/google.cloud.binaryauthorization.v1.AttestorPublicKey"
1632    }
1633}
1634
1635/// Defines additional types related to [AttestorPublicKey].
1636pub mod attestor_public_key {
1637    #[allow(unused_imports)]
1638    use super::*;
1639
1640    #[allow(missing_docs)]
1641    #[derive(Clone, Debug, PartialEq)]
1642    #[non_exhaustive]
1643    pub enum PublicKey {
1644        /// ASCII-armored representation of a PGP public key, as the entire output by
1645        /// the command `gpg --export --armor foo@example.com` (either LF or CRLF
1646        /// line endings).
1647        /// When using this field, `id` should be left blank.  The BinAuthz API
1648        /// handlers will calculate the ID and fill it in automatically.  BinAuthz
1649        /// computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as
1650        /// upper-case hex.  If `id` is provided by the caller, it will be
1651        /// overwritten by the API-calculated ID.
1652        AsciiArmoredPgpPublicKey(std::string::String),
1653        /// A raw PKIX SubjectPublicKeyInfo format public key.
1654        ///
1655        /// NOTE: `id` may be explicitly provided by the caller when using this
1656        /// type of public key, but it MUST be a valid RFC3986 URI. If `id` is left
1657        /// blank, a default one will be computed based on the digest of the DER
1658        /// encoding of the public key.
1659        PkixPublicKey(std::boxed::Box<crate::model::PkixPublicKey>),
1660    }
1661}
1662
1663/// Request message for [BinauthzManagementService.GetPolicy][].
1664#[derive(Clone, Default, PartialEq)]
1665#[non_exhaustive]
1666pub struct GetPolicyRequest {
1667    /// Required. The resource name of the [policy][google.cloud.binaryauthorization.v1.Policy] to retrieve,
1668    /// in the format `projects/*/policy`.
1669    ///
1670    /// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
1671    pub name: std::string::String,
1672
1673    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1674}
1675
1676impl GetPolicyRequest {
1677    /// Creates a new default instance.
1678    pub fn new() -> Self {
1679        std::default::Default::default()
1680    }
1681
1682    /// Sets the value of [name][crate::model::GetPolicyRequest::name].
1683    ///
1684    /// # Example
1685    /// ```ignore,no_run
1686    /// # use google_cloud_binaryauthorization_v1::model::GetPolicyRequest;
1687    /// let x = GetPolicyRequest::new().set_name("example");
1688    /// ```
1689    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1690        self.name = v.into();
1691        self
1692    }
1693}
1694
1695impl wkt::message::Message for GetPolicyRequest {
1696    fn typename() -> &'static str {
1697        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetPolicyRequest"
1698    }
1699}
1700
1701/// Request message for [BinauthzManagementService.UpdatePolicy][].
1702#[derive(Clone, Default, PartialEq)]
1703#[non_exhaustive]
1704pub struct UpdatePolicyRequest {
1705    /// Required. A new or updated [policy][google.cloud.binaryauthorization.v1.Policy] value. The service will
1706    /// overwrite the [policy name][google.cloud.binaryauthorization.v1.Policy.name] field with the resource name in
1707    /// the request URL, in the format `projects/*/policy`.
1708    ///
1709    /// [google.cloud.binaryauthorization.v1.Policy]: crate::model::Policy
1710    /// [google.cloud.binaryauthorization.v1.Policy.name]: crate::model::Policy::name
1711    pub policy: std::option::Option<crate::model::Policy>,
1712
1713    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1714}
1715
1716impl UpdatePolicyRequest {
1717    /// Creates a new default instance.
1718    pub fn new() -> Self {
1719        std::default::Default::default()
1720    }
1721
1722    /// Sets the value of [policy][crate::model::UpdatePolicyRequest::policy].
1723    ///
1724    /// # Example
1725    /// ```ignore,no_run
1726    /// # use google_cloud_binaryauthorization_v1::model::UpdatePolicyRequest;
1727    /// use google_cloud_binaryauthorization_v1::model::Policy;
1728    /// let x = UpdatePolicyRequest::new().set_policy(Policy::default()/* use setters */);
1729    /// ```
1730    pub fn set_policy<T>(mut self, v: T) -> Self
1731    where
1732        T: std::convert::Into<crate::model::Policy>,
1733    {
1734        self.policy = std::option::Option::Some(v.into());
1735        self
1736    }
1737
1738    /// Sets or clears the value of [policy][crate::model::UpdatePolicyRequest::policy].
1739    ///
1740    /// # Example
1741    /// ```ignore,no_run
1742    /// # use google_cloud_binaryauthorization_v1::model::UpdatePolicyRequest;
1743    /// use google_cloud_binaryauthorization_v1::model::Policy;
1744    /// let x = UpdatePolicyRequest::new().set_or_clear_policy(Some(Policy::default()/* use setters */));
1745    /// let x = UpdatePolicyRequest::new().set_or_clear_policy(None::<Policy>);
1746    /// ```
1747    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
1748    where
1749        T: std::convert::Into<crate::model::Policy>,
1750    {
1751        self.policy = v.map(|x| x.into());
1752        self
1753    }
1754}
1755
1756impl wkt::message::Message for UpdatePolicyRequest {
1757    fn typename() -> &'static str {
1758        "type.googleapis.com/google.cloud.binaryauthorization.v1.UpdatePolicyRequest"
1759    }
1760}
1761
1762/// Request message for [BinauthzManagementService.CreateAttestor][].
1763#[derive(Clone, Default, PartialEq)]
1764#[non_exhaustive]
1765pub struct CreateAttestorRequest {
1766    /// Required. The parent of this [attestor][google.cloud.binaryauthorization.v1.Attestor].
1767    ///
1768    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1769    pub parent: std::string::String,
1770
1771    /// Required. The [attestors][google.cloud.binaryauthorization.v1.Attestor] ID.
1772    ///
1773    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1774    pub attestor_id: std::string::String,
1775
1776    /// Required. The initial [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will
1777    /// overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name,
1778    /// in the format `projects/*/attestors/*`.
1779    ///
1780    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1781    /// [google.cloud.binaryauthorization.v1.Attestor.name]: crate::model::Attestor::name
1782    pub attestor: std::option::Option<crate::model::Attestor>,
1783
1784    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1785}
1786
1787impl CreateAttestorRequest {
1788    /// Creates a new default instance.
1789    pub fn new() -> Self {
1790        std::default::Default::default()
1791    }
1792
1793    /// Sets the value of [parent][crate::model::CreateAttestorRequest::parent].
1794    ///
1795    /// # Example
1796    /// ```ignore,no_run
1797    /// # use google_cloud_binaryauthorization_v1::model::CreateAttestorRequest;
1798    /// let x = CreateAttestorRequest::new().set_parent("example");
1799    /// ```
1800    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1801        self.parent = v.into();
1802        self
1803    }
1804
1805    /// Sets the value of [attestor_id][crate::model::CreateAttestorRequest::attestor_id].
1806    ///
1807    /// # Example
1808    /// ```ignore,no_run
1809    /// # use google_cloud_binaryauthorization_v1::model::CreateAttestorRequest;
1810    /// let x = CreateAttestorRequest::new().set_attestor_id("example");
1811    /// ```
1812    pub fn set_attestor_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1813        self.attestor_id = v.into();
1814        self
1815    }
1816
1817    /// Sets the value of [attestor][crate::model::CreateAttestorRequest::attestor].
1818    ///
1819    /// # Example
1820    /// ```ignore,no_run
1821    /// # use google_cloud_binaryauthorization_v1::model::CreateAttestorRequest;
1822    /// use google_cloud_binaryauthorization_v1::model::Attestor;
1823    /// let x = CreateAttestorRequest::new().set_attestor(Attestor::default()/* use setters */);
1824    /// ```
1825    pub fn set_attestor<T>(mut self, v: T) -> Self
1826    where
1827        T: std::convert::Into<crate::model::Attestor>,
1828    {
1829        self.attestor = std::option::Option::Some(v.into());
1830        self
1831    }
1832
1833    /// Sets or clears the value of [attestor][crate::model::CreateAttestorRequest::attestor].
1834    ///
1835    /// # Example
1836    /// ```ignore,no_run
1837    /// # use google_cloud_binaryauthorization_v1::model::CreateAttestorRequest;
1838    /// use google_cloud_binaryauthorization_v1::model::Attestor;
1839    /// let x = CreateAttestorRequest::new().set_or_clear_attestor(Some(Attestor::default()/* use setters */));
1840    /// let x = CreateAttestorRequest::new().set_or_clear_attestor(None::<Attestor>);
1841    /// ```
1842    pub fn set_or_clear_attestor<T>(mut self, v: std::option::Option<T>) -> Self
1843    where
1844        T: std::convert::Into<crate::model::Attestor>,
1845    {
1846        self.attestor = v.map(|x| x.into());
1847        self
1848    }
1849}
1850
1851impl wkt::message::Message for CreateAttestorRequest {
1852    fn typename() -> &'static str {
1853        "type.googleapis.com/google.cloud.binaryauthorization.v1.CreateAttestorRequest"
1854    }
1855}
1856
1857/// Request message for [BinauthzManagementService.GetAttestor][].
1858#[derive(Clone, Default, PartialEq)]
1859#[non_exhaustive]
1860pub struct GetAttestorRequest {
1861    /// Required. The name of the [attestor][google.cloud.binaryauthorization.v1.Attestor] to retrieve, in the format
1862    /// `projects/*/attestors/*`.
1863    ///
1864    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1865    pub name: std::string::String,
1866
1867    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1868}
1869
1870impl GetAttestorRequest {
1871    /// Creates a new default instance.
1872    pub fn new() -> Self {
1873        std::default::Default::default()
1874    }
1875
1876    /// Sets the value of [name][crate::model::GetAttestorRequest::name].
1877    ///
1878    /// # Example
1879    /// ```ignore,no_run
1880    /// # use google_cloud_binaryauthorization_v1::model::GetAttestorRequest;
1881    /// let x = GetAttestorRequest::new().set_name("example");
1882    /// ```
1883    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1884        self.name = v.into();
1885        self
1886    }
1887}
1888
1889impl wkt::message::Message for GetAttestorRequest {
1890    fn typename() -> &'static str {
1891        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetAttestorRequest"
1892    }
1893}
1894
1895/// Request message for [BinauthzManagementService.UpdateAttestor][].
1896#[derive(Clone, Default, PartialEq)]
1897#[non_exhaustive]
1898pub struct UpdateAttestorRequest {
1899    /// Required. The updated [attestor][google.cloud.binaryauthorization.v1.Attestor] value. The service will
1900    /// overwrite the [attestor name][google.cloud.binaryauthorization.v1.Attestor.name] field with the resource name
1901    /// in the request URL, in the format `projects/*/attestors/*`.
1902    ///
1903    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1904    /// [google.cloud.binaryauthorization.v1.Attestor.name]: crate::model::Attestor::name
1905    pub attestor: std::option::Option<crate::model::Attestor>,
1906
1907    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1908}
1909
1910impl UpdateAttestorRequest {
1911    /// Creates a new default instance.
1912    pub fn new() -> Self {
1913        std::default::Default::default()
1914    }
1915
1916    /// Sets the value of [attestor][crate::model::UpdateAttestorRequest::attestor].
1917    ///
1918    /// # Example
1919    /// ```ignore,no_run
1920    /// # use google_cloud_binaryauthorization_v1::model::UpdateAttestorRequest;
1921    /// use google_cloud_binaryauthorization_v1::model::Attestor;
1922    /// let x = UpdateAttestorRequest::new().set_attestor(Attestor::default()/* use setters */);
1923    /// ```
1924    pub fn set_attestor<T>(mut self, v: T) -> Self
1925    where
1926        T: std::convert::Into<crate::model::Attestor>,
1927    {
1928        self.attestor = std::option::Option::Some(v.into());
1929        self
1930    }
1931
1932    /// Sets or clears the value of [attestor][crate::model::UpdateAttestorRequest::attestor].
1933    ///
1934    /// # Example
1935    /// ```ignore,no_run
1936    /// # use google_cloud_binaryauthorization_v1::model::UpdateAttestorRequest;
1937    /// use google_cloud_binaryauthorization_v1::model::Attestor;
1938    /// let x = UpdateAttestorRequest::new().set_or_clear_attestor(Some(Attestor::default()/* use setters */));
1939    /// let x = UpdateAttestorRequest::new().set_or_clear_attestor(None::<Attestor>);
1940    /// ```
1941    pub fn set_or_clear_attestor<T>(mut self, v: std::option::Option<T>) -> Self
1942    where
1943        T: std::convert::Into<crate::model::Attestor>,
1944    {
1945        self.attestor = v.map(|x| x.into());
1946        self
1947    }
1948}
1949
1950impl wkt::message::Message for UpdateAttestorRequest {
1951    fn typename() -> &'static str {
1952        "type.googleapis.com/google.cloud.binaryauthorization.v1.UpdateAttestorRequest"
1953    }
1954}
1955
1956/// Request message for [BinauthzManagementService.ListAttestors][].
1957#[derive(Clone, Default, PartialEq)]
1958#[non_exhaustive]
1959pub struct ListAttestorsRequest {
1960    /// Required. The resource name of the project associated with the
1961    /// [attestors][google.cloud.binaryauthorization.v1.Attestor], in the format `projects/*`.
1962    ///
1963    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
1964    pub parent: std::string::String,
1965
1966    /// Requested page size. The server may return fewer results than requested. If
1967    /// unspecified, the server will pick an appropriate default.
1968    pub page_size: i32,
1969
1970    /// A token identifying a page of results the server should return. Typically,
1971    /// this is the value of [ListAttestorsResponse.next_page_token][google.cloud.binaryauthorization.v1.ListAttestorsResponse.next_page_token] returned
1972    /// from the previous call to the `ListAttestors` method.
1973    ///
1974    /// [google.cloud.binaryauthorization.v1.ListAttestorsResponse.next_page_token]: crate::model::ListAttestorsResponse::next_page_token
1975    pub page_token: std::string::String,
1976
1977    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
1978}
1979
1980impl ListAttestorsRequest {
1981    /// Creates a new default instance.
1982    pub fn new() -> Self {
1983        std::default::Default::default()
1984    }
1985
1986    /// Sets the value of [parent][crate::model::ListAttestorsRequest::parent].
1987    ///
1988    /// # Example
1989    /// ```ignore,no_run
1990    /// # use google_cloud_binaryauthorization_v1::model::ListAttestorsRequest;
1991    /// let x = ListAttestorsRequest::new().set_parent("example");
1992    /// ```
1993    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1994        self.parent = v.into();
1995        self
1996    }
1997
1998    /// Sets the value of [page_size][crate::model::ListAttestorsRequest::page_size].
1999    ///
2000    /// # Example
2001    /// ```ignore,no_run
2002    /// # use google_cloud_binaryauthorization_v1::model::ListAttestorsRequest;
2003    /// let x = ListAttestorsRequest::new().set_page_size(42);
2004    /// ```
2005    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
2006        self.page_size = v.into();
2007        self
2008    }
2009
2010    /// Sets the value of [page_token][crate::model::ListAttestorsRequest::page_token].
2011    ///
2012    /// # Example
2013    /// ```ignore,no_run
2014    /// # use google_cloud_binaryauthorization_v1::model::ListAttestorsRequest;
2015    /// let x = ListAttestorsRequest::new().set_page_token("example");
2016    /// ```
2017    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2018        self.page_token = v.into();
2019        self
2020    }
2021}
2022
2023impl wkt::message::Message for ListAttestorsRequest {
2024    fn typename() -> &'static str {
2025        "type.googleapis.com/google.cloud.binaryauthorization.v1.ListAttestorsRequest"
2026    }
2027}
2028
2029/// Response message for [BinauthzManagementService.ListAttestors][].
2030#[derive(Clone, Default, PartialEq)]
2031#[non_exhaustive]
2032pub struct ListAttestorsResponse {
2033    /// The list of [attestors][google.cloud.binaryauthorization.v1.Attestor].
2034    ///
2035    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2036    pub attestors: std::vec::Vec<crate::model::Attestor>,
2037
2038    /// A token to retrieve the next page of results. Pass this value in the
2039    /// [ListAttestorsRequest.page_token][google.cloud.binaryauthorization.v1.ListAttestorsRequest.page_token] field in the subsequent call to the
2040    /// `ListAttestors` method to retrieve the next page of results.
2041    ///
2042    /// [google.cloud.binaryauthorization.v1.ListAttestorsRequest.page_token]: crate::model::ListAttestorsRequest::page_token
2043    pub next_page_token: std::string::String,
2044
2045    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2046}
2047
2048impl ListAttestorsResponse {
2049    /// Creates a new default instance.
2050    pub fn new() -> Self {
2051        std::default::Default::default()
2052    }
2053
2054    /// Sets the value of [attestors][crate::model::ListAttestorsResponse::attestors].
2055    ///
2056    /// # Example
2057    /// ```ignore,no_run
2058    /// # use google_cloud_binaryauthorization_v1::model::ListAttestorsResponse;
2059    /// use google_cloud_binaryauthorization_v1::model::Attestor;
2060    /// let x = ListAttestorsResponse::new()
2061    ///     .set_attestors([
2062    ///         Attestor::default()/* use setters */,
2063    ///         Attestor::default()/* use (different) setters */,
2064    ///     ]);
2065    /// ```
2066    pub fn set_attestors<T, V>(mut self, v: T) -> Self
2067    where
2068        T: std::iter::IntoIterator<Item = V>,
2069        V: std::convert::Into<crate::model::Attestor>,
2070    {
2071        use std::iter::Iterator;
2072        self.attestors = v.into_iter().map(|i| i.into()).collect();
2073        self
2074    }
2075
2076    /// Sets the value of [next_page_token][crate::model::ListAttestorsResponse::next_page_token].
2077    ///
2078    /// # Example
2079    /// ```ignore,no_run
2080    /// # use google_cloud_binaryauthorization_v1::model::ListAttestorsResponse;
2081    /// let x = ListAttestorsResponse::new().set_next_page_token("example");
2082    /// ```
2083    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2084        self.next_page_token = v.into();
2085        self
2086    }
2087}
2088
2089impl wkt::message::Message for ListAttestorsResponse {
2090    fn typename() -> &'static str {
2091        "type.googleapis.com/google.cloud.binaryauthorization.v1.ListAttestorsResponse"
2092    }
2093}
2094
2095#[doc(hidden)]
2096impl google_cloud_gax::paginator::internal::PageableResponse for ListAttestorsResponse {
2097    type PageItem = crate::model::Attestor;
2098
2099    fn items(self) -> std::vec::Vec<Self::PageItem> {
2100        self.attestors
2101    }
2102
2103    fn next_page_token(&self) -> std::string::String {
2104        use std::clone::Clone;
2105        self.next_page_token.clone()
2106    }
2107}
2108
2109/// Request message for [BinauthzManagementService.DeleteAttestor][].
2110#[derive(Clone, Default, PartialEq)]
2111#[non_exhaustive]
2112pub struct DeleteAttestorRequest {
2113    /// Required. The name of the [attestors][google.cloud.binaryauthorization.v1.Attestor] to delete, in the format
2114    /// `projects/*/attestors/*`.
2115    ///
2116    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2117    pub name: std::string::String,
2118
2119    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2120}
2121
2122impl DeleteAttestorRequest {
2123    /// Creates a new default instance.
2124    pub fn new() -> Self {
2125        std::default::Default::default()
2126    }
2127
2128    /// Sets the value of [name][crate::model::DeleteAttestorRequest::name].
2129    ///
2130    /// # Example
2131    /// ```ignore,no_run
2132    /// # use google_cloud_binaryauthorization_v1::model::DeleteAttestorRequest;
2133    /// let x = DeleteAttestorRequest::new().set_name("example");
2134    /// ```
2135    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2136        self.name = v.into();
2137        self
2138    }
2139}
2140
2141impl wkt::message::Message for DeleteAttestorRequest {
2142    fn typename() -> &'static str {
2143        "type.googleapis.com/google.cloud.binaryauthorization.v1.DeleteAttestorRequest"
2144    }
2145}
2146
2147/// Request to read the current system policy.
2148#[derive(Clone, Default, PartialEq)]
2149#[non_exhaustive]
2150pub struct GetSystemPolicyRequest {
2151    /// Required. The resource name, in the format `locations/*/policy`.
2152    /// Note that the system policy is not associated with a project.
2153    pub name: std::string::String,
2154
2155    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2156}
2157
2158impl GetSystemPolicyRequest {
2159    /// Creates a new default instance.
2160    pub fn new() -> Self {
2161        std::default::Default::default()
2162    }
2163
2164    /// Sets the value of [name][crate::model::GetSystemPolicyRequest::name].
2165    ///
2166    /// # Example
2167    /// ```ignore,no_run
2168    /// # use google_cloud_binaryauthorization_v1::model::GetSystemPolicyRequest;
2169    /// let x = GetSystemPolicyRequest::new().set_name("example");
2170    /// ```
2171    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2172        self.name = v.into();
2173        self
2174    }
2175}
2176
2177impl wkt::message::Message for GetSystemPolicyRequest {
2178    fn typename() -> &'static str {
2179        "type.googleapis.com/google.cloud.binaryauthorization.v1.GetSystemPolicyRequest"
2180    }
2181}
2182
2183/// Request message for
2184/// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence].
2185///
2186/// [google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]: crate::client::ValidationHelperV1::validate_attestation_occurrence
2187#[derive(Clone, Default, PartialEq)]
2188#[non_exhaustive]
2189pub struct ValidateAttestationOccurrenceRequest {
2190    /// Required. The resource name of the [Attestor][google.cloud.binaryauthorization.v1.Attestor] of the
2191    /// [occurrence][grafeas.v1.Occurrence], in the format
2192    /// `projects/*/attestors/*`.
2193    ///
2194    /// [google.cloud.binaryauthorization.v1.Attestor]: crate::model::Attestor
2195    pub attestor: std::string::String,
2196
2197    /// Required. An [AttestationOccurrence][grafeas.v1.AttestationOccurrence] to
2198    /// be checked that it can be verified by the Attestor. It does not have to be
2199    /// an existing entity in Container Analysis. It must otherwise be a valid
2200    /// AttestationOccurrence.
2201    ///
2202    /// [grafeas.v1.AttestationOccurrence]: google_cloud_grafeas_v1::model::AttestationOccurrence
2203    pub attestation: std::option::Option<google_cloud_grafeas_v1::model::AttestationOccurrence>,
2204
2205    /// Required. The resource name of the [Note][grafeas.v1.Note] to which the
2206    /// containing [Occurrence][grafeas.v1.Occurrence] is associated.
2207    pub occurrence_note: std::string::String,
2208
2209    /// Required. The URI of the artifact (e.g. container image) that is the
2210    /// subject of the containing [Occurrence][grafeas.v1.Occurrence].
2211    pub occurrence_resource_uri: std::string::String,
2212
2213    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2214}
2215
2216impl ValidateAttestationOccurrenceRequest {
2217    /// Creates a new default instance.
2218    pub fn new() -> Self {
2219        std::default::Default::default()
2220    }
2221
2222    /// Sets the value of [attestor][crate::model::ValidateAttestationOccurrenceRequest::attestor].
2223    ///
2224    /// # Example
2225    /// ```ignore,no_run
2226    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceRequest;
2227    /// let x = ValidateAttestationOccurrenceRequest::new().set_attestor("example");
2228    /// ```
2229    pub fn set_attestor<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2230        self.attestor = v.into();
2231        self
2232    }
2233
2234    /// Sets the value of [attestation][crate::model::ValidateAttestationOccurrenceRequest::attestation].
2235    ///
2236    /// # Example
2237    /// ```ignore,no_run
2238    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceRequest;
2239    /// use google_cloud_grafeas_v1::model::AttestationOccurrence;
2240    /// let x = ValidateAttestationOccurrenceRequest::new().set_attestation(AttestationOccurrence::default()/* use setters */);
2241    /// ```
2242    pub fn set_attestation<T>(mut self, v: T) -> Self
2243    where
2244        T: std::convert::Into<google_cloud_grafeas_v1::model::AttestationOccurrence>,
2245    {
2246        self.attestation = std::option::Option::Some(v.into());
2247        self
2248    }
2249
2250    /// Sets or clears the value of [attestation][crate::model::ValidateAttestationOccurrenceRequest::attestation].
2251    ///
2252    /// # Example
2253    /// ```ignore,no_run
2254    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceRequest;
2255    /// use google_cloud_grafeas_v1::model::AttestationOccurrence;
2256    /// let x = ValidateAttestationOccurrenceRequest::new().set_or_clear_attestation(Some(AttestationOccurrence::default()/* use setters */));
2257    /// let x = ValidateAttestationOccurrenceRequest::new().set_or_clear_attestation(None::<AttestationOccurrence>);
2258    /// ```
2259    pub fn set_or_clear_attestation<T>(mut self, v: std::option::Option<T>) -> Self
2260    where
2261        T: std::convert::Into<google_cloud_grafeas_v1::model::AttestationOccurrence>,
2262    {
2263        self.attestation = v.map(|x| x.into());
2264        self
2265    }
2266
2267    /// Sets the value of [occurrence_note][crate::model::ValidateAttestationOccurrenceRequest::occurrence_note].
2268    ///
2269    /// # Example
2270    /// ```ignore,no_run
2271    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceRequest;
2272    /// let x = ValidateAttestationOccurrenceRequest::new().set_occurrence_note("example");
2273    /// ```
2274    pub fn set_occurrence_note<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2275        self.occurrence_note = v.into();
2276        self
2277    }
2278
2279    /// Sets the value of [occurrence_resource_uri][crate::model::ValidateAttestationOccurrenceRequest::occurrence_resource_uri].
2280    ///
2281    /// # Example
2282    /// ```ignore,no_run
2283    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceRequest;
2284    /// let x = ValidateAttestationOccurrenceRequest::new().set_occurrence_resource_uri("example");
2285    /// ```
2286    pub fn set_occurrence_resource_uri<T: std::convert::Into<std::string::String>>(
2287        mut self,
2288        v: T,
2289    ) -> Self {
2290        self.occurrence_resource_uri = v.into();
2291        self
2292    }
2293}
2294
2295impl wkt::message::Message for ValidateAttestationOccurrenceRequest {
2296    fn typename() -> &'static str {
2297        "type.googleapis.com/google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceRequest"
2298    }
2299}
2300
2301/// Response message for
2302/// [ValidationHelperV1.ValidateAttestationOccurrence][google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence].
2303///
2304/// [google.cloud.binaryauthorization.v1.ValidationHelperV1.ValidateAttestationOccurrence]: crate::client::ValidationHelperV1::validate_attestation_occurrence
2305#[derive(Clone, Default, PartialEq)]
2306#[non_exhaustive]
2307pub struct ValidateAttestationOccurrenceResponse {
2308    /// The result of the Attestation validation.
2309    pub result: crate::model::validate_attestation_occurrence_response::Result,
2310
2311    /// The reason for denial if the Attestation couldn't be validated.
2312    pub denial_reason: std::string::String,
2313
2314    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
2315}
2316
2317impl ValidateAttestationOccurrenceResponse {
2318    /// Creates a new default instance.
2319    pub fn new() -> Self {
2320        std::default::Default::default()
2321    }
2322
2323    /// Sets the value of [result][crate::model::ValidateAttestationOccurrenceResponse::result].
2324    ///
2325    /// # Example
2326    /// ```ignore,no_run
2327    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceResponse;
2328    /// use google_cloud_binaryauthorization_v1::model::validate_attestation_occurrence_response::Result;
2329    /// let x0 = ValidateAttestationOccurrenceResponse::new().set_result(Result::Verified);
2330    /// let x1 = ValidateAttestationOccurrenceResponse::new().set_result(Result::AttestationNotVerifiable);
2331    /// ```
2332    pub fn set_result<
2333        T: std::convert::Into<crate::model::validate_attestation_occurrence_response::Result>,
2334    >(
2335        mut self,
2336        v: T,
2337    ) -> Self {
2338        self.result = v.into();
2339        self
2340    }
2341
2342    /// Sets the value of [denial_reason][crate::model::ValidateAttestationOccurrenceResponse::denial_reason].
2343    ///
2344    /// # Example
2345    /// ```ignore,no_run
2346    /// # use google_cloud_binaryauthorization_v1::model::ValidateAttestationOccurrenceResponse;
2347    /// let x = ValidateAttestationOccurrenceResponse::new().set_denial_reason("example");
2348    /// ```
2349    pub fn set_denial_reason<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
2350        self.denial_reason = v.into();
2351        self
2352    }
2353}
2354
2355impl wkt::message::Message for ValidateAttestationOccurrenceResponse {
2356    fn typename() -> &'static str {
2357        "type.googleapis.com/google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse"
2358    }
2359}
2360
2361/// Defines additional types related to [ValidateAttestationOccurrenceResponse].
2362pub mod validate_attestation_occurrence_response {
2363    #[allow(unused_imports)]
2364    use super::*;
2365
2366    /// The enum returned in the "result" field.
2367    ///
2368    /// # Working with unknown values
2369    ///
2370    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
2371    /// additional enum variants at any time. Adding new variants is not considered
2372    /// a breaking change. Applications should write their code in anticipation of:
2373    ///
2374    /// - New values appearing in future releases of the client library, **and**
2375    /// - New values received dynamically, without application changes.
2376    ///
2377    /// Please consult the [Working with enums] section in the user guide for some
2378    /// guidelines.
2379    ///
2380    /// [Working with enums]: https://googleapis.github.io/google-cloud-rust/working_with_enums.html
2381    #[derive(Clone, Debug, PartialEq)]
2382    #[non_exhaustive]
2383    pub enum Result {
2384        /// Unspecified.
2385        Unspecified,
2386        /// The Attestation was able to verified by the Attestor.
2387        Verified,
2388        /// The Attestation was not able to verified by the Attestor.
2389        AttestationNotVerifiable,
2390        /// If set, the enum was initialized with an unknown value.
2391        ///
2392        /// Applications can examine the value using [Result::value] or
2393        /// [Result::name].
2394        UnknownValue(result::UnknownValue),
2395    }
2396
2397    #[doc(hidden)]
2398    pub mod result {
2399        #[allow(unused_imports)]
2400        use super::*;
2401        #[derive(Clone, Debug, PartialEq)]
2402        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
2403    }
2404
2405    impl Result {
2406        /// Gets the enum value.
2407        ///
2408        /// Returns `None` if the enum contains an unknown value deserialized from
2409        /// the string representation of enums.
2410        pub fn value(&self) -> std::option::Option<i32> {
2411            match self {
2412                Self::Unspecified => std::option::Option::Some(0),
2413                Self::Verified => std::option::Option::Some(1),
2414                Self::AttestationNotVerifiable => std::option::Option::Some(2),
2415                Self::UnknownValue(u) => u.0.value(),
2416            }
2417        }
2418
2419        /// Gets the enum value as a string.
2420        ///
2421        /// Returns `None` if the enum contains an unknown value deserialized from
2422        /// the integer representation of enums.
2423        pub fn name(&self) -> std::option::Option<&str> {
2424            match self {
2425                Self::Unspecified => std::option::Option::Some("RESULT_UNSPECIFIED"),
2426                Self::Verified => std::option::Option::Some("VERIFIED"),
2427                Self::AttestationNotVerifiable => {
2428                    std::option::Option::Some("ATTESTATION_NOT_VERIFIABLE")
2429                }
2430                Self::UnknownValue(u) => u.0.name(),
2431            }
2432        }
2433    }
2434
2435    impl std::default::Default for Result {
2436        fn default() -> Self {
2437            use std::convert::From;
2438            Self::from(0)
2439        }
2440    }
2441
2442    impl std::fmt::Display for Result {
2443        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
2444            wkt::internal::display_enum(f, self.name(), self.value())
2445        }
2446    }
2447
2448    impl std::convert::From<i32> for Result {
2449        fn from(value: i32) -> Self {
2450            match value {
2451                0 => Self::Unspecified,
2452                1 => Self::Verified,
2453                2 => Self::AttestationNotVerifiable,
2454                _ => Self::UnknownValue(result::UnknownValue(
2455                    wkt::internal::UnknownEnumValue::Integer(value),
2456                )),
2457            }
2458        }
2459    }
2460
2461    impl std::convert::From<&str> for Result {
2462        fn from(value: &str) -> Self {
2463            use std::string::ToString;
2464            match value {
2465                "RESULT_UNSPECIFIED" => Self::Unspecified,
2466                "VERIFIED" => Self::Verified,
2467                "ATTESTATION_NOT_VERIFIABLE" => Self::AttestationNotVerifiable,
2468                _ => Self::UnknownValue(result::UnknownValue(
2469                    wkt::internal::UnknownEnumValue::String(value.to_string()),
2470                )),
2471            }
2472        }
2473    }
2474
2475    impl serde::ser::Serialize for Result {
2476        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
2477        where
2478            S: serde::Serializer,
2479        {
2480            match self {
2481                Self::Unspecified => serializer.serialize_i32(0),
2482                Self::Verified => serializer.serialize_i32(1),
2483                Self::AttestationNotVerifiable => serializer.serialize_i32(2),
2484                Self::UnknownValue(u) => u.0.serialize(serializer),
2485            }
2486        }
2487    }
2488
2489    impl<'de> serde::de::Deserialize<'de> for Result {
2490        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
2491        where
2492            D: serde::Deserializer<'de>,
2493        {
2494            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Result>::new(
2495                ".google.cloud.binaryauthorization.v1.ValidateAttestationOccurrenceResponse.Result",
2496            ))
2497        }
2498    }
2499}