1#![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#[derive(Clone, Default, PartialEq)]
45#[non_exhaustive]
46pub struct TroubleshootIamPolicyRequest {
47 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 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 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#[derive(Clone, Default, PartialEq)]
89#[non_exhaustive]
90pub struct TroubleshootIamPolicyResponse {
91 pub access: crate::model::AccessState,
94
95 pub explained_policies: std::vec::Vec<crate::model::ExplainedPolicy>,
106
107 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 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 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 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#[derive(Clone, Default, PartialEq)]
155#[non_exhaustive]
156pub struct AccessTuple {
157 pub principal: std::string::String,
165
166 pub full_resource_name: std::string::String,
172
173 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 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 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 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#[derive(Clone, Default, PartialEq)]
224#[non_exhaustive]
225pub struct ExplainedPolicy {
226 pub access: crate::model::AccessState,
235
236 pub full_resource_name: std::string::String,
245
246 pub policy: std::option::Option<iam_v1::model::Policy>,
251
252 pub binding_explanations: std::vec::Vec<crate::model::BindingExplanation>,
258
259 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 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 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 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 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 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 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#[derive(Clone, Default, PartialEq)]
337#[non_exhaustive]
338pub struct BindingExplanation {
339 pub access: crate::model::AccessState,
348
349 pub role: std::string::String,
355
356 pub role_permission: crate::model::binding_explanation::RolePermission,
359
360 pub role_permission_relevance: crate::model::HeuristicRelevance,
363
364 pub memberships: std::collections::HashMap<
385 std::string::String,
386 crate::model::binding_explanation::AnnotatedMembership,
387 >,
388
389 pub relevance: crate::model::HeuristicRelevance,
392
393 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 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 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 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 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 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 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 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 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
488pub mod binding_explanation {
490 #[allow(unused_imports)]
491 use super::*;
492
493 #[derive(Clone, Default, PartialEq)]
495 #[non_exhaustive]
496 pub struct AnnotatedMembership {
497 pub membership: crate::model::binding_explanation::Membership,
499
500 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 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 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 #[derive(Clone, Debug, PartialEq)]
555 #[non_exhaustive]
556 pub enum RolePermission {
557 Unspecified,
559 Included,
561 NotIncluded,
563 UnknownInfoDenied,
565 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 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 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 #[derive(Clone, Debug, PartialEq)]
696 #[non_exhaustive]
697 pub enum Membership {
698 Unspecified,
700 Included,
708 NotIncluded,
710 UnknownInfoDenied,
712 UnknownUnsupported,
715 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 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 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#[derive(Clone, Debug, PartialEq)]
854#[non_exhaustive]
855pub enum AccessState {
856 Unspecified,
858 Granted,
860 NotGranted,
862 UnknownConditional,
865 UnknownInfoDenied,
868 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 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 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#[derive(Clone, Debug, PartialEq)]
1004#[non_exhaustive]
1005pub enum HeuristicRelevance {
1006 Unspecified,
1008 Normal,
1011 High,
1014 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 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 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}