21
21
22
22
# [START dlp_deidentify_masking]
23
23
def deidentify_with_mask (
24
- project , string , info_types , masking_character = None , number_to_mask = 0
24
+ project , input_str , info_types , masking_character = None , number_to_mask = 0
25
25
):
26
26
"""Uses the Data Loss Prevention API to deidentify sensitive data in a
27
27
string by masking it with a character.
28
28
Args:
29
29
project: The Google Cloud project id to use as a parent resource.
30
- item : The string to deidentify (will be treated as text).
30
+ input_str : The string to deidentify (will be treated as text).
31
31
masking_character: The character to mask matching sensitive data with.
32
32
number_to_mask: The maximum number of sensitive characters to mask in
33
33
a match. If omitted or set to zero, the API will default to no
@@ -67,7 +67,7 @@ def deidentify_with_mask(
67
67
}
68
68
69
69
# Construct item
70
- item = {"value" : string }
70
+ item = {"value" : input_str }
71
71
72
72
# Call the API
73
73
response = dlp .deidentify_content (
@@ -86,15 +86,16 @@ def deidentify_with_mask(
86
86
# [START dlp_deidentify_replace]
87
87
def deidentify_with_replace (
88
88
project ,
89
- string ,
89
+ input_str ,
90
90
info_types ,
91
- replacement_str = None ,
91
+ replacement_str = "REPLACEMENT_STR" ,
92
92
):
93
93
"""Uses the Data Loss Prevention API to deidentify sensitive data in a
94
94
string by replacing matched input values with a value you specify.
95
95
Args:
96
96
project: The Google Cloud project id to use as a parent resource.
97
- string: The string to deidentify (will be treated as text).
97
+ input_str: The string to deidentify (will be treated as text).
98
+ info_types: A list of strings representing info types to look for.
98
99
replacement_str: The string to replace all values that match given
99
100
info types.
100
101
Returns:
@@ -131,7 +132,7 @@ def deidentify_with_replace(
131
132
}
132
133
133
134
# Construct item
134
- item = {"value" : string }
135
+ item = {"value" : input_str }
135
136
136
137
# Call the API
137
138
response = dlp .deidentify_content (
@@ -151,7 +152,7 @@ def deidentify_with_replace(
151
152
152
153
def deidentify_with_fpe (
153
154
project ,
154
- string ,
155
+ input_str ,
155
156
info_types ,
156
157
alphabet = None ,
157
158
surrogate_type = None ,
@@ -162,7 +163,7 @@ def deidentify_with_fpe(
162
163
string using Format Preserving Encryption (FPE).
163
164
Args:
164
165
project: The Google Cloud project id to use as a parent resource.
165
- item : The string to deidentify (will be treated as text).
166
+ input_str : The string to deidentify (will be treated as text).
166
167
alphabet: The set of characters to replace sensitive ones with. For
167
168
more information, see https://cloud.google.com/dlp/docs/reference/
168
169
rest/v2beta2/organizations.deidentifyTemplates#ffxcommonnativealphabet
@@ -230,7 +231,7 @@ def deidentify_with_fpe(
230
231
}
231
232
232
233
# Convert string to item
233
- item = {"value" : string }
234
+ item = {"value" : input_str }
234
235
235
236
# Call the API
236
237
response = dlp .deidentify_content (
@@ -250,7 +251,7 @@ def deidentify_with_fpe(
250
251
# [START dlp_reidentify_fpe]
251
252
def reidentify_with_fpe (
252
253
project ,
253
- string ,
254
+ input_str ,
254
255
alphabet = None ,
255
256
surrogate_type = None ,
256
257
key_name = None ,
@@ -260,7 +261,7 @@ def reidentify_with_fpe(
260
261
string that was encrypted by Format Preserving Encryption (FPE).
261
262
Args:
262
263
project: The Google Cloud project id to use as a parent resource.
263
- item : The string to deidentify (will be treated as text).
264
+ input_str : The string to deidentify (will be treated as text).
264
265
alphabet: The set of characters to replace sensitive ones with. For
265
266
more information, see https://cloud.google.com/dlp/docs/reference/
266
267
rest/v2beta2/organizations.deidentifyTemplates#ffxcommonnativealphabet
@@ -319,7 +320,7 @@ def reidentify_with_fpe(
319
320
}
320
321
321
322
# Convert string to item
322
- item = {"value" : string }
323
+ item = {"value" : input_str }
323
324
324
325
# Call the API
325
326
response = dlp .reidentify_content (
0 commit comments