Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Oct 29, 2023. It is now read-only.

Commit ce6f5cf

Browse filesBrowse files
yoshi-automationbusunkim96
authored andcommitted
fix(iot): modify retry and timeout configs; add 2.7 deprecation warning; add 'required' to docstring for required args; add 3.8 unit tests (via synth) (#10069)
1 parent df128f9 commit ce6f5cf
Copy full SHA for ce6f5cf

File tree

Expand file treeCollapse file tree

12 files changed

+658
-500
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+658
-500
lines changed

‎docs/_static/custom.css

Copy file name to clipboard
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
div#python2-eol {
22
border-color: red;
33
border-width: medium;
4-
}
4+
}

‎docs/_templates/layout.html

Copy file name to clipboardExpand all lines: docs/_templates/layout.html
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
{% extends "!layout.html" %}
23
{%- block content %}
34
{%- if theme_fixed_sidebar|lower == 'true' %}

‎google/cloud/iot_v1/__init__.py

Copy file name to clipboardExpand all lines: google/cloud/iot_v1/__init__.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,23 @@
1616

1717

1818
from __future__ import absolute_import
19+
import sys
20+
import warnings
1921

2022
from google.cloud.iot_v1 import types
2123
from google.cloud.iot_v1.gapic import device_manager_client
2224
from google.cloud.iot_v1.gapic import enums
2325

2426

27+
if sys.version_info[:2] == (2, 7):
28+
message = (
29+
"A future version of this library will drop support for Python 2.7."
30+
"More details about Python 2 support for Google Cloud Client Libraries"
31+
"can be found at https://cloud.google.com/python/docs/python2-sunset/"
32+
)
33+
warnings.warn(message, DeprecationWarning)
34+
35+
2536
class DeviceManagerClient(device_manager_client.DeviceManagerClient):
2637
__doc__ = device_manager_client.DeviceManagerClient.__doc__
2738
enums = enums

‎google/cloud/iot_v1/gapic/device_manager_client.py

Copy file name to clipboardExpand all lines: google/cloud/iot_v1/gapic/device_manager_client.py
+50-45Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ def create_device_registry(
244244
>>> response = client.create_device_registry(parent, device_registry)
245245
246246
Args:
247-
parent (str): The project and cloud region where this device registry must be created.
248-
For example, ``projects/example-project/locations/us-central1``.
249-
device_registry (Union[dict, ~google.cloud.iot_v1.types.DeviceRegistry]): The device registry. The field ``name`` must be empty. The server will
250-
generate that field from the device registry ``id`` provided and the
251-
``parent`` field.
247+
parent (str): Required. The project and cloud region where this device registry must
248+
be created. For example,
249+
``projects/example-project/locations/us-central1``.
250+
device_registry (Union[dict, ~google.cloud.iot_v1.types.DeviceRegistry]): Required. The device registry. The field ``name`` must be empty. The
251+
server will generate that field from the device registry ``id`` provided
252+
and the ``parent`` field.
252253
253254
If a dict is provided, it must be of the same form as the protobuf
254255
message :class:`~google.cloud.iot_v1.types.DeviceRegistry`
@@ -322,7 +323,7 @@ def get_device_registry(
322323
>>> response = client.get_device_registry(name)
323324
324325
Args:
325-
name (str): The name of the device registry. For example,
326+
name (str): Required. The name of the device registry. For example,
326327
``projects/example-project/locations/us-central1/registries/my-registry``.
327328
retry (Optional[google.api_core.retry.Retry]): A retry object used
328329
to retry requests. If ``None`` is specified, requests will
@@ -397,16 +398,16 @@ def update_device_registry(
397398
>>> response = client.update_device_registry(device_registry, update_mask)
398399
399400
Args:
400-
device_registry (Union[dict, ~google.cloud.iot_v1.types.DeviceRegistry]): The new values for the device registry. The ``id`` field must be empty,
401-
and the ``name`` field must indicate the path of the resource. For
402-
example,
401+
device_registry (Union[dict, ~google.cloud.iot_v1.types.DeviceRegistry]): Required. The new values for the device registry. The ``id`` field must
402+
be empty, and the ``name`` field must indicate the path of the resource.
403+
For example,
403404
``projects/example-project/locations/us-central1/registries/my-registry``.
404405
405406
If a dict is provided, it must be of the same form as the protobuf
406407
message :class:`~google.cloud.iot_v1.types.DeviceRegistry`
407-
update_mask (Union[dict, ~google.cloud.iot_v1.types.FieldMask]): Only updates the ``device_registry`` fields indicated by this mask. The
408-
field mask must not be empty, and it must not contain fields that are
409-
immutable or only set by the server. Mutable top-level fields:
408+
update_mask (Union[dict, ~google.cloud.iot_v1.types.FieldMask]): Required. Only updates the ``device_registry`` fields indicated by this
409+
mask. The field mask must not be empty, and it must not contain fields
410+
that are immutable or only set by the server. Mutable top-level fields:
410411
``event_notification_config``, ``http_config``, ``mqtt_config``, and
411412
``state_notification_config``.
412413
@@ -482,7 +483,7 @@ def delete_device_registry(
482483
>>> client.delete_device_registry(name)
483484
484485
Args:
485-
name (str): The name of the device registry. For example,
486+
name (str): Required. The name of the device registry. For example,
486487
``projects/example-project/locations/us-central1/registries/my-registry``.
487488
retry (Optional[google.api_core.retry.Retry]): A retry object used
488489
to retry requests. If ``None`` is specified, requests will
@@ -562,7 +563,7 @@ def list_device_registries(
562563
... pass
563564
564565
Args:
565-
parent (str): The project and cloud region path. For example,
566+
parent (str): Required. The project and cloud region path. For example,
566567
``projects/example-project/locations/us-central1``.
567568
page_size (int): The maximum number of resources contained in the
568569
underlying API response. If page streaming is performed per-
@@ -657,12 +658,12 @@ def create_device(
657658
>>> response = client.create_device(parent, device)
658659
659660
Args:
660-
parent (str): The name of the device registry where this device should be created. For
661-
example,
661+
parent (str): Required. The name of the device registry where this device should be
662+
created. For example,
662663
``projects/example-project/locations/us-central1/registries/my-registry``.
663-
device (Union[dict, ~google.cloud.iot_v1.types.Device]): The device registration details. The field ``name`` must be empty. The
664-
server generates ``name`` from the device registry ``id`` and the
665-
``parent`` field.
664+
device (Union[dict, ~google.cloud.iot_v1.types.Device]): Required. The device registration details. The field ``name`` must be
665+
empty. The server generates ``name`` from the device registry ``id`` and
666+
the ``parent`` field.
666667
667668
If a dict is provided, it must be of the same form as the protobuf
668669
message :class:`~google.cloud.iot_v1.types.Device`
@@ -735,7 +736,7 @@ def get_device(
735736
>>> response = client.get_device(name)
736737
737738
Args:
738-
name (str): The name of the device. For example,
739+
name (str): Required. The name of the device. For example,
739740
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
740741
or
741742
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
@@ -817,15 +818,16 @@ def update_device(
817818
>>> response = client.update_device(device, update_mask)
818819
819820
Args:
820-
device (Union[dict, ~google.cloud.iot_v1.types.Device]): The new values for the device. The ``id`` and ``num_id`` fields must be
821-
empty, and the field ``name`` must specify the name path. For example,
821+
device (Union[dict, ~google.cloud.iot_v1.types.Device]): Required. The new values for the device. The ``id`` and ``num_id``
822+
fields must be empty, and the field ``name`` must specify the name path.
823+
For example,
822824
``projects/p0/locations/us-central1/registries/registry0/devices/device0``\ or
823825
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
824826
825827
If a dict is provided, it must be of the same form as the protobuf
826828
message :class:`~google.cloud.iot_v1.types.Device`
827-
update_mask (Union[dict, ~google.cloud.iot_v1.types.FieldMask]): Only updates the ``device`` fields indicated by this mask. The field
828-
mask must not be empty, and it must not contain fields that are
829+
update_mask (Union[dict, ~google.cloud.iot_v1.types.FieldMask]): Required. Only updates the ``device`` fields indicated by this mask. The
830+
field mask must not be empty, and it must not contain fields that are
829831
immutable or only set by the server. Mutable top-level fields:
830832
``credentials``, ``blocked``, and ``metadata``
831833
@@ -901,7 +903,7 @@ def delete_device(
901903
>>> client.delete_device(name)
902904
903905
Args:
904-
name (str): The name of the device. For example,
906+
name (str): Required. The name of the device. For example,
905907
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
906908
or
907909
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
@@ -987,7 +989,7 @@ def list_devices(
987989
... pass
988990
989991
Args:
990-
parent (str): The device registry path. Required. For example,
992+
parent (str): Required. The device registry path. Required. For example,
991993
``projects/my-project/locations/us-central1/registries/my-registry``.
992994
device_num_ids (list[long]): A list of device numeric IDs. If empty, this field is ignored. Maximum
993995
IDs: 10,000.
@@ -1104,11 +1106,11 @@ def modify_cloud_to_device_config(
11041106
>>> response = client.modify_cloud_to_device_config(name, binary_data)
11051107
11061108
Args:
1107-
name (str): The name of the device. For example,
1109+
name (str): Required. The name of the device. For example,
11081110
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
11091111
or
11101112
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
1111-
binary_data (bytes): The configuration data for the device.
1113+
binary_data (bytes): Required. The configuration data for the device.
11121114
version_to_update (long): The version number to update. If this value is zero, it will not check the
11131115
version number of the server and will always update the current version;
11141116
otherwise, this update will fail if the version number found on the server
@@ -1188,7 +1190,7 @@ def list_device_config_versions(
11881190
>>> response = client.list_device_config_versions(name)
11891191
11901192
Args:
1191-
name (str): The name of the device. For example,
1193+
name (str): Required. The name of the device. For example,
11921194
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
11931195
or
11941196
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
@@ -1269,7 +1271,7 @@ def list_device_states(
12691271
>>> response = client.list_device_states(name)
12701272
12711273
Args:
1272-
name (str): The name of the device. For example,
1274+
name (str): Required. The name of the device. For example,
12731275
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
12741276
or
12751277
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
@@ -1343,7 +1345,8 @@ def set_iam_policy(
13431345
>>>
13441346
>>> client = iot_v1.DeviceManagerClient()
13451347
>>>
1346-
>>> resource = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]')
1348+
>>> # TODO: Initialize `resource`:
1349+
>>> resource = ''
13471350
>>>
13481351
>>> # TODO: Initialize `policy`:
13491352
>>> policy = {}
@@ -1426,7 +1429,8 @@ def get_iam_policy(
14261429
>>>
14271430
>>> client = iot_v1.DeviceManagerClient()
14281431
>>>
1429-
>>> resource = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]')
1432+
>>> # TODO: Initialize `resource`:
1433+
>>> resource = ''
14301434
>>>
14311435
>>> response = client.get_iam_policy(resource)
14321436
@@ -1506,7 +1510,8 @@ def test_iam_permissions(
15061510
>>>
15071511
>>> client = iot_v1.DeviceManagerClient()
15081512
>>>
1509-
>>> resource = client.registry_path('[PROJECT]', '[LOCATION]', '[REGISTRY]')
1513+
>>> # TODO: Initialize `resource`:
1514+
>>> resource = ''
15101515
>>>
15111516
>>> # TODO: Initialize `permissions`:
15121517
>>> permissions = []
@@ -1609,11 +1614,11 @@ def send_command_to_device(
16091614
>>> response = client.send_command_to_device(name, binary_data)
16101615
16111616
Args:
1612-
name (str): The name of the device. For example,
1617+
name (str): Required. The name of the device. For example,
16131618
``projects/p0/locations/us-central1/registries/registry0/devices/device0``
16141619
or
16151620
``projects/p0/locations/us-central1/registries/registry0/devices/{num_id}``.
1616-
binary_data (bytes): The command data to send to the device.
1621+
binary_data (bytes): Required. The command data to send to the device.
16171622
subfolder (str): Optional subfolder for the command. If empty, the command will be delivered
16181623
to the /devices/{device-id}/commands topic, otherwise it will be delivered
16191624
to the /devices/{device-id}/commands/{subfolder} topic. Multi-level
@@ -1697,12 +1702,12 @@ def bind_device_to_gateway(
16971702
>>> response = client.bind_device_to_gateway(parent, gateway_id, device_id)
16981703
16991704
Args:
1700-
parent (str): The name of the registry. For example,
1705+
parent (str): Required. The name of the registry. For example,
17011706
``projects/example-project/locations/us-central1/registries/my-registry``.
1702-
gateway_id (str): The value of ``gateway_id`` can be either the device numeric ID or the
1703-
user-defined device identifier.
1704-
device_id (str): The device to associate with the specified gateway. The value of
1705-
``device_id`` can be either the device numeric ID or the user-defined
1707+
gateway_id (str): Required. The value of ``gateway_id`` can be either the device numeric
1708+
ID or the user-defined device identifier.
1709+
device_id (str): Required. The device to associate with the specified gateway. The value
1710+
of ``device_id`` can be either the device numeric ID or the user-defined
17061711
device identifier.
17071712
retry (Optional[google.api_core.retry.Retry]): A retry object used
17081713
to retry requests. If ``None`` is specified, requests will
@@ -1782,13 +1787,13 @@ def unbind_device_from_gateway(
17821787
>>> response = client.unbind_device_from_gateway(parent, gateway_id, device_id)
17831788
17841789
Args:
1785-
parent (str): The name of the registry. For example,
1790+
parent (str): Required. The name of the registry. For example,
17861791
``projects/example-project/locations/us-central1/registries/my-registry``.
1787-
gateway_id (str): The value of ``gateway_id`` can be either the device numeric ID or the
1792+
gateway_id (str): Required. The value of ``gateway_id`` can be either the device numeric
1793+
ID or the user-defined device identifier.
1794+
device_id (str): Required. The device to disassociate from the specified gateway. The
1795+
value of ``device_id`` can be either the device numeric ID or the
17881796
user-defined device identifier.
1789-
device_id (str): The device to disassociate from the specified gateway. The value of
1790-
``device_id`` can be either the device numeric ID or the user-defined
1791-
device identifier.
17921797
retry (Optional[google.api_core.retry.Retry]): A retry object used
17931798
to retry requests. If ``None`` is specified, requests will
17941799
be retried using a default configuration.

‎google/cloud/iot_v1/gapic/device_manager_client_config.py

Copy file name to clipboardExpand all lines: google/cloud/iot_v1/gapic/device_manager_client_config.py
+8-22Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"retry_codes": {
55
"idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
66
"non_idempotent": [],
7-
"rate_limited_aware": [
8-
"DEADLINE_EXCEEDED",
9-
"RESOURCE_EXHAUSTED",
10-
"UNAVAILABLE",
11-
],
127
},
138
"retry_params": {
149
"default": {
@@ -18,17 +13,8 @@
1813
"initial_rpc_timeout_millis": 20000,
1914
"rpc_timeout_multiplier": 1.0,
2015
"max_rpc_timeout_millis": 20000,
21-
"total_timeout_millis": 120000,
22-
},
23-
"rate_limited_aware": {
24-
"initial_retry_delay_millis": 1000,
25-
"retry_delay_multiplier": 1.3,
26-
"max_retry_delay_millis": 60000,
27-
"initial_rpc_timeout_millis": 20000,
28-
"rpc_timeout_multiplier": 1.0,
29-
"max_rpc_timeout_millis": 20000,
30-
"total_timeout_millis": 120000,
31-
},
16+
"total_timeout_millis": 600000,
17+
}
3218
},
3319
"methods": {
3420
"CreateDeviceRegistry": {
@@ -48,7 +34,7 @@
4834
},
4935
"DeleteDeviceRegistry": {
5036
"timeout_millis": 60000,
51-
"retry_codes_name": "idempotent",
37+
"retry_codes_name": "non_idempotent",
5238
"retry_params_name": "default",
5339
},
5440
"ListDeviceRegistries": {
@@ -73,7 +59,7 @@
7359
},
7460
"DeleteDevice": {
7561
"timeout_millis": 60000,
76-
"retry_codes_name": "idempotent",
62+
"retry_codes_name": "non_idempotent",
7763
"retry_params_name": "default",
7864
},
7965
"ListDevices": {
@@ -83,8 +69,8 @@
8369
},
8470
"ModifyCloudToDeviceConfig": {
8571
"timeout_millis": 60000,
86-
"retry_codes_name": "rate_limited_aware",
87-
"retry_params_name": "rate_limited_aware",
72+
"retry_codes_name": "non_idempotent",
73+
"retry_params_name": "default",
8874
},
8975
"ListDeviceConfigVersions": {
9076
"timeout_millis": 60000,
@@ -113,8 +99,8 @@
11399
},
114100
"SendCommandToDevice": {
115101
"timeout_millis": 60000,
116-
"retry_codes_name": "rate_limited_aware",
117-
"retry_params_name": "rate_limited_aware",
102+
"retry_codes_name": "non_idempotent",
103+
"retry_params_name": "default",
118104
},
119105
"BindDeviceToGateway": {
120106
"timeout_millis": 60000,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.