From 040cee115130ce20b12cd48198b6325cddd95260 Mon Sep 17 00:00:00 2001 From: Gabor Cseh <77115915+gcseh@users.noreply.github.com> Date: Mon, 27 Sep 2021 18:47:02 +0200 Subject: [PATCH 01/28] chore: add README, nox support for MQTT example (#194) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: Add noxfile * chore: Lint example * chore: Add readme * chore: Fix review comments * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: owlbot repo specifics * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: year update * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: year update * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- owlbot.py | 27 ++ .../api-client/accesstoken_example/noxfile.py | 2 +- samples/api-client/mqtt_example/README.rst | 151 ++++++ samples/api-client/mqtt_example/README.rst.in | 32 ++ .../mqtt_example/cloudiot_mqtt_example.py | 455 +++++++++++------- samples/api-client/mqtt_example/noxfile.py | 266 ++++++++++ .../mqtt_example/requirements-test.txt | 1 + .../api-client/mqtt_example/requirements.txt | 2 + scripts/readme-gen/templates/README.tmpl.rst | 4 +- .../templates/install_deps.tmpl.rst | 4 +- 10 files changed, 766 insertions(+), 178 deletions(-) create mode 100644 samples/api-client/mqtt_example/README.rst create mode 100644 samples/api-client/mqtt_example/README.rst.in create mode 100644 samples/api-client/mqtt_example/noxfile.py create mode 100644 samples/api-client/mqtt_example/requirements-test.txt create mode 100644 samples/api-client/mqtt_example/requirements.txt diff --git a/owlbot.py b/owlbot.py index 9d1f5695..72aefc22 100644 --- a/owlbot.py +++ b/owlbot.py @@ -51,3 +51,30 @@ s.shell.run(["nox", "-s", "blacken"], hide_output=False) +# ---------------------------------------------------------------------------- +# Repo specifics replacements +# ---------------------------------------------------------------------------- + +s.replace( + "samples/api-client/accesstoken_example/noxfile.py", + "# Copyright 2019 Google LLC", + "# Copyright 2021 Google LLC" +) + +s.replace( + "samples/api-client/mqtt_example/noxfile.py", + "# Copyright 2019 Google LLC", + "# Copyright 2021 Google LLC" +) + +s.replace( + "scripts/readme-gen/templates/*.rst", + "GoogleCloudPlatform/python-docs-samples", + "googleapis/python-iot" +) + +s.replace( + "scripts/readme-gen/templates/*.rst", + "python-docs-samples", + "python-iot" +) diff --git a/samples/api-client/accesstoken_example/noxfile.py b/samples/api-client/accesstoken_example/noxfile.py index b008613f..0e13f5f1 100644 --- a/samples/api-client/accesstoken_example/noxfile.py +++ b/samples/api-client/accesstoken_example/noxfile.py @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC +# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/samples/api-client/mqtt_example/README.rst b/samples/api-client/mqtt_example/README.rst new file mode 100644 index 00000000..c11ed15a --- /dev/null +++ b/samples/api-client/mqtt_example/README.rst @@ -0,0 +1,151 @@ +.. This file is automatically generated. Do not edit this file directly. + +Google Cloud IoT Core Python Samples +=============================================================================== + +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-iot&page=editor&open_in_editor=iot/api-client/mqtt_example/README.rst + + +This directory contains samples for `Google Cloud IoT Core`_. Cloud IoT Core allows developers to easily integrate Publish and Subscribe functionality with devices and programmatically manage device authorization. +This example connects a device to Cloud IoT Core via MQTT, using a JWT for authentication. After connecting, the device publishes messages to the device's MQTT topic at a rate of one per second. +Note that before you can run this sample, you must register a device as described in the `Cloud IoT device docs `_. For the gateway samples, you must register and bind a device as described in the `Cloud IoT gateway docs `_. + + + + +.. _Google Cloud IoT Core: https://cloud.google.com/iot/docs + + + + + +Setup +------------------------------------------------------------------------------- + + +Authentication +++++++++++++++ + +This sample requires you to have authentication setup. Refer to the +`Authentication Getting Started Guide`_ for instructions on setting up +credentials for applications. + +.. _Authentication Getting Started Guide: + https://cloud.google.com/docs/authentication/getting-started + +Install Dependencies +++++++++++++++++++++ + +#. Clone python-iot and change directory to the sample directory you want to use. + + .. code-block:: bash + + $ git clone https://github.com/googleapis/python-iot.git + +#. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. + + .. _Python Development Environment Setup Guide: + https://cloud.google.com/python/setup + +#. Create a virtualenv. Samples are compatible with Python 3.6+. + + .. code-block:: bash + + $ virtualenv env + $ source env/bin/activate + +#. Install the dependencies needed to run the samples. + + .. code-block:: bash + + $ pip install -r requirements.txt + +.. _pip: https://pip.pypa.io/ +.. _virtualenv: https://virtualenv.pypa.io/ + +Samples +------------------------------------------------------------------------------- + +MQTT example ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. image:: https://gstatic.com/cloudssh/images/open-btn.png + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-iot&page=editor&open_in_editor=iot/api-client/mqtt_example/cloudiot_mqtt_example.py,iot/api-client/mqtt_example/README.rst + + + + +To run this sample: + +.. code-block:: no-highlight + + $ python cloudiot_mqtt_example.py + + usage: cloudiot_mqtt_example.py [-h] --algorithm {RS256,ES256} + [--ca_certs CA_CERTS] + [--cloud_region CLOUD_REGION] [--data DATA] + --device_id DEVICE_ID + [--gateway_id GATEWAY_ID] + [--jwt_expires_minutes JWT_EXPIRES_MINUTES] + [--listen_dur LISTEN_DUR] + [--message_type {event,state}] + [--mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME] + [--mqtt_bridge_port {8883,443}] + [--num_messages NUM_MESSAGES] + --private_key_file PRIVATE_KEY_FILE + [--project_id PROJECT_ID] --registry_id + REGISTRY_ID + [--service_account_json SERVICE_ACCOUNT_JSON] + {device_demo,gateway_send,gateway_listen} ... + + Example Google Cloud IoT Core MQTT device connection code. + + positional arguments: + {device_demo,gateway_send,gateway_listen} + device_demo Connects a device, sends data, and receives data. + gateway_send Sends data from a gateway on behalf of a device that + is bound to it. + gateway_listen Listens for messages sent to the gateway and bound + devices. + + optional arguments: + -h, --help show this help message and exit + --algorithm {RS256,ES256} + Which encryption algorithm to use to generate the JWT. + --ca_certs CA_CERTS CA root from https://pki.google.com/roots.pem + --cloud_region CLOUD_REGION + GCP cloud region + --data DATA The telemetry data sent on behalf of a device + --device_id DEVICE_ID + Cloud IoT Core device id + --gateway_id GATEWAY_ID + Gateway identifier. + --jwt_expires_minutes JWT_EXPIRES_MINUTES + Expiration time, in minutes, for JWT tokens. + --listen_dur LISTEN_DUR + Duration (seconds) to listen for configuration + messages + --message_type {event,state} + Indicates whether the message to be published is a + telemetry event or a device state message. + --mqtt_bridge_hostname MQTT_BRIDGE_HOSTNAME + MQTT bridge hostname. + --mqtt_bridge_port {8883,443} + MQTT bridge port. + --num_messages NUM_MESSAGES + Number of messages to publish. + --private_key_file PRIVATE_KEY_FILE + Path to private key file. + --project_id PROJECT_ID + GCP cloud project name + --registry_id REGISTRY_ID + Cloud IoT Core registry id + --service_account_json SERVICE_ACCOUNT_JSON + Path to service account json file. + + + + + +.. _Google Cloud SDK: https://cloud.google.com/sdk/ \ No newline at end of file diff --git a/samples/api-client/mqtt_example/README.rst.in b/samples/api-client/mqtt_example/README.rst.in new file mode 100644 index 00000000..842e76e1 --- /dev/null +++ b/samples/api-client/mqtt_example/README.rst.in @@ -0,0 +1,32 @@ +# This file is used to generate README.rst + +product: + name: Google Cloud IoT Core + short_name: Cloud IoT Core + url: https://cloud.google.com/iot/docs + description: > + Cloud IoT Core allows developers to easily integrate Publish and + Subscribe functionality with devices and programmatically manage device + authorization. + + This example connects a device to Cloud IoT Core via MQTT, using a JWT for + authentication. After connecting, the device publishes messages to the device's + MQTT topic at a rate of one per second. + + Note that before you can run this sample, you must register a device as described + in the `Cloud IoT device docs `_. + For the gateway samples, you must register and bind a device as described in the + `Cloud IoT gateway docs `_. + +setup: +- auth +- install_deps + +samples: +- name: MQTT example + file: cloudiot_mqtt_example.py + show_help: True + +cloud_client_library: false + +folder: iot/api-client/mqtt_example diff --git a/samples/api-client/mqtt_example/cloudiot_mqtt_example.py b/samples/api-client/mqtt_example/cloudiot_mqtt_example.py index 70085a78..b52107c9 100644 --- a/samples/api-client/mqtt_example/cloudiot_mqtt_example.py +++ b/samples/api-client/mqtt_example/cloudiot_mqtt_example.py @@ -32,9 +32,10 @@ import jwt import paho.mqtt.client as mqtt + # [END iot_mqtt_includes] -logging.getLogger('googleapiclient.discovery_cache').setLevel(logging.CRITICAL) +logging.getLogger("googleapiclient.discovery_cache").setLevel(logging.CRITICAL) # The initial backoff time after a disconnection occurs, in seconds. minimum_backoff_time = 1 @@ -63,34 +64,39 @@ def create_jwt(project_id, private_key_file, algorithm): """ token = { - # The time that the token was issued at - 'iat': datetime.datetime.utcnow(), - # The time the token expires. - 'exp': datetime.datetime.utcnow() + datetime.timedelta(minutes=20), - # The audience field should always be set to the GCP project id. - 'aud': project_id + # The time that the token was issued at + "iat": datetime.datetime.utcnow(), + # The time the token expires. + "exp": datetime.datetime.utcnow() + datetime.timedelta(minutes=20), + # The audience field should always be set to the GCP project id. + "aud": project_id, } # Read the private key file. - with open(private_key_file, 'r') as f: + with open(private_key_file, "r") as f: private_key = f.read() - print('Creating JWT using {} from private key file {}'.format( - algorithm, private_key_file)) + print( + "Creating JWT using {} from private key file {}".format( + algorithm, private_key_file + ) + ) return jwt.encode(token, private_key, algorithm=algorithm) + + # [END iot_mqtt_jwt] # [START iot_mqtt_config] def error_str(rc): """Convert a Paho error to a human readable string.""" - return '{}: {}'.format(rc, mqtt.error_string(rc)) + return "{}: {}".format(rc, mqtt.error_string(rc)) def on_connect(unused_client, unused_userdata, unused_flags, rc): """Callback for when a device connects.""" - print('on_connect', mqtt.connack_string(rc)) + print("on_connect", mqtt.connack_string(rc)) # After a successful connect, reset backoff time and stop backing off. global should_backoff @@ -101,7 +107,7 @@ def on_connect(unused_client, unused_userdata, unused_flags, rc): def on_disconnect(unused_client, unused_userdata, rc): """Paho callback for when a device disconnects.""" - print('on_disconnect', error_str(rc)) + print("on_disconnect", error_str(rc)) # Since a disconnect occurred, the next loop iteration will wait with # exponential backoff. @@ -111,33 +117,47 @@ def on_disconnect(unused_client, unused_userdata, rc): def on_publish(unused_client, unused_userdata, unused_mid): """Paho callback when a message is sent to the broker.""" - print('on_publish') + print("on_publish") def on_message(unused_client, unused_userdata, message): """Callback when the device receives a message on a subscription.""" - payload = str(message.payload.decode('utf-8')) - print('Received message \'{}\' on topic \'{}\' with Qos {}'.format( - payload, message.topic, str(message.qos))) + payload = str(message.payload.decode("utf-8")) + print( + "Received message '{}' on topic '{}' with Qos {}".format( + payload, message.topic, str(message.qos) + ) + ) def get_client( - project_id, cloud_region, registry_id, device_id, private_key_file, - algorithm, ca_certs, mqtt_bridge_hostname, mqtt_bridge_port): - """Create our MQTT client. The client_id is a unique string that identifies - this device. For Google Cloud IoT Core, it must be in the format below.""" - client_id = 'projects/{}/locations/{}/registries/{}/devices/{}'.format( - project_id, cloud_region, registry_id, device_id) - print('Device client_id is \'{}\''.format(client_id)) + project_id, + cloud_region, + registry_id, + device_id, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, +): + """Create our MQTT client. + + The client_id is a unique string that identifies this device. + For Google Cloud IoT Core, it must be in the format below. + """ + client_id = "projects/{}/locations/{}/registries/{}/devices/{}".format( + project_id, cloud_region, registry_id, device_id + ) + print("Device client_id is '{}'".format(client_id)) client = mqtt.Client(client_id=client_id) # With Google Cloud IoT Core, the username field is ignored, and the # password field is used to transmit a JWT to authorize the device. client.username_pw_set( - username='unused', - password=create_jwt( - project_id, private_key_file, algorithm)) + username="unused", password=create_jwt(project_id, private_key_file, algorithm) + ) # Enable SSL/TLS support. client.tls_set(ca_certs=ca_certs, tls_version=ssl.PROTOCOL_TLSv1_2) @@ -154,45 +174,59 @@ def get_client( client.connect(mqtt_bridge_hostname, mqtt_bridge_port) # This is the topic that the device will receive configuration updates on. - mqtt_config_topic = '/devices/{}/config'.format(device_id) + mqtt_config_topic = "/devices/{}/config".format(device_id) # Subscribe to the config topic. client.subscribe(mqtt_config_topic, qos=1) # The topic that the device will receive commands on. - mqtt_command_topic = '/devices/{}/commands/#'.format(device_id) + mqtt_command_topic = "/devices/{}/commands/#".format(device_id) # Subscribe to the commands topic, QoS 1 enables message acknowledgement. - print('Subscribing to {}'.format(mqtt_command_topic)) + print("Subscribing to {}".format(mqtt_command_topic)) client.subscribe(mqtt_command_topic, qos=0) return client + + # [END iot_mqtt_config] def detach_device(client, device_id): """Detach the device from the gateway.""" # [START iot_detach_device] - detach_topic = '/devices/{}/detach'.format(device_id) - print('Detaching: {}'.format(detach_topic)) - client.publish(detach_topic, '{}', qos=1) + detach_topic = "/devices/{}/detach".format(device_id) + print("Detaching: {}".format(detach_topic)) + client.publish(detach_topic, "{}", qos=1) # [END iot_detach_device] def attach_device(client, device_id, auth): """Attach the device to the gateway.""" # [START iot_attach_device] - attach_topic = '/devices/{}/attach'.format(device_id) + attach_topic = "/devices/{}/attach".format(device_id) attach_payload = '{{"authorization" : "{}"}}'.format(auth) client.publish(attach_topic, attach_payload, qos=1) # [END iot_attach_device] def listen_for_messages( - service_account_json, project_id, cloud_region, registry_id, device_id, - gateway_id, num_messages, private_key_file, algorithm, ca_certs, - mqtt_bridge_hostname, mqtt_bridge_port, jwt_expires_minutes, duration, - cb=None): + service_account_json, + project_id, + cloud_region, + registry_id, + device_id, + gateway_id, + num_messages, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + jwt_expires_minutes, + duration, + cb=None, +): """Listens for messages sent to the gateway and bound devices.""" # [START iot_listen_for_messages] global minimum_backoff_time @@ -201,24 +235,31 @@ def listen_for_messages( jwt_exp_mins = jwt_expires_minutes # Use gateway to connect to server client = get_client( - project_id, cloud_region, registry_id, gateway_id, - private_key_file, algorithm, ca_certs, mqtt_bridge_hostname, - mqtt_bridge_port) - - attach_device(client, device_id, '') - print('Waiting for device to attach.') + project_id, + cloud_region, + registry_id, + gateway_id, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + ) + + attach_device(client, device_id, "") + print("Waiting for device to attach.") time.sleep(5) # The topic devices receive configuration updates on. - device_config_topic = '/devices/{}/config'.format(device_id) + device_config_topic = "/devices/{}/config".format(device_id) client.subscribe(device_config_topic, qos=1) # The topic gateways receive configuration updates on. - gateway_config_topic = '/devices/{}/config'.format(gateway_id) + gateway_config_topic = "/devices/{}/config".format(gateway_id) client.subscribe(gateway_config_topic, qos=1) # The topic gateways receive error updates on. QoS must be 0. - error_topic = '/devices/{}/errors'.format(gateway_id) + error_topic = "/devices/{}/errors".format(gateway_id) client.subscribe(error_topic, qos=0) # Wait for about a minute for config messages. @@ -230,7 +271,7 @@ def listen_for_messages( if should_backoff: # If backoff time is too large, give up. if minimum_backoff_time > MAXIMUM_BACKOFF_TIME: - print('Exceeded maximum backoff time. Giving up.') + print("Exceeded maximum backoff time. Giving up.") break delay = minimum_backoff_time + random.randint(0, 1000) / 1000.0 @@ -240,49 +281,75 @@ def listen_for_messages( seconds_since_issue = (datetime.datetime.utcnow() - jwt_iat).seconds if seconds_since_issue > 60 * jwt_exp_mins: - print('Refreshing token after {}s'.format(seconds_since_issue)) + print("Refreshing token after {}s".format(seconds_since_issue)) jwt_iat = datetime.datetime.utcnow() client.loop() client.disconnect() client = get_client( - project_id, cloud_region, registry_id, gateway_id, - private_key_file, algorithm, ca_certs, mqtt_bridge_hostname, - mqtt_bridge_port) + project_id, + cloud_region, + registry_id, + gateway_id, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + ) time.sleep(1) detach_device(client, device_id) - print('Finished.') + print("Finished.") # [END iot_listen_for_messages] def send_data_from_bound_device( - service_account_json, project_id, cloud_region, registry_id, device_id, - gateway_id, num_messages, private_key_file, algorithm, ca_certs, - mqtt_bridge_hostname, mqtt_bridge_port, jwt_expires_minutes, payload): + service_account_json, + project_id, + cloud_region, + registry_id, + device_id, + gateway_id, + num_messages, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + jwt_expires_minutes, + payload, +): """Sends data from a gateway on behalf of a device that is bound to it.""" # [START send_data_from_bound_device] global minimum_backoff_time # Publish device events and gateway state. - device_topic = '/devices/{}/{}'.format(device_id, 'state') - gateway_topic = '/devices/{}/{}'.format(gateway_id, 'state') + device_topic = "/devices/{}/{}".format(device_id, "state") + gateway_topic = "/devices/{}/{}".format(gateway_id, "state") jwt_iat = datetime.datetime.utcnow() jwt_exp_mins = jwt_expires_minutes # Use gateway to connect to server client = get_client( - project_id, cloud_region, registry_id, gateway_id, - private_key_file, algorithm, ca_certs, mqtt_bridge_hostname, - mqtt_bridge_port) - - attach_device(client, device_id, '') - print('Waiting for device to attach.') + project_id, + cloud_region, + registry_id, + gateway_id, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + ) + + attach_device(client, device_id, "") + print("Waiting for device to attach.") time.sleep(5) # Publish state to gateway topic - gateway_state = 'Starting gateway at: {}'.format(time.time()) + gateway_state = "Starting gateway at: {}".format(time.time()) print(gateway_state) client.publish(gateway_topic, gateway_state, qos=1) @@ -293,7 +360,7 @@ def send_data_from_bound_device( if should_backoff: # If backoff time is too large, give up. if minimum_backoff_time > MAXIMUM_BACKOFF_TIME: - print('Exceeded maximum backoff time. Giving up.') + print("Exceeded maximum backoff time. Giving up.") break delay = minimum_backoff_time + random.randint(0, 1000) / 1000.0 @@ -301,114 +368,126 @@ def send_data_from_bound_device( minimum_backoff_time *= 2 client.connect(mqtt_bridge_hostname, mqtt_bridge_port) - payload = '{}/{}-{}-payload-{}'.format( - registry_id, gateway_id, device_id, i) + payload = "{}/{}-{}-payload-{}".format(registry_id, gateway_id, device_id, i) - print('Publishing message {}/{}: \'{}\' to {}'.format( - i, num_messages, payload, device_topic)) - client.publish( - device_topic, '{} : {}'.format(device_id, payload), qos=1) + print( + "Publishing message {}/{}: '{}' to {}".format( + i, num_messages, payload, device_topic + ) + ) + client.publish(device_topic, "{} : {}".format(device_id, payload), qos=1) seconds_since_issue = (datetime.datetime.utcnow() - jwt_iat).seconds if seconds_since_issue > 60 * jwt_exp_mins: - print('Refreshing token after {}s').format(seconds_since_issue) + print("Refreshing token after {}s").format(seconds_since_issue) jwt_iat = datetime.datetime.utcnow() client = get_client( - project_id, cloud_region, registry_id, gateway_id, - private_key_file, algorithm, ca_certs, mqtt_bridge_hostname, - mqtt_bridge_port) + project_id, + cloud_region, + registry_id, + gateway_id, + private_key_file, + algorithm, + ca_certs, + mqtt_bridge_hostname, + mqtt_bridge_port, + ) time.sleep(5) detach_device(client, device_id) - print('Finished.') + print("Finished.") # [END send_data_from_bound_device] def parse_command_line_args(): """Parse command line arguments.""" - parser = argparse.ArgumentParser(description=( - 'Example Google Cloud IoT Core MQTT device connection code.')) - parser.add_argument( - '--algorithm', - choices=('RS256', 'ES256'), - required=True, - help='Which encryption algorithm to use to generate the JWT.') - parser.add_argument( - '--ca_certs', - default='roots.pem', - help='CA root from https://pki.google.com/roots.pem') + parser = argparse.ArgumentParser( + description=("Example Google Cloud IoT Core MQTT device connection code.") + ) parser.add_argument( - '--cloud_region', default='us-central1', help='GCP cloud region') + "--algorithm", + choices=("RS256", "ES256"), + required=True, + help="Which encryption algorithm to use to generate the JWT.", + ) parser.add_argument( - '--data', - default='Hello there', - help='The telemetry data sent on behalf of a device') + "--ca_certs", + default="roots.pem", + help="CA root from https://pki.google.com/roots.pem", + ) parser.add_argument( - '--device_id', required=True, help='Cloud IoT Core device id') + "--cloud_region", default="us-central1", help="GCP cloud region" + ) parser.add_argument( - '--gateway_id', required=False, help='Gateway identifier.') + "--data", + default="Hello there", + help="The telemetry data sent on behalf of a device", + ) + parser.add_argument("--device_id", required=True, help="Cloud IoT Core device id") + parser.add_argument("--gateway_id", required=False, help="Gateway identifier.") parser.add_argument( - '--jwt_expires_minutes', - default=20, - type=int, - help='Expiration time, in minutes, for JWT tokens.') + "--jwt_expires_minutes", + default=20, + type=int, + help="Expiration time, in minutes, for JWT tokens.", + ) parser.add_argument( - '--listen_dur', - default=60, - type=int, - help='Duration (seconds) to listen for configuration messages') + "--listen_dur", + default=60, + type=int, + help="Duration (seconds) to listen for configuration messages", + ) parser.add_argument( - '--message_type', - choices=('event', 'state'), - default='event', - help=('Indicates whether the message to be published is a ' - 'telemetry event or a device state message.')) + "--message_type", + choices=("event", "state"), + default="event", + help=( + "Indicates whether the message to be published is a " + "telemetry event or a device state message." + ), + ) parser.add_argument( - '--mqtt_bridge_hostname', - default='mqtt.googleapis.com', - help='MQTT bridge hostname.') + "--mqtt_bridge_hostname", + default="mqtt.googleapis.com", + help="MQTT bridge hostname.", + ) parser.add_argument( - '--mqtt_bridge_port', - choices=(8883, 443), - default=8883, - type=int, - help='MQTT bridge port.') + "--mqtt_bridge_port", + choices=(8883, 443), + default=8883, + type=int, + help="MQTT bridge port.", + ) parser.add_argument( - '--num_messages', - type=int, - default=100, - help='Number of messages to publish.') + "--num_messages", type=int, default=100, help="Number of messages to publish." + ) parser.add_argument( - '--private_key_file', - required=True, - help='Path to private key file.') + "--private_key_file", required=True, help="Path to private key file." + ) parser.add_argument( - '--project_id', - default=os.environ.get('GOOGLE_CLOUD_PROJECT'), - help='GCP cloud project name') + "--project_id", + default=os.environ.get("GOOGLE_CLOUD_PROJECT"), + help="GCP cloud project name", + ) parser.add_argument( - '--registry_id', required=True, help='Cloud IoT Core registry id') + "--registry_id", required=True, help="Cloud IoT Core registry id" + ) parser.add_argument( - '--service_account_json', - default=os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"), - help='Path to service account json file.') + "--service_account_json", + default=os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"), + help="Path to service account json file.", + ) # Command subparser - command = parser.add_subparsers(dest='command') + command = parser.add_subparsers(dest="command") - command.add_parser( - 'device_demo', - help=mqtt_device_demo.__doc__) + command.add_parser("device_demo", help=mqtt_device_demo.__doc__) - command.add_parser( - 'gateway_send', - help=send_data_from_bound_device.__doc__) + command.add_parser("gateway_send", help=send_data_from_bound_device.__doc__) - command.add_parser( - 'gateway_listen', - help=listen_for_messages.__doc__) + command.add_parser("gateway_listen", help=listen_for_messages.__doc__) return parser.parse_args() @@ -420,16 +499,23 @@ def mqtt_device_demo(args): global MAXIMUM_BACKOFF_TIME # Publish to the events or state topic based on the flag. - sub_topic = 'events' if args.message_type == 'event' else 'state' + sub_topic = "events" if args.message_type == "event" else "state" - mqtt_topic = '/devices/{}/{}'.format(args.device_id, sub_topic) + mqtt_topic = "/devices/{}/{}".format(args.device_id, sub_topic) jwt_iat = datetime.datetime.utcnow() jwt_exp_mins = args.jwt_expires_minutes client = get_client( - args.project_id, args.cloud_region, args.registry_id, - args.device_id, args.private_key_file, args.algorithm, - args.ca_certs, args.mqtt_bridge_hostname, args.mqtt_bridge_port) + args.project_id, + args.cloud_region, + args.registry_id, + args.device_id, + args.private_key_file, + args.algorithm, + args.ca_certs, + args.mqtt_bridge_hostname, + args.mqtt_bridge_port, + ) # Publish num_messages messages to the MQTT bridge once per second. for i in range(1, args.num_messages + 1): @@ -440,32 +526,36 @@ def mqtt_device_demo(args): if should_backoff: # If backoff time is too large, give up. if minimum_backoff_time > MAXIMUM_BACKOFF_TIME: - print('Exceeded maximum backoff time. Giving up.') + print("Exceeded maximum backoff time. Giving up.") break # Otherwise, wait and connect again. delay = minimum_backoff_time + random.randint(0, 1000) / 1000.0 - print('Waiting for {} before reconnecting.'.format(delay)) + print("Waiting for {} before reconnecting.".format(delay)) time.sleep(delay) minimum_backoff_time *= 2 client.connect(args.mqtt_bridge_hostname, args.mqtt_bridge_port) - payload = '{}/{}-payload-{}'.format( - args.registry_id, args.device_id, i) - print('Publishing message {}/{}: \'{}\''.format( - i, args.num_messages, payload)) + payload = "{}/{}-payload-{}".format(args.registry_id, args.device_id, i) + print("Publishing message {}/{}: '{}'".format(i, args.num_messages, payload)) # [START iot_mqtt_jwt_refresh] seconds_since_issue = (datetime.datetime.utcnow() - jwt_iat).seconds if seconds_since_issue > 60 * jwt_exp_mins: - print('Refreshing token after {}s'.format(seconds_since_issue)) + print("Refreshing token after {}s".format(seconds_since_issue)) jwt_iat = datetime.datetime.utcnow() client.loop() client.disconnect() client = get_client( - args.project_id, args.cloud_region, - args.registry_id, args.device_id, args.private_key_file, - args.algorithm, args.ca_certs, args.mqtt_bridge_hostname, - args.mqtt_bridge_port) + args.project_id, + args.cloud_region, + args.registry_id, + args.device_id, + args.private_key_file, + args.algorithm, + args.ca_certs, + args.mqtt_bridge_hostname, + args.mqtt_bridge_port, + ) # [END iot_mqtt_jwt_refresh] # Publish "payload" to the MQTT topic. qos=1 means at least once # delivery. Cloud IoT Core also supports qos=0 for at most once @@ -482,32 +572,51 @@ def mqtt_device_demo(args): def main(): args = parse_command_line_args() - if args.command.startswith('gateway'): - if (args.gateway_id is None): - print('Error: For gateway commands you must specify a gateway ID') + if args.command.startswith("gateway"): + if args.gateway_id is None: + print("Error: For gateway commands you must specify a gateway ID") return - if args.command == 'gateway_listen': + if args.command == "gateway_listen": listen_for_messages( - args.service_account_json, args.project_id, - args.cloud_region, args.registry_id, args.device_id, - args.gateway_id, args.num_messages, args.private_key_file, - args.algorithm, args.ca_certs, args.mqtt_bridge_hostname, - args.mqtt_bridge_port, args.jwt_expires_minutes, - args.listen_dur) + args.service_account_json, + args.project_id, + args.cloud_region, + args.registry_id, + args.device_id, + args.gateway_id, + args.num_messages, + args.private_key_file, + args.algorithm, + args.ca_certs, + args.mqtt_bridge_hostname, + args.mqtt_bridge_port, + args.jwt_expires_minutes, + args.listen_dur, + ) return - elif args.command == 'gateway_send': + elif args.command == "gateway_send": send_data_from_bound_device( - args.service_account_json, args.project_id, - args.cloud_region, args.registry_id, args.device_id, - args.gateway_id, args.num_messages, args.private_key_file, - args.algorithm, args.ca_certs, args.mqtt_bridge_hostname, - args.mqtt_bridge_port, args.jwt_expires_minutes, args.data) + args.service_account_json, + args.project_id, + args.cloud_region, + args.registry_id, + args.device_id, + args.gateway_id, + args.num_messages, + args.private_key_file, + args.algorithm, + args.ca_certs, + args.mqtt_bridge_hostname, + args.mqtt_bridge_port, + args.jwt_expires_minutes, + args.data, + ) return else: mqtt_device_demo(args) - print('Finished.') + print("Finished.") -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/samples/api-client/mqtt_example/noxfile.py b/samples/api-client/mqtt_example/noxfile.py new file mode 100644 index 00000000..0e13f5f1 --- /dev/null +++ b/samples/api-client/mqtt_example/noxfile.py @@ -0,0 +1,266 @@ +# Copyright 2021 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 __future__ import print_function + +import os +from pathlib import Path +import sys +from typing import Callable, Dict, List, Optional + +import nox + + +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING +# DO NOT EDIT THIS FILE EVER! +# WARNING - WARNING - WARNING - WARNING - WARNING +# WARNING - WARNING - WARNING - WARNING - WARNING + +BLACK_VERSION = "black==19.10b0" + +# Copy `noxfile_config.py` to your directory and modify it instead. + +# `TEST_CONFIG` dict is a configuration hook that allows users to +# modify the test configurations. The values here should be in sync +# with `noxfile_config.py`. Users will copy `noxfile_config.py` into +# their directory and modify it. + +TEST_CONFIG = { + # You can opt out from the test for specific Python versions. + "ignored_versions": [], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + "enforce_type_hints": False, + # An envvar key for determining the project id to use. Change it + # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a + # build specific Cloud project. You can also use your own string + # to use your own Cloud project. + "gcloud_project_env": "GOOGLE_CLOUD_PROJECT", + # 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT', + # If you need to use a specific version of pip, + # change pip_version_override to the string representation + # of the version number, for example, "20.2.4" + "pip_version_override": None, + # A dictionary you want to inject into your test. Don't put any + # secrets here. These values will override predefined values. + "envs": {}, +} + + +try: + # Ensure we can import noxfile_config in the project's directory. + sys.path.append(".") + from noxfile_config import TEST_CONFIG_OVERRIDE +except ImportError as e: + print("No user noxfile_config found: detail: {}".format(e)) + TEST_CONFIG_OVERRIDE = {} + +# Update the TEST_CONFIG with the user supplied values. +TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) + + +def get_pytest_env_vars() -> Dict[str, str]: + """Returns a dict for pytest invocation.""" + ret = {} + + # Override the GCLOUD_PROJECT and the alias. + env_key = TEST_CONFIG["gcloud_project_env"] + # This should error out if not set. + ret["GOOGLE_CLOUD_PROJECT"] = os.environ[env_key] + + # Apply user supplied envs. + ret.update(TEST_CONFIG["envs"]) + return ret + + +# DO NOT EDIT - automatically generated. +# All versions used to test samples. +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] + +# Any default versions that should be ignored. +IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] + +TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS]) + +INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in ( + "True", + "true", +) +# +# Style Checks +# + + +def _determine_local_import_names(start_dir: str) -> List[str]: + """Determines all import names that should be considered "local". + + This is used when running the linter to insure that import order is + properly checked. + """ + file_ext_pairs = [os.path.splitext(path) for path in os.listdir(start_dir)] + return [ + basename + for basename, extension in file_ext_pairs + if extension == ".py" + or os.path.isdir(os.path.join(start_dir, basename)) + and basename not in ("__pycache__") + ] + + +# Linting with flake8. +# +# We ignore the following rules: +# E203: whitespace before ‘:’ +# E266: too many leading ‘#’ for block comment +# E501: line too long +# I202: Additional newline in a section of imports +# +# We also need to specify the rules which are ignored by default: +# ['E226', 'W504', 'E126', 'E123', 'W503', 'E24', 'E704', 'E121'] +FLAKE8_COMMON_ARGS = [ + "--show-source", + "--builtin=gettext", + "--max-complexity=20", + "--import-order-style=google", + "--exclude=.nox,.cache,env,lib,generated_pb2,*_pb2.py,*_pb2_grpc.py", + "--ignore=E121,E123,E126,E203,E226,E24,E266,E501,E704,W503,W504,I202", + "--max-line-length=88", +] + + +@nox.session +def lint(session: nox.sessions.Session) -> None: + if not TEST_CONFIG["enforce_type_hints"]: + session.install("flake8", "flake8-import-order") + else: + session.install("flake8", "flake8-import-order", "flake8-annotations") + + local_names = _determine_local_import_names(".") + args = FLAKE8_COMMON_ARGS + [ + "--application-import-names", + ",".join(local_names), + ".", + ] + session.run("flake8", *args) + + +# +# Black +# + + +@nox.session +def blacken(session: nox.sessions.Session) -> None: + session.install(BLACK_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + session.run("black", *python_files) + + +# +# Sample Tests +# + + +PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] + + +def _session_tests( + session: nox.sessions.Session, post_install: Callable = None +) -> None: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) + + +@nox.session(python=ALL_VERSIONS) +def py(session: nox.sessions.Session) -> None: + """Runs py.test for a sample using the specified version of Python.""" + if session.python in TESTED_VERSIONS: + _session_tests(session) + else: + session.skip( + "SKIPPED: {} tests are disabled for this sample.".format(session.python) + ) + + +# +# Readmegen +# + + +def _get_repo_root() -> Optional[str]: + """ Returns the root folder of the project. """ + # Get root of this repository. Assume we don't have directories nested deeper than 10 items. + p = Path(os.getcwd()) + for i in range(10): + if p is None: + break + if Path(p / ".git").exists(): + return str(p) + # .git is not available in repos cloned via Cloud Build + # setup.py is always in the library's root, so use that instead + # https://github.com/googleapis/synthtool/issues/792 + if Path(p / "setup.py").exists(): + return str(p) + p = p.parent + raise Exception("Unable to detect repository root.") + + +GENERATED_READMES = sorted([x for x in Path(".").rglob("*.rst.in")]) + + +@nox.session +@nox.parametrize("path", GENERATED_READMES) +def readmegen(session: nox.sessions.Session, path: str) -> None: + """(Re-)generates the readme for a sample.""" + session.install("jinja2", "pyyaml") + dir_ = os.path.dirname(path) + + if os.path.exists(os.path.join(dir_, "requirements.txt")): + session.install("-r", os.path.join(dir_, "requirements.txt")) + + in_file = os.path.join(dir_, "README.rst.in") + session.run( + "python", _get_repo_root() + "/scripts/readme-gen/readme_gen.py", in_file + ) diff --git a/samples/api-client/mqtt_example/requirements-test.txt b/samples/api-client/mqtt_example/requirements-test.txt new file mode 100644 index 00000000..92709451 --- /dev/null +++ b/samples/api-client/mqtt_example/requirements-test.txt @@ -0,0 +1 @@ +pytest==6.2.5 diff --git a/samples/api-client/mqtt_example/requirements.txt b/samples/api-client/mqtt_example/requirements.txt new file mode 100644 index 00000000..0afecdd9 --- /dev/null +++ b/samples/api-client/mqtt_example/requirements.txt @@ -0,0 +1,2 @@ +paho-mqtt==1.5.1 +pyjwt==2.1.0 diff --git a/scripts/readme-gen/templates/README.tmpl.rst b/scripts/readme-gen/templates/README.tmpl.rst index 4fd23976..faa6071c 100644 --- a/scripts/readme-gen/templates/README.tmpl.rst +++ b/scripts/readme-gen/templates/README.tmpl.rst @@ -6,7 +6,7 @@ =============================================================================== .. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/README.rst + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-iot&page=editor&open_in_editor={{folder}}/README.rst This directory contains samples for {{product.name}}. {{product.description}} @@ -46,7 +46,7 @@ Samples {% if not sample.hide_cloudshell_button %} .. image:: https://gstatic.com/cloudssh/images/open-btn.png - :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/python-docs-samples&page=editor&open_in_editor={{folder}}/{{sample.file}},{{folder}}/README.rst + :target: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/python-iot&page=editor&open_in_editor={{folder}}/{{sample.file}},{{folder}}/README.rst {% endif %} diff --git a/scripts/readme-gen/templates/install_deps.tmpl.rst b/scripts/readme-gen/templates/install_deps.tmpl.rst index 275d6498..ca60ac23 100644 --- a/scripts/readme-gen/templates/install_deps.tmpl.rst +++ b/scripts/readme-gen/templates/install_deps.tmpl.rst @@ -1,11 +1,11 @@ Install Dependencies ++++++++++++++++++++ -#. Clone python-docs-samples and change directory to the sample directory you want to use. +#. Clone python-iot and change directory to the sample directory you want to use. .. code-block:: bash - $ git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git + $ git clone https://github.com/googleapis/python-iot.git #. Install `pip`_ and `virtualenv`_ if you do not already have them. You may want to refer to the `Python Development Environment Setup Guide`_ for Google Cloud Platform for instructions. From 18d869a87e3346c8dabb3bd27a3ee74c237ce370 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 30 Sep 2021 09:40:50 +0000 Subject: [PATCH 02/28] chore: use gapic-generator-python 0.52.0 (#197) - [ ] Regenerate this pull request now. fix: improper types in pagers generation PiperOrigin-RevId: 399773015 Source-Link: https://github.com/googleapis/googleapis/commit/410c184536a22fadaf00aec3cab04102e34d2322 Source-Link: https://github.com/googleapis/googleapis-gen/commit/290e883545e3ac9ff2bd00cd0dacb28f1b8ca945 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjkwZTg4MzU0NWUzYWM5ZmYyYmQwMGNkMGRhY2IyOGYxYjhjYTk0NSJ9 --- .../iot_v1/services/device_manager/pagers.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/google/cloud/iot_v1/services/device_manager/pagers.py b/google/cloud/iot_v1/services/device_manager/pagers.py index 166e0f5b..e84f8b43 100644 --- a/google/cloud/iot_v1/services/device_manager/pagers.py +++ b/google/cloud/iot_v1/services/device_manager/pagers.py @@ -15,13 +15,13 @@ # from typing import ( Any, - AsyncIterable, + AsyncIterator, Awaitable, Callable, - Iterable, Sequence, Tuple, Optional, + Iterator, ) from google.cloud.iot_v1.types import device_manager @@ -75,14 +75,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - def pages(self) -> Iterable[device_manager.ListDeviceRegistriesResponse]: + def pages(self) -> Iterator[device_manager.ListDeviceRegistriesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterable[resources.DeviceRegistry]: + def __iter__(self) -> Iterator[resources.DeviceRegistry]: for page in self.pages: yield from page.device_registries @@ -137,14 +137,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - async def pages(self) -> AsyncIterable[device_manager.ListDeviceRegistriesResponse]: + async def pages(self) -> AsyncIterator[device_manager.ListDeviceRegistriesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterable[resources.DeviceRegistry]: + def __aiter__(self) -> AsyncIterator[resources.DeviceRegistry]: async def async_generator(): async for page in self.pages: for response in page.device_registries: @@ -203,14 +203,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - def pages(self) -> Iterable[device_manager.ListDevicesResponse]: + def pages(self) -> Iterator[device_manager.ListDevicesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = self._method(self._request, metadata=self._metadata) yield self._response - def __iter__(self) -> Iterable[resources.Device]: + def __iter__(self) -> Iterator[resources.Device]: for page in self.pages: yield from page.devices @@ -265,14 +265,14 @@ def __getattr__(self, name: str) -> Any: return getattr(self._response, name) @property - async def pages(self) -> AsyncIterable[device_manager.ListDevicesResponse]: + async def pages(self) -> AsyncIterator[device_manager.ListDevicesResponse]: yield self._response while self._response.next_page_token: self._request.page_token = self._response.next_page_token self._response = await self._method(self._request, metadata=self._metadata) yield self._response - def __aiter__(self) -> AsyncIterable[resources.Device]: + def __aiter__(self) -> AsyncIterator[resources.Device]: async def async_generator(): async for page in self.pages: for response in page.devices: From 0ca174a21bc0a8e2891511582f5c592062dd50a8 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 30 Sep 2021 15:44:49 +0000 Subject: [PATCH 03/28] chore: fail samples nox session if python version is missing (#199) --- .github/.OwlBot.lock.yaml | 2 +- samples/api-client/accesstoken_example/noxfile.py | 4 ++++ samples/api-client/manager/noxfile.py | 4 ++++ samples/api-client/mqtt_example/noxfile.py | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 2567653c..ae6c57fa 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:87eee22d276554e4e52863ec9b1cb6a7245815dfae20439712bf644348215a5a + digest: sha256:82b12321da4446a73cb11bcb6812fbec8c105abda3946d46e6394e5fbfb64c0f diff --git a/samples/api-client/accesstoken_example/noxfile.py b/samples/api-client/accesstoken_example/noxfile.py index 0e13f5f1..bcce5b6a 100644 --- a/samples/api-client/accesstoken_example/noxfile.py +++ b/samples/api-client/accesstoken_example/noxfile.py @@ -98,6 +98,10 @@ def get_pytest_env_vars() -> Dict[str, str]: "True", "true", ) + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + # # Style Checks # diff --git a/samples/api-client/manager/noxfile.py b/samples/api-client/manager/noxfile.py index b008613f..1fd8956f 100644 --- a/samples/api-client/manager/noxfile.py +++ b/samples/api-client/manager/noxfile.py @@ -98,6 +98,10 @@ def get_pytest_env_vars() -> Dict[str, str]: "True", "true", ) + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + # # Style Checks # diff --git a/samples/api-client/mqtt_example/noxfile.py b/samples/api-client/mqtt_example/noxfile.py index 0e13f5f1..bcce5b6a 100644 --- a/samples/api-client/mqtt_example/noxfile.py +++ b/samples/api-client/mqtt_example/noxfile.py @@ -98,6 +98,10 @@ def get_pytest_env_vars() -> Dict[str, str]: "True", "true", ) + +# Error if a python version is missing +nox.options.error_on_missing_interpreters = True + # # Style Checks # From c2bcbde466f2ca59df14e790ad24786e9ca53ae9 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 5 Oct 2021 11:15:47 -0600 Subject: [PATCH 04/28] build: use trampoline_v2 for python samples and allow custom dockerfile (#201) Source-Link: https://github.com/googleapis/synthtool/commit/a7ed11ec0863c422ba2e73aafa75eab22c32b33d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6e7328583be8edd3ba8f35311c76a1ecbc823010279ccb6ab46b7a76e25eafcc Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/samples/lint/common.cfg | 2 +- .kokoro/samples/python3.6/common.cfg | 2 +- .kokoro/samples/python3.6/periodic.cfg | 2 +- .kokoro/samples/python3.7/common.cfg | 2 +- .kokoro/samples/python3.7/periodic.cfg | 2 +- .kokoro/samples/python3.8/common.cfg | 2 +- .kokoro/samples/python3.8/periodic.cfg | 2 +- .kokoro/samples/python3.9/common.cfg | 2 +- .kokoro/samples/python3.9/periodic.cfg | 2 +- .kokoro/test-samples-against-head.sh | 2 -- .kokoro/test-samples.sh | 2 -- .trampolinerc | 17 ++++++++++++++--- 13 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ae6c57fa..ee94722a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:82b12321da4446a73cb11bcb6812fbec8c105abda3946d46e6394e5fbfb64c0f + digest: sha256:6e7328583be8edd3ba8f35311c76a1ecbc823010279ccb6ab46b7a76e25eafcc diff --git a/.kokoro/samples/lint/common.cfg b/.kokoro/samples/lint/common.cfg index aef9ae58..3f9071b6 100644 --- a/.kokoro/samples/lint/common.cfg +++ b/.kokoro/samples/lint/common.cfg @@ -31,4 +31,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-iot/.kokoro/trampoline.sh" \ No newline at end of file +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg index 1d2fcd9c..f630deef 100644 --- a/.kokoro/samples/python3.6/common.cfg +++ b/.kokoro/samples/python3.6/common.cfg @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-iot/.kokoro/trampoline.sh" \ No newline at end of file +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.6/periodic.cfg b/.kokoro/samples/python3.6/periodic.cfg index 50fec964..71cd1e59 100644 --- a/.kokoro/samples/python3.6/periodic.cfg +++ b/.kokoro/samples/python3.6/periodic.cfg @@ -3,4 +3,4 @@ env_vars: { key: "INSTALL_LIBRARY_FROM_SOURCE" value: "False" -} \ No newline at end of file +} diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg index b9a0e192..12f78320 100644 --- a/.kokoro/samples/python3.7/common.cfg +++ b/.kokoro/samples/python3.7/common.cfg @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-iot/.kokoro/trampoline.sh" \ No newline at end of file +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.7/periodic.cfg b/.kokoro/samples/python3.7/periodic.cfg index 50fec964..71cd1e59 100644 --- a/.kokoro/samples/python3.7/periodic.cfg +++ b/.kokoro/samples/python3.7/periodic.cfg @@ -3,4 +3,4 @@ env_vars: { key: "INSTALL_LIBRARY_FROM_SOURCE" value: "False" -} \ No newline at end of file +} diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg index 42080967..5e3ddd69 100644 --- a/.kokoro/samples/python3.8/common.cfg +++ b/.kokoro/samples/python3.8/common.cfg @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-iot/.kokoro/trampoline.sh" \ No newline at end of file +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.8/periodic.cfg b/.kokoro/samples/python3.8/periodic.cfg index 50fec964..71cd1e59 100644 --- a/.kokoro/samples/python3.8/periodic.cfg +++ b/.kokoro/samples/python3.8/periodic.cfg @@ -3,4 +3,4 @@ env_vars: { key: "INSTALL_LIBRARY_FROM_SOURCE" value: "False" -} \ No newline at end of file +} diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg index 276747ee..d4223f92 100644 --- a/.kokoro/samples/python3.9/common.cfg +++ b/.kokoro/samples/python3.9/common.cfg @@ -37,4 +37,4 @@ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" # Use the trampoline script to run in docker. -build_file: "python-iot/.kokoro/trampoline.sh" \ No newline at end of file +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg index 50fec964..71cd1e59 100644 --- a/.kokoro/samples/python3.9/periodic.cfg +++ b/.kokoro/samples/python3.9/periodic.cfg @@ -3,4 +3,4 @@ env_vars: { key: "INSTALL_LIBRARY_FROM_SOURCE" value: "False" -} \ No newline at end of file +} diff --git a/.kokoro/test-samples-against-head.sh b/.kokoro/test-samples-against-head.sh index 9c281f84..ba3a707b 100755 --- a/.kokoro/test-samples-against-head.sh +++ b/.kokoro/test-samples-against-head.sh @@ -23,6 +23,4 @@ set -eo pipefail # Enables `**` to include files nested inside sub-folders shopt -s globstar -cd github/python-iot - exec .kokoro/test-samples-impl.sh diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index 1f9137a8..11c042d3 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -24,8 +24,6 @@ set -eo pipefail # Enables `**` to include files nested inside sub-folders shopt -s globstar -cd github/python-iot - # Run periodic samples tests at latest release if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then # preserving the test runner implementation. diff --git a/.trampolinerc b/.trampolinerc index 383b6ec8..0eee72ab 100644 --- a/.trampolinerc +++ b/.trampolinerc @@ -16,15 +16,26 @@ # Add required env vars here. required_envvars+=( - "STAGING_BUCKET" - "V2_STAGING_BUCKET" ) # Add env vars which are passed down into the container here. pass_down_envvars+=( + "NOX_SESSION" + ############### + # Docs builds + ############### "STAGING_BUCKET" "V2_STAGING_BUCKET" - "NOX_SESSION" + ################## + # Samples builds + ################## + "INSTALL_LIBRARY_FROM_SOURCE" + "RUN_TESTS_SESSION" + "BUILD_SPECIFIC_GCLOUD_PROJECT" + # Target directories. + "RUN_TESTS_DIRS" + # The nox session to run. + "RUN_TESTS_SESSION" ) # Prevent unintentional override on the default image. From 14c4ab6bd0589111743b4629fbd10c86a43aa698 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 00:42:22 +0000 Subject: [PATCH 05/28] feat: add context manager support in client (#202) - [ ] Regenerate this pull request now. chore: fix docstring for first attribute of protos committer: @busunkim96 PiperOrigin-RevId: 401271153 Source-Link: https://github.com/googleapis/googleapis/commit/787f8c9a731f44e74a90b9847d48659ca9462d10 Source-Link: https://github.com/googleapis/googleapis-gen/commit/81decffe9fc72396a8153e756d1d67a6eecfd620 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9 --- .../services/device_manager/async_client.py | 6 +++ .../iot_v1/services/device_manager/client.py | 18 +++++-- .../device_manager/transports/base.py | 9 ++++ .../device_manager/transports/grpc.py | 3 ++ .../device_manager/transports/grpc_asyncio.py | 3 ++ google/cloud/iot_v1/types/device_manager.py | 29 +++++++++-- google/cloud/iot_v1/types/resources.py | 11 ++++ .../unit/gapic/iot_v1/test_device_manager.py | 50 +++++++++++++++++++ 8 files changed, 122 insertions(+), 7 deletions(-) diff --git a/google/cloud/iot_v1/services/device_manager/async_client.py b/google/cloud/iot_v1/services/device_manager/async_client.py index 08a35bd7..52076cde 100644 --- a/google/cloud/iot_v1/services/device_manager/async_client.py +++ b/google/cloud/iot_v1/services/device_manager/async_client.py @@ -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( diff --git a/google/cloud/iot_v1/services/device_manager/client.py b/google/cloud/iot_v1/services/device_manager/client.py index 7b32007b..e0dd2efb 100644 --- a/google/cloud/iot_v1/services/device_manager/client.py +++ b/google/cloud/iot_v1/services/device_manager/client.py @@ -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( @@ -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( diff --git a/google/cloud/iot_v1/services/device_manager/transports/base.py b/google/cloud/iot_v1/services/device_manager/transports/base.py index ae596089..50704e4b 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/base.py +++ b/google/cloud/iot_v1/services/device_manager/transports/base.py @@ -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, diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc.py b/google/cloud/iot_v1/services/device_manager/transports/grpc.py index 04b119b6..a46904f5 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc.py @@ -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",) diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py index d621cb4d..cfc119b2 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py @@ -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",) diff --git a/google/cloud/iot_v1/types/device_manager.py b/google/cloud/iot_v1/types/device_manager.py index 29ae5f4a..e5c492c1 100644 --- a/google/cloud/iot_v1/types/device_manager.py +++ b/google/cloud/iot_v1/types/device_manager.py @@ -52,6 +52,7 @@ class CreateDeviceRegistryRequest(proto.Message): r"""Request for ``CreateDeviceRegistry``. + Attributes: parent (str): Required. The project and cloud region where this device @@ -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, @@ -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, @@ -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`` @@ -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, @@ -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. @@ -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 @@ -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, @@ -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 @@ -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, @@ -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, @@ -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. @@ -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, @@ -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, @@ -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 @@ -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, @@ -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 @@ -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, @@ -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, @@ -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, @@ -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)) diff --git a/google/cloud/iot_v1/types/resources.py b/google/cloud/iot_v1/types/resources.py index f2932c13..36d92c46 100644 --- a/google/cloud/iot_v1/types/resources.py +++ b/google/cloud/iot_v1/types/resources.py @@ -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 @@ -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. @@ -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, @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 @@ -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. @@ -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 @@ -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 diff --git a/tests/unit/gapic/iot_v1/test_device_manager.py b/tests/unit/gapic/iot_v1/test_device_manager.py index f6bde2a7..262901eb 100644 --- a/tests/unit/gapic/iot_v1/test_device_manager.py +++ b/tests/unit/gapic/iot_v1/test_device_manager.py @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import path_template from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.iot_v1.services.device_manager import DeviceManagerAsyncClient @@ -5159,6 +5160,9 @@ def test_device_manager_base_transport(): with pytest.raises(NotImplementedError): getattr(transport, method)(request=object()) + with pytest.raises(NotImplementedError): + transport.close() + @requires_google_auth_gte_1_25_0 def test_device_manager_base_transport_with_credentials_file(): @@ -5686,3 +5690,49 @@ def test_client_withDEFAULT_CLIENT_INFO(): credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) + + +@pytest.mark.asyncio +async def test_transport_close_async(): + client = DeviceManagerAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + ) + with mock.patch.object( + type(getattr(client.transport, "grpc_channel")), "close" + ) as close: + async with client: + close.assert_not_called() + close.assert_called_once() + + +def test_transport_close(): + transports = { + "grpc": "_grpc_channel", + } + + for transport, close_name in transports.items(): + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + with mock.patch.object( + type(getattr(client.transport, close_name)), "close" + ) as close: + with client: + close.assert_not_called() + close.assert_called_once() + + +def test_client_ctx(): + transports = [ + "grpc", + ] + for transport in transports: + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials(), transport=transport + ) + # Test client calls underlying transport. + with mock.patch.object(type(client.transport), "close") as close: + close.assert_not_called() + with client: + pass + close.assert_called() From 119c08166d82d6cbdf45db71b4ab6093c822a541 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 7 Oct 2021 18:12:53 +0000 Subject: [PATCH 06/28] chore(python): fix formatting issue in noxfile.py.j2 (#204) --- .github/.OwlBot.lock.yaml | 2 +- CONTRIBUTING.rst | 6 ++++-- noxfile.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ee94722a..76d0baa0 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:6e7328583be8edd3ba8f35311c76a1ecbc823010279ccb6ab46b7a76e25eafcc + digest: sha256:4370ced27a324687ede5da07132dcdc5381993502a5e8a3e31e16dc631d026f0 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 2ae49064..898eb9d4 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -22,7 +22,7 @@ In order to add a feature: documentation. - The feature must work fully on the following CPython versions: - 3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows. + 3.6, 3.7, 3.8, 3.9 and 3.10 on both UNIX and Windows. - The feature must not add unnecessary dependencies (where "unnecessary" is of course subjective, but new dependencies should @@ -72,7 +72,7 @@ We use `nox `__ to instrument our tests. - To run a single unit test:: - $ nox -s unit-3.9 -- -k + $ nox -s unit-3.10 -- -k .. note:: @@ -225,11 +225,13 @@ We support: - `Python 3.7`_ - `Python 3.8`_ - `Python 3.9`_ +- `Python 3.10`_ .. _Python 3.6: https://docs.python.org/3.6/ .. _Python 3.7: https://docs.python.org/3.7/ .. _Python 3.8: https://docs.python.org/3.8/ .. _Python 3.9: https://docs.python.org/3.9/ +.. _Python 3.10: https://docs.python.org/3.10/ Supported versions can be found in our ``noxfile.py`` `config`_. diff --git a/noxfile.py b/noxfile.py index 2bf3ffd7..672b28d6 100644 --- a/noxfile.py +++ b/noxfile.py @@ -29,7 +29,7 @@ DEFAULT_PYTHON_VERSION = "3.8" SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] -UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() From 87df16600d419be91ae91dc9600e9d31c3b267f0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 18:16:15 +0000 Subject: [PATCH 07/28] chore(python): Add kokoro configs for python 3.10 samples testing (#205) --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/samples/python3.10/common.cfg | 40 +++++++++++++++++++ .kokoro/samples/python3.10/continuous.cfg | 6 +++ .kokoro/samples/python3.10/periodic-head.cfg | 11 +++++ .kokoro/samples/python3.10/periodic.cfg | 6 +++ .kokoro/samples/python3.10/presubmit.cfg | 6 +++ .../api-client/accesstoken_example/noxfile.py | 2 +- samples/api-client/manager/noxfile.py | 2 +- samples/api-client/mqtt_example/noxfile.py | 2 +- 9 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 .kokoro/samples/python3.10/common.cfg create mode 100644 .kokoro/samples/python3.10/continuous.cfg create mode 100644 .kokoro/samples/python3.10/periodic-head.cfg create mode 100644 .kokoro/samples/python3.10/periodic.cfg create mode 100644 .kokoro/samples/python3.10/presubmit.cfg diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 76d0baa0..7d98291c 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4370ced27a324687ede5da07132dcdc5381993502a5e8a3e31e16dc631d026f0 + digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b diff --git a/.kokoro/samples/python3.10/common.cfg b/.kokoro/samples/python3.10/common.cfg new file mode 100644 index 00000000..8dae3de5 --- /dev/null +++ b/.kokoro/samples/python3.10/common.cfg @@ -0,0 +1,40 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Specify which tests to run +env_vars: { + key: "RUN_TESTS_SESSION" + value: "py-3.10" +} + +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-310" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iot/.kokoro/test-samples.sh" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker" +} + +# Download secrets for samples +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "python-iot/.kokoro/trampoline_v2.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.10/continuous.cfg b/.kokoro/samples/python3.10/continuous.cfg new file mode 100644 index 00000000..a1c8d975 --- /dev/null +++ b/.kokoro/samples/python3.10/continuous.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.10/periodic-head.cfg b/.kokoro/samples/python3.10/periodic-head.cfg new file mode 100644 index 00000000..1896dcfe --- /dev/null +++ b/.kokoro/samples/python3.10/periodic-head.cfg @@ -0,0 +1,11 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-iot/.kokoro/test-samples-against-head.sh" +} diff --git a/.kokoro/samples/python3.10/periodic.cfg b/.kokoro/samples/python3.10/periodic.cfg new file mode 100644 index 00000000..71cd1e59 --- /dev/null +++ b/.kokoro/samples/python3.10/periodic.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "False" +} diff --git a/.kokoro/samples/python3.10/presubmit.cfg b/.kokoro/samples/python3.10/presubmit.cfg new file mode 100644 index 00000000..a1c8d975 --- /dev/null +++ b/.kokoro/samples/python3.10/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/samples/api-client/accesstoken_example/noxfile.py b/samples/api-client/accesstoken_example/noxfile.py index bcce5b6a..6c2af674 100644 --- a/samples/api-client/accesstoken_example/noxfile.py +++ b/samples/api-client/accesstoken_example/noxfile.py @@ -87,7 +87,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] diff --git a/samples/api-client/manager/noxfile.py b/samples/api-client/manager/noxfile.py index 1fd8956f..93a9122c 100644 --- a/samples/api-client/manager/noxfile.py +++ b/samples/api-client/manager/noxfile.py @@ -87,7 +87,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] diff --git a/samples/api-client/mqtt_example/noxfile.py b/samples/api-client/mqtt_example/noxfile.py index bcce5b6a..6c2af674 100644 --- a/samples/api-client/mqtt_example/noxfile.py +++ b/samples/api-client/mqtt_example/noxfile.py @@ -87,7 +87,7 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. # All versions used to test samples. -ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"] From c1149b010f358debbebb5eea483cc628ec91549d Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 5 Nov 2021 05:31:58 -0400 Subject: [PATCH 08/28] fix: fix extras_require typo in setup.py (#210) --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index ea658b0b..e7bb03b3 100644 --- a/setup.py +++ b/setup.py @@ -74,7 +74,7 @@ packages=packages, namespace_packages=namespaces, install_requires=dependencies, - extras_requires=extras, + extras_require=extras, python_requires=">=3.6", scripts=["scripts/fixup_iot_v1_keywords.py"], include_package_data=True, From 66392104db6eec727f9795472d3ca072a4690227 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 12 Nov 2021 11:56:04 -0500 Subject: [PATCH 09/28] chore: add default_version and codeowner_team to repo-metadata.json (#216) --- .repo-metadata.json | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index 8b6371ea..72dc7de6 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -1,14 +1,16 @@ { - "name": "cloudiot", - "name_pretty": "Google Cloud Internet of Things (IoT) Core", - "product_documentation": "https://cloud.google.com/iot", - "client_documentation": "https://googleapis.dev/python/cloudiot/latest", - "issue_tracker": "https://issuetracker.google.com/issues?q=status:open%20componentid:310170", - "release_level": "ga", - "language": "python", - "library_type": "GAPIC_AUTO", - "repo": "googleapis/python-iot", - "distribution_name": "google-cloud-iot", - "api_id": "cloudiot.googleapis.com", - "requires_billing": true -} \ No newline at end of file + "name": "cloudiot", + "name_pretty": "Google Cloud Internet of Things (IoT) Core", + "product_documentation": "https://cloud.google.com/iot", + "client_documentation": "https://googleapis.dev/python/cloudiot/latest", + "issue_tracker": "https://issuetracker.google.com/issues?q=status:open%20componentid:310170", + "release_level": "ga", + "language": "python", + "library_type": "GAPIC_AUTO", + "repo": "googleapis/python-iot", + "distribution_name": "google-cloud-iot", + "api_id": "cloudiot.googleapis.com", + "requires_billing": true, + "default_version": "v1", + "codeowner_team": "@googleapis/api-iot" +} From 31a5fa89c34a7f6fea5cdcd17381ffce831584b3 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Sat, 22 Jan 2022 01:22:37 +0100 Subject: [PATCH 10/28] chore(deps): update all dependencies (#184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [cryptography](https://togithub.com/pyca/cryptography) ([changelog](https://cryptography.io/en/latest/changelog/)) | `==3.4.8` -> `==36.0.1` | [![age](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/compatibility-slim/3.4.8)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/confidence-slim/3.4.8)](https://docs.renovatebot.com/merge-confidence/) | | [cryptography](https://togithub.com/pyca/cryptography) ([changelog](https://cryptography.io/en/latest/changelog/)) | `==3.4.7` -> `==36.0.1` | [![age](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/compatibility-slim/3.4.7)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/cryptography/36.0.1/confidence-slim/3.4.7)](https://docs.renovatebot.com/merge-confidence/) | | [google-api-python-client](https://togithub.com/googleapis/google-api-python-client) | `==2.19.0` -> `==2.36.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/compatibility-slim/2.19.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/confidence-slim/2.19.0)](https://docs.renovatebot.com/merge-confidence/) | | [google-api-python-client](https://togithub.com/googleapis/google-api-python-client) | `==2.10.0` -> `==2.36.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/compatibility-slim/2.10.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-api-python-client/2.36.0/confidence-slim/2.10.0)](https://docs.renovatebot.com/merge-confidence/) | | [google-auth](https://togithub.com/googleapis/google-auth-library-python) | `==2.0.2` -> `==2.3.3` | [![age](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/compatibility-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/confidence-slim/2.0.2)](https://docs.renovatebot.com/merge-confidence/) | | [google-auth](https://togithub.com/googleapis/google-auth-library-python) | `==1.32.1` -> `==2.3.3` | [![age](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/compatibility-slim/1.32.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-auth/2.3.3/confidence-slim/1.32.1)](https://docs.renovatebot.com/merge-confidence/) | | [google-cloud-iot](https://togithub.com/googleapis/python-iot) | `==2.2.1` -> `==2.3.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/compatibility-slim/2.2.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/confidence-slim/2.2.1)](https://docs.renovatebot.com/merge-confidence/) | | [google-cloud-iot](https://togithub.com/googleapis/python-iot) | `==2.1.0` -> `==2.3.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/compatibility-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-iot/2.3.0/confidence-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | | [google-cloud-pubsub](https://togithub.com/googleapis/python-pubsub) | `==1.7.0` -> `==2.9.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.9.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.9.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.9.0/compatibility-slim/1.7.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-pubsub/2.9.0/confidence-slim/1.7.0)](https://docs.renovatebot.com/merge-confidence/) | | [google-cloud-storage](https://togithub.com/googleapis/python-storage) | `==1.42.0` -> `==2.1.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/compatibility-slim/1.42.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-storage/2.1.0/confidence-slim/1.42.0)](https://docs.renovatebot.com/merge-confidence/) | | [paho-mqtt](http://eclipse.org/paho) | `==1.5.1` -> `==1.6.1` | [![age](https://badges.renovateapi.com/packages/pypi/paho-mqtt/1.6.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/paho-mqtt/1.6.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/paho-mqtt/1.6.1/compatibility-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/paho-mqtt/1.6.1/confidence-slim/1.5.1)](https://docs.renovatebot.com/merge-confidence/) | | [pyjwt](https://togithub.com/jpadilla/pyjwt) | `==2.1.0` -> `==2.3.0` | [![age](https://badges.renovateapi.com/packages/pypi/pyjwt/2.3.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/pyjwt/2.3.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/pyjwt/2.3.0/compatibility-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/pyjwt/2.3.0/confidence-slim/2.1.0)](https://docs.renovatebot.com/merge-confidence/) | | [pytest](https://docs.pytest.org/en/latest/) ([source](https://togithub.com/pytest-dev/pytest), [changelog](https://docs.pytest.org/en/stable/changelog.html)) | `==6.2.4` -> `==6.2.5` | [![age](https://badges.renovateapi.com/packages/pypi/pytest/6.2.5/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/pytest/6.2.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/pytest/6.2.5/compatibility-slim/6.2.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/pytest/6.2.5/confidence-slim/6.2.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
pyca/cryptography ### [`v36.0.1`](https://togithub.com/pyca/cryptography/compare/36.0.0...36.0.1) [Compare Source](https://togithub.com/pyca/cryptography/compare/36.0.0...36.0.1) ### [`v36.0.0`](https://togithub.com/pyca/cryptography/compare/35.0.0...36.0.0) [Compare Source](https://togithub.com/pyca/cryptography/compare/35.0.0...36.0.0) ### [`v35.0.0`](https://togithub.com/pyca/cryptography/compare/3.4.8...35.0.0) [Compare Source](https://togithub.com/pyca/cryptography/compare/3.4.8...35.0.0)
googleapis/google-api-python-client ### [`v2.36.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2360-httpsgithubcomgoogleapisgoogle-api-python-clientcomparev2350v2360-2022-01-18) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.35.0...v2.36.0) ##### Features - **analyticsadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/981bbe36878d2c3d5687c56e89bedf562ff9b619 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **artifactregistry:** update the api https://github.com/googleapis/google-api-python-client/commit/0d1152f61591215b004f3f293cc37b995abe422c ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **content:** update the api https://github.com/googleapis/google-api-python-client/commit/195bfc241437417c544b89025ca16e9962915830 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **datapipelines:** update the api https://github.com/googleapis/google-api-python-client/commit/3bb19370a5aac772774c64c703411c6cc7343e4e ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **dataproc:** update the api https://github.com/googleapis/google-api-python-client/commit/2fc3a16831166c7ffe87864723f3fecc5edadf66 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **datastream:** update the api https://github.com/googleapis/google-api-python-client/commit/d51a6ee7486c646b061964e8a960a4a7969c0fae ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **displayvideo:** update the api https://github.com/googleapis/google-api-python-client/commit/459a6363792c76c3b62f0351f6c11c19ebec69bd ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **drive:** update the api https://github.com/googleapis/google-api-python-client/commit/92ec7cf5969f4630ef6b626aaa102edbefcce2e9 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **eventarc:** update the api https://github.com/googleapis/google-api-python-client/commit/8fd4b62bb45609f892902340386691d08916577b ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **metastore:** update the api https://github.com/googleapis/google-api-python-client/commit/b7f92e49126ce0a2b51699f1cdcd9688050202a1 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **ondemandscanning:** update the api https://github.com/googleapis/google-api-python-client/commit/e8a20085b2c69058644955733a2806e3e2ca7fa6 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **osconfig:** update the api https://github.com/googleapis/google-api-python-client/commit/974f389117b61e70dcae964a4cbbc09de3506c25 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **privateca:** update the api https://github.com/googleapis/google-api-python-client/commit/f48c5289642548735424198ab5ed131521e5d680 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **recaptchaenterprise:** update the api https://github.com/googleapis/google-api-python-client/commit/edd3d24b7b41b0bcfe851358dbf58939be9e64cc ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **redis:** update the api https://github.com/googleapis/google-api-python-client/commit/0a68f42ad8d594cb024d998e83b536d18d07d35a ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **run:** update the api https://github.com/googleapis/google-api-python-client/commit/59c518fb1802074b03a4e55be3efb9ab25692b84 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **sasportal:** update the api https://github.com/googleapis/google-api-python-client/commit/1517d9dcd845edf8a55baaef3d27db88f4beaa54 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) - **servicedirectory:** update the api https://github.com/googleapis/google-api-python-client/commit/298a0e1617d486b3a6353b1b965def9dbc4f76e2 ([4d5c983](https://togithub.com/googleapis/google-api-python-client/commit/4d5c983f4cb58820b1ae5fc1ee966216b056220c)) ### [`v2.35.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2350-httpsgithubcomgoogleapisgoogle-api-python-clientcomparev2340v2350-2022-01-13) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.34.0...v2.35.0) ##### Features - **analyticsadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/0dec51cdb8227155731e9b63a4092da556c02d1e ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **androidmanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/975ea480b8050a519a344cdaecb297e0cde188f3 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **bigtableadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/6266ac01c6507d12bfd65ae811b4f4edd9b6954a ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **cloudbuild:** update the api https://github.com/googleapis/google-api-python-client/commit/06362dce43356f7b6dd4253f31f3533f1465885e ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/ce5edd17bfc87c22eddfdc697b16f0b6401d4ca9 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **connectors:** update the api https://github.com/googleapis/google-api-python-client/commit/bc9062b3d55b5b4fbb54e547b8399fbcf09a596b ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **contactcenterinsights:** update the api https://github.com/googleapis/google-api-python-client/commit/5fedb046b952461db978978802f4227f1611c333 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **container:** update the api https://github.com/googleapis/google-api-python-client/commit/a9bdbde1f8c095ecc8693f7cb3ad4c6390d2ed68 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **datacatalog:** update the api https://github.com/googleapis/google-api-python-client/commit/135360cca2be8f746940df79eefd576b07af125c ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **dataproc:** update the api https://github.com/googleapis/google-api-python-client/commit/38c6ad15c360531c96008b81563ca0245e859b0d ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/f4a3a0f31de62c1823c4168df67385deb8e8e2c8 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **dns:** update the api https://github.com/googleapis/google-api-python-client/commit/d039cf7eadc91759236bbfd6de2d123ae3eae948 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **eventarc:** update the api https://github.com/googleapis/google-api-python-client/commit/a8766f583f266fbe7b2d299c3992cc86b758ea31 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **networkservices:** update the api https://github.com/googleapis/google-api-python-client/commit/288618ff2301e4e6a49c5211ed7ae8cef978fc60 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **notebooks:** update the api https://github.com/googleapis/google-api-python-client/commit/66584093cbed2d24f3184def26e164026607e5ed ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **orgpolicy:** update the api https://github.com/googleapis/google-api-python-client/commit/35d0c20e2c3f7d418703d7b3eea7c353094985e5 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **prod_tt_sasportal:** update the api https://github.com/googleapis/google-api-python-client/commit/bbbf1b21186421b529edd01eb99b2a18bf812f9d ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **retail:** update the api https://github.com/googleapis/google-api-python-client/commit/a2a9eb8c0d104d3320b2928e568bef5e6b439541 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **run:** update the api https://github.com/googleapis/google-api-python-client/commit/af2b78b469d050c5eeca0996f7eaaea65930c1e5 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **script:** update the api https://github.com/googleapis/google-api-python-client/commit/79b1292ea77bfaebc837aacffac320e780452a0a ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) - **texttospeech:** update the api https://github.com/googleapis/google-api-python-client/commit/46901569d6e918d86f2d9dc175ecdd2f8719bb93 ([4896942](https://togithub.com/googleapis/google-api-python-client/commit/48969422d118e0a30a166de6bd178d45573fe9f3)) ##### Bug Fixes - remove adsense.v1.4.json ([#​1616](https://togithub.com/googleapis/google-api-python-client/issues/1616)) ([5d3e588](https://togithub.com/googleapis/google-api-python-client/commit/5d3e5883b63d6038aa18e48397ce2eab50cb5e2c)) ### [`v2.34.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2340-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2330v2340-2022-01-05) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.33.0...v2.34.0) ##### Features - **alertcenter:** update the api https://github.com/googleapis/google-api-python-client/commit/945a281fc6a055f37d68a742959bdd18aaf6eb62 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **analyticsdata:** update the api https://github.com/googleapis/google-api-python-client/commit/90327d9a1b198523773d730402c5274c424ddf8f ([797d677](https://www.github.com/googleapis/google-api-python-client/commit/797d67740e7a8493c7e5fccdce3b88b0de90883b)) - **apigee:** update the api https://github.com/googleapis/google-api-python-client/commit/a2271c7c184e8d75b6370cf139ca464e4ebe435d ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **clouddeploy:** update the api https://github.com/googleapis/google-api-python-client/commit/e98fcec145aeb43c1a962404c4599b63dbe7443c ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **cloudsearch:** update the api https://github.com/googleapis/google-api-python-client/commit/6a63e51e98ea3d3662b0dd89e95636ddf14ef941 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/4f21ebf8fd2a9fd1e838e74266e8f8ed847c5236 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **contactcenterinsights:** update the api https://github.com/googleapis/google-api-python-client/commit/bb409be9296aef9c3e106476999e6e1c37d2fa8a ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **container:** update the api https://github.com/googleapis/google-api-python-client/commit/5687b00d4ba57a2ddb4311f66ae627f1c4f3807d ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/d026eb98f0eee8889aa7b55d507296074a140da5 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **dns:** update the api https://github.com/googleapis/google-api-python-client/commit/f96d280615ea04400a22fe9b7fae31bb6e10e4fe ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - expose library version at googleapiclient.**version** ([#​1623](https://www.togithub.com/googleapis/google-api-python-client/issues/1623)) ([83db1d7](https://www.github.com/googleapis/google-api-python-client/commit/83db1d71395e92fb2bd814a31713bd8ba3f412ca)) - **healthcare:** update the api https://github.com/googleapis/google-api-python-client/commit/8a11e53e91c04caba64091272b8e8e7a5b482c41 ([797d677](https://www.github.com/googleapis/google-api-python-client/commit/797d67740e7a8493c7e5fccdce3b88b0de90883b)) - **networkconnectivity:** update the api https://github.com/googleapis/google-api-python-client/commit/6de66e85f4cddf5a26c37c35db2ca0ef561c41fb ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **recaptchaenterprise:** update the api https://github.com/googleapis/google-api-python-client/commit/953a206f931396b030aa521323d05a4467b47d05 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **securitycenter:** update the api https://github.com/googleapis/google-api-python-client/commit/db02cdb70461284f33d1cce098a1babb191a1e87 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **serviceconsumermanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/a8a823f893b0208b9b8e1a71518726c1a919db5b ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **servicenetworking:** update the api https://github.com/googleapis/google-api-python-client/commit/b9be56f5967f7112a3b4620e89fffac4c82907ae ([797d677](https://www.github.com/googleapis/google-api-python-client/commit/797d67740e7a8493c7e5fccdce3b88b0de90883b)) - **serviceusage:** update the api https://github.com/googleapis/google-api-python-client/commit/743505720e00bf57f0f2347b0c9c4b1cbed1ecc9 ([5a6231d](https://www.github.com/googleapis/google-api-python-client/commit/5a6231d31156644fdc0fd5a6ef8a0cef25d1dd9b)) - **testing:** update the api https://github.com/googleapis/google-api-python-client/commit/98d5c1de2a32dce65697bffeb87b3a520ae5a94e ([797d677](https://www.github.com/googleapis/google-api-python-client/commit/797d67740e7a8493c7e5fccdce3b88b0de90883b)) ##### Bug Fixes - **deps:** require uritemplate 3.0.1 ([#​1629](https://www.togithub.com/googleapis/google-api-python-client/issues/1629)) ([1c4cfdb](https://www.github.com/googleapis/google-api-python-client/commit/1c4cfdb76560f757cec9dbc56a290ee748a07ef0)) ### [`v2.33.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2330-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2320v2330-2021-12-07) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.32.0...v2.33.0) ##### Features - **analyticsadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/835ba4092c656966ec26ec08f6be20d5d1abcf43 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **bigquery:** update the api https://github.com/googleapis/google-api-python-client/commit/6abccd47e1e537bbc46447acf1495a610c3dae31 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **chat:** update the api https://github.com/googleapis/google-api-python-client/commit/f5a2e18eebb360f0b416765166303d362944130f ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **cloudasset:** update the api https://github.com/googleapis/google-api-python-client/commit/d3602dbfbb01eda58b5930bf17f8fbdfaad1e6cf ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **cloudkms:** update the api https://github.com/googleapis/google-api-python-client/commit/a3343e30f99a8250ac4dffc401e3106b21e59c13 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **composer:** update the api https://github.com/googleapis/google-api-python-client/commit/614167472dc908fa47eec9a0921b9538ba068066 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/834349f1c54a0be33fb55e3328f88f25fa6a9419 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **contactcenterinsights:** update the api https://github.com/googleapis/google-api-python-client/commit/5482a0bade7167307dbbd81455c023a685318227 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/361134dcbcca446cb9e2b004006f3feb1920fd93 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **displayvideo:** update the api https://github.com/googleapis/google-api-python-client/commit/4d43cceda82a1df22fad872e85e1b7236e239ae8 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **orgpolicy:** update the api https://github.com/googleapis/google-api-python-client/commit/ce6c8aad2d1e8f7d6325c2642f61c07e22fddb5c ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **prod_tt_sasportal:** update the api https://github.com/googleapis/google-api-python-client/commit/dbbe2a7c7d9d43564d4032d109dc5e83d4864e84 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **retail:** update the api https://github.com/googleapis/google-api-python-client/commit/4e21ee29bc68bb989519460ede52c04cc66f203e ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **vmmigration:** update the api https://github.com/googleapis/google-api-python-client/commit/8898d540b6ac5801da6854209ff3dee1af7dc176 ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) - **websecurityscanner:** update the api https://github.com/googleapis/google-api-python-client/commit/bb0332e672950a3fbdfe0d383d948a4925bd433f ([8595441](https://www.github.com/googleapis/google-api-python-client/commit/8595441799dfc7cb2ec12d6ecfe893fd87b2fa7c)) ### [`v2.32.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2320-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2310v2320-2021-11-30) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.31.0...v2.32.0) ##### Features - **androidpublisher:** update the api https://github.com/googleapis/google-api-python-client/commit/5aee28e836eb486c4ed73c4ed2afbd9fc0e70f06 ([a7b9714](https://www.github.com/googleapis/google-api-python-client/commit/a7b97147a582605930e25d51f59e2974442c66a4)) - **artifactregistry:** update the api https://github.com/googleapis/google-api-python-client/commit/faa6c7f4fab2190989c9a587f35998203517ff2a ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **assuredworkloads:** update the api https://github.com/googleapis/google-api-python-client/commit/c0f6be757e47a62337e7963bea576858cbf17341 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **chat:** update the api https://github.com/googleapis/google-api-python-client/commit/ef184772aa82c3dd136d2da03d7dc7a1d9672e1c ([a7b9714](https://www.github.com/googleapis/google-api-python-client/commit/a7b97147a582605930e25d51f59e2974442c66a4)) - **cloudbuild:** update the api https://github.com/googleapis/google-api-python-client/commit/536d4b0a61e15b45439f3f3066410236d50e228b ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **composer:** update the api https://github.com/googleapis/google-api-python-client/commit/bc7ce92bf38d4eed3fce35cd080bf40b43855ba4 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/574d4ace68dc1bd844f01ec13419b7d055fa857e ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **containeranalysis:** update the api https://github.com/googleapis/google-api-python-client/commit/a86a46ed4f6098a6da8d3bc2db8ae1642e4300f3 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **container:** update the api https://github.com/googleapis/google-api-python-client/commit/c4cdd10e83565119457494a21f1abe128ac59083 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **datastream:** update the api https://github.com/googleapis/google-api-python-client/commit/f54ebeac6f8829b81b975a9fcabde5423f769ea9 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/2b33ab2f6823916a872f33c23c9da86b993f0fc0 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **dlp:** update the api https://github.com/googleapis/google-api-python-client/commit/0406443bd63e9bf9312c3ac7a7398ca0a60dac51 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **gameservices:** update the api https://github.com/googleapis/google-api-python-client/commit/8016e68c4c2ac2f065fc1a0c7e86aac35329cf25 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **gkehub:** update the api https://github.com/googleapis/google-api-python-client/commit/fbcb756aa75d122f9929a6319b3bdd413cebc293 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **logging:** update the api https://github.com/googleapis/google-api-python-client/commit/8ce3b8583936958cabce8c7a0cd72ad16817de0c ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **ml:** update the api https://github.com/googleapis/google-api-python-client/commit/cfe625ae36d61eda2f496115ad515a7000d8973c ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **networkconnectivity:** update the api https://github.com/googleapis/google-api-python-client/commit/6348dd518b3be79230e3d23beb4e4f2527d67855 ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **osconfig:** update the api https://github.com/googleapis/google-api-python-client/commit/0c6c8148b57f793fab971f2f815acef70fde478b ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) - **storagetransfer:** update the api https://github.com/googleapis/google-api-python-client/commit/5758865ada7f1c87525752f002f82ca8681e927d ([466c9a9](https://www.github.com/googleapis/google-api-python-client/commit/466c9a938ee07debe7d6e35550b473c62f9f3992)) ### [`v2.31.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2310-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2300v2310-2021-11-16) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.30.0...v2.31.0) ##### Features - **bigtableadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/be7ffcca66cdcb1dfcd9849538772914c90b3ea0 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **chromemanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/59c97996091063cdad497be989d168ec1e71a178 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **cloudasset:** update the api https://github.com/googleapis/google-api-python-client/commit/60f5758b975a9bbac044b9005601c5c026125137 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **cloudfunctions:** update the api https://github.com/googleapis/google-api-python-client/commit/c517033bea4e84d1c118f77df38e2f33b3741ec2 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **contactcenterinsights:** update the api https://github.com/googleapis/google-api-python-client/commit/9ac9faa70c053fd1f5b2de7b6ef5947a04270dba ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **containeranalysis:** update the api https://github.com/googleapis/google-api-python-client/commit/618985bd0fa3f0380152e8d33e3b30ba465e1f2d ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **datapipelines:** update the api https://github.com/googleapis/google-api-python-client/commit/a39bb0f9b41255adf6c790130931f64a153ac0e8 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **datastore:** update the api https://github.com/googleapis/google-api-python-client/commit/5050adbdc30c4247e2454a7e063c7f7ea2724bc0 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/fd46c128ec3d0679283e3cddb1c40eb8b5f3728a ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **documentai:** update the api https://github.com/googleapis/google-api-python-client/commit/3ba31828b05604eaa23101d681354b39c75d712d ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **drive:** update the api https://github.com/googleapis/google-api-python-client/commit/b1840b06a09ec22db69d757706aa98d2bf536a49 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **file:** update the api https://github.com/googleapis/google-api-python-client/commit/b13a2490844c5c84c42e26c7e5bafdf700e689df ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **gkehub:** update the api https://github.com/googleapis/google-api-python-client/commit/37cce48342813c865a2704ca06841f1801ebb60c ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **healthcare:** update the api https://github.com/googleapis/google-api-python-client/commit/8d1f955971aae9e0e4b7956906e43382fcf57d20 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **metastore:** update the api https://github.com/googleapis/google-api-python-client/commit/9c90df783a1fac104920100158ddb7c88d461545 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **monitoring:** update the api https://github.com/googleapis/google-api-python-client/commit/bf890b636ae02bb1d84e050df052fa341a29a4c1 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **mybusinessbusinessinformation:** update the api https://github.com/googleapis/google-api-python-client/commit/90e206c145790d0f9a78bbd7acb2667796868db7 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **paymentsresellersubscription:** update the api https://github.com/googleapis/google-api-python-client/commit/c8796544acc40e330276b7777c728782217b1bb4 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **recaptchaenterprise:** update the api https://github.com/googleapis/google-api-python-client/commit/ff95700fce7de8bc2a58be64890740140532f865 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **recommender:** update the api https://github.com/googleapis/google-api-python-client/commit/d85fe38478c2cb56b3694e6890f6d53c367e057d ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **securitycenter:** update the api https://github.com/googleapis/google-api-python-client/commit/35a6d4e716f26c77b3588f28d3097871a29dea7e ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **speech:** update the api https://github.com/googleapis/google-api-python-client/commit/13f1bcb6311e0ea11ad60a29713c1a0a1fe22f42 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **sqladmin:** update the api https://github.com/googleapis/google-api-python-client/commit/770bc14b5f95b525bd04e40378a718a38ac31a0d ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **tpu:** update the api https://github.com/googleapis/google-api-python-client/commit/ea30e3a05539e4de70e385a34490153f32c16789 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) - **vmmigration:** update the api https://github.com/googleapis/google-api-python-client/commit/80e20909242c4bde06b8adc3afecf1141be34f45 ([815c1ac](https://www.github.com/googleapis/google-api-python-client/commit/815c1ac7e3f7c7ea6df920645adb8cba84b05c22)) ##### Bug Fixes - MediaIoBaseDownload range header off-by-one ([#​1595](https://www.togithub.com/googleapis/google-api-python-client/issues/1595)) ([4b73b2e](https://www.github.com/googleapis/google-api-python-client/commit/4b73b2e9d53e63404c8800f2a2b3f1ee86680815)) ### [`v2.30.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2300-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2290v2300-2021-11-09) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.29.0...v2.30.0) ##### Features - **androidmanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/be2e5dd39ea24ffb04bda06bcd6af55fe15a272f ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **appengine:** update the api https://github.com/googleapis/google-api-python-client/commit/4535ce54bf2a6638f1a70c394021f17883fa0f35 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **artifactregistry:** update the api https://github.com/googleapis/google-api-python-client/commit/882fdb3258c3ead813f0895539bc99503d3a4356 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **chromepolicy:** update the api https://github.com/googleapis/google-api-python-client/commit/c330a6f08c004f0809bfbc1b43801dd5c38dc805 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **cloudidentity:** update the api https://github.com/googleapis/google-api-python-client/commit/d0f05277b6caeab32d8283f2ffdf253608c67a78 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **composer:** update the api https://github.com/googleapis/google-api-python-client/commit/2bfa5a11741e6c653c6297a9e438c0316a9703a0 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/b917688b232d9cc2ca59f25725e9013e2d6d09f7 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **datastream:** update the api https://github.com/googleapis/google-api-python-client/commit/218521cf0ac369533de05f866419d38295f17a40 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **dns:** update the api https://github.com/googleapis/google-api-python-client/commit/540233d5289624ba149069596ae46233fd31e2b7 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **healthcare:** update the api https://github.com/googleapis/google-api-python-client/commit/1e029c853a3232ea499035dd7a9c141d60df4ba1 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **ondemandscanning:** update the api https://github.com/googleapis/google-api-python-client/commit/9f998b473a80a9c92e1d9ff7c7e1c35c208c93f8 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **osconfig:** update the api https://github.com/googleapis/google-api-python-client/commit/59cea85511b634a99028cb73ef0e73fb1e194b5b ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **paymentsresellersubscription:** update the api https://github.com/googleapis/google-api-python-client/commit/efb5b4fc9229f0baa66b928cfa4ba6f6d1315643 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **privateca:** update the api https://github.com/googleapis/google-api-python-client/commit/b4ae2c840870ff9cd6f6fe1f39ab4f00c5e87b08 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **recommender:** update the api https://github.com/googleapis/google-api-python-client/commit/8dffae4069115fdb3dac902eee0bf2c9cbc39ce9 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **retail:** update the api https://github.com/googleapis/google-api-python-client/commit/f71107495bef44a7d7a9108dcdae2eada7815986 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **storagetransfer:** update the api https://github.com/googleapis/google-api-python-client/commit/c835926b3369ad8f8dbe277e6caa9c995db6342f ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **streetviewpublish:** update the api https://github.com/googleapis/google-api-python-client/commit/35f0b1b607af6386790a6ec49541f87bc3091453 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) - **translate:** update the api https://github.com/googleapis/google-api-python-client/commit/1f848a58c798840ee0ac4f768324c9f44b3cfc07 ([5dcb723](https://www.github.com/googleapis/google-api-python-client/commit/5dcb723c970982dce020aa7146697c70569458ee)) ### [`v2.29.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2290-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2280v2290-2021-11-02) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.28.0...v2.29.0) ##### Features - **adexchangebuyer2:** update the api https://github.com/googleapis/google-api-python-client/commit/49432a596a9d2e0a014afb2c57cc0ceec37aa403 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **bigquery:** update the api https://github.com/googleapis/google-api-python-client/commit/faedd49d24634e1646e15cb79a983391a6938faa ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **chromemanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/89fc0743cff2c64a438339003fc1c8fdf99938dd ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **cloudbuild:** update the api https://github.com/googleapis/google-api-python-client/commit/8c2010464ec7a8aa6ffe8a044ae44ea0ab199f45 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **compute:** update the api https://github.com/googleapis/google-api-python-client/commit/c2acfdbefef85f8a4696ae467bd61d05db25cf31 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **contactcenterinsights:** update the api https://github.com/googleapis/google-api-python-client/commit/04ba8ef034ac1fd69e8e641c585e762e19078806 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **container:** update the api https://github.com/googleapis/google-api-python-client/commit/3c92c46132922d77598527fc98780edca5978ce2 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **content:** update the api https://github.com/googleapis/google-api-python-client/commit/037b9e1d5c9865af22a3c70dc44542ea3ce547dc ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **datafusion:** update the api https://github.com/googleapis/google-api-python-client/commit/fc6d716e71875ea73036e576bbaafb2826e01e1d ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **dlp:** update the api https://github.com/googleapis/google-api-python-client/commit/08353cbe37fc4c0dcc1311efead553797067417e ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **documentai:** update the api https://github.com/googleapis/google-api-python-client/commit/7974abc07dceffbc9fdb5365b706ed5e1a9899fc ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **firebaseappcheck:** update the api https://github.com/googleapis/google-api-python-client/commit/13220f0704b0d5b954520307a6702efead926e5e ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **gameservices:** update the api https://github.com/googleapis/google-api-python-client/commit/ea5f2216765868a1d6e48995f23b74709ca5ebef ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **gkehub:** update the api https://github.com/googleapis/google-api-python-client/commit/f4ae68ff69c32b5708f1e5f735cb03f3184f7650 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **healthcare:** update the api https://github.com/googleapis/google-api-python-client/commit/5c430ab79811ae3565a83d57ba06e0d48560f791 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **monitoring:** update the api https://github.com/googleapis/google-api-python-client/commit/3ad9f05ae340101c6016e4ceeef52661d0c01e21 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **networkmanagement:** update the api https://github.com/googleapis/google-api-python-client/commit/992b9f851e871feb796485e6af936a3d05899e4e ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **osconfig:** update the api https://github.com/googleapis/google-api-python-client/commit/972e716c233348d6e5d686f3718607a42e7d728a ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **oslogin:** update the api https://github.com/googleapis/google-api-python-client/commit/1ba23c68428c3c07a778f25dc9fc10998022c414 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **paymentsresellersubscription:** update the api https://github.com/googleapis/google-api-python-client/commit/cc7fd94a993048d6ca7cc34e42c4536df6eeb93d ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **recaptchaenterprise:** update the api https://github.com/googleapis/google-api-python-client/commit/2da594c083639420e285d70d26483e46df9fa1a0 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **redis:** update the api https://github.com/googleapis/google-api-python-client/commit/c16b96450466eb72e8122fc8aca0ce010a113350 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **run:** update the api https://github.com/googleapis/google-api-python-client/commit/c502728bfd31e520d4f5f06cc763dc2316cbb221 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **searchconsole:** update the api https://github.com/googleapis/google-api-python-client/commit/eede698004d718213b315b3728793a967a92e87b ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **speech:** update the api https://github.com/googleapis/google-api-python-client/commit/9f0148f2f0f035b9e3c7d73dbd95a8f961ef3eb1 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **tagmanager:** update the api https://github.com/googleapis/google-api-python-client/commit/fe4351bca507192a682440fa52f50eb98cef4434 ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) - **vmmigration:** update the api https://github.com/googleapis/google-api-python-client/commit/d8afe7c7e0a556d31dc904e8878c1bf884a375af ([a41c7b9](https://www.github.com/googleapis/google-api-python-client/commit/a41c7b9247ed1b9f335c40bc4d24c0660331191a)) ### [`v2.28.0`](https://togithub.com/googleapis/google-api-python-client/blob/HEAD/CHANGELOG.md#​2280-httpswwwgithubcomgoogleapisgoogle-api-python-clientcomparev2270v2280-2021-10-26) [Compare Source](https://togithub.com/googleapis/google-api-python-client/compare/v2.27.0...v2.28.0) ##### Features - **admin:** update the api https://github.com/googleapis/google-api-python-client/commit/34eef11ba78a6e8eda0ec4dd8348e240ac637122 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **analyticsadmin:** update the api https://github.com/googleapis/google-api-python-client/commit/8666e3e7a134d27f832c00ef8fff2e8a5b601774 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **analyticsdata:** update the api https://github.com/googleapis/google-api-python-client/commit/a362e49252915c7da2fe88bfaec9eb7f9c217b11 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **analyticsreporting:** update the api https://github.com/googleapis/google-api-python-client/commit/ec6bf30c38ccf0f258c9f0267c6477b233483702 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **androidpublisher:** update the api https://github.com/googleapis/google-api-python-client/commit/1a6d12e5a619d753e17041696fdfa84626e952d3 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **apigee:** update the api https://github.com/googleapis/google-api-python-client/commit/afc34eebbe98c284718489b94df8bc2293ee31f5 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **artifactregistry:** update the api https://github.com/googleapis/google-api-python-client/commit/421f4d14a998f3da97fd979647b5e05287027679 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **chat:** update the api https://github.com/googleapis/google-api-python-client/commit/ba90d3f0889eac4fb061bbbe913c31eea57c94bb ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **cloudkms:** update the api https://github.com/googleapis/google-api-python-client/commit/f06247e899ba2de5d2c1f0a8d6e8cbb0569143aa ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **containeranalysis:** update the api https://github.com/googleapis/google-api-python-client/commit/15898963782a0649d6cb3a0a0c7ba1566b86b853 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **content:** update the api https://github.com/googleapis/google-api-python-client/commit/8f976a93038ee562d5ed0c9937d52e4b5e2cb8d6 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **datacatalog:** update the api https://github.com/googleapis/google-api-python-client/commit/b7876fdb21b0eeab9c07a73bbf0ca43f5f509906 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **dataproc:** update the api https://github.com/googleapis/google-api-python-client/commit/742a2f738031268771d7146b64ff0e743df79596 ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d387c95170487c8da93d4db25acf0bda4a2d2e)) - **dialogflow:** update the api https://github.com/googleapis/google-api-python-client/commit/117de7bdb601d11ce48c4ad64225d6d207f0597a ([12d387c](https://www.github.com/googleapis/google-api-python-client/commit/12d38
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/python-iot). docs(samples): resolve TypeError in create_iot_topic --- .../accesstoken_example/requirements-test.txt | 7 ++++--- .../accesstoken_example/requirements.txt | 17 +++++++++-------- samples/api-client/manager/manager.py | 6 +++--- samples/api-client/manager/manager_test.py | 2 +- samples/api-client/manager/requirements.txt | 14 +++++++------- .../api-client/mqtt_example/requirements.txt | 4 ++-- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements-test.txt b/samples/api-client/accesstoken_example/requirements-test.txt index a25b6ec6..4bcdfb92 100644 --- a/samples/api-client/accesstoken_example/requirements-test.txt +++ b/samples/api-client/accesstoken_example/requirements-test.txt @@ -1,3 +1,4 @@ -pytest==6.2.4 -google-cloud-pubsub==1.7.0 -google-cloud-storage==1.42.0 +pytest==6.2.5 +google-cloud-pubsub==2.9.0 +google-cloud-storage==2.0.0; python_version == '3.6' +google-cloud-storage==2.1.0; python_version > '3.6' diff --git a/samples/api-client/accesstoken_example/requirements.txt b/samples/api-client/accesstoken_example/requirements.txt index 0c50fb04..27a75cbb 100644 --- a/samples/api-client/accesstoken_example/requirements.txt +++ b/samples/api-client/accesstoken_example/requirements.txt @@ -1,10 +1,11 @@ -cryptography==3.4.7 +cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.10.0 +google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==1.32.1 -google-cloud-iot==2.1.0 -google-cloud-pubsub==1.7.0 -google-cloud-storage==1.42.0 -paho-mqtt==1.5.1 -pyjwt==2.1.0 +google-auth==2.3.3 +google-cloud-iot==2.3.0 +google-cloud-pubsub==2.9.0 +google-cloud-storage==2.0.0; python_version == '3.6' +google-cloud-storage==2.1.0; python_version > '3.6' +paho-mqtt==1.6.1 +pyjwt==2.3.0 diff --git a/samples/api-client/manager/manager.py b/samples/api-client/manager/manager.py index 260d7134..5b4c12a6 100644 --- a/samples/api-client/manager/manager.py +++ b/samples/api-client/manager/manager.py @@ -48,15 +48,15 @@ def create_iot_topic(project, topic_name): pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project, topic_name) - topic = pubsub_client.create_topic(topic_path) - policy = pubsub_client.get_iam_policy(topic_path) + topic = pubsub_client.create_topic(request={"name": topic_path}) + policy = pubsub_client.get_iam_policy(request={"resource": topic_path}) policy.bindings.add( role="roles/pubsub.publisher", members=["serviceAccount:cloud-iot@system.gserviceaccount.com"], ) - pubsub_client.set_iam_policy(topic_path, policy) + pubsub_client.set_iam_policy(request={"resource": topic_path, "policy": policy}) return topic diff --git a/samples/api-client/manager/manager_test.py b/samples/api-client/manager/manager_test.py index e8300fc4..3ced5372 100644 --- a/samples/api-client/manager/manager_test.py +++ b/samples/api-client/manager/manager_test.py @@ -148,7 +148,7 @@ def test_topic(): pubsub_client = pubsub.PublisherClient() topic_path = pubsub_client.topic_path(project_id, topic_id) - pubsub_client.delete_topic(topic_path) + pubsub_client.delete_topic(request={"topic": topic_path}) def test_create_delete_registry(test_topic, capsys): diff --git a/samples/api-client/manager/requirements.txt b/samples/api-client/manager/requirements.txt index b94bf0e7..867f7b56 100644 --- a/samples/api-client/manager/requirements.txt +++ b/samples/api-client/manager/requirements.txt @@ -1,9 +1,9 @@ -cryptography==3.4.8 +cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.19.0 +google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==2.0.2 -google-cloud-iot==2.2.1 -google-cloud-pubsub==1.7.0 -paho-mqtt==1.5.1 -pyjwt==2.1.0 +google-auth==2.3.3 +google-cloud-iot==2.3.0 +google-cloud-pubsub==2.9.0 +paho-mqtt==1.6.1 +pyjwt==2.3.0 diff --git a/samples/api-client/mqtt_example/requirements.txt b/samples/api-client/mqtt_example/requirements.txt index 0afecdd9..0779d49d 100644 --- a/samples/api-client/mqtt_example/requirements.txt +++ b/samples/api-client/mqtt_example/requirements.txt @@ -1,2 +1,2 @@ -paho-mqtt==1.5.1 -pyjwt==2.1.0 +paho-mqtt==1.6.1 +pyjwt==2.3.0 From 9035dcbe8ca3b67fdc4ea49da89264c86b185fdb Mon Sep 17 00:00:00 2001 From: Dan Lee <71398022+dandhlee@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:30:13 -0500 Subject: [PATCH 11/28] chore: update doc links from googleapis.dev to cloud.google.com (#219) Updating the reference documentation website from googleapis.dev to cloud.google.com for the index pages. Also updating references in the README. --- .repo-metadata.json | 2 +- README.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index 72dc7de6..98bd116a 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,7 +2,7 @@ "name": "cloudiot", "name_pretty": "Google Cloud Internet of Things (IoT) Core", "product_documentation": "https://cloud.google.com/iot", - "client_documentation": "https://googleapis.dev/python/cloudiot/latest", + "client_documentation": "https://cloud.google.com/python/docs/reference/cloudiot/latest", "issue_tracker": "https://issuetracker.google.com/issues?q=status:open%20componentid:310170", "release_level": "ga", "language": "python", diff --git a/README.rst b/README.rst index bd4f48fa..44f56ec6 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ connect to the Google Cloud Platform. .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-iot.svg :target: https://pypi.org/project/google-cloud-iot/ .. _Cloud IoT API: https://cloud.google.com/iot -.. _Client Library Documentation: https://googleapis.dev/python/cloudiot/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/cloudiot/latest .. _Product Documentation: https://cloud.google.com/iot Quick Start From 6038e0cf8abbdcf0775e02844f86d1909b2857e0 Mon Sep 17 00:00:00 2001 From: Anurag Kumar Date: Sat, 22 Jan 2022 06:18:12 +0530 Subject: [PATCH 12/28] feat: add support for Python 3.9 / 3.10 (#220) support for python 3.9 and 3.10 Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-iot/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #221 --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index e7bb03b3..da575f07 100644 --- a/setup.py +++ b/setup.py @@ -67,6 +67,8 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Operating System :: OS Independent", "Topic :: Internet", ], From 4971166928788fb191f875ebe0a84cc6179e1d5c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Fri, 21 Jan 2022 19:58:37 -0500 Subject: [PATCH 13/28] chore: add api_shortname to repo-metadata.json (#226) Update .repo-metadata.json as required by go/library-data-integrity Fixes #231 --- .repo-metadata.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.repo-metadata.json b/.repo-metadata.json index 98bd116a..6b56f91c 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -4,7 +4,7 @@ "product_documentation": "https://cloud.google.com/iot", "client_documentation": "https://cloud.google.com/python/docs/reference/cloudiot/latest", "issue_tracker": "https://issuetracker.google.com/issues?q=status:open%20componentid:310170", - "release_level": "ga", + "release_level": "stable", "language": "python", "library_type": "GAPIC_AUTO", "repo": "googleapis/python-iot", @@ -12,5 +12,6 @@ "api_id": "cloudiot.googleapis.com", "requires_billing": true, "default_version": "v1", - "codeowner_team": "@googleapis/api-iot" + "codeowner_team": "@googleapis/api-iot", + "api_shortname": "cloudiot" } From b6df5e4ba104003123ebac6687e55fdef176daf0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 01:08:13 +0000 Subject: [PATCH 14/28] chore: use gapic-generator-python 0.58.4 (#227) - [ ] Regenerate this pull request now. fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 fix(deps): require google-api-core>=1.28.0 fix(deps): require proto-plus>=1.15.0 fix(deps): drop packaging dependency docs: list oneofs in docstring --- .../services/device_manager/async_client.py | 127 ++-- .../iot_v1/services/device_manager/client.py | 63 +- .../device_manager/transports/base.py | 44 +- .../device_manager/transports/grpc.py | 4 +- .../device_manager/transports/grpc_asyncio.py | 5 +- google/cloud/iot_v1/types/device_manager.py | 13 + google/cloud/iot_v1/types/resources.py | 9 + setup.py | 5 +- testing/constraints-3.6.txt | 7 +- .../unit/gapic/iot_v1/test_device_manager.py | 574 +++++++++--------- 10 files changed, 414 insertions(+), 437 deletions(-) diff --git a/google/cloud/iot_v1/services/device_manager/async_client.py b/google/cloud/iot_v1/services/device_manager/async_client.py index 52076cde..a19eb02c 100644 --- a/google/cloud/iot_v1/services/device_manager/async_client.py +++ b/google/cloud/iot_v1/services/device_manager/async_client.py @@ -19,13 +19,18 @@ from typing import Dict, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + from google.cloud.iot_v1.services.device_manager import pagers from google.cloud.iot_v1.types import device_manager from google.cloud.iot_v1.types import resources @@ -173,18 +178,18 @@ def __init__( async def create_device_registry( self, - request: device_manager.CreateDeviceRegistryRequest = None, + request: Union[device_manager.CreateDeviceRegistryRequest, dict] = None, *, parent: str = None, device_registry: resources.DeviceRegistry = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: r"""Creates a device registry that contains devices. Args: - request (:class:`google.cloud.iot_v1.types.CreateDeviceRegistryRequest`): + request (Union[google.cloud.iot_v1.types.CreateDeviceRegistryRequest, dict]): The request object. Request for `CreateDeviceRegistry`. parent (:class:`str`): Required. The project and cloud region where this device @@ -254,17 +259,17 @@ async def create_device_registry( async def get_device_registry( self, - request: device_manager.GetDeviceRegistryRequest = None, + request: Union[device_manager.GetDeviceRegistryRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: r"""Gets a device registry configuration. Args: - request (:class:`google.cloud.iot_v1.types.GetDeviceRegistryRequest`): + request (Union[google.cloud.iot_v1.types.GetDeviceRegistryRequest, dict]): The request object. Request for `GetDeviceRegistry`. name (:class:`str`): Required. The name of the device registry. For example, @@ -332,18 +337,18 @@ async def get_device_registry( async def update_device_registry( self, - request: device_manager.UpdateDeviceRegistryRequest = None, + request: Union[device_manager.UpdateDeviceRegistryRequest, dict] = None, *, device_registry: resources.DeviceRegistry = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: r"""Updates a device registry configuration. Args: - request (:class:`google.cloud.iot_v1.types.UpdateDeviceRegistryRequest`): + request (Union[google.cloud.iot_v1.types.UpdateDeviceRegistryRequest, dict]): The request object. Request for `UpdateDeviceRegistry`. device_registry (:class:`google.cloud.iot_v1.types.DeviceRegistry`): Required. The new values for the device registry. The @@ -418,17 +423,17 @@ async def update_device_registry( async def delete_device_registry( self, - request: device_manager.DeleteDeviceRegistryRequest = None, + request: Union[device_manager.DeleteDeviceRegistryRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a device registry configuration. Args: - request (:class:`google.cloud.iot_v1.types.DeleteDeviceRegistryRequest`): + request (Union[google.cloud.iot_v1.types.DeleteDeviceRegistryRequest, dict]): The request object. Request for `DeleteDeviceRegistry`. name (:class:`str`): Required. The name of the device registry. For example, @@ -491,17 +496,17 @@ async def delete_device_registry( async def list_device_registries( self, - request: device_manager.ListDeviceRegistriesRequest = None, + request: Union[device_manager.ListDeviceRegistriesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDeviceRegistriesAsyncPager: r"""Lists device registries. Args: - request (:class:`google.cloud.iot_v1.types.ListDeviceRegistriesRequest`): + request (Union[google.cloud.iot_v1.types.ListDeviceRegistriesRequest, dict]): The request object. Request for `ListDeviceRegistries`. parent (:class:`str`): Required. The project and cloud region path. For @@ -580,18 +585,18 @@ async def list_device_registries( async def create_device( self, - request: device_manager.CreateDeviceRequest = None, + request: Union[device_manager.CreateDeviceRequest, dict] = None, *, parent: str = None, device: resources.Device = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: r"""Creates a device in a device registry. Args: - request (:class:`google.cloud.iot_v1.types.CreateDeviceRequest`): + request (Union[google.cloud.iot_v1.types.CreateDeviceRequest, dict]): The request object. Request for `CreateDevice`. parent (:class:`str`): Required. The name of the device registry where this @@ -661,17 +666,17 @@ async def create_device( async def get_device( self, - request: device_manager.GetDeviceRequest = None, + request: Union[device_manager.GetDeviceRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: r"""Gets details about a device. Args: - request (:class:`google.cloud.iot_v1.types.GetDeviceRequest`): + request (Union[google.cloud.iot_v1.types.GetDeviceRequest, dict]): The request object. Request for `GetDevice`. name (:class:`str`): Required. The name of the device. For example, @@ -741,18 +746,18 @@ async def get_device( async def update_device( self, - request: device_manager.UpdateDeviceRequest = None, + request: Union[device_manager.UpdateDeviceRequest, dict] = None, *, device: resources.Device = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: r"""Updates a device. Args: - request (:class:`google.cloud.iot_v1.types.UpdateDeviceRequest`): + request (Union[google.cloud.iot_v1.types.UpdateDeviceRequest, dict]): The request object. Request for `UpdateDevice`. device (:class:`google.cloud.iot_v1.types.Device`): Required. The new values for the device. The ``id`` and @@ -827,17 +832,17 @@ async def update_device( async def delete_device( self, - request: device_manager.DeleteDeviceRequest = None, + request: Union[device_manager.DeleteDeviceRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a device. Args: - request (:class:`google.cloud.iot_v1.types.DeleteDeviceRequest`): + request (Union[google.cloud.iot_v1.types.DeleteDeviceRequest, dict]): The request object. Request for `DeleteDevice`. name (:class:`str`): Required. The name of the device. For example, @@ -902,17 +907,17 @@ async def delete_device( async def list_devices( self, - request: device_manager.ListDevicesRequest = None, + request: Union[device_manager.ListDevicesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDevicesAsyncPager: r"""List devices in a device registry. Args: - request (:class:`google.cloud.iot_v1.types.ListDevicesRequest`): + request (Union[google.cloud.iot_v1.types.ListDevicesRequest, dict]): The request object. Request for `ListDevices`. parent (:class:`str`): Required. The device registry path. Required. For @@ -991,11 +996,11 @@ async def list_devices( async def modify_cloud_to_device_config( self, - request: device_manager.ModifyCloudToDeviceConfigRequest = None, + request: Union[device_manager.ModifyCloudToDeviceConfigRequest, dict] = None, *, name: str = None, binary_data: bytes = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceConfig: @@ -1004,7 +1009,7 @@ async def modify_cloud_to_device_config( the modified configuration version and its metadata. Args: - request (:class:`google.cloud.iot_v1.types.ModifyCloudToDeviceConfigRequest`): + request (Union[google.cloud.iot_v1.types.ModifyCloudToDeviceConfigRequest, dict]): The request object. Request for `ModifyCloudToDeviceConfig`. name (:class:`str`): @@ -1087,10 +1092,10 @@ async def modify_cloud_to_device_config( async def list_device_config_versions( self, - request: device_manager.ListDeviceConfigVersionsRequest = None, + request: Union[device_manager.ListDeviceConfigVersionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.ListDeviceConfigVersionsResponse: @@ -1098,7 +1103,7 @@ async def list_device_config_versions( configuration in descending order (i.e.: newest first). Args: - request (:class:`google.cloud.iot_v1.types.ListDeviceConfigVersionsRequest`): + request (Union[google.cloud.iot_v1.types.ListDeviceConfigVersionsRequest, dict]): The request object. Request for `ListDeviceConfigVersions`. name (:class:`str`): @@ -1169,10 +1174,10 @@ async def list_device_config_versions( async def list_device_states( self, - request: device_manager.ListDeviceStatesRequest = None, + request: Union[device_manager.ListDeviceStatesRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.ListDeviceStatesResponse: @@ -1180,7 +1185,7 @@ async def list_device_states( descending order (i.e.: newest first). Args: - request (:class:`google.cloud.iot_v1.types.ListDeviceStatesRequest`): + request (Union[google.cloud.iot_v1.types.ListDeviceStatesRequest, dict]): The request object. Request for `ListDeviceStates`. name (:class:`str`): Required. The name of the device. For example, @@ -1250,10 +1255,10 @@ async def list_device_states( async def set_iam_policy( self, - request: iam_policy_pb2.SetIamPolicyRequest = None, + request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1261,7 +1266,7 @@ async def set_iam_policy( resource. Replaces any existing policy. Args: - request (:class:`google.iam.v1.iam_policy_pb2.SetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` method. resource (:class:`str`): @@ -1377,10 +1382,10 @@ async def set_iam_policy( async def get_iam_policy( self, - request: iam_policy_pb2.GetIamPolicyRequest = None, + request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1389,7 +1394,7 @@ async def get_iam_policy( not have a policy set. Args: - request (:class:`google.iam.v1.iam_policy_pb2.GetIamPolicyRequest`): + request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` method. resource (:class:`str`): @@ -1505,11 +1510,11 @@ async def get_iam_policy( async def test_iam_permissions( self, - request: iam_policy_pb2.TestIamPermissionsRequest = None, + request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None, *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1518,7 +1523,7 @@ async def test_iam_permissions( permissions, not a NOT_FOUND error. Args: - request (:class:`google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest`): + request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for `TestIamPermissions` method. resource (:class:`str`): @@ -1590,12 +1595,12 @@ async def test_iam_permissions( async def send_command_to_device( self, - request: device_manager.SendCommandToDeviceRequest = None, + request: Union[device_manager.SendCommandToDeviceRequest, dict] = None, *, name: str = None, binary_data: bytes = None, subfolder: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.SendCommandToDeviceResponse: @@ -1618,7 +1623,7 @@ async def send_command_to_device( from the device. Args: - request (:class:`google.cloud.iot_v1.types.SendCommandToDeviceRequest`): + request (Union[google.cloud.iot_v1.types.SendCommandToDeviceRequest, dict]): The request object. Request for `SendCommandToDevice`. name (:class:`str`): Required. The name of the device. For example, @@ -1715,19 +1720,19 @@ async def send_command_to_device( async def bind_device_to_gateway( self, - request: device_manager.BindDeviceToGatewayRequest = None, + request: Union[device_manager.BindDeviceToGatewayRequest, dict] = None, *, parent: str = None, gateway_id: str = None, device_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.BindDeviceToGatewayResponse: r"""Associates the device with the gateway. Args: - request (:class:`google.cloud.iot_v1.types.BindDeviceToGatewayRequest`): + request (Union[google.cloud.iot_v1.types.BindDeviceToGatewayRequest, dict]): The request object. Request for `BindDeviceToGateway`. parent (:class:`str`): Required. The name of the registry. For example, @@ -1804,12 +1809,12 @@ async def bind_device_to_gateway( async def unbind_device_from_gateway( self, - request: device_manager.UnbindDeviceFromGatewayRequest = None, + request: Union[device_manager.UnbindDeviceFromGatewayRequest, dict] = None, *, parent: str = None, gateway_id: str = None, device_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.UnbindDeviceFromGatewayResponse: @@ -1817,7 +1822,7 @@ async def unbind_device_from_gateway( gateway. Args: - request (:class:`google.cloud.iot_v1.types.UnbindDeviceFromGatewayRequest`): + request (Union[google.cloud.iot_v1.types.UnbindDeviceFromGatewayRequest, dict]): The request object. Request for `UnbindDeviceFromGateway`. parent (:class:`str`): diff --git a/google/cloud/iot_v1/services/device_manager/client.py b/google/cloud/iot_v1/services/device_manager/client.py index e0dd2efb..6a1943d5 100644 --- a/google/cloud/iot_v1/services/device_manager/client.py +++ b/google/cloud/iot_v1/services/device_manager/client.py @@ -14,22 +14,26 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore + from google.cloud.iot_v1.services.device_manager import pagers from google.cloud.iot_v1.types import device_manager from google.cloud.iot_v1.types import resources @@ -303,8 +307,15 @@ def __init__( client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( + "true", + "false", + ): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + use_client_cert = ( + os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" ) client_cert_source_func = None @@ -375,7 +386,7 @@ def create_device_registry( *, parent: str = None, device_registry: resources.DeviceRegistry = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: @@ -455,7 +466,7 @@ def get_device_registry( request: Union[device_manager.GetDeviceRegistryRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: @@ -524,7 +535,7 @@ def update_device_registry( *, device_registry: resources.DeviceRegistry = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceRegistry: @@ -609,7 +620,7 @@ def delete_device_registry( request: Union[device_manager.DeleteDeviceRegistryRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -672,7 +683,7 @@ def list_device_registries( request: Union[device_manager.ListDeviceRegistriesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDeviceRegistriesPager: @@ -752,7 +763,7 @@ def create_device( *, parent: str = None, device: resources.Device = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: @@ -832,7 +843,7 @@ def get_device( request: Union[device_manager.GetDeviceRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: @@ -903,7 +914,7 @@ def update_device( *, device: resources.Device = None, update_mask: field_mask_pb2.FieldMask = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.Device: @@ -988,7 +999,7 @@ def delete_device( request: Union[device_manager.DeleteDeviceRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> None: @@ -1053,7 +1064,7 @@ def list_devices( request: Union[device_manager.ListDevicesRequest, dict] = None, *, parent: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListDevicesPager: @@ -1133,7 +1144,7 @@ def modify_cloud_to_device_config( *, name: str = None, binary_data: bytes = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> resources.DeviceConfig: @@ -1219,7 +1230,7 @@ def list_device_config_versions( request: Union[device_manager.ListDeviceConfigVersionsRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.ListDeviceConfigVersionsResponse: @@ -1293,7 +1304,7 @@ def list_device_states( request: Union[device_manager.ListDeviceStatesRequest, dict] = None, *, name: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.ListDeviceStatesResponse: @@ -1364,7 +1375,7 @@ def set_iam_policy( request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1490,7 +1501,7 @@ def get_iam_policy( request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None, *, resource: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> policy_pb2.Policy: @@ -1618,7 +1629,7 @@ def test_iam_permissions( *, resource: str = None, permissions: Sequence[str] = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: @@ -1703,7 +1714,7 @@ def send_command_to_device( name: str = None, binary_data: bytes = None, subfolder: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.SendCommandToDeviceResponse: @@ -1817,7 +1828,7 @@ def bind_device_to_gateway( parent: str = None, gateway_id: str = None, device_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.BindDeviceToGatewayResponse: @@ -1906,7 +1917,7 @@ def unbind_device_from_gateway( parent: str = None, gateway_id: str = None, device_id: str = None, - retry: retries.Retry = gapic_v1.method.DEFAULT, + retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: float = None, metadata: Sequence[Tuple[str, str]] = (), ) -> device_manager.UnbindDeviceFromGatewayResponse: diff --git a/google/cloud/iot_v1/services/device_manager/transports/base.py b/google/cloud/iot_v1/services/device_manager/transports/base.py index 50704e4b..3435d32a 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/base.py +++ b/google/cloud/iot_v1/services/device_manager/transports/base.py @@ -15,14 +15,13 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import packaging.version import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore @@ -39,15 +38,6 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None - class DeviceManagerTransport(abc.ABC): """Abstract transport class for DeviceManager.""" @@ -100,7 +90,7 @@ def __init__( host += ":443" self._host = host - scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES} # Save the scopes. self._scopes = scopes @@ -116,7 +106,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id @@ -133,29 +122,6 @@ def __init__( # Save the credentials. self._credentials = credentials - # TODO(busunkim): This method is in the base transport - # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-auth is increased. - - # TODO: Remove this function once google-auth >= 1.25.0 is required - @classmethod - def _get_scopes_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Optional[Sequence[str]]]: - """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" - - scopes_kwargs = {} - - if _GOOGLE_AUTH_VERSION and ( - packaging.version.parse(_GOOGLE_AUTH_VERSION) - >= packaging.version.parse("1.25.0") - ): - scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} - else: - scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} - - return scopes_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc.py b/google/cloud/iot_v1/services/device_manager/transports/grpc.py index a46904f5..976558dd 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc.py @@ -16,8 +16,8 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py index cfc119b2..5cd35a9a 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py @@ -16,11 +16,10 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore diff --git a/google/cloud/iot_v1/types/device_manager.py b/google/cloud/iot_v1/types/device_manager.py index e5c492c1..dd6e161f 100644 --- a/google/cloud/iot_v1/types/device_manager.py +++ b/google/cloud/iot_v1/types/device_manager.py @@ -292,24 +292,37 @@ class GatewayListOptions(proto.Message): r"""Options for limiting the list based on gateway type and associations. + This message has `oneof`_ fields (mutually exclusive fields). + For each oneof, at most one member field can be set at the same time. + Setting any member of the oneof automatically clears all other + members. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: gateway_type (google.cloud.iot_v1.types.GatewayType): If ``GATEWAY`` is specified, only gateways are returned. If ``NON_GATEWAY`` is specified, only non-gateway devices are returned. If ``GATEWAY_TYPE_UNSPECIFIED`` is specified, all devices are returned. + + This field is a member of `oneof`_ ``filter``. associations_gateway_id (str): If set, only devices associated with the specified gateway are returned. The gateway ID can be numeric (``num_id``) or the user-defined string (``id``). For example, if ``123`` is specified, only devices bound to the gateway with ``num_id`` 123 are returned. + + This field is a member of `oneof`_ ``filter``. associations_device_id (str): If set, returns only the gateways with which the specified device is associated. The device ID can be numeric (``num_id``) or the user-defined string (``id``). For example, if ``456`` is specified, returns only the gateways to which the device with ``num_id`` 456 is bound. + + This field is a member of `oneof`_ ``filter``. """ gateway_type = proto.Field( diff --git a/google/cloud/iot_v1/types/resources.py b/google/cloud/iot_v1/types/resources.py index 36d92c46..e8a618d0 100644 --- a/google/cloud/iot_v1/types/resources.py +++ b/google/cloud/iot_v1/types/resources.py @@ -418,10 +418,15 @@ class RegistryCredential(proto.Message): r"""A server-stored registry credential used to validate device credentials. + + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: public_key_certificate (google.cloud.iot_v1.types.PublicKeyCertificate): A public key certificate used to verify the device credentials. + + This field is a member of `oneof`_ ``credential``. """ public_key_certificate = proto.Field( @@ -480,6 +485,8 @@ class PublicKeyCertificate(proto.Message): class DeviceCredential(proto.Message): r"""A server-stored device credential used for authentication. + .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields + Attributes: public_key (google.cloud.iot_v1.types.PublicKeyCredential): A public key used to verify the signature of @@ -498,6 +505,8 @@ class DeviceCredential(proto.Message): keys will be accepted. New device credentials must be different from every registry-level certificate. + + This field is a member of `oneof`_ ``credential``. expiration_time (google.protobuf.timestamp_pb2.Timestamp): [Optional] The time at which this credential becomes invalid. This credential will be ignored for new client diff --git a/setup.py b/setup.py index da575f07..71686a33 100644 --- a/setup.py +++ b/setup.py @@ -25,10 +25,9 @@ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 - "google-api-core[grpc] >= 1.26.0, <3.0.0dev", + "google-api-core[grpc] >= 1.28.0, <3.0.0dev", "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", - "proto-plus >= 1.4.0", - "packaging >= 14.3", + "proto-plus >= 1.15.0", ] extras = {"libcst": "libcst >= 0.2.5"} diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index a07c242f..685bbab0 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -4,9 +4,6 @@ # Pin the version to the lower bound. # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 -google-api-core==1.26.0 -proto-plus==1.4.0 +google-api-core==1.28.0 +proto-plus==1.15.0 grpc-google-iam-v1==0.12.3 -libcst==0.2.5 -packaging==14.3 -google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core diff --git a/tests/unit/gapic/iot_v1/test_device_manager.py b/tests/unit/gapic/iot_v1/test_device_manager.py index 262901eb..8ab367a8 100644 --- a/tests/unit/gapic/iot_v1/test_device_manager.py +++ b/tests/unit/gapic/iot_v1/test_device_manager.py @@ -15,7 +15,6 @@ # import os import mock -import packaging.version import grpc from grpc.experimental import aio @@ -36,9 +35,6 @@ from google.cloud.iot_v1.services.device_manager import DeviceManagerClient from google.cloud.iot_v1.services.device_manager import pagers from google.cloud.iot_v1.services.device_manager import transports -from google.cloud.iot_v1.services.device_manager.transports.base import ( - _GOOGLE_AUTH_VERSION, -) from google.cloud.iot_v1.types import device_manager from google.cloud.iot_v1.types import resources from google.iam.v1 import iam_policy_pb2 # type: ignore @@ -53,20 +49,6 @@ import google.auth -# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively -# through google-api-core: -# - Delete the auth "less than" test cases -# - Delete these pytest markers (Make the "greater than or equal to" tests the default). -requires_google_auth_lt_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), - reason="This test requires google-auth < 1.25.0", -) -requires_google_auth_gte_1_25_0 = pytest.mark.skipif( - packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), - reason="This test requires google-auth >= 1.25.0", -) - - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -223,7 +205,7 @@ def test_device_manager_client_client_options( options = client_options.ClientOptions(api_endpoint="squid.clam.whelk") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(transport=transport_name, client_options=options) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -240,7 +222,7 @@ def test_device_manager_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -257,7 +239,7 @@ def test_device_manager_client_client_options( with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -273,20 +255,20 @@ def test_device_manager_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -345,7 +327,7 @@ def test_device_manager_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -387,7 +369,7 @@ def test_device_manager_client_mtls_env_auto( expected_client_cert_source = client_cert_source_callback patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -409,7 +391,7 @@ def test_device_manager_client_mtls_env_auto( return_value=False, ): patched.return_value = None - client = client_class() + client = client_class(transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -440,7 +422,7 @@ def test_device_manager_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -471,7 +453,7 @@ def test_device_manager_client_client_options_credentials_file( options = client_options.ClientOptions(credentials_file="credentials.json") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -504,9 +486,10 @@ def test_device_manager_client_client_options_from_dict(): ) -def test_create_device_registry( - transport: str = "grpc", request_type=device_manager.CreateDeviceRegistryRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.CreateDeviceRegistryRequest, dict,] +) +def test_create_device_registry(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -537,10 +520,6 @@ def test_create_device_registry( assert response.log_level == resources.LogLevel.NONE -def test_create_device_registry_from_dict(): - test_create_device_registry(request_type=dict) - - def test_create_device_registry_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -677,8 +656,12 @@ def test_create_device_registry_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].device_registry == resources.DeviceRegistry(id="id_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].device_registry + mock_val = resources.DeviceRegistry(id="id_value") + assert arg == mock_val def test_create_device_registry_flattened_error(): @@ -721,8 +704,12 @@ async def test_create_device_registry_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].device_registry == resources.DeviceRegistry(id="id_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].device_registry + mock_val = resources.DeviceRegistry(id="id_value") + assert arg == mock_val @pytest.mark.asyncio @@ -741,9 +728,10 @@ async def test_create_device_registry_flattened_error_async(): ) -def test_get_device_registry( - transport: str = "grpc", request_type=device_manager.GetDeviceRegistryRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.GetDeviceRegistryRequest, dict,] +) +def test_get_device_registry(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -774,10 +762,6 @@ def test_get_device_registry( assert response.log_level == resources.LogLevel.NONE -def test_get_device_registry_from_dict(): - test_get_device_registry(request_type=dict) - - def test_get_device_registry_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -911,7 +895,9 @@ def test_get_device_registry_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_device_registry_flattened_error(): @@ -949,7 +935,9 @@ async def test_get_device_registry_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -966,9 +954,10 @@ async def test_get_device_registry_flattened_error_async(): ) -def test_update_device_registry( - transport: str = "grpc", request_type=device_manager.UpdateDeviceRegistryRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.UpdateDeviceRegistryRequest, dict,] +) +def test_update_device_registry(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -999,10 +988,6 @@ def test_update_device_registry( assert response.log_level == resources.LogLevel.NONE -def test_update_device_registry_from_dict(): - test_update_device_registry(request_type=dict) - - def test_update_device_registry_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1145,8 +1130,12 @@ def test_update_device_registry_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].device_registry == resources.DeviceRegistry(id="id_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].device_registry + mock_val = resources.DeviceRegistry(id="id_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_device_registry_flattened_error(): @@ -1189,8 +1178,12 @@ async def test_update_device_registry_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].device_registry == resources.DeviceRegistry(id="id_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].device_registry + mock_val = resources.DeviceRegistry(id="id_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -1209,9 +1202,10 @@ async def test_update_device_registry_flattened_error_async(): ) -def test_delete_device_registry( - transport: str = "grpc", request_type=device_manager.DeleteDeviceRegistryRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.DeleteDeviceRegistryRequest, dict,] +) +def test_delete_device_registry(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1237,10 +1231,6 @@ def test_delete_device_registry( assert response is None -def test_delete_device_registry_from_dict(): - test_delete_device_registry(request_type=dict) - - def test_delete_device_registry_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1365,7 +1355,9 @@ def test_delete_device_registry_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_device_registry_flattened_error(): @@ -1401,7 +1393,9 @@ async def test_delete_device_registry_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1418,9 +1412,10 @@ async def test_delete_device_registry_flattened_error_async(): ) -def test_list_device_registries( - transport: str = "grpc", request_type=device_manager.ListDeviceRegistriesRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.ListDeviceRegistriesRequest, dict,] +) +def test_list_device_registries(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1449,10 +1444,6 @@ def test_list_device_registries( assert response.next_page_token == "next_page_token_value" -def test_list_device_registries_from_dict(): - test_list_device_registries(request_type=dict) - - def test_list_device_registries_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1584,7 +1575,9 @@ def test_list_device_registries_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_device_registries_flattened_error(): @@ -1622,7 +1615,9 @@ async def test_list_device_registries_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1639,8 +1634,10 @@ async def test_list_device_registries_flattened_error_async(): ) -def test_list_device_registries_pager(): - client = DeviceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_device_registries_pager(transport_name: str = "grpc"): + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1684,8 +1681,10 @@ def test_list_device_registries_pager(): assert all(isinstance(i, resources.DeviceRegistry) for i in results) -def test_list_device_registries_pages(): - client = DeviceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_device_registries_pages(transport_name: str = "grpc"): + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1805,9 +1804,8 @@ async def test_list_device_registries_async_pages(): assert page_.raw_page.next_page_token == token -def test_create_device( - transport: str = "grpc", request_type=device_manager.CreateDeviceRequest -): +@pytest.mark.parametrize("request_type", [device_manager.CreateDeviceRequest, dict,]) +def test_create_device(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1842,10 +1840,6 @@ def test_create_device( assert response.log_level == resources.LogLevel.NONE -def test_create_device_from_dict(): - test_create_device(request_type=dict) - - def test_create_device_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1974,8 +1968,12 @@ def test_create_device_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].device == resources.Device(id="id_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].device + mock_val = resources.Device(id="id_value") + assert arg == mock_val def test_create_device_flattened_error(): @@ -2013,8 +2011,12 @@ async def test_create_device_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].device == resources.Device(id="id_value") + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].device + mock_val = resources.Device(id="id_value") + assert arg == mock_val @pytest.mark.asyncio @@ -2033,9 +2035,8 @@ async def test_create_device_flattened_error_async(): ) -def test_get_device( - transport: str = "grpc", request_type=device_manager.GetDeviceRequest -): +@pytest.mark.parametrize("request_type", [device_manager.GetDeviceRequest, dict,]) +def test_get_device(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2070,10 +2071,6 @@ def test_get_device( assert response.log_level == resources.LogLevel.NONE -def test_get_device_from_dict(): - test_get_device(request_type=dict) - - def test_get_device_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2200,7 +2197,9 @@ def test_get_device_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_device_flattened_error(): @@ -2234,7 +2233,9 @@ async def test_get_device_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2251,9 +2252,8 @@ async def test_get_device_flattened_error_async(): ) -def test_update_device( - transport: str = "grpc", request_type=device_manager.UpdateDeviceRequest -): +@pytest.mark.parametrize("request_type", [device_manager.UpdateDeviceRequest, dict,]) +def test_update_device(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2288,10 +2288,6 @@ def test_update_device( assert response.log_level == resources.LogLevel.NONE -def test_update_device_from_dict(): - test_update_device(request_type=dict) - - def test_update_device_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2421,8 +2417,12 @@ def test_update_device_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].device == resources.Device(id="id_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].device + mock_val = resources.Device(id="id_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_device_flattened_error(): @@ -2461,8 +2461,12 @@ async def test_update_device_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].device == resources.Device(id="id_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].device + mock_val = resources.Device(id="id_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -2481,9 +2485,8 @@ async def test_update_device_flattened_error_async(): ) -def test_delete_device( - transport: str = "grpc", request_type=device_manager.DeleteDeviceRequest -): +@pytest.mark.parametrize("request_type", [device_manager.DeleteDeviceRequest, dict,]) +def test_delete_device(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2507,10 +2510,6 @@ def test_delete_device( assert response is None -def test_delete_device_from_dict(): - test_delete_device(request_type=dict) - - def test_delete_device_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2624,7 +2623,9 @@ def test_delete_device_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_device_flattened_error(): @@ -2658,7 +2659,9 @@ async def test_delete_device_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2675,9 +2678,8 @@ async def test_delete_device_flattened_error_async(): ) -def test_list_devices( - transport: str = "grpc", request_type=device_manager.ListDevicesRequest -): +@pytest.mark.parametrize("request_type", [device_manager.ListDevicesRequest, dict,]) +def test_list_devices(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2704,10 +2706,6 @@ def test_list_devices( assert response.next_page_token == "next_page_token_value" -def test_list_devices_from_dict(): - test_list_devices(request_type=dict) - - def test_list_devices_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2826,7 +2824,9 @@ def test_list_devices_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_devices_flattened_error(): @@ -2862,7 +2862,9 @@ async def test_list_devices_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2879,8 +2881,10 @@ async def test_list_devices_flattened_error_async(): ) -def test_list_devices_pager(): - client = DeviceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_devices_pager(transport_name: str = "grpc"): + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_devices), "__call__") as call: @@ -2913,8 +2917,10 @@ def test_list_devices_pager(): assert all(isinstance(i, resources.Device) for i in results) -def test_list_devices_pages(): - client = DeviceManagerClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_devices_pages(transport_name: str = "grpc"): + client = DeviceManagerClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_devices), "__call__") as call: @@ -3001,10 +3007,10 @@ async def test_list_devices_async_pages(): assert page_.raw_page.next_page_token == token -def test_modify_cloud_to_device_config( - transport: str = "grpc", - request_type=device_manager.ModifyCloudToDeviceConfigRequest, -): +@pytest.mark.parametrize( + "request_type", [device_manager.ModifyCloudToDeviceConfigRequest, dict,] +) +def test_modify_cloud_to_device_config(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3034,10 +3040,6 @@ def test_modify_cloud_to_device_config( assert response.binary_data == b"binary_data_blob" -def test_modify_cloud_to_device_config_from_dict(): - test_modify_cloud_to_device_config(request_type=dict) - - def test_modify_cloud_to_device_config_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3170,8 +3172,12 @@ def test_modify_cloud_to_device_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].binary_data == b"binary_data_blob" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].binary_data + mock_val = b"binary_data_blob" + assert arg == mock_val def test_modify_cloud_to_device_config_flattened_error(): @@ -3213,8 +3219,12 @@ async def test_modify_cloud_to_device_config_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].binary_data == b"binary_data_blob" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].binary_data + mock_val = b"binary_data_blob" + assert arg == mock_val @pytest.mark.asyncio @@ -3233,9 +3243,10 @@ async def test_modify_cloud_to_device_config_flattened_error_async(): ) -def test_list_device_config_versions( - transport: str = "grpc", request_type=device_manager.ListDeviceConfigVersionsRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.ListDeviceConfigVersionsRequest, dict,] +) +def test_list_device_config_versions(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3261,10 +3272,6 @@ def test_list_device_config_versions( assert isinstance(response, device_manager.ListDeviceConfigVersionsResponse) -def test_list_device_config_versions_from_dict(): - test_list_device_config_versions(request_type=dict) - - def test_list_device_config_versions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3393,7 +3400,9 @@ def test_list_device_config_versions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_list_device_config_versions_flattened_error(): @@ -3431,7 +3440,9 @@ async def test_list_device_config_versions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3448,9 +3459,10 @@ async def test_list_device_config_versions_flattened_error_async(): ) -def test_list_device_states( - transport: str = "grpc", request_type=device_manager.ListDeviceStatesRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.ListDeviceStatesRequest, dict,] +) +def test_list_device_states(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3476,10 +3488,6 @@ def test_list_device_states( assert isinstance(response, device_manager.ListDeviceStatesResponse) -def test_list_device_states_from_dict(): - test_list_device_states(request_type=dict) - - def test_list_device_states_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3607,7 +3615,9 @@ def test_list_device_states_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_list_device_states_flattened_error(): @@ -3645,7 +3655,9 @@ async def test_list_device_states_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3662,9 +3674,8 @@ async def test_list_device_states_flattened_error_async(): ) -def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.SetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +def test_set_iam_policy(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3690,10 +3701,6 @@ def test_set_iam_policy( assert response.etag == b"etag_blob" -def test_set_iam_policy_from_dict(): - test_set_iam_policy(request_type=dict) - - def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3826,7 +3833,9 @@ def test_set_iam_policy_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val def test_set_iam_policy_flattened_error(): @@ -3860,7 +3869,9 @@ async def test_set_iam_policy_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3877,9 +3888,8 @@ async def test_set_iam_policy_flattened_error_async(): ) -def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.GetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +def test_get_iam_policy(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3905,10 +3915,6 @@ def test_get_iam_policy( assert response.etag == b"etag_blob" -def test_get_iam_policy_from_dict(): - test_get_iam_policy(request_type=dict) - - def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4041,7 +4047,9 @@ def test_get_iam_policy_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val def test_get_iam_policy_flattened_error(): @@ -4075,7 +4083,9 @@ async def test_get_iam_policy_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4092,9 +4102,10 @@ async def test_get_iam_policy_flattened_error_async(): ) -def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy_pb2.TestIamPermissionsRequest -): +@pytest.mark.parametrize( + "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4123,10 +4134,6 @@ def test_test_iam_permissions( assert response.permissions == ["permissions_value"] -def test_test_iam_permissions_from_dict(): - test_test_iam_permissions(request_type=dict) - - def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4277,8 +4284,12 @@ def test_test_iam_permissions_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" - assert args[0].permissions == ["permissions_value"] + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val + arg = args[0].permissions + mock_val = ["permissions_value"] + assert arg == mock_val def test_test_iam_permissions_flattened_error(): @@ -4320,8 +4331,12 @@ async def test_test_iam_permissions_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].resource == "resource_value" - assert args[0].permissions == ["permissions_value"] + arg = args[0].resource + mock_val = "resource_value" + assert arg == mock_val + arg = args[0].permissions + mock_val = ["permissions_value"] + assert arg == mock_val @pytest.mark.asyncio @@ -4340,9 +4355,10 @@ async def test_test_iam_permissions_flattened_error_async(): ) -def test_send_command_to_device( - transport: str = "grpc", request_type=device_manager.SendCommandToDeviceRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.SendCommandToDeviceRequest, dict,] +) +def test_send_command_to_device(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4368,10 +4384,6 @@ def test_send_command_to_device( assert isinstance(response, device_manager.SendCommandToDeviceResponse) -def test_send_command_to_device_from_dict(): - test_send_command_to_device(request_type=dict) - - def test_send_command_to_device_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4504,9 +4516,15 @@ def test_send_command_to_device_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].binary_data == b"binary_data_blob" - assert args[0].subfolder == "subfolder_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].binary_data + mock_val = b"binary_data_blob" + assert arg == mock_val + arg = args[0].subfolder + mock_val = "subfolder_value" + assert arg == mock_val def test_send_command_to_device_flattened_error(): @@ -4551,9 +4569,15 @@ async def test_send_command_to_device_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" - assert args[0].binary_data == b"binary_data_blob" - assert args[0].subfolder == "subfolder_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val + arg = args[0].binary_data + mock_val = b"binary_data_blob" + assert arg == mock_val + arg = args[0].subfolder + mock_val = "subfolder_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4573,9 +4597,10 @@ async def test_send_command_to_device_flattened_error_async(): ) -def test_bind_device_to_gateway( - transport: str = "grpc", request_type=device_manager.BindDeviceToGatewayRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.BindDeviceToGatewayRequest, dict,] +) +def test_bind_device_to_gateway(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4601,10 +4626,6 @@ def test_bind_device_to_gateway( assert isinstance(response, device_manager.BindDeviceToGatewayResponse) -def test_bind_device_to_gateway_from_dict(): - test_bind_device_to_gateway(request_type=dict) - - def test_bind_device_to_gateway_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4737,9 +4758,15 @@ def test_bind_device_to_gateway_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway_id == "gateway_id_value" - assert args[0].device_id == "device_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].gateway_id + mock_val = "gateway_id_value" + assert arg == mock_val + arg = args[0].device_id + mock_val = "device_id_value" + assert arg == mock_val def test_bind_device_to_gateway_flattened_error(): @@ -4784,9 +4811,15 @@ async def test_bind_device_to_gateway_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway_id == "gateway_id_value" - assert args[0].device_id == "device_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].gateway_id + mock_val = "gateway_id_value" + assert arg == mock_val + arg = args[0].device_id + mock_val = "device_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4806,9 +4839,10 @@ async def test_bind_device_to_gateway_flattened_error_async(): ) -def test_unbind_device_from_gateway( - transport: str = "grpc", request_type=device_manager.UnbindDeviceFromGatewayRequest -): +@pytest.mark.parametrize( + "request_type", [device_manager.UnbindDeviceFromGatewayRequest, dict,] +) +def test_unbind_device_from_gateway(request_type, transport: str = "grpc"): client = DeviceManagerClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4834,10 +4868,6 @@ def test_unbind_device_from_gateway( assert isinstance(response, device_manager.UnbindDeviceFromGatewayResponse) -def test_unbind_device_from_gateway_from_dict(): - test_unbind_device_from_gateway(request_type=dict) - - def test_unbind_device_from_gateway_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4970,9 +5000,15 @@ def test_unbind_device_from_gateway_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway_id == "gateway_id_value" - assert args[0].device_id == "device_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].gateway_id + mock_val = "gateway_id_value" + assert arg == mock_val + arg = args[0].device_id + mock_val = "device_id_value" + assert arg == mock_val def test_unbind_device_from_gateway_flattened_error(): @@ -5017,9 +5053,15 @@ async def test_unbind_device_from_gateway_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].gateway_id == "gateway_id_value" - assert args[0].device_id == "device_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].gateway_id + mock_val = "gateway_id_value" + assert arg == mock_val + arg = args[0].device_id + mock_val = "device_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -5164,7 +5206,6 @@ def test_device_manager_base_transport(): transport.close() -@requires_google_auth_gte_1_25_0 def test_device_manager_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( @@ -5188,29 +5229,6 @@ def test_device_manager_base_transport_with_credentials_file(): ) -@requires_google_auth_lt_1_25_0 -def test_device_manager_base_transport_with_credentials_file_old_google_auth(): - # Instantiate the base transport with a credentials file - with mock.patch.object( - google.auth, "load_credentials_from_file", autospec=True - ) as load_creds, mock.patch( - "google.cloud.iot_v1.services.device_manager.transports.DeviceManagerTransport._prep_wrapped_messages" - ) as Transport: - Transport.return_value = None - load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) - transport = transports.DeviceManagerTransport( - credentials_file="credentials.json", quota_project_id="octopus", - ) - load_creds.assert_called_once_with( - "credentials.json", - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudiot", - ), - quota_project_id="octopus", - ) - - def test_device_manager_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( @@ -5222,7 +5240,6 @@ def test_device_manager_base_transport_with_adc(): adc.assert_called_once() -@requires_google_auth_gte_1_25_0 def test_device_manager_auth_adc(): # If no credentials are provided, we should use ADC credentials. with mock.patch.object(google.auth, "default", autospec=True) as adc: @@ -5238,21 +5255,6 @@ def test_device_manager_auth_adc(): ) -@requires_google_auth_lt_1_25_0 -def test_device_manager_auth_adc_old_google_auth(): - # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - DeviceManagerClient() - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudiot", - ), - quota_project_id=None, - ) - - @pytest.mark.parametrize( "transport_class", [ @@ -5260,7 +5262,6 @@ def test_device_manager_auth_adc_old_google_auth(): transports.DeviceManagerGrpcAsyncIOTransport, ], ) -@requires_google_auth_gte_1_25_0 def test_device_manager_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -5277,29 +5278,6 @@ def test_device_manager_transport_auth_adc(transport_class): ) -@pytest.mark.parametrize( - "transport_class", - [ - transports.DeviceManagerGrpcTransport, - transports.DeviceManagerGrpcAsyncIOTransport, - ], -) -@requires_google_auth_lt_1_25_0 -def test_device_manager_transport_auth_adc_old_google_auth(transport_class): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object(google.auth, "default", autospec=True) as adc: - adc.return_value = (ga_credentials.AnonymousCredentials(), None) - transport_class(quota_project_id="octopus") - adc.assert_called_once_with( - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/cloudiot", - ), - quota_project_id="octopus", - ) - - @pytest.mark.parametrize( "transport_class,grpc_helpers", [ @@ -5671,7 +5649,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( From d063467ec22bfd8a06069fdb86a2ace2a8513960 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 01:16:13 +0000 Subject: [PATCH 15/28] chore: update templated files using the latest post processor image (#236) --- .github/.OwlBot.lock.yaml | 2 +- .github/CODEOWNERS | 9 +-- .github/release-please.yml | 1 + .github/release-trigger.yml | 1 + .kokoro/docs/common.cfg | 1 + .kokoro/release.sh | 2 +- .kokoro/release/common.cfg | 12 +++- noxfile.py | 2 +- samples/AUTHORING_GUIDE.md | 2 +- samples/CONTRIBUTING.md | 2 +- .../api-client/accesstoken_example/noxfile.py | 71 +++++++++++-------- samples/api-client/manager/noxfile.py | 71 +++++++++++-------- samples/api-client/mqtt_example/noxfile.py | 71 +++++++++++-------- 13 files changed, 144 insertions(+), 103 deletions(-) create mode 100644 .github/release-trigger.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 7d98291c..52d79c11 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:58f73ba196b5414782605236dd0712a73541b44ff2ff4d3a36ec41092dd6fa5b + digest: sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1aad53aa..23c835c8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,9 +3,10 @@ # # For syntax help see: # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax +# Note: This file is autogenerated. To make changes to the codeowner team, please update .repo-metadata.json. -# The @googleapis/yoshi-python is the default owner for changes in this repo -* @googleapis/yoshi-python +# @googleapis/yoshi-python @googleapis/api-iot are the default owners for changes in this repo +* @googleapis/yoshi-python @googleapis/api-iot - -/samples/**/*.py @gcseh @googleapis/api-iot @googleapis/python-samples-owners \ No newline at end of file +# @googleapis/python-samples-reviewers @googleapis/api-iot are the default owners for samples changes +/samples/ @googleapis/python-samples-reviewers @googleapis/api-iot diff --git a/.github/release-please.yml b/.github/release-please.yml index 4507ad05..466597e5 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: python +handleGHRelease: true diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 00000000..d4ca9418 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index 8d2b6443..9f4bf34f 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -30,6 +30,7 @@ env_vars: { env_vars: { key: "V2_STAGING_BUCKET" + # Push google cloud library docs to the Cloud RAD bucket `docs-staging-v2` value: "docs-staging-v2" } diff --git a/.kokoro/release.sh b/.kokoro/release.sh index baeeaacd..15219a1e 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-iot python3 setup.py sdist bdist_wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 37d9075e..764da078 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-iot/.kokoro/release.sh" } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } +} + # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/noxfile.py b/noxfile.py index 672b28d6..f041f1f5 100644 --- a/noxfile.py +++ b/noxfile.py @@ -101,7 +101,7 @@ def default(session): "py.test", "--quiet", f"--junitxml=unit_{session.python}_sponge_log.xml", - "--cov=google/cloud", + "--cov=google", "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", diff --git a/samples/AUTHORING_GUIDE.md b/samples/AUTHORING_GUIDE.md index 55c97b32..8249522f 100644 --- a/samples/AUTHORING_GUIDE.md +++ b/samples/AUTHORING_GUIDE.md @@ -1 +1 @@ -See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md \ No newline at end of file +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md \ No newline at end of file diff --git a/samples/CONTRIBUTING.md b/samples/CONTRIBUTING.md index 34c882b6..f5fe2e6b 100644 --- a/samples/CONTRIBUTING.md +++ b/samples/CONTRIBUTING.md @@ -1 +1 @@ -See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md \ No newline at end of file +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md \ No newline at end of file diff --git a/samples/api-client/accesstoken_example/noxfile.py b/samples/api-client/accesstoken_example/noxfile.py index 6c2af674..3637109c 100644 --- a/samples/api-client/accesstoken_example/noxfile.py +++ b/samples/api-client/accesstoken_example/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,45 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) diff --git a/samples/api-client/manager/noxfile.py b/samples/api-client/manager/noxfile.py index 93a9122c..20cdfc62 100644 --- a/samples/api-client/manager/noxfile.py +++ b/samples/api-client/manager/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,45 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) diff --git a/samples/api-client/mqtt_example/noxfile.py b/samples/api-client/mqtt_example/noxfile.py index 6c2af674..3637109c 100644 --- a/samples/api-client/mqtt_example/noxfile.py +++ b/samples/api-client/mqtt_example/noxfile.py @@ -14,6 +14,7 @@ from __future__ import print_function +import glob import os from pathlib import Path import sys @@ -184,37 +185,45 @@ def blacken(session: nox.sessions.Session) -> None: def _session_tests( session: nox.sessions.Session, post_install: Callable = None ) -> None: - if TEST_CONFIG["pip_version_override"]: - pip_version = TEST_CONFIG["pip_version_override"] - session.install(f"pip=={pip_version}") - """Runs py.test for a particular project.""" - if os.path.exists("requirements.txt"): - if os.path.exists("constraints.txt"): - session.install("-r", "requirements.txt", "-c", "constraints.txt") - else: - session.install("-r", "requirements.txt") - - if os.path.exists("requirements-test.txt"): - if os.path.exists("constraints-test.txt"): - session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt") - else: - session.install("-r", "requirements-test.txt") - - if INSTALL_LIBRARY_FROM_SOURCE: - session.install("-e", _get_repo_root()) - - if post_install: - post_install(session) - - session.run( - "pytest", - *(PYTEST_COMMON_ARGS + session.posargs), - # Pytest will return 5 when no tests are collected. This can happen - # on travis where slow and flaky tests are excluded. - # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html - success_codes=[0, 5], - env=get_pytest_env_vars(), - ) + # check for presence of tests + test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) + if len(test_list) == 0: + print("No tests found, skipping directory.") + else: + if TEST_CONFIG["pip_version_override"]: + pip_version = TEST_CONFIG["pip_version_override"] + session.install(f"pip=={pip_version}") + """Runs py.test for a particular project.""" + if os.path.exists("requirements.txt"): + if os.path.exists("constraints.txt"): + session.install("-r", "requirements.txt", "-c", "constraints.txt") + else: + session.install("-r", "requirements.txt") + + if os.path.exists("requirements-test.txt"): + if os.path.exists("constraints-test.txt"): + session.install( + "-r", "requirements-test.txt", "-c", "constraints-test.txt" + ) + else: + session.install("-r", "requirements-test.txt") + + if INSTALL_LIBRARY_FROM_SOURCE: + session.install("-e", _get_repo_root()) + + if post_install: + post_install(session) + + session.run( + "pytest", + *(PYTEST_COMMON_ARGS + session.posargs), + # Pytest will return 5 when no tests are collected. This can happen + # on travis where slow and flaky tests are excluded. + # See http://doc.pytest.org/en/latest/_modules/_pytest/main.html + success_codes=[0, 5], + env=get_pytest_env_vars(), + ) @nox.session(python=ALL_VERSIONS) From 6e38180c3f32e3f37cacb90c9a3fdbb442e21a41 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 21 Jan 2022 20:41:18 -0500 Subject: [PATCH 16/28] ci(python): run lint / unit tests / docs as GH actions (#238) * ci(python): run lint / unit tests / docs as GH actions Source-Link: https://github.com/googleapis/synthtool/commit/57be0cdb0b94e1669cee0ca38d790de1dfdbcd44 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 * add commit to trigger gh action * add commit to trigger gh action Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 16 +++++++++- .github/workflows/docs.yml | 38 +++++++++++++++++++++++ .github/workflows/lint.yml | 25 +++++++++++++++ .github/workflows/unittest.yml | 57 ++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/unittest.yml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 52d79c11..b668c04d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,17 @@ +# Copyright 2022 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. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828 + digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 + diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..f7b8344c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - main +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1e8b05c3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..074ee250 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=100 From 135c1a47659d9d789ff125aa4f7992138b426276 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 09:50:32 -0500 Subject: [PATCH 17/28] chore(python): set coverage level to 100% (#242) * chore(python): use cov_level in unittest gh action Source-Link: https://github.com/googleapis/synthtool/commit/e5aaa84b1dda1829c54d4696827817f133ed9780 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:d22cd2ddce65fdac6986f115563faf2fc81482b09dfbea83ac2808c92ecfdff0 * set coverage level to 100% Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 3 +-- noxfile.py | 2 +- owlbot.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index b668c04d..39ad3cec 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 - + digest: sha256:d22cd2ddce65fdac6986f115563faf2fc81482b09dfbea83ac2808c92ecfdff0 diff --git a/noxfile.py b/noxfile.py index f041f1f5..2a2001c4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -175,7 +175,7 @@ def cover(session): test runs (not system test runs), and then erases coverage data. """ session.install("coverage", "pytest-cov") - session.run("coverage", "report", "--show-missing", "--fail-under=98") + session.run("coverage", "report", "--show-missing", "--fail-under=100") session.run("coverage", "erase") diff --git a/owlbot.py b/owlbot.py index 72aefc22..5e3c46be 100644 --- a/owlbot.py +++ b/owlbot.py @@ -39,7 +39,7 @@ templated_files = common.py_library( samples=True, microgenerator=True, - cov_level=98, + cov_level=100, ) s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file From 944d48eaf77fd0c01f0363992a817df1a6bb4fd8 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Mon, 24 Jan 2022 13:13:49 -0700 Subject: [PATCH 18/28] chore: make samples 3.6 check optional (#243) --- .github/sync-repo-settings.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 3e98ae70..37438d33 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -10,6 +10,5 @@ branchProtectionRules: - 'Kokoro' - 'cla/google' - 'Samples - Lint' - - 'Samples - Python 3.6' - 'Samples - Python 3.7' - 'Samples - Python 3.8' From 63f5a9327c36714b688fd742fe8beeb0182e2146 Mon Sep 17 00:00:00 2001 From: sobowale olamide adekunle Date: Tue, 25 Jan 2022 15:01:41 +0100 Subject: [PATCH 19/28] docs(samples): modify accesstoken sample to use environment identity during setup (#245) * Feat: Modify accesstoken flow to use environment identity during setup. * Bug: Trigger CI * Feat: Trigger CI * Bug: Trigger CL. * Feat: Refactor accesstoken flow. * Feat: Trigger CI. * Feat: Revamp Cloud Iot Access token flow to use environment identity during setup instead of device identity. --- .../accesstoken_example/accesstoken.py | 57 +++++++------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/samples/api-client/accesstoken_example/accesstoken.py b/samples/api-client/accesstoken_example/accesstoken.py index 35073a6f..09414243 100644 --- a/samples/api-client/accesstoken_example/accesstoken.py +++ b/samples/api-client/accesstoken_example/accesstoken.py @@ -42,6 +42,8 @@ import os import time +from google.cloud import pubsub +from google.cloud import storage import jwt import requests as req @@ -127,18 +129,16 @@ def publish_pubsub_message( rsa_private_key_path, ) - # Create Pub/Sub topic - request_path = "https://pubsub.googleapis.com/v1/projects/{}/topics/{}".format( - project_id, topic_id - ) + pubsub_client = pubsub.PublisherClient() + topic_path = pubsub_client.topic_path(project_id, topic_id) + pubsub_client.create_topic(request={"name": topic_path}) + print("Successfully created Pub/Sub topic: {}.".format(topic_id)) + headers = { "Authorization": "Bearer {}".format(access_token), "content-type": "application/json", "cache-control": "no-cache", } - resp = req.put(url=request_path, data={}, headers=headers) - assert resp.ok, resp.raise_for_status() - print("Successfully created Pub/Sub topic: {}.".format(topic_id)) # Publish message to Pub/Sub topic publish_payload = { @@ -160,11 +160,7 @@ def publish_pubsub_message( ) # Delete Pub/Sub topic - pubsub_delete_request_path = "https://pubsub.googleapis.com/v1/projects/{}/topics/{}".format( - project_id, topic_id - ) - delete_resp = req.delete(url=pubsub_delete_request_path, headers=headers) - assert delete_resp.ok, delete_resp.raise_for_status() + pubsub_client.delete_topic(request={"topic": topic_path}) print("Successfully deleted Pub/Sub topic: {}".format(topic_id)) # [END iot_access_token_pubsub] @@ -202,27 +198,18 @@ def download_cloud_storage_file( rsa_private_key_path, ) - # Create GCS bucket - create_payload = { - "name": bucket_name, - "location": cloud_region, - "storageClass": "STANDARD", - "iamConfiguration": {"uniformBucketLevelAccess": {"enabled": True}}, - } - create_request_path = "https://storage.googleapis.com/storage/v1/b?project={}".format( - project_id - ) headers = { "authorization": "Bearer {}".format(access_token), "content-type": "application/json", "cache-control": "no-cache", } - create_resp = req.post( - url=create_request_path, - data=bytes(json.dumps(create_payload), "utf-8"), - headers=headers, - ) - assert create_resp.ok, create_resp.raise_for_status() + + # Create GCS bucket + storage_client = storage.Client() + bucket = storage_client.bucket(bucket_name) + bucket.storage_class = "COLDLINE" + bucket.iam_configuration.uniform_bucket_level_access_enabled = True + storage_client.create_bucket(bucket, location=cloud_region) print("Successfully created Storage bucket: {}".format(bucket_name)) # Upload data to GCS bucket. @@ -232,6 +219,7 @@ def download_cloud_storage_file( bucket_name, data_name ) upload_resp = req.post(url=upload_request_path, data=binary_data, headers=headers) + print("Upload response: ", upload_resp.json()) assert upload_resp.ok, upload_resp.raise_for_status() print( "Successfully uploaded {} as {} to bucket {}.".format( @@ -248,19 +236,12 @@ def download_cloud_storage_file( print("Successfully downloaded {} from bucket {}.".format(data_name, bucket_name)) # Delete data from GCS bucket. - delete_request_path = "https://storage.googleapis.com/storage/v1/b/{}/o/{}".format( - bucket_name, data_name - ) - delete_data_resp = req.delete(url=delete_request_path, headers=headers) - assert delete_data_resp.ok, delete_data_resp.raise_for_status() + blob = bucket.blob(data_name) + blob.delete() print("Successfully deleted {} from bucket {}.".format(data_name, bucket_name)) # Delete GCS Bucket - gcs_delete_request_path = "https://storage.googleapis.com/storage/v1/b/{}".format( - bucket_name - ) - delete_resp = req.delete(url=gcs_delete_request_path, headers=headers) - assert delete_resp.ok, delete_resp.raise_for_status() + bucket.delete() print("Successfully deleted bucket: {}".format(bucket_name)) # [END iot_access_token_gcs] From c3ec086cbce1171509438ba7ced62b041b690d58 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 25 Jan 2022 10:07:22 -0500 Subject: [PATCH 20/28] feat: add api key support (#244) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: upgrade gapic-generator-java, gax-java and gapic-generator-python PiperOrigin-RevId: 423842556 Source-Link: https://github.com/googleapis/googleapis/commit/a616ca08f4b1416abbac7bc5dd6d61c791756a81 Source-Link: https://github.com/googleapis/googleapis-gen/commit/29b938c58c1e51d019f2ee539d55dc0a3c86a905 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMjliOTM4YzU4YzFlNTFkMDE5ZjJlZTUzOWQ1NWRjMGEzYzg2YTkwNSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .../services/device_manager/async_client.py | 38 +++++- .../iot_v1/services/device_manager/client.py | 127 +++++++++++------ .../unit/gapic/iot_v1/test_device_manager.py | 128 ++++++++++++++++++ 3 files changed, 249 insertions(+), 44 deletions(-) diff --git a/google/cloud/iot_v1/services/device_manager/async_client.py b/google/cloud/iot_v1/services/device_manager/async_client.py index a19eb02c..18931a01 100644 --- a/google/cloud/iot_v1/services/device_manager/async_client.py +++ b/google/cloud/iot_v1/services/device_manager/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -116,6 +116,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return DeviceManagerClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> DeviceManagerTransport: """Returns the transport used by the client instance. diff --git a/google/cloud/iot_v1/services/device_manager/client.py b/google/cloud/iot_v1/services/device_manager/client.py index 6a1943d5..d6fafc3b 100644 --- a/google/cloud/iot_v1/services/device_manager/client.py +++ b/google/cloud/iot_v1/services/device_manager/client.py @@ -256,6 +256,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -306,57 +373,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, DeviceManagerTransport): # transport is a DeviceManagerTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -368,6 +400,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, diff --git a/tests/unit/gapic/iot_v1/test_device_manager.py b/tests/unit/gapic/iot_v1/test_device_manager.py index 8ab367a8..1eae43ce 100644 --- a/tests/unit/gapic/iot_v1/test_device_manager.py +++ b/tests/unit/gapic/iot_v1/test_device_manager.py @@ -404,6 +404,87 @@ def test_device_manager_client_mtls_env_auto( ) +@pytest.mark.parametrize( + "client_class", [DeviceManagerClient, DeviceManagerAsyncClient] +) +@mock.patch.object( + DeviceManagerClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(DeviceManagerClient), +) +@mock.patch.object( + DeviceManagerAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(DeviceManagerAsyncClient), +) +def test_device_manager_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -5101,6 +5182,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.DeviceManagerGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeviceManagerClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = DeviceManagerClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.DeviceManagerGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -5714,3 +5812,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (DeviceManagerClient, transports.DeviceManagerGrpcTransport), + (DeviceManagerAsyncClient, transports.DeviceManagerGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) From e9e71b19712915f7a65a212c75344609183a2298 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 15:44:42 +0000 Subject: [PATCH 21/28] chore: use gapic-generator-python 0.62.1 (#249) - [ ] Regenerate this pull request now. fix: resolve DuplicateCredentialArgs error when using credentials_file committer: parthea PiperOrigin-RevId: 425964861 Source-Link: https://github.com/googleapis/googleapis/commit/84b1a5a4f6fb2d04905be58e586b8a7a4310a8cf Source-Link: https://github.com/googleapis/googleapis-gen/commit/4fb761bbd8506ac156f49bac5f18306aa8eb3aa8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9 --- .../services/device_manager/async_client.py | 51 ++++++------ .../iot_v1/services/device_manager/client.py | 51 ++++++------ .../device_manager/transports/grpc.py | 5 +- .../device_manager/transports/grpc_asyncio.py | 5 +- google/cloud/iot_v1/types/device_manager.py | 12 +-- .../unit/gapic/iot_v1/test_device_manager.py | 82 ++++++++++++++++++- 6 files changed, 145 insertions(+), 61 deletions(-) diff --git a/google/cloud/iot_v1/services/device_manager/async_client.py b/google/cloud/iot_v1/services/device_manager/async_client.py index 18931a01..852cf800 100644 --- a/google/cloud/iot_v1/services/device_manager/async_client.py +++ b/google/cloud/iot_v1/services/device_manager/async_client.py @@ -255,7 +255,7 @@ async def create_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, device_registry]) if request is not None and has_flattened_params: @@ -325,7 +325,7 @@ async def get_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -417,7 +417,7 @@ async def update_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([device_registry, update_mask]) if request is not None and has_flattened_params: @@ -485,7 +485,7 @@ async def delete_device_registry( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -567,7 +567,7 @@ async def list_device_registries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -662,7 +662,7 @@ async def create_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, device]) if request is not None and has_flattened_params: @@ -734,7 +734,7 @@ async def get_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -826,7 +826,7 @@ async def update_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([device, update_mask]) if request is not None and has_flattened_params: @@ -896,7 +896,7 @@ async def delete_device( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -978,7 +978,7 @@ async def list_devices( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1077,7 +1077,7 @@ async def modify_cloud_to_device_config( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, binary_data]) if request is not None and has_flattened_params: @@ -1162,7 +1162,7 @@ async def list_device_config_versions( Response for ListDeviceConfigVersions. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1243,7 +1243,7 @@ async def list_device_states( Response for ListDeviceStates. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1380,7 +1380,7 @@ async def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1508,7 +1508,7 @@ async def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1591,7 +1591,7 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1682,12 +1682,13 @@ async def send_command_to_device( If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to - the /devices/{device- - id}/commands/{subfolder} topic. Multi- - level subfolders are allowed. This field - must not have more than 256 characters, - and must not contain any MQTT wildcards - ("+" or "#") or null characters. + the + /devices/{device-id}/commands/{subfolder} + topic. Multi-level subfolders are + allowed. This field must not have more + than 256 characters, and must not + contain any MQTT wildcards ("+" or "#") + or null characters. This corresponds to the ``subfolder`` field on the ``request`` instance; if ``request`` is provided, this @@ -1703,7 +1704,7 @@ async def send_command_to_device( Response for SendCommandToDevice. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, binary_data, subfolder]) if request is not None and has_flattened_params: @@ -1803,7 +1804,7 @@ async def bind_device_to_gateway( Response for BindDeviceToGateway. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, gateway_id, device_id]) if request is not None and has_flattened_params: @@ -1894,7 +1895,7 @@ async def unbind_device_from_gateway( Response for UnbindDeviceFromGateway. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, gateway_id, device_id]) if request is not None and has_flattened_params: diff --git a/google/cloud/iot_v1/services/device_manager/client.py b/google/cloud/iot_v1/services/device_manager/client.py index d6fafc3b..78286873 100644 --- a/google/cloud/iot_v1/services/device_manager/client.py +++ b/google/cloud/iot_v1/services/device_manager/client.py @@ -464,7 +464,7 @@ def create_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, device_registry]) if request is not None and has_flattened_params: @@ -534,7 +534,7 @@ def get_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -616,7 +616,7 @@ def update_device_registry( A container for a group of devices. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([device_registry, update_mask]) if request is not None and has_flattened_params: @@ -684,7 +684,7 @@ def delete_device_registry( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -756,7 +756,7 @@ def list_device_registries( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -841,7 +841,7 @@ def create_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, device]) if request is not None and has_flattened_params: @@ -913,7 +913,7 @@ def get_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -995,7 +995,7 @@ def update_device( The device resource. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([device, update_mask]) if request is not None and has_flattened_params: @@ -1065,7 +1065,7 @@ def delete_device( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1137,7 +1137,7 @@ def list_devices( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1226,7 +1226,7 @@ def modify_cloud_to_device_config( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, binary_data]) if request is not None and has_flattened_params: @@ -1302,7 +1302,7 @@ def list_device_config_versions( Response for ListDeviceConfigVersions. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1375,7 +1375,7 @@ def list_device_states( Response for ListDeviceStates. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1502,7 +1502,7 @@ def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1629,7 +1629,7 @@ def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1711,7 +1711,7 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1801,12 +1801,13 @@ def send_command_to_device( If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise it will be delivered to - the /devices/{device- - id}/commands/{subfolder} topic. Multi- - level subfolders are allowed. This field - must not have more than 256 characters, - and must not contain any MQTT wildcards - ("+" or "#") or null characters. + the + /devices/{device-id}/commands/{subfolder} + topic. Multi-level subfolders are + allowed. This field must not have more + than 256 characters, and must not + contain any MQTT wildcards ("+" or "#") + or null characters. This corresponds to the ``subfolder`` field on the ``request`` instance; if ``request`` is provided, this @@ -1822,7 +1823,7 @@ def send_command_to_device( Response for SendCommandToDevice. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, binary_data, subfolder]) if request is not None and has_flattened_params: @@ -1911,7 +1912,7 @@ def bind_device_to_gateway( Response for BindDeviceToGateway. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, gateway_id, device_id]) if request is not None and has_flattened_params: @@ -2002,7 +2003,7 @@ def unbind_device_from_gateway( Response for UnbindDeviceFromGateway. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, gateway_id, device_id]) if request is not None and has_flattened_params: diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc.py b/google/cloud/iot_v1/services/device_manager/transports/grpc.py index 976558dd..20675cf3 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc.py @@ -163,8 +163,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py index 5cd35a9a..57d8203e 100644 --- a/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py +++ b/google/cloud/iot_v1/services/device_manager/transports/grpc_asyncio.py @@ -208,8 +208,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/google/cloud/iot_v1/types/device_manager.py b/google/cloud/iot_v1/types/device_manager.py index dd6e161f..8f4dc0d7 100644 --- a/google/cloud/iot_v1/types/device_manager.py +++ b/google/cloud/iot_v1/types/device_manager.py @@ -468,12 +468,12 @@ class SendCommandToDeviceRequest(proto.Message): Optional subfolder for the command. If empty, the command will be delivered to the /devices/{device-id}/commands topic, otherwise - it will be delivered to the /devices/{device- - id}/commands/{subfolder} topic. Multi-level - subfolders are allowed. This field must not have - more than 256 characters, and must not contain - any MQTT wildcards ("+" or "#") or null - characters. + it will be delivered to the + /devices/{device-id}/commands/{subfolder} topic. + Multi-level subfolders are allowed. This field + must not have more than 256 characters, and must + not contain any MQTT wildcards ("+" or "#") or + null characters. """ name = proto.Field(proto.STRING, number=1,) diff --git a/tests/unit/gapic/iot_v1/test_device_manager.py b/tests/unit/gapic/iot_v1/test_device_manager.py index 1eae43ce..ace8c5aa 100644 --- a/tests/unit/gapic/iot_v1/test_device_manager.py +++ b/tests/unit/gapic/iot_v1/test_device_manager.py @@ -517,21 +517,28 @@ def test_device_manager_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (DeviceManagerClient, transports.DeviceManagerGrpcTransport, "grpc"), + ( + DeviceManagerClient, + transports.DeviceManagerGrpcTransport, + "grpc", + grpc_helpers, + ), ( DeviceManagerAsyncClient, transports.DeviceManagerGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_device_manager_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -567,6 +574,75 @@ def test_device_manager_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + ( + DeviceManagerClient, + transports.DeviceManagerGrpcTransport, + "grpc", + grpc_helpers, + ), + ( + DeviceManagerAsyncClient, + transports.DeviceManagerGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_device_manager_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "cloudiot.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=( + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/cloudiot", + ), + scopes=None, + default_host="cloudiot.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "request_type", [device_manager.CreateDeviceRegistryRequest, dict,] ) From a5cd2a191bef7852e134d6931bfcf924817bfef0 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 7 Feb 2022 17:20:59 +0100 Subject: [PATCH 22/28] chore(deps): update all dependencies (#247) * chore(deps): update all dependencies * remove pin for python 3.6 * remove pin for python 3.6 Co-authored-by: Anthonios Partheniou --- samples/api-client/accesstoken_example/requirements-test.txt | 3 +-- samples/api-client/accesstoken_example/requirements.txt | 5 ++--- samples/api-client/manager/requirements.txt | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements-test.txt b/samples/api-client/accesstoken_example/requirements-test.txt index 4bcdfb92..f10e2894 100644 --- a/samples/api-client/accesstoken_example/requirements-test.txt +++ b/samples/api-client/accesstoken_example/requirements-test.txt @@ -1,4 +1,3 @@ pytest==6.2.5 google-cloud-pubsub==2.9.0 -google-cloud-storage==2.0.0; python_version == '3.6' -google-cloud-storage==2.1.0; python_version > '3.6' +google-cloud-storage==2.1.0 diff --git a/samples/api-client/accesstoken_example/requirements.txt b/samples/api-client/accesstoken_example/requirements.txt index 27a75cbb..551d6a52 100644 --- a/samples/api-client/accesstoken_example/requirements.txt +++ b/samples/api-client/accesstoken_example/requirements.txt @@ -2,10 +2,9 @@ cryptography==36.0.1 flaky==3.7.0 google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==2.3.3 +google-auth==2.5.0 google-cloud-iot==2.3.0 google-cloud-pubsub==2.9.0 -google-cloud-storage==2.0.0; python_version == '3.6' -google-cloud-storage==2.1.0; python_version > '3.6' +google-cloud-storage==2.1.0 paho-mqtt==1.6.1 pyjwt==2.3.0 diff --git a/samples/api-client/manager/requirements.txt b/samples/api-client/manager/requirements.txt index 867f7b56..81f33dd8 100644 --- a/samples/api-client/manager/requirements.txt +++ b/samples/api-client/manager/requirements.txt @@ -2,7 +2,7 @@ cryptography==36.0.1 flaky==3.7.0 google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==2.3.3 +google-auth==2.5.0 google-cloud-iot==2.3.0 google-cloud-pubsub==2.9.0 paho-mqtt==1.6.1 From e1c9b9cf793af78929086b2e5ae9ffe4a210918c Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Tue, 8 Feb 2022 22:53:38 +0100 Subject: [PATCH 23/28] chore(deps): update all dependencies (#251) --- samples/api-client/accesstoken_example/requirements-test.txt | 2 +- samples/api-client/accesstoken_example/requirements.txt | 2 +- samples/api-client/manager/requirements-test.txt | 2 +- samples/api-client/manager/requirements.txt | 2 +- samples/api-client/mqtt_example/requirements-test.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements-test.txt b/samples/api-client/accesstoken_example/requirements-test.txt index f10e2894..65a947e8 100644 --- a/samples/api-client/accesstoken_example/requirements-test.txt +++ b/samples/api-client/accesstoken_example/requirements-test.txt @@ -1,3 +1,3 @@ -pytest==6.2.5 +pytest==7.0.0 google-cloud-pubsub==2.9.0 google-cloud-storage==2.1.0 diff --git a/samples/api-client/accesstoken_example/requirements.txt b/samples/api-client/accesstoken_example/requirements.txt index 551d6a52..a718c2a6 100644 --- a/samples/api-client/accesstoken_example/requirements.txt +++ b/samples/api-client/accesstoken_example/requirements.txt @@ -2,7 +2,7 @@ cryptography==36.0.1 flaky==3.7.0 google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==2.5.0 +google-auth==2.6.0 google-cloud-iot==2.3.0 google-cloud-pubsub==2.9.0 google-cloud-storage==2.1.0 diff --git a/samples/api-client/manager/requirements-test.txt b/samples/api-client/manager/requirements-test.txt index 92709451..4a46ff60 100644 --- a/samples/api-client/manager/requirements-test.txt +++ b/samples/api-client/manager/requirements-test.txt @@ -1 +1 @@ -pytest==6.2.5 +pytest==7.0.0 diff --git a/samples/api-client/manager/requirements.txt b/samples/api-client/manager/requirements.txt index 81f33dd8..86ccc0ff 100644 --- a/samples/api-client/manager/requirements.txt +++ b/samples/api-client/manager/requirements.txt @@ -2,7 +2,7 @@ cryptography==36.0.1 flaky==3.7.0 google-api-python-client==2.36.0 google-auth-httplib2==0.1.0 -google-auth==2.5.0 +google-auth==2.6.0 google-cloud-iot==2.3.0 google-cloud-pubsub==2.9.0 paho-mqtt==1.6.1 diff --git a/samples/api-client/mqtt_example/requirements-test.txt b/samples/api-client/mqtt_example/requirements-test.txt index 92709451..4a46ff60 100644 --- a/samples/api-client/mqtt_example/requirements-test.txt +++ b/samples/api-client/mqtt_example/requirements-test.txt @@ -1 +1 @@ -pytest==6.2.5 +pytest==7.0.0 From e19b32636206742029d3dbf1e24c19dee04acccb Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 9 Feb 2022 18:28:49 +0100 Subject: [PATCH 24/28] chore(deps): update dependency google-api-python-client to v2.37.0 (#252) --- samples/api-client/accesstoken_example/requirements.txt | 2 +- samples/api-client/manager/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements.txt b/samples/api-client/accesstoken_example/requirements.txt index a718c2a6..084cd1a0 100644 --- a/samples/api-client/accesstoken_example/requirements.txt +++ b/samples/api-client/accesstoken_example/requirements.txt @@ -1,6 +1,6 @@ cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.36.0 +google-api-python-client==2.37.0 google-auth-httplib2==0.1.0 google-auth==2.6.0 google-cloud-iot==2.3.0 diff --git a/samples/api-client/manager/requirements.txt b/samples/api-client/manager/requirements.txt index 86ccc0ff..8899cc4e 100644 --- a/samples/api-client/manager/requirements.txt +++ b/samples/api-client/manager/requirements.txt @@ -1,6 +1,6 @@ cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.36.0 +google-api-python-client==2.37.0 google-auth-httplib2==0.1.0 google-auth==2.6.0 google-cloud-iot==2.3.0 From a68cbf47f79e5d16f921920825014c01eba0b448 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 11 Feb 2022 11:20:22 -0700 Subject: [PATCH 25/28] docs: add generated snippets (#253) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.63.2 PiperOrigin-RevId: 427792504 Source-Link: https://github.com/googleapis/googleapis/commit/55b9e1e0b3106c850d13958352bc0751147b6b15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/bf4e86b753f42cb0edb1fd51fbe840d7da0a1cde Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYmY0ZTg2Yjc1M2Y0MmNiMGVkYjFmZDUxZmJlODQwZDdkYTBhMWNkZSJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../services/device_manager/async_client.py | 370 ++++ .../iot_v1/services/device_manager/client.py | 389 ++++ ...ce_manager_bind_device_to_gateway_async.py | 47 + ...ice_manager_bind_device_to_gateway_sync.py | 47 + ...t_v1_device_manager_create_device_async.py | 45 + ...ce_manager_create_device_registry_async.py | 45 + ...ice_manager_create_device_registry_sync.py | 45 + ...ot_v1_device_manager_create_device_sync.py | 45 + ...t_v1_device_manager_delete_device_async.py | 43 + ...ce_manager_delete_device_registry_async.py | 43 + ...ice_manager_delete_device_registry_sync.py | 43 + ...ot_v1_device_manager_delete_device_sync.py | 43 + ..._iot_v1_device_manager_get_device_async.py | 45 + ...evice_manager_get_device_registry_async.py | 45 + ...device_manager_get_device_registry_sync.py | 45 + ...d_iot_v1_device_manager_get_device_sync.py | 45 + ..._v1_device_manager_get_iam_policy_async.py | 45 + ...t_v1_device_manager_get_iam_policy_sync.py | 45 + ...nager_list_device_config_versions_async.py | 45 + ...anager_list_device_config_versions_sync.py | 45 + ...ce_manager_list_device_registries_async.py | 46 + ...ice_manager_list_device_registries_sync.py | 46 + ...device_manager_list_device_states_async.py | 45 + ..._device_manager_list_device_states_sync.py | 45 + ...ot_v1_device_manager_list_devices_async.py | 46 + ...iot_v1_device_manager_list_devices_sync.py | 46 + ...ger_modify_cloud_to_device_config_async.py | 46 + ...ager_modify_cloud_to_device_config_sync.py | 46 + ...ce_manager_send_command_to_device_async.py | 46 + ...ice_manager_send_command_to_device_sync.py | 46 + ..._v1_device_manager_set_iam_policy_async.py | 45 + ...t_v1_device_manager_set_iam_policy_sync.py | 45 + ...vice_manager_test_iam_permissions_async.py | 46 + ...evice_manager_test_iam_permissions_sync.py | 46 + ...anager_unbind_device_from_gateway_async.py | 47 + ...manager_unbind_device_from_gateway_sync.py | 47 + ...t_v1_device_manager_update_device_async.py | 44 + ...ce_manager_update_device_registry_async.py | 44 + ...ice_manager_update_device_registry_sync.py | 44 + ...ot_v1_device_manager_update_device_sync.py | 44 + .../snippet_metadata_iot_v1.json | 1687 +++++++++++++++++ 41 files changed, 4162 insertions(+) create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_async.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_sync.py create mode 100644 samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_sync.py create mode 100644 samples/generated_samples/snippet_metadata_iot_v1.json diff --git a/google/cloud/iot_v1/services/device_manager/async_client.py b/google/cloud/iot_v1/services/device_manager/async_client.py index 852cf800..2f2ac4d8 100644 --- a/google/cloud/iot_v1/services/device_manager/async_client.py +++ b/google/cloud/iot_v1/services/device_manager/async_client.py @@ -224,6 +224,25 @@ async def create_device_registry( ) -> resources.DeviceRegistry: r"""Creates a device registry that contains devices. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_create_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRegistryRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.CreateDeviceRegistryRequest, dict]): The request object. Request for `CreateDeviceRegistry`. @@ -304,6 +323,25 @@ async def get_device_registry( ) -> resources.DeviceRegistry: r"""Gets a device registry configuration. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + response = client.get_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.GetDeviceRegistryRequest, dict]): The request object. Request for `GetDeviceRegistry`. @@ -383,6 +421,24 @@ async def update_device_registry( ) -> resources.DeviceRegistry: r"""Updates a device registry configuration. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_update_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRegistryRequest( + ) + + # Make the request + response = client.update_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UpdateDeviceRegistryRequest, dict]): The request object. Request for `UpdateDeviceRegistry`. @@ -468,6 +524,22 @@ async def delete_device_registry( ) -> None: r"""Deletes a device registry configuration. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_delete_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + client.delete_device_registry(request=request) + Args: request (Union[google.cloud.iot_v1.types.DeleteDeviceRegistryRequest, dict]): The request object. Request for `DeleteDeviceRegistry`. @@ -541,6 +613,26 @@ async def list_device_registries( ) -> pagers.ListDeviceRegistriesAsyncPager: r"""Lists device registries. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_registries(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceRegistriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_device_registries(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceRegistriesRequest, dict]): The request object. Request for `ListDeviceRegistries`. @@ -631,6 +723,25 @@ async def create_device( ) -> resources.Device: r"""Creates a device in a device registry. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_create_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.CreateDeviceRequest, dict]): The request object. Request for `CreateDevice`. @@ -711,6 +822,25 @@ async def get_device( ) -> resources.Device: r"""Gets details about a device. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRequest( + name="name_value", + ) + + # Make the request + response = client.get_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.GetDeviceRequest, dict]): The request object. Request for `GetDevice`. @@ -792,6 +922,24 @@ async def update_device( ) -> resources.Device: r"""Updates a device. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_update_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRequest( + ) + + # Make the request + response = client.update_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UpdateDeviceRequest, dict]): The request object. Request for `UpdateDevice`. @@ -877,6 +1025,22 @@ async def delete_device( ) -> None: r"""Deletes a device. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_delete_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRequest( + name="name_value", + ) + + # Make the request + client.delete_device(request=request) + Args: request (Union[google.cloud.iot_v1.types.DeleteDeviceRequest, dict]): The request object. Request for `DeleteDevice`. @@ -952,6 +1116,26 @@ async def list_devices( ) -> pagers.ListDevicesAsyncPager: r"""List devices in a device registry. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_devices(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDevicesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_devices(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDevicesRequest, dict]): The request object. Request for `ListDevices`. @@ -1044,6 +1228,27 @@ async def modify_cloud_to_device_config( eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_modify_cloud_to_device_config(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ModifyCloudToDeviceConfigRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.modify_cloud_to_device_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ModifyCloudToDeviceConfigRequest, dict]): The request object. Request for @@ -1138,6 +1343,26 @@ async def list_device_config_versions( r"""Lists the last few versions of the device configuration in descending order (i.e.: newest first). + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_config_versions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceConfigVersionsRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_config_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceConfigVersionsRequest, dict]): The request object. Request for @@ -1220,6 +1445,26 @@ async def list_device_states( r"""Lists the last few versions of the device state in descending order (i.e.: newest first). + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_states(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceStatesRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_states(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceStatesRequest, dict]): The request object. Request for `ListDeviceStates`. @@ -1301,6 +1546,26 @@ async def set_iam_policy( r"""Sets the access control policy on the specified resource. Replaces any existing policy. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_set_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1429,6 +1694,26 @@ async def get_iam_policy( Returns an empty policy if the resource exists and does not have a policy set. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1558,6 +1843,27 @@ async def test_iam_permissions( If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_test_iam_permissions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1658,6 +1964,27 @@ async def send_command_to_device( guaranteed; for QoS 0, no acknowledgment will be expected from the device. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_send_command_to_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SendCommandToDeviceRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.send_command_to_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.SendCommandToDeviceRequest, dict]): The request object. Request for `SendCommandToDevice`. @@ -1768,6 +2095,27 @@ async def bind_device_to_gateway( ) -> device_manager.BindDeviceToGatewayResponse: r"""Associates the device with the gateway. + .. code-block:: + + from google.cloud import iot_v1 + + def sample_bind_device_to_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.BindDeviceToGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.bind_device_to_gateway(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.BindDeviceToGatewayRequest, dict]): The request object. Request for `BindDeviceToGateway`. @@ -1858,6 +2206,28 @@ async def unbind_device_from_gateway( r"""Deletes the association between the device and the gateway. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_unbind_device_from_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UnbindDeviceFromGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.unbind_device_from_gateway(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UnbindDeviceFromGatewayRequest, dict]): The request object. Request for diff --git a/google/cloud/iot_v1/services/device_manager/client.py b/google/cloud/iot_v1/services/device_manager/client.py index 78286873..4f26c108 100644 --- a/google/cloud/iot_v1/services/device_manager/client.py +++ b/google/cloud/iot_v1/services/device_manager/client.py @@ -433,6 +433,26 @@ def create_device_registry( ) -> resources.DeviceRegistry: r"""Creates a device registry that contains devices. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_create_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRegistryRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.CreateDeviceRegistryRequest, dict]): The request object. Request for `CreateDeviceRegistry`. @@ -513,6 +533,26 @@ def get_device_registry( ) -> resources.DeviceRegistry: r"""Gets a device registry configuration. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + response = client.get_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.GetDeviceRegistryRequest, dict]): The request object. Request for `GetDeviceRegistry`. @@ -582,6 +622,25 @@ def update_device_registry( ) -> resources.DeviceRegistry: r"""Updates a device registry configuration. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_update_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRegistryRequest( + ) + + # Make the request + response = client.update_device_registry(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UpdateDeviceRegistryRequest, dict]): The request object. Request for `UpdateDeviceRegistry`. @@ -667,6 +726,23 @@ def delete_device_registry( ) -> None: r"""Deletes a device registry configuration. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_delete_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + client.delete_device_registry(request=request) + Args: request (Union[google.cloud.iot_v1.types.DeleteDeviceRegistryRequest, dict]): The request object. Request for `DeleteDeviceRegistry`. @@ -730,6 +806,27 @@ def list_device_registries( ) -> pagers.ListDeviceRegistriesPager: r"""Lists device registries. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_registries(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceRegistriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_device_registries(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceRegistriesRequest, dict]): The request object. Request for `ListDeviceRegistries`. @@ -810,6 +907,26 @@ def create_device( ) -> resources.Device: r"""Creates a device in a device registry. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_create_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.CreateDeviceRequest, dict]): The request object. Request for `CreateDevice`. @@ -890,6 +1007,26 @@ def get_device( ) -> resources.Device: r"""Gets details about a device. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRequest( + name="name_value", + ) + + # Make the request + response = client.get_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.GetDeviceRequest, dict]): The request object. Request for `GetDevice`. @@ -961,6 +1098,25 @@ def update_device( ) -> resources.Device: r"""Updates a device. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_update_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRequest( + ) + + # Make the request + response = client.update_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UpdateDeviceRequest, dict]): The request object. Request for `UpdateDevice`. @@ -1046,6 +1202,23 @@ def delete_device( ) -> None: r"""Deletes a device. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_delete_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRequest( + name="name_value", + ) + + # Make the request + client.delete_device(request=request) + Args: request (Union[google.cloud.iot_v1.types.DeleteDeviceRequest, dict]): The request object. Request for `DeleteDevice`. @@ -1111,6 +1284,27 @@ def list_devices( ) -> pagers.ListDevicesPager: r"""List devices in a device registry. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_devices(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDevicesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_devices(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDevicesRequest, dict]): The request object. Request for `ListDevices`. @@ -1193,6 +1387,28 @@ def modify_cloud_to_device_config( eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_modify_cloud_to_device_config(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ModifyCloudToDeviceConfigRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.modify_cloud_to_device_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ModifyCloudToDeviceConfigRequest, dict]): The request object. Request for @@ -1278,6 +1494,27 @@ def list_device_config_versions( r"""Lists the last few versions of the device configuration in descending order (i.e.: newest first). + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_config_versions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceConfigVersionsRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_config_versions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceConfigVersionsRequest, dict]): The request object. Request for @@ -1352,6 +1589,27 @@ def list_device_states( r"""Lists the last few versions of the device state in descending order (i.e.: newest first). + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_list_device_states(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceStatesRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_states(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.ListDeviceStatesRequest, dict]): The request object. Request for `ListDeviceStates`. @@ -1423,6 +1681,27 @@ def set_iam_policy( r"""Sets the access control policy on the specified resource. Replaces any existing policy. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_set_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1550,6 +1829,27 @@ def get_iam_policy( Returns an empty policy if the resource exists and does not have a policy set. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_get_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1678,6 +1978,28 @@ def test_iam_permissions( If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_test_iam_permissions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1777,6 +2099,28 @@ def send_command_to_device( guaranteed; for QoS 0, no acknowledgment will be expected from the device. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_send_command_to_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SendCommandToDeviceRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.send_command_to_device(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.SendCommandToDeviceRequest, dict]): The request object. Request for `SendCommandToDevice`. @@ -1876,6 +2220,28 @@ def bind_device_to_gateway( ) -> device_manager.BindDeviceToGatewayResponse: r"""Associates the device with the gateway. + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_bind_device_to_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.BindDeviceToGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.bind_device_to_gateway(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.BindDeviceToGatewayRequest, dict]): The request object. Request for `BindDeviceToGateway`. @@ -1966,6 +2332,29 @@ def unbind_device_from_gateway( r"""Deletes the association between the device and the gateway. + + + .. code-block:: + + from google.cloud import iot_v1 + + def sample_unbind_device_from_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UnbindDeviceFromGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.unbind_device_from_gateway(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.iot_v1.types.UnbindDeviceFromGatewayRequest, dict]): The request object. Request for diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_async.py new file mode 100644 index 00000000..1f237ae3 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_async.py @@ -0,0 +1,47 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BindDeviceToGateway +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_async] +from google.cloud import iot_v1 + + +async def sample_bind_device_to_gateway(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.BindDeviceToGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = await client.bind_device_to_gateway(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_sync.py new file mode 100644 index 00000000..13707ed7 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_sync.py @@ -0,0 +1,47 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for BindDeviceToGateway +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_sync] +from google.cloud import iot_v1 + + +def sample_bind_device_to_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.BindDeviceToGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.bind_device_to_gateway(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_async.py new file mode 100644 index 00000000..7890a577 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_CreateDevice_async] +from google.cloud import iot_v1 + + +async def sample_create_device(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_CreateDevice_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_async.py new file mode 100644 index 00000000..804b0825 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_async] +from google.cloud import iot_v1 + + +async def sample_create_device_registry(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRegistryRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_sync.py new file mode 100644 index 00000000..7f484f20 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_registry_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_sync] +from google.cloud import iot_v1 + + +def sample_create_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRegistryRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_sync.py new file mode 100644 index 00000000..3a945324 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_create_device_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_CreateDevice_sync] +from google.cloud import iot_v1 + + +def sample_create_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.CreateDeviceRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_CreateDevice_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_async.py new file mode 100644 index 00000000..c4e76b81 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_async.py @@ -0,0 +1,43 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_async] +from google.cloud import iot_v1 + + +async def sample_delete_device(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRequest( + name="name_value", + ) + + # Make the request + await client.delete_device(request=request) + + +# [END cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_async.py new file mode 100644 index 00000000..c52f86c6 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_async.py @@ -0,0 +1,43 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_async] +from google.cloud import iot_v1 + + +async def sample_delete_device_registry(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + await client.delete_device_registry(request=request) + + +# [END cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_sync.py new file mode 100644 index 00000000..02e678d5 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_registry_sync.py @@ -0,0 +1,43 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_sync] +from google.cloud import iot_v1 + + +def sample_delete_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + client.delete_device_registry(request=request) + + +# [END cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_sync.py new file mode 100644 index 00000000..81541b5d --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_delete_device_sync.py @@ -0,0 +1,43 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_sync] +from google.cloud import iot_v1 + + +def sample_delete_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.DeleteDeviceRequest( + name="name_value", + ) + + # Make the request + client.delete_device(request=request) + + +# [END cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_async.py new file mode 100644 index 00000000..89c460d2 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetDevice_async] +from google.cloud import iot_v1 + + +async def sample_get_device(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRequest( + name="name_value", + ) + + # Make the request + response = await client.get_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetDevice_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_async.py new file mode 100644 index 00000000..31efd0d7 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_async] +from google.cloud import iot_v1 + + +async def sample_get_device_registry(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + response = await client.get_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_sync.py new file mode 100644 index 00000000..5943f5a1 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_registry_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_sync] +from google.cloud import iot_v1 + + +def sample_get_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRegistryRequest( + name="name_value", + ) + + # Make the request + response = client.get_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_sync.py new file mode 100644 index 00000000..9107dbca --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_device_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetDevice_sync] +from google.cloud import iot_v1 + + +def sample_get_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetDeviceRequest( + name="name_value", + ) + + # Make the request + response = client.get_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetDevice_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_async.py new file mode 100644 index 00000000..295a65fe --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_async] +from google.cloud import iot_v1 + + +async def sample_get_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_sync.py new file mode 100644 index 00000000..8910834f --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_sync] +from google.cloud import iot_v1 + + +def sample_get_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_async.py new file mode 100644 index 00000000..fbf32509 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceConfigVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_async] +from google.cloud import iot_v1 + + +async def sample_list_device_config_versions(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceConfigVersionsRequest( + name="name_value", + ) + + # Make the request + response = await client.list_device_config_versions(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_sync.py new file mode 100644 index 00000000..4e01fd9d --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_config_versions_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceConfigVersions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_sync] +from google.cloud import iot_v1 + + +def sample_list_device_config_versions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceConfigVersionsRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_config_versions(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_async.py new file mode 100644 index 00000000..880c7c41 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_async.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceRegistries +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_async] +from google.cloud import iot_v1 + + +async def sample_list_device_registries(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceRegistriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_device_registries(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_sync.py new file mode 100644 index 00000000..2d5ef450 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_registries_sync.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceRegistries +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_sync] +from google.cloud import iot_v1 + + +def sample_list_device_registries(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceRegistriesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_device_registries(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_async.py new file mode 100644 index 00000000..075f70ae --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceStates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_async] +from google.cloud import iot_v1 + + +async def sample_list_device_states(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceStatesRequest( + name="name_value", + ) + + # Make the request + response = await client.list_device_states(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_sync.py new file mode 100644 index 00000000..681c83c2 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_device_states_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeviceStates +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_sync] +from google.cloud import iot_v1 + + +def sample_list_device_states(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDeviceStatesRequest( + name="name_value", + ) + + # Make the request + response = client.list_device_states(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_async.py new file mode 100644 index 00000000..ac77f720 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_async.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDevices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDevices_async] +from google.cloud import iot_v1 + + +async def sample_list_devices(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.ListDevicesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_devices(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDevices_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_sync.py new file mode 100644 index 00000000..ea51d220 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_list_devices_sync.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDevices +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ListDevices_sync] +from google.cloud import iot_v1 + + +def sample_list_devices(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ListDevicesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_devices(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ListDevices_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_async.py new file mode 100644 index 00000000..4ee479cf --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_async.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ModifyCloudToDeviceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_async] +from google.cloud import iot_v1 + + +async def sample_modify_cloud_to_device_config(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.ModifyCloudToDeviceConfigRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = await client.modify_cloud_to_device_config(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_sync.py new file mode 100644 index 00000000..5c048b90 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_sync.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ModifyCloudToDeviceConfig +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_sync] +from google.cloud import iot_v1 + + +def sample_modify_cloud_to_device_config(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.ModifyCloudToDeviceConfigRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.modify_cloud_to_device_config(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_async.py new file mode 100644 index 00000000..361d9575 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_async.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SendCommandToDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_async] +from google.cloud import iot_v1 + + +async def sample_send_command_to_device(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.SendCommandToDeviceRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = await client.send_command_to_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_sync.py new file mode 100644 index 00000000..f6c0bc78 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_send_command_to_device_sync.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SendCommandToDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_sync] +from google.cloud import iot_v1 + + +def sample_send_command_to_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SendCommandToDeviceRequest( + name="name_value", + binary_data=b'binary_data_blob', + ) + + # Make the request + response = client.send_command_to_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_async.py new file mode 100644 index 00000000..915c16d3 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_async] +from google.cloud import iot_v1 + + +async def sample_set_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_sync.py new file mode 100644 index 00000000..70c8b526 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_sync] +from google.cloud import iot_v1 + + +def sample_set_iam_policy(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_async.py new file mode 100644 index 00000000..7f577c30 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_async] +from google.cloud import iot_v1 + + +async def sample_test_iam_permissions(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_sync.py new file mode 100644 index 00000000..da19dd05 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_sync] +from google.cloud import iot_v1 + + +def sample_test_iam_permissions(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_async.py new file mode 100644 index 00000000..d17aa3aa --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_async.py @@ -0,0 +1,47 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UnbindDeviceFromGateway +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_async] +from google.cloud import iot_v1 + + +async def sample_unbind_device_from_gateway(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.UnbindDeviceFromGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = await client.unbind_device_from_gateway(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_sync.py new file mode 100644 index 00000000..402fd515 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_sync.py @@ -0,0 +1,47 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UnbindDeviceFromGateway +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_sync] +from google.cloud import iot_v1 + + +def sample_unbind_device_from_gateway(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UnbindDeviceFromGatewayRequest( + parent="parent_value", + gateway_id="gateway_id_value", + device_id="device_id_value", + ) + + # Make the request + response = client.unbind_device_from_gateway(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_async.py new file mode 100644 index 00000000..25072957 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_async.py @@ -0,0 +1,44 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_async] +from google.cloud import iot_v1 + + +async def sample_update_device(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRequest( + ) + + # Make the request + response = await client.update_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_async.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_async.py new file mode 100644 index 00000000..b69818ba --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_async.py @@ -0,0 +1,44 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_async] +from google.cloud import iot_v1 + + +async def sample_update_device_registry(): + # Create a client + client = iot_v1.DeviceManagerAsyncClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRegistryRequest( + ) + + # Make the request + response = await client.update_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_async] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_sync.py new file mode 100644 index 00000000..a3c571e6 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_registry_sync.py @@ -0,0 +1,44 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeviceRegistry +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_sync] +from google.cloud import iot_v1 + + +def sample_update_device_registry(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRegistryRequest( + ) + + # Make the request + response = client.update_device_registry(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_sync] diff --git a/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_sync.py b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_sync.py new file mode 100644 index 00000000..735fe4e0 --- /dev/null +++ b/samples/generated_samples/cloudiot_generated_iot_v1_device_manager_update_device_sync.py @@ -0,0 +1,44 @@ +# -*- 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDevice +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-iot + + +# [START cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_sync] +from google.cloud import iot_v1 + + +def sample_update_device(): + # Create a client + client = iot_v1.DeviceManagerClient() + + # Initialize request argument(s) + request = iot_v1.UpdateDeviceRequest( + ) + + # Make the request + response = client.update_device(request=request) + + # Handle the response + print(response) + +# [END cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_sync] diff --git a/samples/generated_samples/snippet_metadata_iot_v1.json b/samples/generated_samples/snippet_metadata_iot_v1.json new file mode 100644 index 00000000..4579a13f --- /dev/null +++ b/samples/generated_samples/snippet_metadata_iot_v1.json @@ -0,0 +1,1687 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "BindDeviceToGateway" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_async", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "BindDeviceToGateway" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_bind_device_to_gateway_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_BindDeviceToGateway_sync", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "CreateDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_create_device_registry_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "CreateDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_create_device_registry_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_CreateDeviceRegistry_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "CreateDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_create_device_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_CreateDevice_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "CreateDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_create_device_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_CreateDevice_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "DeleteDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_delete_device_registry_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "DeleteDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_delete_device_registry_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_DeleteDeviceRegistry_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "DeleteDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_delete_device_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "DeleteDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_delete_device_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_DeleteDevice_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_device_registry_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_device_registry_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetDeviceRegistry_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_device_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetDevice_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_device_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetDevice_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_iam_policy_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_get_iam_policy_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceConfigVersions" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_config_versions_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceConfigVersions" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_config_versions_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceConfigVersions_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceRegistries" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_registries_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceRegistries" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_registries_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceRegistries_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceStates" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_states_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDeviceStates" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_device_states_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDeviceStates_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDevices" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_devices_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDevices_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ListDevices" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_list_devices_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ListDevices_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ModifyCloudToDeviceConfig" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "ModifyCloudToDeviceConfig" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_modify_cloud_to_device_config_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_ModifyCloudToDeviceConfig_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "SendCommandToDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_send_command_to_device_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "SendCommandToDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_send_command_to_device_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_SendCommandToDevice_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_set_iam_policy_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_set_iam_policy_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_test_iam_permissions_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_test_iam_permissions_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UnbindDeviceFromGateway" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_async", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UnbindDeviceFromGateway" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_unbind_device_from_gateway_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UnbindDeviceFromGateway_sync", + "segments": [ + { + "end": 46, + "start": 27, + "type": "FULL" + }, + { + "end": 46, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 40, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 43, + "start": 41, + "type": "REQUEST_EXECUTION" + }, + { + "end": 47, + "start": 44, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UpdateDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_update_device_registry_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UpdateDeviceRegistry" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_update_device_registry_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UpdateDeviceRegistry_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UpdateDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_update_device_async.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "DeviceManager" + }, + "shortName": "UpdateDevice" + } + }, + "file": "cloudiot_generated_iot_v1_device_manager_update_device_sync.py", + "regionTag": "cloudiot_generated_iot_v1_DeviceManager_UpdateDevice_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} From 2788354f937121d70801104b6c2be241698041d8 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Mon, 14 Feb 2022 16:52:31 +0100 Subject: [PATCH 26/28] chore(deps): update dependency pytest to v7.0.1 (#254) --- samples/api-client/accesstoken_example/requirements-test.txt | 2 +- samples/api-client/manager/requirements-test.txt | 2 +- samples/api-client/mqtt_example/requirements-test.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements-test.txt b/samples/api-client/accesstoken_example/requirements-test.txt index 65a947e8..1a1b18d2 100644 --- a/samples/api-client/accesstoken_example/requirements-test.txt +++ b/samples/api-client/accesstoken_example/requirements-test.txt @@ -1,3 +1,3 @@ -pytest==7.0.0 +pytest==7.0.1 google-cloud-pubsub==2.9.0 google-cloud-storage==2.1.0 diff --git a/samples/api-client/manager/requirements-test.txt b/samples/api-client/manager/requirements-test.txt index 4a46ff60..c2845bff 100644 --- a/samples/api-client/manager/requirements-test.txt +++ b/samples/api-client/manager/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.0 +pytest==7.0.1 diff --git a/samples/api-client/mqtt_example/requirements-test.txt b/samples/api-client/mqtt_example/requirements-test.txt index 4a46ff60..c2845bff 100644 --- a/samples/api-client/mqtt_example/requirements-test.txt +++ b/samples/api-client/mqtt_example/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.0 +pytest==7.0.1 From 8bb45b857f8f58d27ff1800650316ad0f6219fb6 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Thu, 24 Feb 2022 16:51:30 +0100 Subject: [PATCH 27/28] chore(deps): update dependency google-api-python-client to v2.38.0 (#256) --- samples/api-client/accesstoken_example/requirements.txt | 2 +- samples/api-client/manager/requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/api-client/accesstoken_example/requirements.txt b/samples/api-client/accesstoken_example/requirements.txt index 084cd1a0..68085ae5 100644 --- a/samples/api-client/accesstoken_example/requirements.txt +++ b/samples/api-client/accesstoken_example/requirements.txt @@ -1,6 +1,6 @@ cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.37.0 +google-api-python-client==2.38.0 google-auth-httplib2==0.1.0 google-auth==2.6.0 google-cloud-iot==2.3.0 diff --git a/samples/api-client/manager/requirements.txt b/samples/api-client/manager/requirements.txt index 8899cc4e..96774b88 100644 --- a/samples/api-client/manager/requirements.txt +++ b/samples/api-client/manager/requirements.txt @@ -1,6 +1,6 @@ cryptography==36.0.1 flaky==3.7.0 -google-api-python-client==2.37.0 +google-api-python-client==2.38.0 google-auth-httplib2==0.1.0 google-auth==2.6.0 google-cloud-iot==2.3.0 From a242d934d9e450b6ceb256f2756584f94208c4fe Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Thu, 24 Feb 2022 09:03:02 -0700 Subject: [PATCH 28/28] chore(main): release 2.4.0 (#240) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ setup.py | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3ccf848..cdd0ba13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,34 @@ [1]: https://pypi.org/project/google-cloud-iot/#history +## [2.4.0](https://github.com/googleapis/python-iot/compare/v2.3.0...v2.4.0) (2022-02-24) + + +### Features + +* add api key support ([#244](https://github.com/googleapis/python-iot/issues/244)) ([c3ec086](https://github.com/googleapis/python-iot/commit/c3ec086cbce1171509438ba7ced62b041b690d58)) +* add context manager support in client ([#202](https://github.com/googleapis/python-iot/issues/202)) ([14c4ab6](https://github.com/googleapis/python-iot/commit/14c4ab6bd0589111743b4629fbd10c86a43aa698)) +* add support for Python 3.9 / 3.10 ([#220](https://github.com/googleapis/python-iot/issues/220)) ([6038e0c](https://github.com/googleapis/python-iot/commit/6038e0cf8abbdcf0775e02844f86d1909b2857e0)), closes [#221](https://github.com/googleapis/python-iot/issues/221) + + +### Bug Fixes + +* **deps:** drop packaging dependency ([b6df5e4](https://github.com/googleapis/python-iot/commit/b6df5e4ba104003123ebac6687e55fdef176daf0)) +* **deps:** require google-api-core>=1.28.0 ([b6df5e4](https://github.com/googleapis/python-iot/commit/b6df5e4ba104003123ebac6687e55fdef176daf0)) +* **deps:** require proto-plus>=1.15.0 ([b6df5e4](https://github.com/googleapis/python-iot/commit/b6df5e4ba104003123ebac6687e55fdef176daf0)) +* fix extras_require typo in setup.py ([#210](https://github.com/googleapis/python-iot/issues/210)) ([c1149b0](https://github.com/googleapis/python-iot/commit/c1149b010f358debbebb5eea483cc628ec91549d)) +* improper types in pagers generation ([18d869a](https://github.com/googleapis/python-iot/commit/18d869a87e3346c8dabb3bd27a3ee74c237ce370)) +* provide appropriate mock values for message body fields ([b6df5e4](https://github.com/googleapis/python-iot/commit/b6df5e4ba104003123ebac6687e55fdef176daf0)) +* resolve DuplicateCredentialArgs error when using credentials_file ([e9e71b1](https://github.com/googleapis/python-iot/commit/e9e71b19712915f7a65a212c75344609183a2298)) + + +### Documentation + +* add generated snippets ([#253](https://github.com/googleapis/python-iot/issues/253)) ([a68cbf4](https://github.com/googleapis/python-iot/commit/a68cbf47f79e5d16f921920825014c01eba0b448)) +* list oneofs in docstring ([b6df5e4](https://github.com/googleapis/python-iot/commit/b6df5e4ba104003123ebac6687e55fdef176daf0)) +* **samples:** modify accesstoken sample to use environment identity during setup ([#245](https://github.com/googleapis/python-iot/issues/245)) ([63f5a93](https://github.com/googleapis/python-iot/commit/63f5a9327c36714b688fd742fe8beeb0182e2146)) +* **samples:** resolve TypeError in create_iot_topic ([31a5fa8](https://github.com/googleapis/python-iot/commit/31a5fa89c34a7f6fea5cdcd17381ffce831584b3)) + ## [2.3.0](https://www.github.com/googleapis/python-iot/compare/v2.2.1...v2.3.0) (2021-09-24) diff --git a/setup.py b/setup.py index 71686a33..6217458e 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ name = "google-cloud-iot" description = "Cloud IoT API API client library" -version = "2.3.0" +version = "2.4.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x