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

Commit

Permalink
Browse files Browse the repository at this point in the history
feat!: migrate to use microgen (#29)
  • Loading branch information
arithmetic1728 committed Sep 10, 2020
1 parent 43f1f1a commit f420fd3
Show file tree
Hide file tree
Showing 49 changed files with 13,659 additions and 9,184 deletions.
13 changes: 6 additions & 7 deletions .coveragerc
Expand Up @@ -21,15 +21,14 @@ branch = True
[report]
fail_under = 100
show_missing = True
omit = google/cloud/iot/__init__.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
*/gapic/*.py
*/proto/*.py
*/core/*.py
*/site-packages/*.py
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
6 changes: 4 additions & 2 deletions README.rst
Expand Up @@ -50,11 +50,13 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.5
Python >= 3.6

Deprecated Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^
Python == 2.7. Python 2.7 support will be removed on January 1, 2020.
Python == 2.7.

The last version of this library compatible with Python 2.7 is google-cloud-iot==1.0.0.


Mac/Linux
Expand Down
157 changes: 157 additions & 0 deletions UPGRADING.md
@@ -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}'
```
1 change: 1 addition & 0 deletions docs/UPGRADING.md
6 changes: 0 additions & 6 deletions docs/gapic/v1/api.rst

This file was deleted.

5 changes: 0 additions & 5 deletions docs/gapic/v1/types.rst

This file was deleted.

15 changes: 13 additions & 2 deletions docs/index.rst
Expand Up @@ -7,8 +7,19 @@ Api Reference
.. toctree::
:maxdepth: 2

gapic/v1/api
gapic/v1/types
iot_v1/services
iot_v1/types


Migration Guide
---------------

See the guide below for instructions on migrating to the 2.x release of this library.

.. toctree::
:maxdepth: 2

UPGRADING


Changelog
Expand Down
6 changes: 6 additions & 0 deletions docs/iot_v1/services.rst
@@ -0,0 +1,6 @@
Services for Google Cloud Iot v1 API
====================================

.. automodule:: google.cloud.iot_v1.services.device_manager
:members:
:inherited-members:
5 changes: 5 additions & 0 deletions docs/iot_v1/types.rst
@@ -0,0 +1,5 @@
Types for Google Cloud Iot v1 API
=================================

.. automodule:: google.cloud.iot_v1.types
:members:
21 changes: 0 additions & 21 deletions google/cloud/iot.py

This file was deleted.

116 changes: 116 additions & 0 deletions google/cloud/iot/__init__.py
@@ -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",
)
2 changes: 2 additions & 0 deletions google/cloud/iot/py.typed
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-iot package uses inline types.

0 comments on commit f420fd3

Please sign in to comment.