Skip to content
This repository was archived by the owner on Oct 29, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions google/cloud/iot_v1/services/device_manager/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,12 @@ async def unbind_device_from_gateway(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
18 changes: 14 additions & 4 deletions google/cloud/iot_v1/services/device_manager/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def create_device_registry(
Expand Down Expand Up @@ -1995,6 +1992,19 @@ def unbind_device_from_gateway(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.

.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.

.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def create_device_registry(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -781,5 +781,8 @@ def unbind_device_from_gateway(
)
return self._stubs["unbind_device_from_gateway"]

def close(self):
self.grpc_channel.close()


__all__ = ("DeviceManagerGrpcTransport",)
Original file line number Diff line number Diff line change
Expand Up @@ -792,5 +792,8 @@ def unbind_device_from_gateway(
)
return self._stubs["unbind_device_from_gateway"]

def close(self):
return self.grpc_channel.close()


__all__ = ("DeviceManagerGrpcAsyncIOTransport",)
29 changes: 26 additions & 3 deletions google/cloud/iot_v1/types/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

class CreateDeviceRegistryRequest(proto.Message):
r"""Request for ``CreateDeviceRegistry``.

Attributes:
parent (str):
Required. The project and cloud region where this device
Expand All @@ -71,6 +72,7 @@ class CreateDeviceRegistryRequest(proto.Message):

class GetDeviceRegistryRequest(proto.Message):
r"""Request for ``GetDeviceRegistry``.

Attributes:
name (str):
Required. The name of the device registry. For example,
Expand All @@ -82,6 +84,7 @@ class GetDeviceRegistryRequest(proto.Message):

class DeleteDeviceRegistryRequest(proto.Message):
r"""Request for ``DeleteDeviceRegistry``.

Attributes:
name (str):
Required. The name of the device registry. For example,
Expand All @@ -93,6 +96,7 @@ class DeleteDeviceRegistryRequest(proto.Message):

class UpdateDeviceRegistryRequest(proto.Message):
r"""Request for ``UpdateDeviceRegistry``.

Attributes:
device_registry (google.cloud.iot_v1.types.DeviceRegistry):
Required. The new values for the device registry. The ``id``
Expand All @@ -118,6 +122,7 @@ class UpdateDeviceRegistryRequest(proto.Message):

class ListDeviceRegistriesRequest(proto.Message):
r"""Request for ``ListDeviceRegistries``.

Attributes:
parent (str):
Required. The project and cloud region path. For example,
Expand All @@ -142,6 +147,7 @@ class ListDeviceRegistriesRequest(proto.Message):

class ListDeviceRegistriesResponse(proto.Message):
r"""Response for ``ListDeviceRegistries``.

Attributes:
device_registries (Sequence[google.cloud.iot_v1.types.DeviceRegistry]):
The registries that matched the query.
Expand All @@ -163,6 +169,7 @@ def raw_page(self):

class CreateDeviceRequest(proto.Message):
r"""Request for ``CreateDevice``.

Attributes:
parent (str):
Required. The name of the device registry where this device
Expand All @@ -180,6 +187,7 @@ class CreateDeviceRequest(proto.Message):

class GetDeviceRequest(proto.Message):
r"""Request for ``GetDevice``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand All @@ -199,6 +207,7 @@ class GetDeviceRequest(proto.Message):

class UpdateDeviceRequest(proto.Message):
r"""Request for ``UpdateDevice``.

Attributes:
device (google.cloud.iot_v1.types.Device):
Required. The new values for the device. The ``id`` and
Expand All @@ -222,6 +231,7 @@ class UpdateDeviceRequest(proto.Message):

class DeleteDeviceRequest(proto.Message):
r"""Request for ``DeleteDevice``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand All @@ -235,6 +245,7 @@ class DeleteDeviceRequest(proto.Message):

class ListDevicesRequest(proto.Message):
r"""Request for ``ListDevices``.

Attributes:
parent (str):
Required. The device registry path. Required. For example,
Expand Down Expand Up @@ -310,6 +321,7 @@ class GatewayListOptions(proto.Message):

class ListDevicesResponse(proto.Message):
r"""Response for ``ListDevices``.

Attributes:
devices (Sequence[google.cloud.iot_v1.types.Device]):
The devices that match the request.
Expand All @@ -329,6 +341,7 @@ def raw_page(self):

class ModifyCloudToDeviceConfigRequest(proto.Message):
r"""Request for ``ModifyCloudToDeviceConfig``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand Down Expand Up @@ -356,6 +369,7 @@ class ModifyCloudToDeviceConfigRequest(proto.Message):

class ListDeviceConfigVersionsRequest(proto.Message):
r"""Request for ``ListDeviceConfigVersions``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand All @@ -376,6 +390,7 @@ class ListDeviceConfigVersionsRequest(proto.Message):

class ListDeviceConfigVersionsResponse(proto.Message):
r"""Response for ``ListDeviceConfigVersions``.

Attributes:
device_configs (Sequence[google.cloud.iot_v1.types.DeviceConfig]):
The device configuration for the last few
Expand All @@ -390,6 +405,7 @@ class ListDeviceConfigVersionsResponse(proto.Message):

class ListDeviceStatesRequest(proto.Message):
r"""Request for ``ListDeviceStates``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand All @@ -410,6 +426,7 @@ class ListDeviceStatesRequest(proto.Message):

class ListDeviceStatesResponse(proto.Message):
r"""Response for ``ListDeviceStates``.

Attributes:
device_states (Sequence[google.cloud.iot_v1.types.DeviceState]):
The last few device states. States are listed
Expand All @@ -424,6 +441,7 @@ class ListDeviceStatesResponse(proto.Message):

class SendCommandToDeviceRequest(proto.Message):
r"""Request for ``SendCommandToDevice``.

Attributes:
name (str):
Required. The name of the device. For example,
Expand Down Expand Up @@ -451,11 +469,13 @@ class SendCommandToDeviceRequest(proto.Message):


class SendCommandToDeviceResponse(proto.Message):
r"""Response for ``SendCommandToDevice``. """
r"""Response for ``SendCommandToDevice``.
"""


class BindDeviceToGatewayRequest(proto.Message):
r"""Request for ``BindDeviceToGateway``.

Attributes:
parent (str):
Required. The name of the registry. For example,
Expand All @@ -475,11 +495,13 @@ class BindDeviceToGatewayRequest(proto.Message):


class BindDeviceToGatewayResponse(proto.Message):
r"""Response for ``BindDeviceToGateway``. """
r"""Response for ``BindDeviceToGateway``.
"""


class UnbindDeviceFromGatewayRequest(proto.Message):
r"""Request for ``UnbindDeviceFromGateway``.

Attributes:
parent (str):
Required. The name of the registry. For example,
Expand All @@ -499,7 +521,8 @@ class UnbindDeviceFromGatewayRequest(proto.Message):


class UnbindDeviceFromGatewayResponse(proto.Message):
r"""Response for ``UnbindDeviceFromGateway``. """
r"""Response for ``UnbindDeviceFromGateway``.
"""


__all__ = tuple(sorted(__protobuf__.manifest))
11 changes: 11 additions & 0 deletions google/cloud/iot_v1/types/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class PublicKeyFormat(proto.Enum):

class Device(proto.Message):
r"""The device resource.

Attributes:
id (str):
The user-defined device identifier. The
Expand Down Expand Up @@ -249,6 +250,7 @@ class Device(proto.Message):

class GatewayConfig(proto.Message):
r"""Gateway-related configuration and state.

Attributes:
gateway_type (google.cloud.iot_v1.types.GatewayType):
Indicates whether the device is a gateway.
Expand All @@ -273,6 +275,7 @@ class GatewayConfig(proto.Message):

class DeviceRegistry(proto.Message):
r"""A container for a group of devices.

Attributes:
id (str):
The identifier of this device registry. For example,
Expand Down Expand Up @@ -353,6 +356,7 @@ class DeviceRegistry(proto.Message):

class MqttConfig(proto.Message):
r"""The configuration of MQTT for a device registry.

Attributes:
mqtt_enabled_state (google.cloud.iot_v1.types.MqttState):
If enabled, allows connections using the MQTT
Expand All @@ -365,6 +369,7 @@ class MqttConfig(proto.Message):

class HttpConfig(proto.Message):
r"""The configuration of the HTTP bridge for a device registry.

Attributes:
http_enabled_state (google.cloud.iot_v1.types.HttpState):
If enabled, allows devices to use
Expand All @@ -378,6 +383,7 @@ class HttpConfig(proto.Message):

class EventNotificationConfig(proto.Message):
r"""The configuration for forwarding telemetry events.

Attributes:
subfolder_matches (str):
If the subfolder name matches this string
Expand Down Expand Up @@ -453,6 +459,7 @@ class X509CertificateDetails(proto.Message):

class PublicKeyCertificate(proto.Message):
r"""A public key certificate format and data.

Attributes:
format (google.cloud.iot_v1.types.PublicKeyCertificateFormat):
The certificate format.
Expand All @@ -472,6 +479,7 @@ class PublicKeyCertificate(proto.Message):

class DeviceCredential(proto.Message):
r"""A server-stored device credential used for authentication.

Attributes:
public_key (google.cloud.iot_v1.types.PublicKeyCredential):
A public key used to verify the signature of
Expand Down Expand Up @@ -507,6 +515,7 @@ class DeviceCredential(proto.Message):

class PublicKeyCredential(proto.Message):
r"""A public key format and data.

Attributes:
format (google.cloud.iot_v1.types.PublicKeyFormat):
The format of the key.
Expand All @@ -520,6 +529,7 @@ class PublicKeyCredential(proto.Message):

class DeviceConfig(proto.Message):
r"""The device configuration. Eventually delivered to devices.

Attributes:
version (int):
[Output only] The version of this update. The version number
Expand Down Expand Up @@ -559,6 +569,7 @@ class DeviceConfig(proto.Message):

class DeviceState(proto.Message):
r"""The device state, as reported by the device.

Attributes:
update_time (google.protobuf.timestamp_pb2.Timestamp):
[Output only] The time at which this state version was
Expand Down
Loading