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