Skip to content

Commit 8378c67

Browse files
authored
Clean up some ProjectName uses in DLP (GoogleCloudPlatform#3166)
Clean up some samples that got added with the old way of setting the parent field. See internal bug b/158100365 for context. - [X] I have followed [Sample Format Guide](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/SAMPLE_FORMAT.md) - [X] `pom.xml` parent set to latest `shared-configuration` - [X] Appropriate changes to README are included in PR - [X] API's need to be enabled to test (tell us) - [X] Environment Variables need to be set (ask us to set them) - [X] **Tests** pass: `mvn clean verify` **required** - [X] **Lint** passes: `mvn -P lint checkstyle:check` **required** - [X] **Static Analysis**: `mvn -P lint clean compile pmd:cpd-check spotbugs:check` **advisory only** - [X] Please **merge** this PR for me once it is approved.
1 parent cd51cbc commit 8378c67

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

dlp/src/main/java/dlp/snippets/DeIdentifyWithExceptionList.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import com.google.privacy.dlp.v2.InfoTypeTransformations;
3131
import com.google.privacy.dlp.v2.InfoTypeTransformations.InfoTypeTransformation;
3232
import com.google.privacy.dlp.v2.InspectConfig;
33+
import com.google.privacy.dlp.v2.LocationName;
3334
import com.google.privacy.dlp.v2.PrimitiveTransformation;
34-
import com.google.privacy.dlp.v2.ProjectName;
3535
import com.google.privacy.dlp.v2.ReplaceWithInfoTypeConfig;
3636
import java.io.IOException;
3737

@@ -100,7 +100,7 @@ public static void deIdentifyWithExceptionList(String projectId, String textToDe
100100
// Combine configurations into a request for the service.
101101
DeidentifyContentRequest request =
102102
DeidentifyContentRequest.newBuilder()
103-
.setParent(ProjectName.of(projectId).toString())
103+
.setParent(LocationName.of(projectId, "global").toString())
104104
.setItem(contentItem)
105105
.setInspectConfig(inspectConfig)
106106
.setDeidentifyConfig(deidentifyConfig)

dlp/src/main/java/dlp/snippets/DeIdentifyWithSimpleWordList.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
import com.google.privacy.dlp.v2.InfoTypeTransformations;
3131
import com.google.privacy.dlp.v2.InfoTypeTransformations.InfoTypeTransformation;
3232
import com.google.privacy.dlp.v2.InspectConfig;
33+
import com.google.privacy.dlp.v2.LocationName;
3334
import com.google.privacy.dlp.v2.PrimitiveTransformation;
34-
import com.google.privacy.dlp.v2.ProjectName;
3535
import com.google.privacy.dlp.v2.ReplaceWithInfoTypeConfig;
3636
import java.io.IOException;
3737

@@ -95,7 +95,7 @@ public static void deidentifyWithSimpleWordList(String projectId, String textToD
9595
// Combine configurations into a request for the service.
9696
DeidentifyContentRequest request =
9797
DeidentifyContentRequest.newBuilder()
98-
.setParent(ProjectName.of(projectId).toString())
98+
.setParent(LocationName.of(projectId, "global").toString())
9999
.setItem(contentItem)
100100
.setInspectConfig(inspectConfig)
101101
.setDeidentifyConfig(deidentifyConfig)

dlp/src/main/java/dlp/snippets/InspectWithCustomRegex.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import com.google.privacy.dlp.v2.InspectContentRequest;
3131
import com.google.privacy.dlp.v2.InspectContentResponse;
3232
import com.google.privacy.dlp.v2.Likelihood;
33-
import com.google.privacy.dlp.v2.ProjectName;
33+
import com.google.privacy.dlp.v2.LocationName;
3434
import com.google.protobuf.ByteString;
3535
import java.io.IOException;
3636

@@ -51,9 +51,6 @@ public static void inspectWithCustomRegex(
5151
// once, and can be reused for multiple requests. After completing all of your requests, call
5252
// the "close" method on the client to safely clean up any remaining background resources.
5353
try (DlpServiceClient dlp = DlpServiceClient.create()) {
54-
// Specify the project used for request.
55-
ProjectName project = ProjectName.of(projectId);
56-
5754
// Specify the type and content to be inspected.
5855
ByteContentItem byteItem =
5956
ByteContentItem.newBuilder()
@@ -84,8 +81,7 @@ public static void inspectWithCustomRegex(
8481
// Construct the Inspect request to be sent by the client.
8582
InspectContentRequest request =
8683
InspectContentRequest.newBuilder()
87-
.setParent(project.toString())
88-
.setItem(item)
84+
.setParent(LocationName.of(projectId, "global").toString()).setItem(item)
8985
.setInspectConfig(config)
9086
.build();
9187

dlp/src/main/java/dlp/snippets/InspectWithHotwordRules.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import com.google.privacy.dlp.v2.InspectionRule;
3636
import com.google.privacy.dlp.v2.InspectionRuleSet;
3737
import com.google.privacy.dlp.v2.Likelihood;
38-
import com.google.privacy.dlp.v2.ProjectName;
38+
import com.google.privacy.dlp.v2.LocationName;
3939
import com.google.protobuf.ByteString;
4040
import java.io.IOException;
4141

@@ -58,9 +58,6 @@ public static void inspectWithHotwordRules(
5858
// once, and can be reused for multiple requests. After completing all of your requests, call
5959
// the "close" method on the client to safely clean up any remaining background resources.
6060
try (DlpServiceClient dlp = DlpServiceClient.create()) {
61-
// Specify the project used for request.
62-
ProjectName project = ProjectName.of(projectId);
63-
6461
// Specify the type and content to be inspected.
6562
ByteContentItem byteItem =
6663
ByteContentItem.newBuilder()
@@ -111,7 +108,7 @@ public static void inspectWithHotwordRules(
111108
// Construct the Inspect request to be sent by the client.
112109
InspectContentRequest request =
113110
InspectContentRequest.newBuilder()
114-
.setParent(project.toString())
111+
.setParent(LocationName.of(projectId, "global").toString())
115112
.setItem(item)
116113
.setInspectConfig(config)
117114
.build();

0 commit comments

Comments
 (0)