Skip to content

Commit 6d56113

Browse files
feat!: migrate to use microgen (#38)
* 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 19a15ff commit 6d56113

File tree

143 files changed

+38748
-26439
lines changed

Some content is hidden

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

143 files changed

+38748
-26439
lines changed

packages/google-cloud-tasks/.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/tasks/__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-tasks/README.rst

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

5151
Supported Python Versions
5252
^^^^^^^^^^^^^^^^^^^^^^^^^
53-
Python >= 3.5
53+
Python >= 3.6
5454

5555
Deprecated Python Versions
5656
^^^^^^^^^^^^^^^^^^^^^^^^^^
57-
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
57+
Python == 2.7.
58+
59+
The last version of this library compatible with Python 2.7 is google-cloud-tasks==1.5.0.
5860

5961

6062
Mac/Linux
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-tasks` 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-tasks/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-tasks
24+
```
25+
26+
* The script `fixup_tasks_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_tasks_v2_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import tasks_v2
36+
37+
client = tasks_v2.CloudTasksClient()
38+
39+
build = client.get_queue("queue_name")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud import tasks_v2
46+
47+
client = tasks_v2.CloudTasksClient()
48+
49+
build = client.get_queue(request={'name': "queue_name"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-tasks<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_queue(
59+
self,
60+
parent,
61+
queue,
62+
retry=google.api_core.gapic_v1.method.DEFAULT,
63+
timeout=google.api_core.gapic_v1.method.DEFAULT,
64+
metadata=None,
65+
):
66+
```
67+
68+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
69+
70+
Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer.
71+
72+
73+
**After:**
74+
```py
75+
def create_queue(
76+
self,
77+
request: cloudtasks.CreateQueueRequest = None,
78+
*,
79+
parent: str = None,
80+
queue: gct_queue.Queue = None,
81+
retry: retries.Retry = gapic_v1.method.DEFAULT,
82+
timeout: float = None,
83+
metadata: Sequence[Tuple[str, str]] = (),
84+
) -> gct_queue.Queue:
85+
```
86+
87+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
88+
> Passing both will result in an error.
89+
90+
91+
Both of these calls are valid:
92+
93+
```py
94+
response = client.create_queue(
95+
request={
96+
"parent": parent,
97+
"queue": queue,
98+
}
99+
)
100+
```
101+
102+
```py
103+
response = client.create_queue(
104+
parent=parent,
105+
queue=queue,
106+
)
107+
```
108+
109+
This call is invalid because it mixes `request` with a keyword argument `queue`. Executing this code
110+
will result in an error.
111+
112+
```py
113+
response = client.create_queue(
114+
request={
115+
"parent": parent,
116+
},
117+
queue=queue
118+
)
119+
```
120+
121+
122+
123+
## Enums and Types
124+
125+
126+
> **WARNING**: Breaking change
127+
128+
The submodules `enums` and `types` have been removed.
129+
130+
**Before:**
131+
```py
132+
from google.cloud import tasks_v2
133+
134+
http_method = tasks_v2.enums.HttpMethod.POST
135+
queue = tasks_v2.types.Queue(name="name")
136+
```
137+
138+
139+
**After:**
140+
```py
141+
from google.cloud import tasks_v2
142+
143+
http_method = tasks_v2.HttpMethod.POST
144+
queue = tasks_v2.Queue(name="name")
145+
```
146+
147+
## Location Path Helper Method
148+
149+
Location path helper method has been removed. Please construct
150+
the path manually.
151+
152+
```py
153+
project = 'my-project'
154+
location = 'location'
155+
156+
location_path = f'projects/{project}/locations/{location}'
157+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md

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

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

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

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

packages/google-cloud-tasks/docs/gapic/v2beta2/api.rst

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

packages/google-cloud-tasks/docs/gapic/v2beta2/types.rst

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

packages/google-cloud-tasks/docs/gapic/v2beta3/api.rst

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

0 commit comments

Comments
 (0)