|
23 | 23 | import com.google.cloud.dlp.v2beta1.stub.DlpServiceStub; |
24 | 24 | import com.google.longrunning.Operation; |
25 | 25 | import com.google.longrunning.OperationsClient; |
| 26 | +import com.google.privacy.dlp.v2beta1.AnalyzeDataSourceRiskRequest; |
| 27 | +import com.google.privacy.dlp.v2beta1.BigQueryTable; |
26 | 28 | import com.google.privacy.dlp.v2beta1.ContentItem; |
27 | 29 | 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; |
28 | 33 | import com.google.privacy.dlp.v2beta1.InspectConfig; |
29 | 34 | import com.google.privacy.dlp.v2beta1.InspectContentRequest; |
30 | 35 | import com.google.privacy.dlp.v2beta1.InspectContentResponse; |
|
37 | 42 | import com.google.privacy.dlp.v2beta1.ListRootCategoriesRequest; |
38 | 43 | import com.google.privacy.dlp.v2beta1.ListRootCategoriesResponse; |
39 | 44 | import com.google.privacy.dlp.v2beta1.OutputStorageConfig; |
| 45 | +import com.google.privacy.dlp.v2beta1.PrivacyMetric; |
40 | 46 | import com.google.privacy.dlp.v2beta1.RedactContentRequest; |
41 | 47 | import com.google.privacy.dlp.v2beta1.RedactContentRequest.ReplaceConfig; |
42 | 48 | import com.google.privacy.dlp.v2beta1.RedactContentResponse; |
43 | 49 | import com.google.privacy.dlp.v2beta1.ResultName; |
| 50 | +import com.google.privacy.dlp.v2beta1.RiskAnalysisOperationMetadata; |
| 51 | +import com.google.privacy.dlp.v2beta1.RiskAnalysisOperationResult; |
44 | 52 | import com.google.privacy.dlp.v2beta1.StorageConfig; |
45 | 53 | import java.io.IOException; |
46 | 54 | import java.util.List; |
|
60 | 68 | * <pre> |
61 | 69 | * <code> |
62 | 70 | * try (DlpServiceClient dlpServiceClient = DlpServiceClient.create()) { |
63 | | - * String name = "EMAIL_ADDRESS"; |
64 | | - * InfoType infoTypesElement = InfoType.newBuilder() |
65 | | - * .setName(name) |
66 | | - * .build(); |
67 | | - * List<InfoType> 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<ContentItem> 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<ContentItem> items = new ArrayList<>(); |
| 74 | + * DeidentifyContentResponse response = dlpServiceClient.deidentifyContent(deidentifyConfig, inspectConfig, items); |
79 | 75 | * } |
80 | 76 | * </code> |
81 | 77 | * </pre> |
@@ -197,6 +193,209 @@ public final OperationsClient getOperationsClient() { |
197 | 193 | return operationsClient; |
198 | 194 | } |
199 | 195 |
|
| 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<ContentItem> items = new ArrayList<>(); |
| 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/*. |
| 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<ContentItem> items = new ArrayList<>(); |
| 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<ContentItem> items = new ArrayList<>(); |
| 270 | + * DeidentifyContentRequest request = DeidentifyContentRequest.newBuilder() |
| 271 | + * .setDeidentifyConfig(deidentifyConfig) |
| 272 | + * .setInspectConfig(inspectConfig) |
| 273 | + * .addAllItems(items) |
| 274 | + * .build(); |
| 275 | + * ApiFuture<DeidentifyContentResponse> 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<Operation> 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<Operation> 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 | + |
200 | 399 | // AUTO-GENERATED DOCUMENTATION AND METHOD |
201 | 400 | /** |
202 | 401 | * 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 |
509 | 708 | * |
510 | 709 | * @param inspectConfig Configuration for the inspector. |
511 | 710 | * @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. <p>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. <p>The CSV file(s) contain the following |
518 | | - * columns regardless of storage type scanned: <li>id <li>info_type |
519 | | - * <li>likelihood <li>byte size of finding <li>quote |
520 | | - * <li>timestamp<br/> <p>For Cloud Storage the next columns are: |
521 | | - * <li>file_path <li>start_offset<br/> <p>For Cloud Datastore the next |
522 | | - * columns are: <li>project_id <li>namespace_id <li>path |
523 | | - * <li>column_name <li>offset<br/> <p>For BigQuery the next columns |
524 | | - * are: <li>row_number <li>project_id <li>dataset_id <li>table_id |
| 711 | + * @param outputConfig Optional location to store findings. |
525 | 712 | * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
526 | 713 | */ |
527 | 714 | public final OperationFuture<InspectOperationResult, InspectOperationMetadata, Operation> |
@@ -685,8 +872,7 @@ public final UnaryCallable<RedactContentRequest, RedactContentResponse> redactCo |
685 | 872 | * </code></pre> |
686 | 873 | * |
687 | 874 | * @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}`. |
690 | 876 | * @throws com.google.api.gax.rpc.ApiException if the remote call fails |
691 | 877 | */ |
692 | 878 | public final ListInspectFindingsResponse listInspectFindings(ResultName name) { |
|
0 commit comments