Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 3 additions & 104 deletions README.md

Large diffs are not rendered by default.

60 changes: 1 addition & 59 deletions samples/snippets/README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1 @@
# Cloud Data Loss Prevention (DLP) API Samples

<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-dlp&page=editor&open_in_editor=samples/snippets/README.md">
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>

The [Data Loss Prevention API](https://cloud.google.com/dlp/docs/) provides programmatic access to
a powerful detection engine for personally identifiable information and other privacy-sensitive data
in unstructured data streams.

## Setup
- A Google Cloud project with billing enabled
- [Enable](https://console.cloud.google.com/launcher/details/google/dlp.googleapis.com) the DLP API.
- [Create a service account](https://cloud.google.com/docs/authentication/getting-started)
and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable pointing to the downloaded credentials file.

## Running

To run a specific sample, edit any variables under the `TODO(developer):` in the
function at the top of each sample, and then execute the function as convenient.

For example, if using the command line you might use the following (replacing
`<CLASS_NAME>` with the name of the sample):
```bash
mvn exec:java -Dexec.mainClass="dlp.snippets.<CLASS_NAME>"
```


## Testing

### Setup
- Ensure that `GOOGLE_APPLICATION_CREDENTIALS` points to authorized service account credentials file.
- Set the `DLP_DEID_WRAPPED_KEY` environment variable to an AES-256 key encrypted ('wrapped') [with a Cloud Key Management Service (KMS) key](https://cloud.google.com/kms/docs/encrypt-decrypt).
- Set the `DLP_DEID_KEY_NAME` environment variable to the path-name of the Cloud KMS key you wrapped `DLP_DEID_WRAPPED_KEY` with.
- [Create a Google Cloud Storage bucket](https://console.cloud.google.com/storage) and upload [test.txt](src/test/resources/test.txt).
- Set the `GCS_PATH` environment variable to point to the path for the bucket.
- Copy and paste the data below into a CSV file and [create a BigQuery table](https://cloud.google.com/bigquery/docs/loading-data-local) from the file:
```$xslt
Name,TelephoneNumber,Mystery,Age,Gender
James,(567) 890-1234,8291 3627 8250 1234,19,Male
Gandalf,(223) 456-7890,4231 5555 6781 9876,27,Male
Dumbledore,(313) 337-1337,6291 8765 1095 7629,27,Male
Joe,(452) 223-1234,3782 2288 1166 3030,35,Male
Marie,(452) 223-1234,8291 3627 8250 1234,35,Female
Carrie,(567) 890-1234,2253 5218 4251 4526,35,Female
```
- Set the `BIGQUERY_DATASET` and `BIGQUERY_TABLE` environment values.
- [Create a Google Cloud Pub/Sub](https://console.cloud.google.com/datastore) topic and and a subscription that is subscribed to the topic.
- Set the `PUB_SUB_TOPIC` and `PUB_SUB_SUBSCRIPTION` environment variables to the corresponding values.
- [Create a Google Cloud Datastore](https://console.cloud.google.com/datastore) kind and add an entity with properties:
- `property1` : john@doe.com
- `property2` : 343-343-3435
- Update the Datastore kind in [InspectTests.java](src/test/java/dlp/snippets/InspectTests.java).


### Run
Run all tests:
```
mvn clean verify
```
The samples have been moved to [GoogleCloudPlatform/java-docs-samples](https://github.com/GoogleCloudPlatform/java-docs-samples) in PR: https://github.com/GoogleCloudPlatform/java-docs-samples/pull/7664
28 changes: 5 additions & 23 deletions samples/snippets/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>dlp-snippets</artifactId>
<artifactId>-snippets</artifactId>
<packaging>jar</packaging>
<name>Google Cloud Data Loss Prevention Snippets</name>
<url>https://github.com/googleapis/java-dlp</url>

<!--
The parent pom defines common style checks and testing strategies for our samples.
Removing or replacing it should not affect the execution of the samples in anyway.
Removing or replacing it should not affect the execution of the samples in any way.
-->
<parent>
<groupId>com.google.cloud.samples</groupId>
Expand All @@ -23,30 +23,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<!-- [START dlp_install_with_bom] -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>26.1.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<!-- TODO: switch to libraries-bom after this artifact is included -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dlp</artifactId>
<version>3.15.0</version>
</dependency>
<!-- [START_EXCLUDE] -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -59,7 +43,5 @@
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<!-- [END_EXCLUDE] -->
</dependencies>
<!-- [END dlp_install_with_bom] -->
</project>

This file was deleted.

Loading