Skip to content

Commit 2448dd0

Browse files
author
Takashi Matsuo
committed
[dlp] opt in using BUILD_SPECIFIC_GCLOUD_PROJECT
1 parent 28a9cf1 commit 2448dd0

File tree

4 files changed

+69
-17
lines changed

4 files changed

+69
-17
lines changed

dlp/README.rst

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ This directory contains samples for Google Data Loss Prevention. `Google Data Lo
1414

1515
.. _Google Data Loss Prevention: https://cloud.google.com/dlp/docs/
1616

17+
To run the sample, you need to enable the API at: https://console.cloud.google.com/apis/library/dlp.googleapis.com
18+
19+
20+
To run the sample, you need to have the following roles:
21+
* `DLP Administrator`
22+
* `DLP API Service Agent`
23+
24+
25+
1726
Setup
1827
-------------------------------------------------------------------------------
1928

@@ -58,15 +67,6 @@ Install Dependencies
5867
.. _pip: https://pip.pypa.io/
5968
.. _virtualenv: https://virtualenv.pypa.io/
6069

61-
#. For running *_test.py files, install test dependencies
62-
63-
.. code-block:: bash
64-
65-
$ pip install -r requirements-test.txt
66-
$ pytest inspect_content_test.py
67-
68-
** *_test.py files are demo wrappers and make API calls. You may get rate limited for making high number of requests. **
69-
7070
Samples
7171
-------------------------------------------------------------------------------
7272

@@ -83,7 +83,7 @@ To run this sample:
8383

8484
.. code-block:: bash
8585
86-
$ python quickstart.py <project-id>
86+
$ python quickstart.py
8787
8888
8989
Inspect Content
@@ -101,15 +101,16 @@ To run this sample:
101101
102102
$ python inspect_content.py
103103
104-
usage: inspect_content.py [-h] {string,file,gcs,datastore,bigquery} ...
104+
usage: inspect_content.py [-h] {string,table,file,gcs,datastore,bigquery} ...
105105
106106
Sample app that uses the Data Loss Prevention API to inspect a string, a local
107107
file or a file on Google Cloud Storage.
108108
109109
positional arguments:
110-
{string,file,gcs,datastore,bigquery}
110+
{string,table,file,gcs,datastore,bigquery}
111111
Select how to submit content to the API.
112112
string Inspect a string.
113+
table Inspect a table.
113114
file Inspect a local file.
114115
gcs Inspect files on Google Cloud Storage.
115116
datastore Inspect files on Google Datastore.
@@ -135,13 +136,14 @@ To run this sample:
135136
136137
$ python redact.py
137138
138-
usage: redact.py [-h] [--project PROJECT] [--info_types INFO_TYPES]
139+
usage: redact.py [-h] [--project PROJECT]
140+
[--info_types INFO_TYPES [INFO_TYPES ...]]
139141
[--min_likelihood {LIKELIHOOD_UNSPECIFIED,VERY_UNLIKELY,UNLIKELY,POSSIBLE,LIKELY,VERY_LIKELY}]
140142
[--mime_type MIME_TYPE]
141143
filename output_filename
142144
143-
Sample app that uses the Data Loss Prevent API to redact the contents of a
144-
string or an image file.
145+
Sample app that uses the Data Loss Prevent API to redact the contents of an
146+
image file.
145147
146148
positional arguments:
147149
filename The path to the file to inspect.
@@ -151,7 +153,7 @@ To run this sample:
151153
-h, --help show this help message and exit
152154
--project PROJECT The Google Cloud project id to use as a parent
153155
resource.
154-
--info_types INFO_TYPES
156+
--info_types INFO_TYPES [INFO_TYPES ...]
155157
Strings representing info types to look for. A full
156158
list of info categories and types is available from
157159
the API. Examples include "FIRST_NAME", "LAST_NAME",

dlp/README.rst.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ product:
44
name: Google Data Loss Prevention
55
short_name: Data Loss Prevention
66
url: https://cloud.google.com/dlp/docs/
7-
description: >
7+
description: >
88
`Google Data Loss Prevention`_ provides programmatic access to a powerful
99
detection engine for personally identifiable information and other
1010
privacy-sensitive data in unstructured data streams.
@@ -13,6 +13,12 @@ setup:
1313
- auth
1414
- install_deps
1515

16+
required_api_url: https://console.cloud.google.com/apis/library/dlp.googleapis.com
17+
18+
required_roles:
19+
- DLP Administrator
20+
- DLP API Service Agent
21+
1622
samples:
1723
- name: Quickstart
1824
file: quickstart.py

dlp/noxfile_config.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Default TEST_CONFIG_OVERRIDE for python repos.
16+
17+
# You can copy this file into your directory, then it will be inported from
18+
# the noxfile.py.
19+
20+
# The source of truth:
21+
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/noxfile_config.py
22+
23+
TEST_CONFIG_OVERRIDE = {
24+
# You can opt out from the test for specific Python versions.
25+
'ignored_versions': ["2.7"],
26+
27+
# An envvar key for determining the project id to use. Change it
28+
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
29+
# build specific Cloud project. You can also use your own string
30+
# to use your own Cloud project.
31+
# 'gcloud_project_env': 'GCLOUD_PROJECT',
32+
'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
33+
34+
# A dictionary you want to inject into your test. Don't put any
35+
# secrets here. These values will override predefined values.
36+
'envs': {},
37+
}

scripts/readme-gen/templates/README.tmpl.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ To run the sample, you need to enable the API at: {{required_api_url}}
2323
To run the sample, you need to have `{{required_role}}` role.
2424
{% endif %}
2525

26+
{% if required_roles %}
27+
To run the sample, you need to have the following roles:
28+
{% for role in required_roles %}
29+
* `{{role}}`
30+
{% endfor %}
31+
{% endif %}
32+
2633
{{other_required_steps}}
2734

2835
{% if setup %}

0 commit comments

Comments
 (0)