Skip to content
This repository was archived by the owner on Dec 31, 2023. It is now read-only.

Commit f52a799

Browse files
feat!: migrate to use microgenerator (#23)
1 parent 5e9532a commit f52a799

Some content is hidden

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

45 files changed

+10409
-10409
lines changed

README.rst

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Python Client for Cloud Build API (`GA`_)
22
============================================
33

4-
|ga| |pypi| |versions|
4+
|ga| |pypi| |versions|
55

66
`Cloud Build API`_: Creates and manages builds on Google Cloud Platform.
77

@@ -48,6 +48,15 @@ dependencies.
4848

4949
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
5050

51+
Supported Python Versions
52+
^^^^^^^^^^^^^^^^^^^^^^^^^
53+
Python >= 3.6
54+
55+
Deprecated Python Versions
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
Python == 2.7.
58+
59+
The last version of this library compatible with Python 2.7 is google-cloud-build==1.1.0.
5160

5261
Mac/Linux
5362
^^^^^^^^^
@@ -81,4 +90,4 @@ Next Steps
8190
APIs that we cover.
8291

8392
.. _Cloud Build API Product documentation: https://cloud.google.com/cloud-build
84-
.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst
93+
.. _repository’s main README: https://github.com/googleapis/google-cloud-python/blob/master/README.rst

UPGRADING.md

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# 2.0.0 Migration Guide
2+
3+
The 2.0 release of the `google-cloud-build` 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-cloudbuild/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-build
24+
```
25+
26+
* The script `fixup_cloudbuild_v1_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_cloudbuild_v1_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud.devtools import cloudbuild
36+
37+
client = cloudbuild.CloudBuildClient()
38+
39+
build = client.get_build("project_id")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud.devtools import cloudbuild
46+
47+
client = cloudbuild.CloudBuildClient()
48+
49+
build = client.get_build(request = {'project_id': "project_id"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-build<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters.
55+
56+
**Before:**
57+
```py
58+
def list_builds(
59+
self,
60+
project_id,
61+
page_size=None,
62+
filter_=None,
63+
retry=google.api_core.gapic_v1.method.DEFAULT,
64+
timeout=google.api_core.gapic_v1.method.DEFAULT,
65+
metadata=None,
66+
):
67+
```
68+
69+
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional.
70+
71+
Some methods have additional keyword only parameters. The available parameters depend on the [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/devtools/cloudbuild/v1/cloudbuild.proto#L82) specified by the API producer.
72+
73+
74+
**After:**
75+
```py
76+
def list_builds(
77+
self,
78+
request: cloudbuild.ListBuildsRequest = None,
79+
*,
80+
project_id: str = None,
81+
filter: str = None,
82+
retry: retries.Retry = gapic_v1.method.DEFAULT,
83+
timeout: float = None,
84+
metadata: Sequence[Tuple[str, str]] = (),
85+
) -> pagers.ListBuildsPager:
86+
```
87+
88+
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
89+
> Passing both will result in an error.
90+
91+
92+
Both of these calls are valid:
93+
94+
```py
95+
response = client.list_builds(
96+
request={
97+
"project_id": project_id,
98+
"filter": filter,
99+
}
100+
)
101+
```
102+
103+
```py
104+
response = client.list_builds(
105+
project_id=project_id,
106+
filter=filter,
107+
)
108+
```
109+
110+
This call is invalid because it mixes `request` with a keyword argument `filter`. Executing this code
111+
will result in an error.
112+
113+
```py
114+
response = client.list_builds(
115+
request={
116+
"project_id": project_id,
117+
},
118+
filter=filter
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.devtools import cloudbuild
134+
135+
build_status = cloudbuild.enums.Build.Status.SUCCESS
136+
built_image = cloudbuild.types.BuiltImage(name="name")
137+
```
138+
139+
140+
**After:**
141+
```py
142+
from google.cloud.devtools import cloudbuild
143+
144+
build_status = cloudbuild.Build.Status.SUCCESS
145+
built_image = cloudbuild.BuiltImage(name="name")
146+
```

docs/UPGRADING.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md

docs/cloudbuild_v1/services.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Devtools Cloudbuild v1 API
2+
==============================================
3+
4+
.. automodule:: google.cloud.devtools.cloudbuild_v1.services.cloud_build
5+
:members:
6+
:inherited-members:

docs/cloudbuild_v1/types.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Devtools Cloudbuild v1 API
2+
===========================================
3+
4+
.. automodule:: google.cloud.devtools.cloudbuild_v1.types
5+
:members:

docs/gapic/v1/api.rst

-6
This file was deleted.

docs/gapic/v1/types.rst

-5
This file was deleted.

docs/index.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,19 @@ API Reference
99
.. toctree::
1010
:maxdepth: 2
1111

12-
gapic/v1/api
13-
gapic/v1/types
12+
cloudbuild_v1/services
13+
cloudbuild_v1/types
14+
15+
16+
Migration Guide
17+
---------------
18+
19+
See the guide below for instructions on migrating to the 2.x release of this library.
20+
21+
.. toctree::
22+
:maxdepth: 2
23+
24+
UPGRADING
1425

1526

1627
Changelog

google/cloud/devtools/__init__.py

-24
This file was deleted.

google/cloud/devtools/cloudbuild.py

-29
This file was deleted.

0 commit comments

Comments
 (0)