This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat!: migrate to use microgen (#29)
- Loading branch information
1 parent
43f1f1a
commit f420fd3
Showing
49 changed files
with
13,659 additions
and
9,184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
# 2.0.0 Migration Guide | ||
|
||
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. | ||
|
||
If you experience issues or have questions, please file an [issue](https://github.com/googleapis/python-iot/issues). | ||
|
||
## Supported Python Versions | ||
|
||
> **WARNING**: Breaking change | ||
The 2.0.0 release requires Python 3.6+. | ||
|
||
|
||
## Method Calls | ||
|
||
> **WARNING**: Breaking change | ||
Methods expect request objects. We provide a script that will convert most common use cases. | ||
|
||
* Install the library | ||
|
||
```py | ||
python3 -m pip install google-cloud-iot | ||
``` | ||
|
||
* The script `fixup_iot_v1_keywords.py` is shipped with the library. It expects | ||
an input directory (with the code to convert) and an empty destination directory. | ||
|
||
```sh | ||
$ fixup_iot_v1_keywords.py --input-directory .samples/ --output-directory samples/ | ||
``` | ||
|
||
**Before:** | ||
```py | ||
from google.cloud import iot_v1 | ||
|
||
client = iot_v1.DeviceManagerClient() | ||
|
||
registry = client.get_device_registry("registry_name") | ||
``` | ||
|
||
|
||
**After:** | ||
```py | ||
from google.cloud import iot_v1 | ||
|
||
client = iot_v1.DeviceManagerClient() | ||
|
||
registry = client.get_device_registry(request={'name': "registry_name"}) | ||
``` | ||
|
||
### More Details | ||
|
||
In `google-cloud-iot<2.0.0`, parameters required by the API were positional parameters and optional parameters were keyword parameters. | ||
|
||
**Before:** | ||
```py | ||
def create_device( | ||
self, | ||
parent, | ||
device, | ||
retry=google.api_core.gapic_v1.method.DEFAULT, | ||
timeout=google.api_core.gapic_v1.method.DEFAULT, | ||
metadata=None, | ||
): | ||
``` | ||
|
||
In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a parameter is required or optional. | ||
|
||
Some methods have additional keyword only parameters. The available parameters depend on the `google.api.method_signature` annotation specified by the API producer. | ||
|
||
|
||
**After:** | ||
```py | ||
def create_device( | ||
self, | ||
request: device_manager.CreateDeviceRequest = None, | ||
*, | ||
parent: str = None, | ||
device: resources.Device = None, | ||
retry: retries.Retry = gapic_v1.method.DEFAULT, | ||
timeout: float = None, | ||
metadata: Sequence[Tuple[str, str]] = (), | ||
) -> resources.Device: | ||
``` | ||
|
||
> **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive. | ||
> Passing both will result in an error. | ||
|
||
Both of these calls are valid: | ||
|
||
```py | ||
response = client.create_device( | ||
request={ | ||
"parent": parent, | ||
"device": device, | ||
} | ||
) | ||
``` | ||
|
||
```py | ||
response = client.create_device( | ||
parent=parent, | ||
device=device, | ||
) | ||
``` | ||
|
||
This call is invalid because it mixes `request` with a keyword argument `device`. Executing this code | ||
will result in an error. | ||
|
||
```py | ||
response = client.create_device( | ||
request={ | ||
"parent": parent, | ||
}, | ||
device=device | ||
) | ||
``` | ||
|
||
|
||
|
||
## Enums and Types | ||
|
||
|
||
> **WARNING**: Breaking change | ||
The submodules `enums` and `types` have been removed. | ||
|
||
**Before:** | ||
```py | ||
from google.cloud import iot_v1 | ||
|
||
gateway_type = iot_v1.enums.GatewayType.GATEWAY | ||
device = iot_v1.types.Device(name="name") | ||
``` | ||
|
||
|
||
**After:** | ||
```py | ||
from google.cloud import iot_v1 | ||
|
||
gateway_type = iot_v1.GatewayType.GATEWAY | ||
device = iot_v1.Device(name="name") | ||
``` | ||
|
||
## Location Path Helper Method | ||
|
||
Location path helper method has been removed. Please construct | ||
the path manually. | ||
|
||
```py | ||
project = 'my-project' | ||
location = 'location' | ||
|
||
location_path = f'projects/{project}/locations/{location}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../UPGRADING.md |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Services for Google Cloud Iot v1 API | ||
==================================== | ||
|
||
.. automodule:: google.cloud.iot_v1.services.device_manager | ||
:members: | ||
:inherited-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Types for Google Cloud Iot v1 API | ||
================================= | ||
|
||
.. automodule:: google.cloud.iot_v1.types | ||
:members: |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
# Copyright 2020 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
from google.cloud.iot_v1.services.device_manager.async_client import ( | ||
DeviceManagerAsyncClient, | ||
) | ||
from google.cloud.iot_v1.services.device_manager.client import DeviceManagerClient | ||
from google.cloud.iot_v1.types.device_manager import BindDeviceToGatewayRequest | ||
from google.cloud.iot_v1.types.device_manager import BindDeviceToGatewayResponse | ||
from google.cloud.iot_v1.types.device_manager import CreateDeviceRegistryRequest | ||
from google.cloud.iot_v1.types.device_manager import CreateDeviceRequest | ||
from google.cloud.iot_v1.types.device_manager import DeleteDeviceRegistryRequest | ||
from google.cloud.iot_v1.types.device_manager import DeleteDeviceRequest | ||
from google.cloud.iot_v1.types.device_manager import GatewayListOptions | ||
from google.cloud.iot_v1.types.device_manager import GetDeviceRegistryRequest | ||
from google.cloud.iot_v1.types.device_manager import GetDeviceRequest | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceConfigVersionsRequest | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceConfigVersionsResponse | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceRegistriesRequest | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceRegistriesResponse | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceStatesRequest | ||
from google.cloud.iot_v1.types.device_manager import ListDeviceStatesResponse | ||
from google.cloud.iot_v1.types.device_manager import ListDevicesRequest | ||
from google.cloud.iot_v1.types.device_manager import ListDevicesResponse | ||
from google.cloud.iot_v1.types.device_manager import ModifyCloudToDeviceConfigRequest | ||
from google.cloud.iot_v1.types.device_manager import SendCommandToDeviceRequest | ||
from google.cloud.iot_v1.types.device_manager import SendCommandToDeviceResponse | ||
from google.cloud.iot_v1.types.device_manager import UnbindDeviceFromGatewayRequest | ||
from google.cloud.iot_v1.types.device_manager import UnbindDeviceFromGatewayResponse | ||
from google.cloud.iot_v1.types.device_manager import UpdateDeviceRegistryRequest | ||
from google.cloud.iot_v1.types.device_manager import UpdateDeviceRequest | ||
from google.cloud.iot_v1.types.resources import Device | ||
from google.cloud.iot_v1.types.resources import DeviceConfig | ||
from google.cloud.iot_v1.types.resources import DeviceCredential | ||
from google.cloud.iot_v1.types.resources import DeviceRegistry | ||
from google.cloud.iot_v1.types.resources import DeviceState | ||
from google.cloud.iot_v1.types.resources import EventNotificationConfig | ||
from google.cloud.iot_v1.types.resources import GatewayAuthMethod | ||
from google.cloud.iot_v1.types.resources import GatewayConfig | ||
from google.cloud.iot_v1.types.resources import GatewayType | ||
from google.cloud.iot_v1.types.resources import HttpConfig | ||
from google.cloud.iot_v1.types.resources import HttpState | ||
from google.cloud.iot_v1.types.resources import LogLevel | ||
from google.cloud.iot_v1.types.resources import MqttConfig | ||
from google.cloud.iot_v1.types.resources import MqttState | ||
from google.cloud.iot_v1.types.resources import PublicKeyCertificate | ||
from google.cloud.iot_v1.types.resources import PublicKeyCertificateFormat | ||
from google.cloud.iot_v1.types.resources import PublicKeyCredential | ||
from google.cloud.iot_v1.types.resources import PublicKeyFormat | ||
from google.cloud.iot_v1.types.resources import RegistryCredential | ||
from google.cloud.iot_v1.types.resources import StateNotificationConfig | ||
from google.cloud.iot_v1.types.resources import X509CertificateDetails | ||
|
||
__all__ = ( | ||
"BindDeviceToGatewayRequest", | ||
"BindDeviceToGatewayResponse", | ||
"CreateDeviceRegistryRequest", | ||
"CreateDeviceRequest", | ||
"DeleteDeviceRegistryRequest", | ||
"DeleteDeviceRequest", | ||
"Device", | ||
"DeviceConfig", | ||
"DeviceCredential", | ||
"DeviceManagerAsyncClient", | ||
"DeviceManagerClient", | ||
"DeviceRegistry", | ||
"DeviceState", | ||
"EventNotificationConfig", | ||
"GatewayAuthMethod", | ||
"GatewayConfig", | ||
"GatewayListOptions", | ||
"GatewayType", | ||
"GetDeviceRegistryRequest", | ||
"GetDeviceRequest", | ||
"HttpConfig", | ||
"HttpState", | ||
"ListDeviceConfigVersionsRequest", | ||
"ListDeviceConfigVersionsResponse", | ||
"ListDeviceRegistriesRequest", | ||
"ListDeviceRegistriesResponse", | ||
"ListDeviceStatesRequest", | ||
"ListDeviceStatesResponse", | ||
"ListDevicesRequest", | ||
"ListDevicesResponse", | ||
"LogLevel", | ||
"ModifyCloudToDeviceConfigRequest", | ||
"MqttConfig", | ||
"MqttState", | ||
"PublicKeyCertificate", | ||
"PublicKeyCertificateFormat", | ||
"PublicKeyCredential", | ||
"PublicKeyFormat", | ||
"RegistryCredential", | ||
"SendCommandToDeviceRequest", | ||
"SendCommandToDeviceResponse", | ||
"StateNotificationConfig", | ||
"UnbindDeviceFromGatewayRequest", | ||
"UnbindDeviceFromGatewayResponse", | ||
"UpdateDeviceRegistryRequest", | ||
"UpdateDeviceRequest", | ||
"X509CertificateDetails", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Marker file for PEP 561. | ||
# The google-cloud-iot package uses inline types. |
Oops, something went wrong.