@@ -500,13 +500,13 @@ def write_data(data):
500500# [END dlp_deidentify_date_shift]
501501
502502
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
506506 string by replacing it with the info type.
507507 Args:
508508 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).
510510 info_types: A list of strings representing info types to look for.
511511 A full list of info type categories can be fetched from the API.
512512 Returns:
@@ -552,7 +552,7 @@ def redact_sensitive_data(project, item, info_types):
552552 print (response .item .value )
553553
554554
555- # [END dlp_redact_sensitive_data ]
555+ # [END dlp_deidentify_replace_infotype ]
556556
557557
558558if __name__ == "__main__" :
@@ -768,12 +768,12 @@ def redact_sensitive_data(project, item, info_types):
768768 "key_name." ,
769769 )
770770
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."
775775 )
776- redact_parser .add_argument (
776+ replace_with_infotype_parser .add_argument (
777777 "--info_types" ,
778778 action = "append" ,
779779 help = "Strings representing info types to look for. A full list of "
@@ -782,13 +782,13 @@ def redact_sensitive_data(project, item, info_types):
782782 "If unspecified, the three above examples will be used." ,
783783 default = ["FIRST_NAME" , "LAST_NAME" , "EMAIL_ADDRESS" ],
784784 )
785- redact_parser .add_argument (
785+ replace_with_infotype_parser .add_argument (
786786 "project" ,
787787 help = "The Google Cloud project id to use as a parent resource." ,
788788 )
789- redact_parser .add_argument (
789+ replace_with_infotype_parser .add_argument (
790790 "item" ,
791- help = "The string to redact ."
791+ help = "The string to deidentify ."
792792 "Example: 'My credit card is 4242 4242 4242 4242'" ,
793793 )
794794
@@ -840,8 +840,8 @@ def redact_sensitive_data(project, item, info_types):
840840 wrapped_key = args .wrapped_key ,
841841 key_name = args .key_name ,
842842 )
843- elif args .content == "redact " :
844- redact_sensitive_data (
843+ elif args .content == "replace_with_infotype " :
844+ deidentify_with_replace_infotype (
845845 args .project ,
846846 item = args .item ,
847847 info_types = args .info_types ,
0 commit comments