Skip to content
Browse files
feat!: migrate to use microgen (#29)
  • Loading branch information
arithmetic1728 committed Sep 10, 2020
1 parent 43f1f1a commit f420fd37441c92f3c9324b1d7278b210e3c5a8bc
Show file tree
Hide file tree
Showing 49 changed files with 13,659 additions and 9,184 deletions.
@@ -21,15 +21,14 @@ branch = True
fail_under = 100
show_missing = True
omit = google/cloud/iot/
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore abstract methods
raise NotImplementedError
omit =
# 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
@@ -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.

@@ -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](, 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](

## 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

python3 -m pip install google-cloud-iot

* The script `` is shipped with the library. It expects
an input directory (with the code to convert) and an empty destination directory.

$ --input-directory .samples/ --output-directory samples/

from import iot_v1
client = iot_v1.DeviceManagerClient()
registry = client.get_device_registry("registry_name")

from 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.

def create_device(

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.

def create_device(
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:

response = client.create_device(
"parent": parent,
"device": device,

response = client.create_device(

This call is invalid because it mixes `request` with a keyword argument `device`. Executing this code
will result in an error.

response = client.create_device(
"parent": parent,

## Enums and Types

> **WARNING**: Breaking change
The submodules `enums` and `types` have been removed.

from import iot_v1
gateway_type = iot_v1.enums.GatewayType.GATEWAY
device = iot_v1.types.Device(name="name")

from 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.

project = 'my-project'
location = 'location'
location_path = f'projects/{project}/locations/{location}'

This file was deleted.

This file was deleted.

@@ -7,8 +7,19 @@ Api Reference
.. toctree::
:maxdepth: 2


Migration Guide

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

.. toctree::
:maxdepth: 2


@@ -0,0 +1,6 @@
Services for Google Cloud Iot v1 API

.. automodule::
@@ -0,0 +1,5 @@
Types for Google Cloud Iot v1 API

.. automodule::

This file was deleted.

@@ -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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

from import (
from import DeviceManagerClient
from import BindDeviceToGatewayRequest
from import BindDeviceToGatewayResponse
from import CreateDeviceRegistryRequest
from import CreateDeviceRequest
from import DeleteDeviceRegistryRequest
from import DeleteDeviceRequest
from import GatewayListOptions
from import GetDeviceRegistryRequest
from import GetDeviceRequest
from import ListDeviceConfigVersionsRequest
from import ListDeviceConfigVersionsResponse
from import ListDeviceRegistriesRequest
from import ListDeviceRegistriesResponse
from import ListDeviceStatesRequest
from import ListDeviceStatesResponse
from import ListDevicesRequest
from import ListDevicesResponse
from import ModifyCloudToDeviceConfigRequest
from import SendCommandToDeviceRequest
from import SendCommandToDeviceResponse
from import UnbindDeviceFromGatewayRequest
from import UnbindDeviceFromGatewayResponse
from import UpdateDeviceRegistryRequest
from import UpdateDeviceRequest
from import Device
from import DeviceConfig
from import DeviceCredential
from import DeviceRegistry
from import DeviceState
from import EventNotificationConfig
from import GatewayAuthMethod
from import GatewayConfig
from import GatewayType
from import HttpConfig
from import HttpState
from import LogLevel
from import MqttConfig
from import MqttState
from import PublicKeyCertificate
from import PublicKeyCertificateFormat
from import PublicKeyCredential
from import PublicKeyFormat
from import RegistryCredential
from import StateNotificationConfig
from import X509CertificateDetails

__all__ = (
@@ -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.