@@ -500,13 +500,13 @@ def write_data(data):
500
500
# [END dlp_deidentify_date_shift]
501
501
502
502
503
- # [START dlp_redact_sensitive_data ]
504
- def redact_sensitive_data (project , item , info_types ):
505
- """Uses the Data Loss Prevention API to redact sensitive data in a
503
+ # [START dlp_deidentify_replace_infotype ]
504
+ def deidentify_with_replace_infotype (project , item , info_types ):
505
+ """Uses the Data Loss Prevention API to deidentify sensitive data in a
506
506
string by replacing it with the info type.
507
507
Args:
508
508
project: The Google Cloud project id to use as a parent resource.
509
- item: The string to redact (will be treated as text).
509
+ item: The string to deidentify (will be treated as text).
510
510
info_types: A list of strings representing info types to look for.
511
511
A full list of info type categories can be fetched from the API.
512
512
Returns:
@@ -552,7 +552,7 @@ def redact_sensitive_data(project, item, info_types):
552
552
print (response .item .value )
553
553
554
554
555
- # [END dlp_redact_sensitive_data ]
555
+ # [END dlp_deidentify_replace_infotype ]
556
556
557
557
558
558
if __name__ == "__main__" :
@@ -768,12 +768,12 @@ def redact_sensitive_data(project, item, info_types):
768
768
"key_name." ,
769
769
)
770
770
771
- redact_parser = subparsers .add_parser (
772
- "redact " ,
773
- help = "Redact sensitive data in a string by replacing it with the "
774
- "info type of the data." ,
771
+ replace_with_infotype_parser = subparsers .add_parser (
772
+ "replace_with_infotype " ,
773
+ help = "Deidentify sensitive data in a string by replacing it with the "
774
+ "info type of the data."
775
775
)
776
- redact_parser .add_argument (
776
+ replace_with_infotype_parser .add_argument (
777
777
"--info_types" ,
778
778
action = "append" ,
779
779
help = "Strings representing info types to look for. A full list of "
@@ -782,13 +782,13 @@ def redact_sensitive_data(project, item, info_types):
782
782
"If unspecified, the three above examples will be used." ,
783
783
default = ["FIRST_NAME" , "LAST_NAME" , "EMAIL_ADDRESS" ],
784
784
)
785
- redact_parser .add_argument (
785
+ replace_with_infotype_parser .add_argument (
786
786
"project" ,
787
787
help = "The Google Cloud project id to use as a parent resource." ,
788
788
)
789
- redact_parser .add_argument (
789
+ replace_with_infotype_parser .add_argument (
790
790
"item" ,
791
- help = "The string to redact ."
791
+ help = "The string to deidentify ."
792
792
"Example: 'My credit card is 4242 4242 4242 4242'" ,
793
793
)
794
794
@@ -840,8 +840,8 @@ def redact_sensitive_data(project, item, info_types):
840
840
wrapped_key = args .wrapped_key ,
841
841
key_name = args .key_name ,
842
842
)
843
- elif args .content == "redact " :
844
- redact_sensitive_data (
843
+ elif args .content == "replace_with_infotype " :
844
+ deidentify_with_replace_infotype (
845
845
args .project ,
846
846
item = args .item ,
847
847
info_types = args .info_types ,
0 commit comments