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