Skip to content

Commit 01d6b18

Browse files
authored
Adds DLP samples (GoogleCloudPlatform#405)
1 parent 3054644 commit 01d6b18

17 files changed

+2847
-0
lines changed

dlp/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Google DLP PHP Sample Application
2+
3+
## Description
4+
5+
This simple command-line application demonstrates how to invoke Google
6+
DLP API from PHP.
7+
8+
## Build and Run
9+
1. **Enable APIs** - [Enable the DLP API](
10+
https://console.cloud.google.com/flows/enableapi?apiid=dlp.googleapis.com)
11+
and create a new project or select an existing project.
12+
2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click
13+
"New Credentials"
14+
and select "Service Account Key". Create a new service account, use the JSON key type, and
15+
select "Create". Once downloaded, set the environment variable `GOOGLE_APPLICATION_CREDENTIALS`
16+
to the path of the JSON key that was downloaded.
17+
3. **Clone the repo** and cd into this directory
18+
```
19+
$ git clone https://github.com/GoogleCloudPlatform/php-docs-samples
20+
$ cd php-docs-samples/dlp
21+
```
22+
4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md).
23+
Run `php composer.phar install` (if composer is installed locally) or `composer install`
24+
(if composer is installed globally).
25+
5. Run `php dlp.php`. The following commands are available:
26+
27+
```
28+
help Displays help for a command
29+
inspect-datastore Inspect Cloud Datastore using the Data Loss Prevention (DLP) API.
30+
inspect-file Inspect a file using the Data Loss Prevention (DLP) API.
31+
inspect-string Inspect a string using the Data Loss Prevention (DLP) API.
32+
list Lists commands
33+
list-categories Lists all Info Type Categories for the Data Loss Prevention (DLP) API.
34+
list-info-types Lists all Info Types for the Data Loss Prevention (DLP) API.
35+
redact-string Redact sensitive data from a string using the Data Loss Prevention (DLP) API.
36+
```
37+
38+
Example:
39+
40+
```
41+
$ php dlp.php inspect-string 'Robert Frost'
42+
Findings:
43+
Quote: Robert
44+
Info type: US_MALE_NAME
45+
Likelihood: Very likely
46+
```
47+
48+
49+
6. Run `php dlp.php COMMAND --help` to print information about the usage of each command.
50+
51+
## Contributing changes
52+
53+
* See [CONTRIBUTING.md](../../CONTRIBUTING.md)
54+
55+
## Licensing
56+
57+
* See [LICENSE](../../LICENSE)

dlp/composer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "google/dlp-sample",
3+
"type": "project",
4+
"require": {
5+
"google/cloud-dlp": "^0.1.0",
6+
"symfony/console": "^3.3"
7+
},
8+
"autoload": {
9+
"files": [
10+
"src/inspect_datastore.php",
11+
"src/inspect_file.php",
12+
"src/inspect_string.php",
13+
"src/list_categories.php",
14+
"src/list_info_types.php",
15+
"src/redact_string.php"
16+
]
17+
},
18+
"require-dev": {
19+
"phpunit/phpunit": "~4"
20+
}
21+
}

0 commit comments

Comments
 (0)