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 iam_v1;
25extern crate lazy_static;
26extern crate reqwest;
27extern crate serde;
28extern crate serde_json;
29extern crate serde_with;
30extern crate std;
31extern crate tracing;
32extern crate wkt;
33
34mod debug;
35mod deserialize;
36mod serialize;
37
38#[derive(Clone, Default, PartialEq)]
40#[non_exhaustive]
41pub struct CreateDataPolicyRequest {
42 pub parent: std::string::String,
45
46 pub data_policy_id: std::string::String,
50
51 pub data_policy: std::option::Option<crate::model::DataPolicy>,
54
55 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
56}
57
58impl CreateDataPolicyRequest {
59 pub fn new() -> Self {
60 std::default::Default::default()
61 }
62
63 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
65 self.parent = v.into();
66 self
67 }
68
69 pub fn set_data_policy_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
71 self.data_policy_id = v.into();
72 self
73 }
74
75 pub fn set_data_policy<T>(mut self, v: T) -> Self
77 where
78 T: std::convert::Into<crate::model::DataPolicy>,
79 {
80 self.data_policy = std::option::Option::Some(v.into());
81 self
82 }
83
84 pub fn set_or_clear_data_policy<T>(mut self, v: std::option::Option<T>) -> Self
86 where
87 T: std::convert::Into<crate::model::DataPolicy>,
88 {
89 self.data_policy = v.map(|x| x.into());
90 self
91 }
92}
93
94impl wkt::message::Message for CreateDataPolicyRequest {
95 fn typename() -> &'static str {
96 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.CreateDataPolicyRequest"
97 }
98}
99
100#[derive(Clone, Default, PartialEq)]
102#[non_exhaustive]
103pub struct UpdateDataPolicyRequest {
104 pub data_policy: std::option::Option<crate::model::DataPolicy>,
109
110 pub update_mask: std::option::Option<wkt::FieldMask>,
117
118 pub allow_missing: bool,
121
122 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
123}
124
125impl UpdateDataPolicyRequest {
126 pub fn new() -> Self {
127 std::default::Default::default()
128 }
129
130 pub fn set_data_policy<T>(mut self, v: T) -> Self
132 where
133 T: std::convert::Into<crate::model::DataPolicy>,
134 {
135 self.data_policy = std::option::Option::Some(v.into());
136 self
137 }
138
139 pub fn set_or_clear_data_policy<T>(mut self, v: std::option::Option<T>) -> Self
141 where
142 T: std::convert::Into<crate::model::DataPolicy>,
143 {
144 self.data_policy = v.map(|x| x.into());
145 self
146 }
147
148 pub fn set_update_mask<T>(mut self, v: T) -> Self
150 where
151 T: std::convert::Into<wkt::FieldMask>,
152 {
153 self.update_mask = std::option::Option::Some(v.into());
154 self
155 }
156
157 pub fn set_or_clear_update_mask<T>(mut self, v: std::option::Option<T>) -> Self
159 where
160 T: std::convert::Into<wkt::FieldMask>,
161 {
162 self.update_mask = v.map(|x| x.into());
163 self
164 }
165
166 pub fn set_allow_missing<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
168 self.allow_missing = v.into();
169 self
170 }
171}
172
173impl wkt::message::Message for UpdateDataPolicyRequest {
174 fn typename() -> &'static str {
175 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.UpdateDataPolicyRequest"
176 }
177}
178
179#[derive(Clone, Default, PartialEq)]
181#[non_exhaustive]
182pub struct AddGranteesRequest {
183 pub data_policy: std::string::String,
186
187 pub grantees: std::vec::Vec<std::string::String>,
199
200 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
201}
202
203impl AddGranteesRequest {
204 pub fn new() -> Self {
205 std::default::Default::default()
206 }
207
208 pub fn set_data_policy<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
210 self.data_policy = v.into();
211 self
212 }
213
214 pub fn set_grantees<T, V>(mut self, v: T) -> Self
216 where
217 T: std::iter::IntoIterator<Item = V>,
218 V: std::convert::Into<std::string::String>,
219 {
220 use std::iter::Iterator;
221 self.grantees = v.into_iter().map(|i| i.into()).collect();
222 self
223 }
224}
225
226impl wkt::message::Message for AddGranteesRequest {
227 fn typename() -> &'static str {
228 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.AddGranteesRequest"
229 }
230}
231
232#[derive(Clone, Default, PartialEq)]
234#[non_exhaustive]
235pub struct RemoveGranteesRequest {
236 pub data_policy: std::string::String,
239
240 pub grantees: std::vec::Vec<std::string::String>,
252
253 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
254}
255
256impl RemoveGranteesRequest {
257 pub fn new() -> Self {
258 std::default::Default::default()
259 }
260
261 pub fn set_data_policy<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
263 self.data_policy = v.into();
264 self
265 }
266
267 pub fn set_grantees<T, V>(mut self, v: T) -> Self
269 where
270 T: std::iter::IntoIterator<Item = V>,
271 V: std::convert::Into<std::string::String>,
272 {
273 use std::iter::Iterator;
274 self.grantees = v.into_iter().map(|i| i.into()).collect();
275 self
276 }
277}
278
279impl wkt::message::Message for RemoveGranteesRequest {
280 fn typename() -> &'static str {
281 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.RemoveGranteesRequest"
282 }
283}
284
285#[derive(Clone, Default, PartialEq)]
287#[non_exhaustive]
288pub struct DeleteDataPolicyRequest {
289 pub name: std::string::String,
292
293 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
294}
295
296impl DeleteDataPolicyRequest {
297 pub fn new() -> Self {
298 std::default::Default::default()
299 }
300
301 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
303 self.name = v.into();
304 self
305 }
306}
307
308impl wkt::message::Message for DeleteDataPolicyRequest {
309 fn typename() -> &'static str {
310 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.DeleteDataPolicyRequest"
311 }
312}
313
314#[derive(Clone, Default, PartialEq)]
316#[non_exhaustive]
317pub struct GetDataPolicyRequest {
318 pub name: std::string::String,
321
322 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
323}
324
325impl GetDataPolicyRequest {
326 pub fn new() -> Self {
327 std::default::Default::default()
328 }
329
330 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
332 self.name = v.into();
333 self
334 }
335}
336
337impl wkt::message::Message for GetDataPolicyRequest {
338 fn typename() -> &'static str {
339 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.GetDataPolicyRequest"
340 }
341}
342
343#[derive(Clone, Default, PartialEq)]
345#[non_exhaustive]
346pub struct ListDataPoliciesRequest {
347 pub parent: std::string::String,
350
351 pub page_size: i32,
354
355 pub page_token: std::string::String,
358
359 pub filter: std::string::String,
368
369 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
370}
371
372impl ListDataPoliciesRequest {
373 pub fn new() -> Self {
374 std::default::Default::default()
375 }
376
377 pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
379 self.parent = v.into();
380 self
381 }
382
383 pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
385 self.page_size = v.into();
386 self
387 }
388
389 pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
391 self.page_token = v.into();
392 self
393 }
394
395 pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
397 self.filter = v.into();
398 self
399 }
400}
401
402impl wkt::message::Message for ListDataPoliciesRequest {
403 fn typename() -> &'static str {
404 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.ListDataPoliciesRequest"
405 }
406}
407
408#[derive(Clone, Default, PartialEq)]
410#[non_exhaustive]
411pub struct ListDataPoliciesResponse {
412 pub data_policies: std::vec::Vec<crate::model::DataPolicy>,
414
415 pub next_page_token: std::string::String,
418
419 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
420}
421
422impl ListDataPoliciesResponse {
423 pub fn new() -> Self {
424 std::default::Default::default()
425 }
426
427 pub fn set_data_policies<T, V>(mut self, v: T) -> Self
429 where
430 T: std::iter::IntoIterator<Item = V>,
431 V: std::convert::Into<crate::model::DataPolicy>,
432 {
433 use std::iter::Iterator;
434 self.data_policies = v.into_iter().map(|i| i.into()).collect();
435 self
436 }
437
438 pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
440 self.next_page_token = v.into();
441 self
442 }
443}
444
445impl wkt::message::Message for ListDataPoliciesResponse {
446 fn typename() -> &'static str {
447 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.ListDataPoliciesResponse"
448 }
449}
450
451#[doc(hidden)]
452impl gax::paginator::internal::PageableResponse for ListDataPoliciesResponse {
453 type PageItem = crate::model::DataPolicy;
454
455 fn items(self) -> std::vec::Vec<Self::PageItem> {
456 self.data_policies
457 }
458
459 fn next_page_token(&self) -> std::string::String {
460 use std::clone::Clone;
461 self.next_page_token.clone()
462 }
463}
464
465#[derive(Clone, Default, PartialEq)]
467#[non_exhaustive]
468pub struct DataPolicy {
469 pub name: std::string::String,
472
473 pub data_policy_id: std::string::String,
477
478 pub etag: std::option::Option<std::string::String>,
484
485 pub data_policy_type: crate::model::data_policy::DataPolicyType,
487
488 pub policy_tag: std::string::String,
492
493 pub grantees: std::vec::Vec<std::string::String>,
502
503 pub version: crate::model::data_policy::Version,
505
506 pub policy: std::option::Option<crate::model::data_policy::Policy>,
508
509 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
510}
511
512impl DataPolicy {
513 pub fn new() -> Self {
514 std::default::Default::default()
515 }
516
517 pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
519 self.name = v.into();
520 self
521 }
522
523 pub fn set_data_policy_id<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
525 self.data_policy_id = v.into();
526 self
527 }
528
529 pub fn set_etag<T>(mut self, v: T) -> Self
531 where
532 T: std::convert::Into<std::string::String>,
533 {
534 self.etag = std::option::Option::Some(v.into());
535 self
536 }
537
538 pub fn set_or_clear_etag<T>(mut self, v: std::option::Option<T>) -> Self
540 where
541 T: std::convert::Into<std::string::String>,
542 {
543 self.etag = v.map(|x| x.into());
544 self
545 }
546
547 pub fn set_data_policy_type<
549 T: std::convert::Into<crate::model::data_policy::DataPolicyType>,
550 >(
551 mut self,
552 v: T,
553 ) -> Self {
554 self.data_policy_type = v.into();
555 self
556 }
557
558 pub fn set_policy_tag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
560 self.policy_tag = v.into();
561 self
562 }
563
564 pub fn set_grantees<T, V>(mut self, v: T) -> Self
566 where
567 T: std::iter::IntoIterator<Item = V>,
568 V: std::convert::Into<std::string::String>,
569 {
570 use std::iter::Iterator;
571 self.grantees = v.into_iter().map(|i| i.into()).collect();
572 self
573 }
574
575 pub fn set_version<T: std::convert::Into<crate::model::data_policy::Version>>(
577 mut self,
578 v: T,
579 ) -> Self {
580 self.version = v.into();
581 self
582 }
583
584 pub fn set_policy<
589 T: std::convert::Into<std::option::Option<crate::model::data_policy::Policy>>,
590 >(
591 mut self,
592 v: T,
593 ) -> Self {
594 self.policy = v.into();
595 self
596 }
597
598 pub fn data_masking_policy(
602 &self,
603 ) -> std::option::Option<&std::boxed::Box<crate::model::DataMaskingPolicy>> {
604 #[allow(unreachable_patterns)]
605 self.policy.as_ref().and_then(|v| match v {
606 crate::model::data_policy::Policy::DataMaskingPolicy(v) => std::option::Option::Some(v),
607 _ => std::option::Option::None,
608 })
609 }
610
611 pub fn set_data_masking_policy<
617 T: std::convert::Into<std::boxed::Box<crate::model::DataMaskingPolicy>>,
618 >(
619 mut self,
620 v: T,
621 ) -> Self {
622 self.policy = std::option::Option::Some(
623 crate::model::data_policy::Policy::DataMaskingPolicy(v.into()),
624 );
625 self
626 }
627}
628
629impl wkt::message::Message for DataPolicy {
630 fn typename() -> &'static str {
631 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.DataPolicy"
632 }
633}
634
635pub mod data_policy {
637 #[allow(unused_imports)]
638 use super::*;
639
640 #[derive(Clone, Debug, PartialEq)]
656 #[non_exhaustive]
657 pub enum DataPolicyType {
658 Unspecified,
660 DataMaskingPolicy,
662 RawDataAccessPolicy,
664 ColumnLevelSecurityPolicy,
668 UnknownValue(data_policy_type::UnknownValue),
673 }
674
675 #[doc(hidden)]
676 pub mod data_policy_type {
677 #[allow(unused_imports)]
678 use super::*;
679 #[derive(Clone, Debug, PartialEq)]
680 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
681 }
682
683 impl DataPolicyType {
684 pub fn value(&self) -> std::option::Option<i32> {
689 match self {
690 Self::Unspecified => std::option::Option::Some(0),
691 Self::DataMaskingPolicy => std::option::Option::Some(1),
692 Self::RawDataAccessPolicy => std::option::Option::Some(2),
693 Self::ColumnLevelSecurityPolicy => std::option::Option::Some(3),
694 Self::UnknownValue(u) => u.0.value(),
695 }
696 }
697
698 pub fn name(&self) -> std::option::Option<&str> {
703 match self {
704 Self::Unspecified => std::option::Option::Some("DATA_POLICY_TYPE_UNSPECIFIED"),
705 Self::DataMaskingPolicy => std::option::Option::Some("DATA_MASKING_POLICY"),
706 Self::RawDataAccessPolicy => std::option::Option::Some("RAW_DATA_ACCESS_POLICY"),
707 Self::ColumnLevelSecurityPolicy => {
708 std::option::Option::Some("COLUMN_LEVEL_SECURITY_POLICY")
709 }
710 Self::UnknownValue(u) => u.0.name(),
711 }
712 }
713 }
714
715 impl std::default::Default for DataPolicyType {
716 fn default() -> Self {
717 use std::convert::From;
718 Self::from(0)
719 }
720 }
721
722 impl std::fmt::Display for DataPolicyType {
723 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
724 wkt::internal::display_enum(f, self.name(), self.value())
725 }
726 }
727
728 impl std::convert::From<i32> for DataPolicyType {
729 fn from(value: i32) -> Self {
730 match value {
731 0 => Self::Unspecified,
732 1 => Self::DataMaskingPolicy,
733 2 => Self::RawDataAccessPolicy,
734 3 => Self::ColumnLevelSecurityPolicy,
735 _ => Self::UnknownValue(data_policy_type::UnknownValue(
736 wkt::internal::UnknownEnumValue::Integer(value),
737 )),
738 }
739 }
740 }
741
742 impl std::convert::From<&str> for DataPolicyType {
743 fn from(value: &str) -> Self {
744 use std::string::ToString;
745 match value {
746 "DATA_POLICY_TYPE_UNSPECIFIED" => Self::Unspecified,
747 "DATA_MASKING_POLICY" => Self::DataMaskingPolicy,
748 "RAW_DATA_ACCESS_POLICY" => Self::RawDataAccessPolicy,
749 "COLUMN_LEVEL_SECURITY_POLICY" => Self::ColumnLevelSecurityPolicy,
750 _ => Self::UnknownValue(data_policy_type::UnknownValue(
751 wkt::internal::UnknownEnumValue::String(value.to_string()),
752 )),
753 }
754 }
755 }
756
757 impl serde::ser::Serialize for DataPolicyType {
758 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
759 where
760 S: serde::Serializer,
761 {
762 match self {
763 Self::Unspecified => serializer.serialize_i32(0),
764 Self::DataMaskingPolicy => serializer.serialize_i32(1),
765 Self::RawDataAccessPolicy => serializer.serialize_i32(2),
766 Self::ColumnLevelSecurityPolicy => serializer.serialize_i32(3),
767 Self::UnknownValue(u) => u.0.serialize(serializer),
768 }
769 }
770 }
771
772 impl<'de> serde::de::Deserialize<'de> for DataPolicyType {
773 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
774 where
775 D: serde::Deserializer<'de>,
776 {
777 deserializer.deserialize_any(wkt::internal::EnumVisitor::<DataPolicyType>::new(
778 ".google.cloud.bigquery.datapolicies.v2.DataPolicy.DataPolicyType",
779 ))
780 }
781 }
782
783 #[derive(Clone, Debug, PartialEq)]
799 #[non_exhaustive]
800 pub enum Version {
801 Unspecified,
803 V1,
806 V2,
808 UnknownValue(version::UnknownValue),
813 }
814
815 #[doc(hidden)]
816 pub mod version {
817 #[allow(unused_imports)]
818 use super::*;
819 #[derive(Clone, Debug, PartialEq)]
820 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
821 }
822
823 impl Version {
824 pub fn value(&self) -> std::option::Option<i32> {
829 match self {
830 Self::Unspecified => std::option::Option::Some(0),
831 Self::V1 => std::option::Option::Some(1),
832 Self::V2 => std::option::Option::Some(2),
833 Self::UnknownValue(u) => u.0.value(),
834 }
835 }
836
837 pub fn name(&self) -> std::option::Option<&str> {
842 match self {
843 Self::Unspecified => std::option::Option::Some("VERSION_UNSPECIFIED"),
844 Self::V1 => std::option::Option::Some("V1"),
845 Self::V2 => std::option::Option::Some("V2"),
846 Self::UnknownValue(u) => u.0.name(),
847 }
848 }
849 }
850
851 impl std::default::Default for Version {
852 fn default() -> Self {
853 use std::convert::From;
854 Self::from(0)
855 }
856 }
857
858 impl std::fmt::Display for Version {
859 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
860 wkt::internal::display_enum(f, self.name(), self.value())
861 }
862 }
863
864 impl std::convert::From<i32> for Version {
865 fn from(value: i32) -> Self {
866 match value {
867 0 => Self::Unspecified,
868 1 => Self::V1,
869 2 => Self::V2,
870 _ => Self::UnknownValue(version::UnknownValue(
871 wkt::internal::UnknownEnumValue::Integer(value),
872 )),
873 }
874 }
875 }
876
877 impl std::convert::From<&str> for Version {
878 fn from(value: &str) -> Self {
879 use std::string::ToString;
880 match value {
881 "VERSION_UNSPECIFIED" => Self::Unspecified,
882 "V1" => Self::V1,
883 "V2" => Self::V2,
884 _ => Self::UnknownValue(version::UnknownValue(
885 wkt::internal::UnknownEnumValue::String(value.to_string()),
886 )),
887 }
888 }
889 }
890
891 impl serde::ser::Serialize for Version {
892 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
893 where
894 S: serde::Serializer,
895 {
896 match self {
897 Self::Unspecified => serializer.serialize_i32(0),
898 Self::V1 => serializer.serialize_i32(1),
899 Self::V2 => serializer.serialize_i32(2),
900 Self::UnknownValue(u) => u.0.serialize(serializer),
901 }
902 }
903 }
904
905 impl<'de> serde::de::Deserialize<'de> for Version {
906 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
907 where
908 D: serde::Deserializer<'de>,
909 {
910 deserializer.deserialize_any(wkt::internal::EnumVisitor::<Version>::new(
911 ".google.cloud.bigquery.datapolicies.v2.DataPolicy.Version",
912 ))
913 }
914 }
915
916 #[derive(Clone, Debug, PartialEq)]
918 #[non_exhaustive]
919 pub enum Policy {
920 DataMaskingPolicy(std::boxed::Box<crate::model::DataMaskingPolicy>),
923 }
924}
925
926#[derive(Clone, Default, PartialEq)]
928#[non_exhaustive]
929pub struct DataMaskingPolicy {
930 pub masking_expression:
932 std::option::Option<crate::model::data_masking_policy::MaskingExpression>,
933
934 pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
935}
936
937impl DataMaskingPolicy {
938 pub fn new() -> Self {
939 std::default::Default::default()
940 }
941
942 pub fn set_masking_expression<
947 T: std::convert::Into<
948 std::option::Option<crate::model::data_masking_policy::MaskingExpression>,
949 >,
950 >(
951 mut self,
952 v: T,
953 ) -> Self {
954 self.masking_expression = v.into();
955 self
956 }
957
958 pub fn predefined_expression(
962 &self,
963 ) -> std::option::Option<&crate::model::data_masking_policy::PredefinedExpression> {
964 #[allow(unreachable_patterns)]
965 self.masking_expression.as_ref().and_then(|v| match v {
966 crate::model::data_masking_policy::MaskingExpression::PredefinedExpression(v) => {
967 std::option::Option::Some(v)
968 }
969 _ => std::option::Option::None,
970 })
971 }
972
973 pub fn set_predefined_expression<
979 T: std::convert::Into<crate::model::data_masking_policy::PredefinedExpression>,
980 >(
981 mut self,
982 v: T,
983 ) -> Self {
984 self.masking_expression = std::option::Option::Some(
985 crate::model::data_masking_policy::MaskingExpression::PredefinedExpression(v.into()),
986 );
987 self
988 }
989
990 pub fn routine(&self) -> std::option::Option<&std::string::String> {
994 #[allow(unreachable_patterns)]
995 self.masking_expression.as_ref().and_then(|v| match v {
996 crate::model::data_masking_policy::MaskingExpression::Routine(v) => {
997 std::option::Option::Some(v)
998 }
999 _ => std::option::Option::None,
1000 })
1001 }
1002
1003 pub fn set_routine<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
1009 self.masking_expression = std::option::Option::Some(
1010 crate::model::data_masking_policy::MaskingExpression::Routine(v.into()),
1011 );
1012 self
1013 }
1014}
1015
1016impl wkt::message::Message for DataMaskingPolicy {
1017 fn typename() -> &'static str {
1018 "type.googleapis.com/google.cloud.bigquery.datapolicies.v2.DataMaskingPolicy"
1019 }
1020}
1021
1022pub mod data_masking_policy {
1024 #[allow(unused_imports)]
1025 use super::*;
1026
1027 #[derive(Clone, Debug, PartialEq)]
1044 #[non_exhaustive]
1045 pub enum PredefinedExpression {
1046 Unspecified,
1049 Sha256,
1051 AlwaysNull,
1053 DefaultMaskingValue,
1072 LastFourCharacters,
1079 FirstFourCharacters,
1086 EmailMask,
1096 DateYearMask,
1109 RandomHash,
1114 UnknownValue(predefined_expression::UnknownValue),
1119 }
1120
1121 #[doc(hidden)]
1122 pub mod predefined_expression {
1123 #[allow(unused_imports)]
1124 use super::*;
1125 #[derive(Clone, Debug, PartialEq)]
1126 pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
1127 }
1128
1129 impl PredefinedExpression {
1130 pub fn value(&self) -> std::option::Option<i32> {
1135 match self {
1136 Self::Unspecified => std::option::Option::Some(0),
1137 Self::Sha256 => std::option::Option::Some(1),
1138 Self::AlwaysNull => std::option::Option::Some(2),
1139 Self::DefaultMaskingValue => std::option::Option::Some(3),
1140 Self::LastFourCharacters => std::option::Option::Some(4),
1141 Self::FirstFourCharacters => std::option::Option::Some(5),
1142 Self::EmailMask => std::option::Option::Some(6),
1143 Self::DateYearMask => std::option::Option::Some(7),
1144 Self::RandomHash => std::option::Option::Some(8),
1145 Self::UnknownValue(u) => u.0.value(),
1146 }
1147 }
1148
1149 pub fn name(&self) -> std::option::Option<&str> {
1154 match self {
1155 Self::Unspecified => std::option::Option::Some("PREDEFINED_EXPRESSION_UNSPECIFIED"),
1156 Self::Sha256 => std::option::Option::Some("SHA256"),
1157 Self::AlwaysNull => std::option::Option::Some("ALWAYS_NULL"),
1158 Self::DefaultMaskingValue => std::option::Option::Some("DEFAULT_MASKING_VALUE"),
1159 Self::LastFourCharacters => std::option::Option::Some("LAST_FOUR_CHARACTERS"),
1160 Self::FirstFourCharacters => std::option::Option::Some("FIRST_FOUR_CHARACTERS"),
1161 Self::EmailMask => std::option::Option::Some("EMAIL_MASK"),
1162 Self::DateYearMask => std::option::Option::Some("DATE_YEAR_MASK"),
1163 Self::RandomHash => std::option::Option::Some("RANDOM_HASH"),
1164 Self::UnknownValue(u) => u.0.name(),
1165 }
1166 }
1167 }
1168
1169 impl std::default::Default for PredefinedExpression {
1170 fn default() -> Self {
1171 use std::convert::From;
1172 Self::from(0)
1173 }
1174 }
1175
1176 impl std::fmt::Display for PredefinedExpression {
1177 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
1178 wkt::internal::display_enum(f, self.name(), self.value())
1179 }
1180 }
1181
1182 impl std::convert::From<i32> for PredefinedExpression {
1183 fn from(value: i32) -> Self {
1184 match value {
1185 0 => Self::Unspecified,
1186 1 => Self::Sha256,
1187 2 => Self::AlwaysNull,
1188 3 => Self::DefaultMaskingValue,
1189 4 => Self::LastFourCharacters,
1190 5 => Self::FirstFourCharacters,
1191 6 => Self::EmailMask,
1192 7 => Self::DateYearMask,
1193 8 => Self::RandomHash,
1194 _ => Self::UnknownValue(predefined_expression::UnknownValue(
1195 wkt::internal::UnknownEnumValue::Integer(value),
1196 )),
1197 }
1198 }
1199 }
1200
1201 impl std::convert::From<&str> for PredefinedExpression {
1202 fn from(value: &str) -> Self {
1203 use std::string::ToString;
1204 match value {
1205 "PREDEFINED_EXPRESSION_UNSPECIFIED" => Self::Unspecified,
1206 "SHA256" => Self::Sha256,
1207 "ALWAYS_NULL" => Self::AlwaysNull,
1208 "DEFAULT_MASKING_VALUE" => Self::DefaultMaskingValue,
1209 "LAST_FOUR_CHARACTERS" => Self::LastFourCharacters,
1210 "FIRST_FOUR_CHARACTERS" => Self::FirstFourCharacters,
1211 "EMAIL_MASK" => Self::EmailMask,
1212 "DATE_YEAR_MASK" => Self::DateYearMask,
1213 "RANDOM_HASH" => Self::RandomHash,
1214 _ => Self::UnknownValue(predefined_expression::UnknownValue(
1215 wkt::internal::UnknownEnumValue::String(value.to_string()),
1216 )),
1217 }
1218 }
1219 }
1220
1221 impl serde::ser::Serialize for PredefinedExpression {
1222 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
1223 where
1224 S: serde::Serializer,
1225 {
1226 match self {
1227 Self::Unspecified => serializer.serialize_i32(0),
1228 Self::Sha256 => serializer.serialize_i32(1),
1229 Self::AlwaysNull => serializer.serialize_i32(2),
1230 Self::DefaultMaskingValue => serializer.serialize_i32(3),
1231 Self::LastFourCharacters => serializer.serialize_i32(4),
1232 Self::FirstFourCharacters => serializer.serialize_i32(5),
1233 Self::EmailMask => serializer.serialize_i32(6),
1234 Self::DateYearMask => serializer.serialize_i32(7),
1235 Self::RandomHash => serializer.serialize_i32(8),
1236 Self::UnknownValue(u) => u.0.serialize(serializer),
1237 }
1238 }
1239 }
1240
1241 impl<'de> serde::de::Deserialize<'de> for PredefinedExpression {
1242 fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
1243 where
1244 D: serde::Deserializer<'de>,
1245 {
1246 deserializer.deserialize_any(wkt::internal::EnumVisitor::<PredefinedExpression>::new(
1247 ".google.cloud.bigquery.datapolicies.v2.DataMaskingPolicy.PredefinedExpression",
1248 ))
1249 }
1250 }
1251
1252 #[derive(Clone, Debug, PartialEq)]
1254 #[non_exhaustive]
1255 pub enum MaskingExpression {
1256 PredefinedExpression(crate::model::data_masking_policy::PredefinedExpression),
1258 Routine(std::string::String),
1262 }
1263}