|
26 | 26 | import com.google.privacy.dlp.v2.DeidentifyConfig; |
27 | 27 | import com.google.privacy.dlp.v2.DeidentifyContentRequest; |
28 | 28 | import com.google.privacy.dlp.v2.DeidentifyContentResponse; |
| 29 | +import com.google.privacy.dlp.v2.ExclusionRule; |
29 | 30 | import com.google.privacy.dlp.v2.InfoType; |
30 | 31 | import com.google.privacy.dlp.v2.InfoTypeTransformations; |
31 | 32 | import com.google.privacy.dlp.v2.InfoTypeTransformations.InfoTypeTransformation; |
32 | 33 | import com.google.privacy.dlp.v2.InspectConfig; |
| 34 | +import com.google.privacy.dlp.v2.InspectionRule; |
| 35 | +import com.google.privacy.dlp.v2.InspectionRuleSet; |
33 | 36 | import com.google.privacy.dlp.v2.LocationName; |
| 37 | +import com.google.privacy.dlp.v2.MatchingType; |
34 | 38 | import com.google.privacy.dlp.v2.PrimitiveTransformation; |
35 | 39 | import com.google.privacy.dlp.v2.ReplaceWithInfoTypeConfig; |
36 | 40 | import java.io.IOException; |
@@ -69,12 +73,31 @@ public static void deIdentifyWithExceptionList(String projectId, String textToDe |
69 | 73 | CustomInfoType customInfoType = |
70 | 74 | CustomInfoType.newBuilder().setInfoType(developerEmail).setDictionary(wordList).build(); |
71 | 75 |
|
| 76 | + ExclusionRule exclusionRule = |
| 77 | + ExclusionRule.newBuilder() |
| 78 | + .setDictionary(wordList) |
| 79 | + .setMatchingType(MatchingType.MATCHING_TYPE_FULL_MATCH) |
| 80 | + .build(); |
| 81 | + |
| 82 | + InspectionRule inspectionRule = |
| 83 | + InspectionRule.newBuilder() |
| 84 | + .setExclusionRule(exclusionRule) |
| 85 | + .build(); |
| 86 | + |
72 | 87 | // Specify the word list custom info type and build-in info type the inspection will look for. |
73 | 88 | InfoType emailAddress = InfoType.newBuilder().setName("EMAIL_ADDRESS").build(); |
| 89 | + |
| 90 | + InspectionRuleSet inspectionRuleSet = |
| 91 | + InspectionRuleSet.newBuilder() |
| 92 | + .addInfoTypes(emailAddress) |
| 93 | + .addRules(inspectionRule) |
| 94 | + .build(); |
| 95 | + |
74 | 96 | InspectConfig inspectConfig = |
75 | 97 | InspectConfig.newBuilder() |
76 | 98 | .addInfoTypes(emailAddress) |
77 | 99 | .addCustomInfoTypes(customInfoType) |
| 100 | + .addRuleSet(inspectionRuleSet) |
78 | 101 | .build(); |
79 | 102 |
|
80 | 103 | // Define type of deidentification as replacement. |
|
0 commit comments