Skip to content

Commit 8a3b6c5

Browse files
authored
refresh dlp client (#2522)
* refresh dlp client * refresh with latest dlp_gapic.yaml
1 parent 852f8f9 commit 8a3b6c5

9 files changed

Lines changed: 526 additions & 50 deletions

File tree

google-cloud-dlp/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
<artifactId>grpc-google-cloud-dlp-v2beta1</artifactId>
7575
<scope>test</scope>
7676
</dependency>
77+
<dependency>
78+
<groupId>commons-lang</groupId>
79+
<artifactId>commons-lang</artifactId>
80+
<version>2.6</version>
81+
<scope>test</scope>
82+
</dependency>
7783
</dependencies>
7884
<profiles>
7985
<profile>

google-cloud-dlp/src/main/java/com/google/cloud/dlp/v2beta1/DlpServiceClient.java

Lines changed: 217 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
import com.google.cloud.dlp.v2beta1.stub.DlpServiceStub;
2424
import com.google.longrunning.Operation;
2525
import com.google.longrunning.OperationsClient;
26+
import com.google.privacy.dlp.v2beta1.AnalyzeDataSourceRiskRequest;
27+
import com.google.privacy.dlp.v2beta1.BigQueryTable;
2628
import com.google.privacy.dlp.v2beta1.ContentItem;
2729
import com.google.privacy.dlp.v2beta1.CreateInspectOperationRequest;
30+
import com.google.privacy.dlp.v2beta1.DeidentifyConfig;
31+
import com.google.privacy.dlp.v2beta1.DeidentifyContentRequest;
32+
import com.google.privacy.dlp.v2beta1.DeidentifyContentResponse;
2833
import com.google.privacy.dlp.v2beta1.InspectConfig;
2934
import com.google.privacy.dlp.v2beta1.InspectContentRequest;
3035
import com.google.privacy.dlp.v2beta1.InspectContentResponse;
@@ -37,10 +42,13 @@
3742
import com.google.privacy.dlp.v2beta1.ListRootCategoriesRequest;
3843
import com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse;
3944
import com.google.privacy.dlp.v2beta1.OutputStorageConfig;
45+
import com.google.privacy.dlp.v2beta1.PrivacyMetric;
4046
import com.google.privacy.dlp.v2beta1.RedactContentRequest;
4147
import com.google.privacy.dlp.v2beta1.RedactContentRequest.ReplaceConfig;
4248
import com.google.privacy.dlp.v2beta1.RedactContentResponse;
4349
import com.google.privacy.dlp.v2beta1.ResultName;
50+
import com.google.privacy.dlp.v2beta1.RiskAnalysisOperationMetadata;
51+
import com.google.privacy.dlp.v2beta1.RiskAnalysisOperationResult;
4452
import com.google.privacy.dlp.v2beta1.StorageConfig;
4553
import java.io.IOException;
4654
import java.util.List;
@@ -60,22 +68,10 @@
6068
* <pre>
6169
* <code>
6270
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
63-
* String name = "EMAIL_ADDRESS";
64-
* InfoType infoTypesElement = InfoType.newBuilder()
65-
* .setName(name)
66-
* .build();
67-
* List&lt;InfoType&gt; infoTypes = Arrays.asList(infoTypesElement);
68-
* InspectConfig inspectConfig = InspectConfig.newBuilder()
69-
* .addAllInfoTypes(infoTypes)
70-
* .build();
71-
* String type = "text/plain";
72-
* String value = "My email is example{@literal @}example.com.";
73-
* ContentItem itemsElement = ContentItem.newBuilder()
74-
* .setType(type)
75-
* .setValue(value)
76-
* .build();
77-
* List&lt;ContentItem&gt; items = Arrays.asList(itemsElement);
78-
* InspectContentResponse response = dlpServiceClient.inspectContent(inspectConfig, items);
71+
* DeidentifyConfig deidentifyConfig = DeidentifyConfig.newBuilder().build();
72+
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
73+
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
74+
* DeidentifyContentResponse response = dlpServiceClient.deidentifyContent(deidentifyConfig, inspectConfig, items);
7975
* }
8076
* </code>
8177
* </pre>
@@ -197,6 +193,209 @@ public final OperationsClient getOperationsClient() {
197193
return operationsClient;
198194
}
199195

196+
// AUTO-GENERATED DOCUMENTATION AND METHOD
197+
/**
198+
* De-identifies potentially sensitive info from a list of strings. This method has limits on
199+
* input size and output size.
200+
*
201+
* <p>Sample code:
202+
*
203+
* <pre><code>
204+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
205+
* DeidentifyConfig deidentifyConfig = DeidentifyConfig.newBuilder().build();
206+
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
207+
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
208+
* DeidentifyContentResponse response = dlpServiceClient.deidentifyContent(deidentifyConfig, inspectConfig, items);
209+
* }
210+
* </code></pre>
211+
*
212+
* @param deidentifyConfig Configuration for the de-identification of the list of content items.
213+
* @param inspectConfig Configuration for the inspector.
214+
* @param items The list of items to inspect. Up to 100 are allowed per request. All items will be
215+
* treated as text/&#42;.
216+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
217+
*/
218+
public final DeidentifyContentResponse deidentifyContent(
219+
DeidentifyConfig deidentifyConfig, InspectConfig inspectConfig, List<ContentItem> items) {
220+
221+
DeidentifyContentRequest request =
222+
DeidentifyContentRequest.newBuilder()
223+
.setDeidentifyConfig(deidentifyConfig)
224+
.setInspectConfig(inspectConfig)
225+
.addAllItems(items)
226+
.build();
227+
return deidentifyContent(request);
228+
}
229+
230+
// AUTO-GENERATED DOCUMENTATION AND METHOD
231+
/**
232+
* De-identifies potentially sensitive info from a list of strings. This method has limits on
233+
* input size and output size.
234+
*
235+
* <p>Sample code:
236+
*
237+
* <pre><code>
238+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
239+
* DeidentifyConfig deidentifyConfig = DeidentifyConfig.newBuilder().build();
240+
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
241+
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
242+
* DeidentifyContentRequest request = DeidentifyContentRequest.newBuilder()
243+
* .setDeidentifyConfig(deidentifyConfig)
244+
* .setInspectConfig(inspectConfig)
245+
* .addAllItems(items)
246+
* .build();
247+
* DeidentifyContentResponse response = dlpServiceClient.deidentifyContent(request);
248+
* }
249+
* </code></pre>
250+
*
251+
* @param request The request object containing all of the parameters for the API call.
252+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
253+
*/
254+
public final DeidentifyContentResponse deidentifyContent(DeidentifyContentRequest request) {
255+
return deidentifyContentCallable().call(request);
256+
}
257+
258+
// AUTO-GENERATED DOCUMENTATION AND METHOD
259+
/**
260+
* De-identifies potentially sensitive info from a list of strings. This method has limits on
261+
* input size and output size.
262+
*
263+
* <p>Sample code:
264+
*
265+
* <pre><code>
266+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
267+
* DeidentifyConfig deidentifyConfig = DeidentifyConfig.newBuilder().build();
268+
* InspectConfig inspectConfig = InspectConfig.newBuilder().build();
269+
* List&lt;ContentItem&gt; items = new ArrayList&lt;&gt;();
270+
* DeidentifyContentRequest request = DeidentifyContentRequest.newBuilder()
271+
* .setDeidentifyConfig(deidentifyConfig)
272+
* .setInspectConfig(inspectConfig)
273+
* .addAllItems(items)
274+
* .build();
275+
* ApiFuture&lt;DeidentifyContentResponse&gt; future = dlpServiceClient.deidentifyContentCallable().futureCall(request);
276+
* // Do something
277+
* DeidentifyContentResponse response = future.get();
278+
* }
279+
* </code></pre>
280+
*/
281+
public final UnaryCallable<DeidentifyContentRequest, DeidentifyContentResponse>
282+
deidentifyContentCallable() {
283+
return stub.deidentifyContentCallable();
284+
}
285+
286+
// AUTO-GENERATED DOCUMENTATION AND METHOD
287+
/**
288+
* Schedules a job to compute risk analysis metrics over content in a Google Cloud Platform
289+
* repository.
290+
*
291+
* <p>Sample code:
292+
*
293+
* <pre><code>
294+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
295+
* PrivacyMetric privacyMetric = PrivacyMetric.newBuilder().build();
296+
* BigQueryTable sourceTable = BigQueryTable.newBuilder().build();
297+
* RiskAnalysisOperationResult response = dlpServiceClient.analyzeDataSourceRiskAsync(privacyMetric, sourceTable).get();
298+
* }
299+
* </code></pre>
300+
*
301+
* @param privacyMetric Privacy metric to compute.
302+
* @param sourceTable Input dataset to compute metrics over.
303+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
304+
*/
305+
public final OperationFuture<
306+
RiskAnalysisOperationResult, RiskAnalysisOperationMetadata, Operation>
307+
analyzeDataSourceRiskAsync(PrivacyMetric privacyMetric, BigQueryTable sourceTable) {
308+
309+
AnalyzeDataSourceRiskRequest request =
310+
AnalyzeDataSourceRiskRequest.newBuilder()
311+
.setPrivacyMetric(privacyMetric)
312+
.setSourceTable(sourceTable)
313+
.build();
314+
return analyzeDataSourceRiskAsync(request);
315+
}
316+
317+
// AUTO-GENERATED DOCUMENTATION AND METHOD
318+
/**
319+
* Schedules a job to compute risk analysis metrics over content in a Google Cloud Platform
320+
* repository.
321+
*
322+
* <p>Sample code:
323+
*
324+
* <pre><code>
325+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
326+
* PrivacyMetric privacyMetric = PrivacyMetric.newBuilder().build();
327+
* BigQueryTable sourceTable = BigQueryTable.newBuilder().build();
328+
* AnalyzeDataSourceRiskRequest request = AnalyzeDataSourceRiskRequest.newBuilder()
329+
* .setPrivacyMetric(privacyMetric)
330+
* .setSourceTable(sourceTable)
331+
* .build();
332+
* RiskAnalysisOperationResult response = dlpServiceClient.analyzeDataSourceRiskAsync(request).get();
333+
* }
334+
* </code></pre>
335+
*
336+
* @param request The request object containing all of the parameters for the API call.
337+
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
338+
*/
339+
public final OperationFuture<
340+
RiskAnalysisOperationResult, RiskAnalysisOperationMetadata, Operation>
341+
analyzeDataSourceRiskAsync(AnalyzeDataSourceRiskRequest request) {
342+
return analyzeDataSourceRiskOperationCallable().futureCall(request);
343+
}
344+
345+
// AUTO-GENERATED DOCUMENTATION AND METHOD
346+
/**
347+
* Schedules a job to compute risk analysis metrics over content in a Google Cloud Platform
348+
* repository.
349+
*
350+
* <p>Sample code:
351+
*
352+
* <pre><code>
353+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
354+
* PrivacyMetric privacyMetric = PrivacyMetric.newBuilder().build();
355+
* BigQueryTable sourceTable = BigQueryTable.newBuilder().build();
356+
* AnalyzeDataSourceRiskRequest request = AnalyzeDataSourceRiskRequest.newBuilder()
357+
* .setPrivacyMetric(privacyMetric)
358+
* .setSourceTable(sourceTable)
359+
* .build();
360+
* OperationFuture&lt;Operation&gt; future = dlpServiceClient.analyzeDataSourceRiskOperationCallable().futureCall(request);
361+
* // Do something
362+
* RiskAnalysisOperationResult response = future.get();
363+
* }
364+
* </code></pre>
365+
*/
366+
public final OperationCallable<
367+
AnalyzeDataSourceRiskRequest, RiskAnalysisOperationResult, RiskAnalysisOperationMetadata,
368+
Operation>
369+
analyzeDataSourceRiskOperationCallable() {
370+
return stub.analyzeDataSourceRiskOperationCallable();
371+
}
372+
373+
// AUTO-GENERATED DOCUMENTATION AND METHOD
374+
/**
375+
* Schedules a job to compute risk analysis metrics over content in a Google Cloud Platform
376+
* repository.
377+
*
378+
* <p>Sample code:
379+
*
380+
* <pre><code>
381+
* try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) {
382+
* PrivacyMetric privacyMetric = PrivacyMetric.newBuilder().build();
383+
* BigQueryTable sourceTable = BigQueryTable.newBuilder().build();
384+
* AnalyzeDataSourceRiskRequest request = AnalyzeDataSourceRiskRequest.newBuilder()
385+
* .setPrivacyMetric(privacyMetric)
386+
* .setSourceTable(sourceTable)
387+
* .build();
388+
* ApiFuture&lt;Operation&gt; future = dlpServiceClient.analyzeDataSourceRiskCallable().futureCall(request);
389+
* // Do something
390+
* Operation response = future.get();
391+
* }
392+
* </code></pre>
393+
*/
394+
public final UnaryCallable<AnalyzeDataSourceRiskRequest, Operation>
395+
analyzeDataSourceRiskCallable() {
396+
return stub.analyzeDataSourceRiskCallable();
397+
}
398+
200399
// AUTO-GENERATED DOCUMENTATION AND METHOD
201400
/**
202401
* Finds potentially sensitive info in a list of strings. This method has limits on input size,
@@ -509,19 +708,7 @@ public final UnaryCallable<RedactContentRequest, RedactContentResponse> redactCo
509708
*
510709
* @param inspectConfig Configuration for the inspector.
511710
* @param storageConfig Specification of the data set to process.
512-
* @param outputConfig Optional location to store findings. The bucket must already exist and the
513-
* Google APIs service account for DLP must have write permission to write to the given
514-
* bucket. &lt;p&gt;Results are split over multiple csv files with each file name matching the
515-
* pattern "[operation_id]_[count].csv", for example `3094877188788974909_1.csv`. The
516-
* `operation_id` matches the identifier for the Operation, and the `count` is a counter used
517-
* for tracking the number of files written. &lt;p&gt;The CSV file(s) contain the following
518-
* columns regardless of storage type scanned: &lt;li&gt;id &lt;li&gt;info_type
519-
* &lt;li&gt;likelihood &lt;li&gt;byte size of finding &lt;li&gt;quote
520-
* &lt;li&gt;timestamp&lt;br/&gt; &lt;p&gt;For Cloud Storage the next columns are:
521-
* &lt;li&gt;file_path &lt;li&gt;start_offset&lt;br/&gt; &lt;p&gt;For Cloud Datastore the next
522-
* columns are: &lt;li&gt;project_id &lt;li&gt;namespace_id &lt;li&gt;path
523-
* &lt;li&gt;column_name &lt;li&gt;offset&lt;br/&gt; &lt;p&gt;For BigQuery the next columns
524-
* are: &lt;li&gt;row_number &lt;li&gt;project_id &lt;li&gt;dataset_id &lt;li&gt;table_id
711+
* @param outputConfig Optional location to store findings.
525712
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
526713
*/
527714
public final OperationFuture<InspectOperationResult, InspectOperationMetadata, Operation>
@@ -685,8 +872,7 @@ public final UnaryCallable<RedactContentRequest, RedactContentResponse> redactCo
685872
* </code></pre>
686873
*
687874
* @param name Identifier of the results set returned as metadata of the longrunning operation
688-
* created by a call to CreateInspectOperation. Should be in the format of
689-
* `inspect/results/{id}`.
875+
* created by a call to InspectDataSource. Should be in the format of `inspect/results/{id}`.
690876
* @throws com.google.api.gax.rpc.ApiException if the remote call fails
691877
*/
692878
public final ListInspectFindingsResponse listInspectFindings(ResultName name) {

0 commit comments

Comments
 (0)