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

Commit f420fd3

Browse files
feat!: migrate to use microgen (#29)
1 parent 43f1f1a commit f420fd3

Some content is hidden

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

49 files changed

+13659
-9184
lines changed

.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/iot/__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

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-iot==1.0.0.
5860

5961

6062
Mac/Linux

UPGRADING.md

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-iot` 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-iot/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-iot
24+
```
25+
26+
* The script `fixup_iot_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_iot_v1_keywords.py --input-directory .samples/ --output-directory samples/
31+
```
32+
33+
**Before:**
34+
```py
35+
from google.cloud import iot_v1
36+
37+
client = iot_v1.DeviceManagerClient()
38+
39+
registry = client.get_device_registry("registry_name")
40+
```
41+
42+
43+
**After:**
44+
```py
45+
from google.cloud import iot_v1
46+
47+
client = iot_v1.DeviceManagerClient()
48+
49+
registry = client.get_device_registry(request={'name': "registry_name"})
50+
```
51+
52+
### More Details
53+
54+
In `google-cloud-iot<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_device(
59+
self,
60+
parent,
61+
device,
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_device(
76+
self,
77+
request: device_manager.CreateDeviceRequest = None,
78+
*,
79+
parent: str = None,
80+
device: resources.Device = None,
81+
retry: retries.Retry = gapic_v1.method.DEFAULT,
82+
timeout: float = None,
83+
metadata: Sequence[Tuple[str, str]] = (),
84+
) -> resources.Device:
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_device(
95+
request={
96+
"parent": parent,
97+
"device": device,
98+
}
99+
)
100+
```
101+
102+
```py
103+
response = client.create_device(
104+
parent=parent,
105+
device=device,
106+
)
107+
```
108+
109+
This call is invalid because it mixes `request` with a keyword argument `device`. Executing this code
110+
will result in an error.
111+
112+
```py
113+
response = client.create_device(
114+
request={
115+
"parent": parent,
116+
},
117+
device=device
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 iot_v1
133+
134+
gateway_type = iot_v1.enums.GatewayType.GATEWAY
135+
device = iot_v1.types.Device(name="name")
136+
```
137+
138+
139+
**After:**
140+
```py
141+
from google.cloud import iot_v1
142+
143+
gateway_type = iot_v1.GatewayType.GATEWAY
144+
device = iot_v1.Device(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+
```

docs/UPGRADING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../UPGRADING.md

docs/gapic/v1/api.rst

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

docs/gapic/v1/types.rst

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

docs/index.rst

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

10-
gapic/v1/api
11-
gapic/v1/types
10+
iot_v1/services
11+
iot_v1/types
12+
13+
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
1223

1324

1425
Changelog

docs/iot_v1/services.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Iot v1 API
2+
====================================
3+
4+
.. automodule:: google.cloud.iot_v1.services.device_manager
5+
:members:
6+
:inherited-members:

docs/iot_v1/types.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Types for Google Cloud Iot v1 API
2+
=================================
3+
4+
.. automodule:: google.cloud.iot_v1.types
5+
:members:

google/cloud/iot.py

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

0 commit comments

Comments
 (0)