google_cloud_policytroubleshooter_v1/
model.rs

1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Code generated by sidekick. DO NOT EDIT.
16
17#![allow(rustdoc::redundant_explicit_links)]
18#![allow(rustdoc::broken_intra_doc_links)]
19#![no_implicit_prelude]
20extern crate async_trait;
21extern crate bytes;
22extern crate gax;
23extern crate gaxi;
24extern crate gtype;
25extern crate iam_v1;
26extern crate lazy_static;
27extern crate reqwest;
28extern crate rpc;
29extern crate serde;
30extern crate serde_json;
31extern crate serde_with;
32extern crate std;
33extern crate tracing;
34extern crate wkt;
35
36mod debug;
37mod deserialize;
38mod serialize;
39
40/// Request for
41/// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy].
42///
43/// [google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]: crate::client::IamChecker::troubleshoot_iam_policy
44#[derive(Clone, Default, PartialEq)]
45#[non_exhaustive]
46pub struct TroubleshootIamPolicyRequest {
47    /// The information to use for checking whether a principal has a permission
48    /// for a resource.
49    pub access_tuple: std::option::Option<crate::model::AccessTuple>,
50
51    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
52}
53
54impl TroubleshootIamPolicyRequest {
55    pub fn new() -> Self {
56        std::default::Default::default()
57    }
58
59    /// Sets the value of [access_tuple][crate::model::TroubleshootIamPolicyRequest::access_tuple].
60    pub fn set_access_tuple<T>(mut self, v: T) -> Self
61    where
62        T: std::convert::Into<crate::model::AccessTuple>,
63    {
64        self.access_tuple = std::option::Option::Some(v.into());
65        self
66    }
67
68    /// Sets or clears the value of [access_tuple][crate::model::TroubleshootIamPolicyRequest::access_tuple].
69    pub fn set_or_clear_access_tuple<T>(mut self, v: std::option::Option<T>) -> Self
70    where
71        T: std::convert::Into<crate::model::AccessTuple>,
72    {
73        self.access_tuple = v.map(|x| x.into());
74        self
75    }
76}
77
78impl wkt::message::Message for TroubleshootIamPolicyRequest {
79    fn typename() -> &'static str {
80        "type.googleapis.com/google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyRequest"
81    }
82}
83
84/// Response for
85/// [TroubleshootIamPolicy][google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy].
86///
87/// [google.cloud.policytroubleshooter.v1.IamChecker.TroubleshootIamPolicy]: crate::client::IamChecker::troubleshoot_iam_policy
88#[derive(Clone, Default, PartialEq)]
89#[non_exhaustive]
90pub struct TroubleshootIamPolicyResponse {
91    /// Indicates whether the principal has the specified permission for the
92    /// specified resource, based on evaluating all of the applicable IAM policies.
93    pub access: crate::model::AccessState,
94
95    /// List of IAM policies that were evaluated to check the principal's
96    /// permissions, with annotations to indicate how each policy contributed to
97    /// the final result.
98    ///
99    /// The list of policies can include the policy for the resource itself. It can
100    /// also include policies that are inherited from higher levels of the resource
101    /// hierarchy, including the organization, the folder, and the project.
102    ///
103    /// To learn more about the resource hierarchy, see
104    /// <https://cloud.google.com/iam/help/resource-hierarchy>.
105    pub explained_policies: std::vec::Vec<crate::model::ExplainedPolicy>,
106
107    /// The general errors contained in the troubleshooting response.
108    pub errors: std::vec::Vec<rpc::model::Status>,
109
110    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
111}
112
113impl TroubleshootIamPolicyResponse {
114    pub fn new() -> Self {
115        std::default::Default::default()
116    }
117
118    /// Sets the value of [access][crate::model::TroubleshootIamPolicyResponse::access].
119    pub fn set_access<T: std::convert::Into<crate::model::AccessState>>(mut self, v: T) -> Self {
120        self.access = v.into();
121        self
122    }
123
124    /// Sets the value of [explained_policies][crate::model::TroubleshootIamPolicyResponse::explained_policies].
125    pub fn set_explained_policies<T, V>(mut self, v: T) -> Self
126    where
127        T: std::iter::IntoIterator<Item = V>,
128        V: std::convert::Into<crate::model::ExplainedPolicy>,
129    {
130        use std::iter::Iterator;
131        self.explained_policies = v.into_iter().map(|i| i.into()).collect();
132        self
133    }
134
135    /// Sets the value of [errors][crate::model::TroubleshootIamPolicyResponse::errors].
136    pub fn set_errors<T, V>(mut self, v: T) -> Self
137    where
138        T: std::iter::IntoIterator<Item = V>,
139        V: std::convert::Into<rpc::model::Status>,
140    {
141        use std::iter::Iterator;
142        self.errors = v.into_iter().map(|i| i.into()).collect();
143        self
144    }
145}
146
147impl wkt::message::Message for TroubleshootIamPolicyResponse {
148    fn typename() -> &'static str {
149        "type.googleapis.com/google.cloud.policytroubleshooter.v1.TroubleshootIamPolicyResponse"
150    }
151}
152
153/// Information about the principal, resource, and permission to check.
154#[derive(Clone, Default, PartialEq)]
155#[non_exhaustive]
156pub struct AccessTuple {
157    /// Required. The principal whose access you want to check, in the form of
158    /// the email address that represents that principal. For example,
159    /// `alice@example.com` or
160    /// `my-service-account@my-project.iam.gserviceaccount.com`.
161    ///
162    /// The principal must be a Google Account or a service account. Other types of
163    /// principals are not supported.
164    pub principal: std::string::String,
165
166    /// Required. The full resource name that identifies the resource. For example,
167    /// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
168    ///
169    /// For examples of full resource names for Google Cloud services, see
170    /// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names>.
171    pub full_resource_name: std::string::String,
172
173    /// Required. The IAM permission to check for the specified principal and
174    /// resource.
175    ///
176    /// For a complete list of IAM permissions, see
177    /// <https://cloud.google.com/iam/help/permissions/reference>.
178    ///
179    /// For a complete list of predefined IAM roles and the permissions in each
180    /// role, see <https://cloud.google.com/iam/help/roles/reference>.
181    pub permission: std::string::String,
182
183    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
184}
185
186impl AccessTuple {
187    pub fn new() -> Self {
188        std::default::Default::default()
189    }
190
191    /// Sets the value of [principal][crate::model::AccessTuple::principal].
192    pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
193        self.principal = v.into();
194        self
195    }
196
197    /// Sets the value of [full_resource_name][crate::model::AccessTuple::full_resource_name].
198    pub fn set_full_resource_name<T: std::convert::Into<std::string::String>>(
199        mut self,
200        v: T,
201    ) -> Self {
202        self.full_resource_name = v.into();
203        self
204    }
205
206    /// Sets the value of [permission][crate::model::AccessTuple::permission].
207    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
208        self.permission = v.into();
209        self
210    }
211}
212
213impl wkt::message::Message for AccessTuple {
214    fn typename() -> &'static str {
215        "type.googleapis.com/google.cloud.policytroubleshooter.v1.AccessTuple"
216    }
217}
218
219/// Details about how a specific IAM [Policy][google.iam.v1.Policy] contributed
220/// to the access check.
221///
222/// [google.iam.v1.Policy]: iam_v1::model::Policy
223#[derive(Clone, Default, PartialEq)]
224#[non_exhaustive]
225pub struct ExplainedPolicy {
226    /// Indicates whether _this policy_ provides the specified permission to the
227    /// specified principal for the specified resource.
228    ///
229    /// This field does _not_ indicate whether the principal actually has the
230    /// permission for the resource. There might be another policy that overrides
231    /// this policy. To determine whether the principal actually has the
232    /// permission, use the `access` field in the
233    /// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
234    pub access: crate::model::AccessState,
235
236    /// The full resource name that identifies the resource. For example,
237    /// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
238    ///
239    /// If the sender of the request does not have access to the policy, this field
240    /// is omitted.
241    ///
242    /// For examples of full resource names for Google Cloud services, see
243    /// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names>.
244    pub full_resource_name: std::string::String,
245
246    /// The IAM policy attached to the resource.
247    ///
248    /// If the sender of the request does not have access to the policy, this field
249    /// is empty.
250    pub policy: std::option::Option<iam_v1::model::Policy>,
251
252    /// Details about how each binding in the policy affects the principal's
253    /// ability, or inability, to use the permission for the resource.
254    ///
255    /// If the sender of the request does not have access to the policy, this field
256    /// is omitted.
257    pub binding_explanations: std::vec::Vec<crate::model::BindingExplanation>,
258
259    /// The relevance of this policy to the overall determination in the
260    /// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
261    ///
262    /// If the sender of the request does not have access to the policy, this field
263    /// is omitted.
264    pub relevance: crate::model::HeuristicRelevance,
265
266    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
267}
268
269impl ExplainedPolicy {
270    pub fn new() -> Self {
271        std::default::Default::default()
272    }
273
274    /// Sets the value of [access][crate::model::ExplainedPolicy::access].
275    pub fn set_access<T: std::convert::Into<crate::model::AccessState>>(mut self, v: T) -> Self {
276        self.access = v.into();
277        self
278    }
279
280    /// Sets the value of [full_resource_name][crate::model::ExplainedPolicy::full_resource_name].
281    pub fn set_full_resource_name<T: std::convert::Into<std::string::String>>(
282        mut self,
283        v: T,
284    ) -> Self {
285        self.full_resource_name = v.into();
286        self
287    }
288
289    /// Sets the value of [policy][crate::model::ExplainedPolicy::policy].
290    pub fn set_policy<T>(mut self, v: T) -> Self
291    where
292        T: std::convert::Into<iam_v1::model::Policy>,
293    {
294        self.policy = std::option::Option::Some(v.into());
295        self
296    }
297
298    /// Sets or clears the value of [policy][crate::model::ExplainedPolicy::policy].
299    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
300    where
301        T: std::convert::Into<iam_v1::model::Policy>,
302    {
303        self.policy = v.map(|x| x.into());
304        self
305    }
306
307    /// Sets the value of [binding_explanations][crate::model::ExplainedPolicy::binding_explanations].
308    pub fn set_binding_explanations<T, V>(mut self, v: T) -> Self
309    where
310        T: std::iter::IntoIterator<Item = V>,
311        V: std::convert::Into<crate::model::BindingExplanation>,
312    {
313        use std::iter::Iterator;
314        self.binding_explanations = v.into_iter().map(|i| i.into()).collect();
315        self
316    }
317
318    /// Sets the value of [relevance][crate::model::ExplainedPolicy::relevance].
319    pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
320        mut self,
321        v: T,
322    ) -> Self {
323        self.relevance = v.into();
324        self
325    }
326}
327
328impl wkt::message::Message for ExplainedPolicy {
329    fn typename() -> &'static str {
330        "type.googleapis.com/google.cloud.policytroubleshooter.v1.ExplainedPolicy"
331    }
332}
333
334/// Details about how a binding in a policy affects a principal's ability to use
335/// a permission.
336#[derive(Clone, Default, PartialEq)]
337#[non_exhaustive]
338pub struct BindingExplanation {
339    /// Required. Indicates whether _this binding_ provides the specified
340    /// permission to the specified principal for the specified resource.
341    ///
342    /// This field does _not_ indicate whether the principal actually has the
343    /// permission for the resource. There might be another binding that overrides
344    /// this binding. To determine whether the principal actually has the
345    /// permission, use the `access` field in the
346    /// [TroubleshootIamPolicyResponse][IamChecker.TroubleshootIamPolicyResponse].
347    pub access: crate::model::AccessState,
348
349    /// The role that this binding grants. For example,
350    /// `roles/compute.serviceAgent`.
351    ///
352    /// For a complete list of predefined IAM roles, as well as the permissions in
353    /// each role, see <https://cloud.google.com/iam/help/roles/reference>.
354    pub role: std::string::String,
355
356    /// Indicates whether the role granted by this binding contains the specified
357    /// permission.
358    pub role_permission: crate::model::binding_explanation::RolePermission,
359
360    /// The relevance of the permission's existence, or nonexistence, in the role
361    /// to the overall determination for the entire policy.
362    pub role_permission_relevance: crate::model::HeuristicRelevance,
363
364    /// Indicates whether each principal in the binding includes the principal
365    /// specified in the request, either directly or indirectly. Each key
366    /// identifies a principal in the binding, and each value indicates whether the
367    /// principal in the binding includes the principal in the request.
368    ///
369    /// For example, suppose that a binding includes the following principals:
370    ///
371    /// * `user:alice@example.com`
372    /// * `group:product-eng@example.com`
373    ///
374    /// You want to troubleshoot access for `user:bob@example.com`. This user is a
375    /// principal of the group `group:product-eng@example.com`.
376    ///
377    /// For the first principal in the binding, the key is
378    /// `user:alice@example.com`, and the `membership` field in the value is set to
379    /// `MEMBERSHIP_NOT_INCLUDED`.
380    ///
381    /// For the second principal in the binding, the key is
382    /// `group:product-eng@example.com`, and the `membership` field in the value is
383    /// set to `MEMBERSHIP_INCLUDED`.
384    pub memberships: std::collections::HashMap<
385        std::string::String,
386        crate::model::binding_explanation::AnnotatedMembership,
387    >,
388
389    /// The relevance of this binding to the overall determination for the entire
390    /// policy.
391    pub relevance: crate::model::HeuristicRelevance,
392
393    /// A condition expression that prevents this binding from granting access
394    /// unless the expression evaluates to `true`.
395    ///
396    /// To learn about IAM Conditions, see
397    /// <https://cloud.google.com/iam/help/conditions/overview>.
398    pub condition: std::option::Option<gtype::model::Expr>,
399
400    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
401}
402
403impl BindingExplanation {
404    pub fn new() -> Self {
405        std::default::Default::default()
406    }
407
408    /// Sets the value of [access][crate::model::BindingExplanation::access].
409    pub fn set_access<T: std::convert::Into<crate::model::AccessState>>(mut self, v: T) -> Self {
410        self.access = v.into();
411        self
412    }
413
414    /// Sets the value of [role][crate::model::BindingExplanation::role].
415    pub fn set_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
416        self.role = v.into();
417        self
418    }
419
420    /// Sets the value of [role_permission][crate::model::BindingExplanation::role_permission].
421    pub fn set_role_permission<
422        T: std::convert::Into<crate::model::binding_explanation::RolePermission>,
423    >(
424        mut self,
425        v: T,
426    ) -> Self {
427        self.role_permission = v.into();
428        self
429    }
430
431    /// Sets the value of [role_permission_relevance][crate::model::BindingExplanation::role_permission_relevance].
432    pub fn set_role_permission_relevance<
433        T: std::convert::Into<crate::model::HeuristicRelevance>,
434    >(
435        mut self,
436        v: T,
437    ) -> Self {
438        self.role_permission_relevance = v.into();
439        self
440    }
441
442    /// Sets the value of [memberships][crate::model::BindingExplanation::memberships].
443    pub fn set_memberships<T, K, V>(mut self, v: T) -> Self
444    where
445        T: std::iter::IntoIterator<Item = (K, V)>,
446        K: std::convert::Into<std::string::String>,
447        V: std::convert::Into<crate::model::binding_explanation::AnnotatedMembership>,
448    {
449        use std::iter::Iterator;
450        self.memberships = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
451        self
452    }
453
454    /// Sets the value of [relevance][crate::model::BindingExplanation::relevance].
455    pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
456        mut self,
457        v: T,
458    ) -> Self {
459        self.relevance = v.into();
460        self
461    }
462
463    /// Sets the value of [condition][crate::model::BindingExplanation::condition].
464    pub fn set_condition<T>(mut self, v: T) -> Self
465    where
466        T: std::convert::Into<gtype::model::Expr>,
467    {
468        self.condition = std::option::Option::Some(v.into());
469        self
470    }
471
472    /// Sets or clears the value of [condition][crate::model::BindingExplanation::condition].
473    pub fn set_or_clear_condition<T>(mut self, v: std::option::Option<T>) -> Self
474    where
475        T: std::convert::Into<gtype::model::Expr>,
476    {
477        self.condition = v.map(|x| x.into());
478        self
479    }
480}
481
482impl wkt::message::Message for BindingExplanation {
483    fn typename() -> &'static str {
484        "type.googleapis.com/google.cloud.policytroubleshooter.v1.BindingExplanation"
485    }
486}
487
488/// Defines additional types related to [BindingExplanation].
489pub mod binding_explanation {
490    #[allow(unused_imports)]
491    use super::*;
492
493    /// Details about whether the binding includes the principal.
494    #[derive(Clone, Default, PartialEq)]
495    #[non_exhaustive]
496    pub struct AnnotatedMembership {
497        /// Indicates whether the binding includes the principal.
498        pub membership: crate::model::binding_explanation::Membership,
499
500        /// The relevance of the principal's status to the overall determination for
501        /// the binding.
502        pub relevance: crate::model::HeuristicRelevance,
503
504        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
505    }
506
507    impl AnnotatedMembership {
508        pub fn new() -> Self {
509            std::default::Default::default()
510        }
511
512        /// Sets the value of [membership][crate::model::binding_explanation::AnnotatedMembership::membership].
513        pub fn set_membership<
514            T: std::convert::Into<crate::model::binding_explanation::Membership>,
515        >(
516            mut self,
517            v: T,
518        ) -> Self {
519            self.membership = v.into();
520            self
521        }
522
523        /// Sets the value of [relevance][crate::model::binding_explanation::AnnotatedMembership::relevance].
524        pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
525            mut self,
526            v: T,
527        ) -> Self {
528            self.relevance = v.into();
529            self
530        }
531    }
532
533    impl wkt::message::Message for AnnotatedMembership {
534        fn typename() -> &'static str {
535            "type.googleapis.com/google.cloud.policytroubleshooter.v1.BindingExplanation.AnnotatedMembership"
536        }
537    }
538
539    /// Whether a role includes a specific permission.
540    ///
541    /// # Working with unknown values
542    ///
543    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
544    /// additional enum variants at any time. Adding new variants is not considered
545    /// a breaking change. Applications should write their code in anticipation of:
546    ///
547    /// - New values appearing in future releases of the client library, **and**
548    /// - New values received dynamically, without application changes.
549    ///
550    /// Please consult the [Working with enums] section in the user guide for some
551    /// guidelines.
552    ///
553    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
554    #[derive(Clone, Debug, PartialEq)]
555    #[non_exhaustive]
556    pub enum RolePermission {
557        /// Default value. This value is unused.
558        Unspecified,
559        /// The permission is included in the role.
560        Included,
561        /// The permission is not included in the role.
562        NotIncluded,
563        /// The sender of the request is not allowed to access the binding.
564        UnknownInfoDenied,
565        /// If set, the enum was initialized with an unknown value.
566        ///
567        /// Applications can examine the value using [RolePermission::value] or
568        /// [RolePermission::name].
569        UnknownValue(role_permission::UnknownValue),
570    }
571
572    #[doc(hidden)]
573    pub mod role_permission {
574        #[allow(unused_imports)]
575        use super::*;
576        #[derive(Clone, Debug, PartialEq)]
577        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
578    }
579
580    impl RolePermission {
581        /// Gets the enum value.
582        ///
583        /// Returns `None` if the enum contains an unknown value deserialized from
584        /// the string representation of enums.
585        pub fn value(&self) -> std::option::Option<i32> {
586            match self {
587                Self::Unspecified => std::option::Option::Some(0),
588                Self::Included => std::option::Option::Some(1),
589                Self::NotIncluded => std::option::Option::Some(2),
590                Self::UnknownInfoDenied => std::option::Option::Some(3),
591                Self::UnknownValue(u) => u.0.value(),
592            }
593        }
594
595        /// Gets the enum value as a string.
596        ///
597        /// Returns `None` if the enum contains an unknown value deserialized from
598        /// the integer representation of enums.
599        pub fn name(&self) -> std::option::Option<&str> {
600            match self {
601                Self::Unspecified => std::option::Option::Some("ROLE_PERMISSION_UNSPECIFIED"),
602                Self::Included => std::option::Option::Some("ROLE_PERMISSION_INCLUDED"),
603                Self::NotIncluded => std::option::Option::Some("ROLE_PERMISSION_NOT_INCLUDED"),
604                Self::UnknownInfoDenied => {
605                    std::option::Option::Some("ROLE_PERMISSION_UNKNOWN_INFO_DENIED")
606                }
607                Self::UnknownValue(u) => u.0.name(),
608            }
609        }
610    }
611
612    impl std::default::Default for RolePermission {
613        fn default() -> Self {
614            use std::convert::From;
615            Self::from(0)
616        }
617    }
618
619    impl std::fmt::Display for RolePermission {
620        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
621            wkt::internal::display_enum(f, self.name(), self.value())
622        }
623    }
624
625    impl std::convert::From<i32> for RolePermission {
626        fn from(value: i32) -> Self {
627            match value {
628                0 => Self::Unspecified,
629                1 => Self::Included,
630                2 => Self::NotIncluded,
631                3 => Self::UnknownInfoDenied,
632                _ => Self::UnknownValue(role_permission::UnknownValue(
633                    wkt::internal::UnknownEnumValue::Integer(value),
634                )),
635            }
636        }
637    }
638
639    impl std::convert::From<&str> for RolePermission {
640        fn from(value: &str) -> Self {
641            use std::string::ToString;
642            match value {
643                "ROLE_PERMISSION_UNSPECIFIED" => Self::Unspecified,
644                "ROLE_PERMISSION_INCLUDED" => Self::Included,
645                "ROLE_PERMISSION_NOT_INCLUDED" => Self::NotIncluded,
646                "ROLE_PERMISSION_UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
647                _ => Self::UnknownValue(role_permission::UnknownValue(
648                    wkt::internal::UnknownEnumValue::String(value.to_string()),
649                )),
650            }
651        }
652    }
653
654    impl serde::ser::Serialize for RolePermission {
655        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
656        where
657            S: serde::Serializer,
658        {
659            match self {
660                Self::Unspecified => serializer.serialize_i32(0),
661                Self::Included => serializer.serialize_i32(1),
662                Self::NotIncluded => serializer.serialize_i32(2),
663                Self::UnknownInfoDenied => serializer.serialize_i32(3),
664                Self::UnknownValue(u) => u.0.serialize(serializer),
665            }
666        }
667    }
668
669    impl<'de> serde::de::Deserialize<'de> for RolePermission {
670        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
671        where
672            D: serde::Deserializer<'de>,
673        {
674            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RolePermission>::new(
675                ".google.cloud.policytroubleshooter.v1.BindingExplanation.RolePermission",
676            ))
677        }
678    }
679
680    /// Whether the binding includes the principal.
681    ///
682    /// # Working with unknown values
683    ///
684    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
685    /// additional enum variants at any time. Adding new variants is not considered
686    /// a breaking change. Applications should write their code in anticipation of:
687    ///
688    /// - New values appearing in future releases of the client library, **and**
689    /// - New values received dynamically, without application changes.
690    ///
691    /// Please consult the [Working with enums] section in the user guide for some
692    /// guidelines.
693    ///
694    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
695    #[derive(Clone, Debug, PartialEq)]
696    #[non_exhaustive]
697    pub enum Membership {
698        /// Default value. This value is unused.
699        Unspecified,
700        /// The binding includes the principal. The principal can be included
701        /// directly or indirectly. For example:
702        ///
703        /// * A principal is included directly if that principal is listed in the
704        ///   binding.
705        /// * A principal is included indirectly if that principal is in a Google
706        ///   group or Google Workspace domain that is listed in the binding.
707        Included,
708        /// The binding does not include the principal.
709        NotIncluded,
710        /// The sender of the request is not allowed to access the binding.
711        UnknownInfoDenied,
712        /// The principal is an unsupported type. Only Google Accounts and service
713        /// accounts are supported.
714        UnknownUnsupported,
715        /// If set, the enum was initialized with an unknown value.
716        ///
717        /// Applications can examine the value using [Membership::value] or
718        /// [Membership::name].
719        UnknownValue(membership::UnknownValue),
720    }
721
722    #[doc(hidden)]
723    pub mod membership {
724        #[allow(unused_imports)]
725        use super::*;
726        #[derive(Clone, Debug, PartialEq)]
727        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
728    }
729
730    impl Membership {
731        /// Gets the enum value.
732        ///
733        /// Returns `None` if the enum contains an unknown value deserialized from
734        /// the string representation of enums.
735        pub fn value(&self) -> std::option::Option<i32> {
736            match self {
737                Self::Unspecified => std::option::Option::Some(0),
738                Self::Included => std::option::Option::Some(1),
739                Self::NotIncluded => std::option::Option::Some(2),
740                Self::UnknownInfoDenied => std::option::Option::Some(3),
741                Self::UnknownUnsupported => std::option::Option::Some(4),
742                Self::UnknownValue(u) => u.0.value(),
743            }
744        }
745
746        /// Gets the enum value as a string.
747        ///
748        /// Returns `None` if the enum contains an unknown value deserialized from
749        /// the integer representation of enums.
750        pub fn name(&self) -> std::option::Option<&str> {
751            match self {
752                Self::Unspecified => std::option::Option::Some("MEMBERSHIP_UNSPECIFIED"),
753                Self::Included => std::option::Option::Some("MEMBERSHIP_INCLUDED"),
754                Self::NotIncluded => std::option::Option::Some("MEMBERSHIP_NOT_INCLUDED"),
755                Self::UnknownInfoDenied => {
756                    std::option::Option::Some("MEMBERSHIP_UNKNOWN_INFO_DENIED")
757                }
758                Self::UnknownUnsupported => {
759                    std::option::Option::Some("MEMBERSHIP_UNKNOWN_UNSUPPORTED")
760                }
761                Self::UnknownValue(u) => u.0.name(),
762            }
763        }
764    }
765
766    impl std::default::Default for Membership {
767        fn default() -> Self {
768            use std::convert::From;
769            Self::from(0)
770        }
771    }
772
773    impl std::fmt::Display for Membership {
774        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
775            wkt::internal::display_enum(f, self.name(), self.value())
776        }
777    }
778
779    impl std::convert::From<i32> for Membership {
780        fn from(value: i32) -> Self {
781            match value {
782                0 => Self::Unspecified,
783                1 => Self::Included,
784                2 => Self::NotIncluded,
785                3 => Self::UnknownInfoDenied,
786                4 => Self::UnknownUnsupported,
787                _ => Self::UnknownValue(membership::UnknownValue(
788                    wkt::internal::UnknownEnumValue::Integer(value),
789                )),
790            }
791        }
792    }
793
794    impl std::convert::From<&str> for Membership {
795        fn from(value: &str) -> Self {
796            use std::string::ToString;
797            match value {
798                "MEMBERSHIP_UNSPECIFIED" => Self::Unspecified,
799                "MEMBERSHIP_INCLUDED" => Self::Included,
800                "MEMBERSHIP_NOT_INCLUDED" => Self::NotIncluded,
801                "MEMBERSHIP_UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
802                "MEMBERSHIP_UNKNOWN_UNSUPPORTED" => Self::UnknownUnsupported,
803                _ => Self::UnknownValue(membership::UnknownValue(
804                    wkt::internal::UnknownEnumValue::String(value.to_string()),
805                )),
806            }
807        }
808    }
809
810    impl serde::ser::Serialize for Membership {
811        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
812        where
813            S: serde::Serializer,
814        {
815            match self {
816                Self::Unspecified => serializer.serialize_i32(0),
817                Self::Included => serializer.serialize_i32(1),
818                Self::NotIncluded => serializer.serialize_i32(2),
819                Self::UnknownInfoDenied => serializer.serialize_i32(3),
820                Self::UnknownUnsupported => serializer.serialize_i32(4),
821                Self::UnknownValue(u) => u.0.serialize(serializer),
822            }
823        }
824    }
825
826    impl<'de> serde::de::Deserialize<'de> for Membership {
827        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
828        where
829            D: serde::Deserializer<'de>,
830        {
831            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Membership>::new(
832                ".google.cloud.policytroubleshooter.v1.BindingExplanation.Membership",
833            ))
834        }
835    }
836}
837
838/// Whether a principal has a permission for a resource.
839///
840/// # Working with unknown values
841///
842/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
843/// additional enum variants at any time. Adding new variants is not considered
844/// a breaking change. Applications should write their code in anticipation of:
845///
846/// - New values appearing in future releases of the client library, **and**
847/// - New values received dynamically, without application changes.
848///
849/// Please consult the [Working with enums] section in the user guide for some
850/// guidelines.
851///
852/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
853#[derive(Clone, Debug, PartialEq)]
854#[non_exhaustive]
855pub enum AccessState {
856    /// Default value. This value is unused.
857    Unspecified,
858    /// The principal has the permission.
859    Granted,
860    /// The principal does not have the permission.
861    NotGranted,
862    /// The principal has the permission only if a condition expression evaluates
863    /// to `true`.
864    UnknownConditional,
865    /// The sender of the request does not have access to all of the policies that
866    /// Policy Troubleshooter needs to evaluate.
867    UnknownInfoDenied,
868    /// If set, the enum was initialized with an unknown value.
869    ///
870    /// Applications can examine the value using [AccessState::value] or
871    /// [AccessState::name].
872    UnknownValue(access_state::UnknownValue),
873}
874
875#[doc(hidden)]
876pub mod access_state {
877    #[allow(unused_imports)]
878    use super::*;
879    #[derive(Clone, Debug, PartialEq)]
880    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
881}
882
883impl AccessState {
884    /// Gets the enum value.
885    ///
886    /// Returns `None` if the enum contains an unknown value deserialized from
887    /// the string representation of enums.
888    pub fn value(&self) -> std::option::Option<i32> {
889        match self {
890            Self::Unspecified => std::option::Option::Some(0),
891            Self::Granted => std::option::Option::Some(1),
892            Self::NotGranted => std::option::Option::Some(2),
893            Self::UnknownConditional => std::option::Option::Some(3),
894            Self::UnknownInfoDenied => std::option::Option::Some(4),
895            Self::UnknownValue(u) => u.0.value(),
896        }
897    }
898
899    /// Gets the enum value as a string.
900    ///
901    /// Returns `None` if the enum contains an unknown value deserialized from
902    /// the integer representation of enums.
903    pub fn name(&self) -> std::option::Option<&str> {
904        match self {
905            Self::Unspecified => std::option::Option::Some("ACCESS_STATE_UNSPECIFIED"),
906            Self::Granted => std::option::Option::Some("GRANTED"),
907            Self::NotGranted => std::option::Option::Some("NOT_GRANTED"),
908            Self::UnknownConditional => std::option::Option::Some("UNKNOWN_CONDITIONAL"),
909            Self::UnknownInfoDenied => std::option::Option::Some("UNKNOWN_INFO_DENIED"),
910            Self::UnknownValue(u) => u.0.name(),
911        }
912    }
913}
914
915impl std::default::Default for AccessState {
916    fn default() -> Self {
917        use std::convert::From;
918        Self::from(0)
919    }
920}
921
922impl std::fmt::Display for AccessState {
923    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
924        wkt::internal::display_enum(f, self.name(), self.value())
925    }
926}
927
928impl std::convert::From<i32> for AccessState {
929    fn from(value: i32) -> Self {
930        match value {
931            0 => Self::Unspecified,
932            1 => Self::Granted,
933            2 => Self::NotGranted,
934            3 => Self::UnknownConditional,
935            4 => Self::UnknownInfoDenied,
936            _ => Self::UnknownValue(access_state::UnknownValue(
937                wkt::internal::UnknownEnumValue::Integer(value),
938            )),
939        }
940    }
941}
942
943impl std::convert::From<&str> for AccessState {
944    fn from(value: &str) -> Self {
945        use std::string::ToString;
946        match value {
947            "ACCESS_STATE_UNSPECIFIED" => Self::Unspecified,
948            "GRANTED" => Self::Granted,
949            "NOT_GRANTED" => Self::NotGranted,
950            "UNKNOWN_CONDITIONAL" => Self::UnknownConditional,
951            "UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
952            _ => Self::UnknownValue(access_state::UnknownValue(
953                wkt::internal::UnknownEnumValue::String(value.to_string()),
954            )),
955        }
956    }
957}
958
959impl serde::ser::Serialize for AccessState {
960    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
961    where
962        S: serde::Serializer,
963    {
964        match self {
965            Self::Unspecified => serializer.serialize_i32(0),
966            Self::Granted => serializer.serialize_i32(1),
967            Self::NotGranted => serializer.serialize_i32(2),
968            Self::UnknownConditional => serializer.serialize_i32(3),
969            Self::UnknownInfoDenied => serializer.serialize_i32(4),
970            Self::UnknownValue(u) => u.0.serialize(serializer),
971        }
972    }
973}
974
975impl<'de> serde::de::Deserialize<'de> for AccessState {
976    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
977    where
978        D: serde::Deserializer<'de>,
979    {
980        deserializer.deserialize_any(wkt::internal::EnumVisitor::<AccessState>::new(
981            ".google.cloud.policytroubleshooter.v1.AccessState",
982        ))
983    }
984}
985
986/// The extent to which a single data point, such as the existence of a binding
987/// or whether a binding includes a specific principal, contributes to an overall
988/// determination.
989///
990/// # Working with unknown values
991///
992/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
993/// additional enum variants at any time. Adding new variants is not considered
994/// a breaking change. Applications should write their code in anticipation of:
995///
996/// - New values appearing in future releases of the client library, **and**
997/// - New values received dynamically, without application changes.
998///
999/// Please consult the [Working with enums] section in the user guide for some
1000/// guidelines.
1001///
1002/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
1003#[derive(Clone, Debug, PartialEq)]
1004#[non_exhaustive]
1005pub enum HeuristicRelevance {
1006    /// Default value. This value is unused.
1007    Unspecified,
1008    /// The data point has a limited effect on the result. Changing the data point
1009    /// is unlikely to affect the overall determination.
1010    Normal,
1011    /// The data point has a strong effect on the result. Changing the data point
1012    /// is likely to affect the overall determination.
1013    High,
1014    /// If set, the enum was initialized with an unknown value.
1015    ///
1016    /// Applications can examine the value using [HeuristicRelevance::value] or
1017    /// [HeuristicRelevance::name].
1018    UnknownValue(heuristic_relevance::UnknownValue),
1019}
1020
1021#[doc(hidden)]
1022pub mod heuristic_relevance {
1023    #[allow(unused_imports)]
1024    use super::*;
1025    #[derive(Clone, Debug, PartialEq)]
1026    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1027}
1028
1029impl HeuristicRelevance {
1030    /// Gets the enum value.
1031    ///
1032    /// Returns `None` if the enum contains an unknown value deserialized from
1033    /// the string representation of enums.
1034    pub fn value(&self) -> std::option::Option<i32> {
1035        match self {
1036            Self::Unspecified => std::option::Option::Some(0),
1037            Self::Normal => std::option::Option::Some(1),
1038            Self::High => std::option::Option::Some(2),
1039            Self::UnknownValue(u) => u.0.value(),
1040        }
1041    }
1042
1043    /// Gets the enum value as a string.
1044    ///
1045    /// Returns `None` if the enum contains an unknown value deserialized from
1046    /// the integer representation of enums.
1047    pub fn name(&self) -> std::option::Option<&str> {
1048        match self {
1049            Self::Unspecified => std::option::Option::Some("HEURISTIC_RELEVANCE_UNSPECIFIED"),
1050            Self::Normal => std::option::Option::Some("NORMAL"),
1051            Self::High => std::option::Option::Some("HIGH"),
1052            Self::UnknownValue(u) => u.0.name(),
1053        }
1054    }
1055}
1056
1057impl std::default::Default for HeuristicRelevance {
1058    fn default() -> Self {
1059        use std::convert::From;
1060        Self::from(0)
1061    }
1062}
1063
1064impl std::fmt::Display for HeuristicRelevance {
1065    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1066        wkt::internal::display_enum(f, self.name(), self.value())
1067    }
1068}
1069
1070impl std::convert::From<i32> for HeuristicRelevance {
1071    fn from(value: i32) -> Self {
1072        match value {
1073            0 => Self::Unspecified,
1074            1 => Self::Normal,
1075            2 => Self::High,
1076            _ => Self::UnknownValue(heuristic_relevance::UnknownValue(
1077                wkt::internal::UnknownEnumValue::Integer(value),
1078            )),
1079        }
1080    }
1081}
1082
1083impl std::convert::From<&str> for HeuristicRelevance {
1084    fn from(value: &str) -> Self {
1085        use std::string::ToString;
1086        match value {
1087            "HEURISTIC_RELEVANCE_UNSPECIFIED" => Self::Unspecified,
1088            "NORMAL" => Self::Normal,
1089            "HIGH" => Self::High,
1090            _ => Self::UnknownValue(heuristic_relevance::UnknownValue(
1091                wkt::internal::UnknownEnumValue::String(value.to_string()),
1092            )),
1093        }
1094    }
1095}
1096
1097impl serde::ser::Serialize for HeuristicRelevance {
1098    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1099    where
1100        S: serde::Serializer,
1101    {
1102        match self {
1103            Self::Unspecified => serializer.serialize_i32(0),
1104            Self::Normal => serializer.serialize_i32(1),
1105            Self::High => serializer.serialize_i32(2),
1106            Self::UnknownValue(u) => u.0.serialize(serializer),
1107        }
1108    }
1109}
1110
1111impl<'de> serde::de::Deserialize<'de> for HeuristicRelevance {
1112    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1113    where
1114        D: serde::Deserializer<'de>,
1115    {
1116        deserializer.deserialize_any(wkt::internal::EnumVisitor::<HeuristicRelevance>::new(
1117            ".google.cloud.policytroubleshooter.v1.HeuristicRelevance",
1118        ))
1119    }
1120}