Skip to content

Commit 71b3663

Browse files
feat!: migrate to use microgen (googleapis#34)
* feat!: migrate to use microgen * Update UPGRADING.md Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
1 parent 69c4425 commit 71b3663

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+25787
-31039
lines changed

packages/google-cloud-dlp/.coveragerc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ branch = True
2121
[report]
2222
fail_under = 100
2323
show_missing = True
24+
omit = google/cloud/dlp/__init__.py
2425
exclude_lines =
2526
# Re-enable the standard pragma
2627
pragma: NO COVER
2728
# Ignore debug-only repr
2829
def __repr__
29-
# Ignore abstract methods
30-
raise NotImplementedError
31-
omit =
32-
*/gapic/*.py
33-
*/proto/*.py
34-
*/core/*.py
35-
*/site-packages/*.py
30+
# Ignore pkg_resources exceptions.
31+
# This is added at the module level as a safeguard for if someone
32+
# generates the code and tries to run it without pip installing. This
33+
# makes it virtually impossible to test properly.
34+
except pkg_resources.DistributionNotFound

packages/google-cloud-dlp/README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ dependencies.
5151

5252
Supported Python Versions
5353
^^^^^^^^^^^^^^^^^^^^^^^^^
54-
Python >= 3.5
54+
Python >= 3.6
5555

5656
Deprecated Python Versions
5757
^^^^^^^^^^^^^^^^^^^^^^^^^^
58-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
58+
Python == 2.7.
59+
60+
The last version of this library compatible with Python 2.7 is google-cloud-dlp==1.1.0.
5961

6062

6163
Mac/Linux
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-dlp` client is a significant upgrade based on a [next-gen code generator](https://github.com/googleapis/gapic-generator-python), and includes substantial interface changes. Existing code written for earlier versions of this library will likely require updates to use this version. This document describes the changes that have been made, and what you need to do to update your usage.
4+
5+
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-dlp/issues).
6+
7+
## Supported Python Versions
8+
9+
> **WARNING**: Breaking change
10+
11+
The 2.0.0 release requires Python 3.6+.
12+
13+
14+
## Method Calls
15+
16+
> **WARNING**: Breaking change
17+
18+
Methods expect request objects. We provide a script that will convert most common use cases.
19+
20+
* Install the library
21+
22+
```py
23+
python3 -m pip install google-cloud-dlp
24+
```
25+
26+
* The script `fixup_dlp_v2_keywords.py` is shipped with the library. It expects
27+
an input directory (with the code to convert) and an empty destination directory.
28+
29+
```sh
30+
$ fixup_dlp_v2_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import dlp
36+
37+
client = dlp.DlpServiceClient()
38+
39+
template = client.get_inspect_template(name="name")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud import dlp
46+
47+
client = dlp.DlpServiceClient()
48+
49+
template = client.get_inspect_template(request={"name": "name"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-dlp<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
55+
56+
**Before:**
57+
```py
58+
def create_inspect_template(
59+
self,
60+
parent,
61+
inspect_template,
62+
template_id=None,
63+
location_id=None,
64+
retry=google.api_core.gapic_v1.method.DEFAULT,
65+
timeout=google.api_core.gapic_v1.method.DEFAULT,
66+
metadata=None,
67+
):
68+
```
69+
70+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
71+
72+
Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer.
73+
74+
75+
**After:**
76+
```py
77+
def create_inspect_template(
78+
self,
79+
request: dlp.CreateInspectTemplateRequest = None,
80+
*,
81+
parent: str = None,
82+
inspect_template: dlp.InspectTemplate = None,
83+
retry: retries.Retry = gapic_v1.method.DEFAULT,
84+
timeout: float = None,
85+
metadata: Sequence[Tuple[str, str]] = (),
86+
) -> dlp.InspectTemplate:
87+
```
88+
89+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
90+
> Passing both will result in an error.
91+
92+
93+
Both of these calls are valid:
94+
95+
```py
96+
response = client.create_inspect_template(
97+
request={
98+
"parent": parent,
99+
"inspect_template": inspect_template,
100+
}
101+
)
102+
```
103+
104+
```py
105+
response = client.create_inspect_template(
106+
parent=parent,
107+
inspect_template=inspect_template,
108+
)
109+
```
110+
111+
This call is invalid because it mixes `request` with a keyword argument `inspect_template`. Executing this code will result in an error.
112+
113+
```py
114+
response = client.list_builds(
115+
request={
116+
"parent": parent,
117+
},
118+
inspect_template=inspect_template
119+
)
120+
```
121+
122+
123+
124+
## Enums and Types
125+
126+
127+
> **WARNING**: Breaking change
128+
129+
The submodules `enums` and `types` have been removed.
130+
131+
**Before:**
132+
```py
133+
from google.cloud import dlp
134+
135+
file_type = dlp.enums.FileType.IMAGE
136+
finding = dlp.types.Finding(name="name")
137+
```
138+
139+
140+
**After:**
141+
```py
142+
from google.cloud import dlp
143+
144+
file_type = dlp.FileType.IMAGE
145+
finding = dlp.Finding(name="name")
146+
```
147+
148+
## Path Helper Methods
149+
150+
The following path helper methods have been removed. Please construct
151+
these paths manually.
152+
153+
```py
154+
project = 'my-project'
155+
dlp_job = 'dlp-job'
156+
location = 'location'
157+
158+
project_path = f'projects/{project}'
159+
dlp_job_path = f'projects/{project}/dlpJobs/{dlp_job}'
160+
location_path = f'projects/{project}/locations/{location}'
161+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Dlp v2 API
2+
====================================
3+
4+
.. automodule:: google.cloud.dlp_v2.services.dlp_service
5+
:members:
6+
:inherited-members:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Dlp v2 API
2+
=================================
3+
4+
.. automodule:: google.cloud.dlp_v2.types
5+
:members:

packages/google-cloud-dlp/docs/gapic/v2/api.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/google-cloud-dlp/docs/gapic/v2/types.rst

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/google-cloud-dlp/docs/index.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ Api Reference
77
.. toctree::
88
:maxdepth: 2
99

10-
gapic/v2/api
11-
gapic/v2/types
10+
dlp_v2/services
11+
dlp_v2/types
1212
changelog
1313

14+
Migration Guide
15+
---------------
16+
17+
See the guide below for instructions on migrating to the 2.x release of this library.
18+
19+
.. toctree::
20+
:maxdepth: 2
21+
22+
UPGRADING
23+
1424
Changelog
1525
---------
1626

packages/google-cloud-dlp/google/cloud/dlp.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)