From 23ba0ca8160360e86877142e3a2f5ef59e42c711 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 4 Apr 2022 20:02:24 +0000 Subject: [PATCH 1/2] feat: AuditConfig for IAM v1 PiperOrigin-RevId: 439356405 Source-Link: https://github.com/googleapis/googleapis/commit/afa2ba156bd5c83ad8168030ab801a8ca84ac819 Source-Link: https://github.com/googleapis/googleapis-gen/commit/3e40c17e1510c95fab58fc2143ccb61cceca5989 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiM2U0MGMxN2UxNTEwYzk1ZmFiNThmYzIxNDNjY2I2MWNjZWNhNTk4OSJ9 --- owl-bot-staging/v1/.eslintignore | 7 + owl-bot-staging/v1/.eslintrc.json | 3 + owl-bot-staging/v1/.gitignore | 14 + owl-bot-staging/v1/.jsdoc.js | 55 + owl-bot-staging/v1/.mocharc.js | 33 + owl-bot-staging/v1/.prettierrc.js | 22 + owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 16 + owl-bot-staging/v1/package.json | 64 + .../google/cloud/iot/v1/device_manager.proto | 652 +++++ .../google/cloud/iot/v1/resources.proto | 483 ++++ .../device_manager.bind_device_to_gateway.js | 72 + .../v1/device_manager.create_device.js | 67 + .../device_manager.create_device_registry.js | 66 + .../v1/device_manager.delete_device.js | 60 + .../device_manager.delete_device_registry.js | 59 + .../generated/v1/device_manager.get_device.js | 66 + .../v1/device_manager.get_device_registry.js | 59 + .../v1/device_manager.get_iam_policy.js | 64 + ...ice_manager.list_device_config_versions.js | 66 + .../device_manager.list_device_registries.js | 74 + .../v1/device_manager.list_device_states.js | 66 + .../v1/device_manager.list_devices.js | 95 + ...e_manager.modify_cloud_to_device_config.js | 73 + .../device_manager.send_command_to_device.js | 73 + .../v1/device_manager.set_iam_policy.js | 74 + .../v1/device_manager.test_iam_permissions.js | 67 + ...vice_manager.unbind_device_from_gateway.js | 72 + .../v1/device_manager.update_device.js | 69 + .../device_manager.update_device_registry.js | 69 + .../snippet_metadata.google.cloud.iot.v1.json | 883 ++++++ owl-bot-staging/v1/src/index.ts | 25 + .../v1/src/v1/device_manager_client.ts | 2229 +++++++++++++++ .../src/v1/device_manager_client_config.json | 135 + .../v1/src/v1/device_manager_proto_list.json | 4 + owl-bot-staging/v1/src/v1/gapic_metadata.json | 221 ++ owl-bot-staging/v1/src/v1/index.ts | 19 + .../system-test/fixtures/sample/src/index.js | 27 + .../system-test/fixtures/sample/src/index.ts | 32 + owl-bot-staging/v1/system-test/install.ts | 49 + .../v1/test/gapic_device_manager_v1.ts | 2426 +++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + 43 files changed, 8794 insertions(+) create mode 100644 owl-bot-staging/v1/.eslintignore create mode 100644 owl-bot-staging/v1/.eslintrc.json create mode 100644 owl-bot-staging/v1/.gitignore create mode 100644 owl-bot-staging/v1/.jsdoc.js create mode 100644 owl-bot-staging/v1/.mocharc.js create mode 100644 owl-bot-staging/v1/.prettierrc.js create mode 100644 owl-bot-staging/v1/README.md create mode 100644 owl-bot-staging/v1/linkinator.config.json create mode 100644 owl-bot-staging/v1/package.json create mode 100644 owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto create mode 100644 owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js create mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json create mode 100644 owl-bot-staging/v1/src/index.ts create mode 100644 owl-bot-staging/v1/src/v1/device_manager_client.ts create mode 100644 owl-bot-staging/v1/src/v1/device_manager_client_config.json create mode 100644 owl-bot-staging/v1/src/v1/device_manager_proto_list.json create mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json create mode 100644 owl-bot-staging/v1/src/v1/index.ts create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js create mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts create mode 100644 owl-bot-staging/v1/system-test/install.ts create mode 100644 owl-bot-staging/v1/test/gapic_device_manager_v1.ts create mode 100644 owl-bot-staging/v1/tsconfig.json create mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore new file mode 100644 index 00000000..cfc348ec --- /dev/null +++ b/owl-bot-staging/v1/.eslintignore @@ -0,0 +1,7 @@ +**/node_modules +**/.coverage +build/ +docs/ +protos/ +system-test/ +samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json new file mode 100644 index 00000000..78215349 --- /dev/null +++ b/owl-bot-staging/v1/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore new file mode 100644 index 00000000..5d32b237 --- /dev/null +++ b/owl-bot-staging/v1/.gitignore @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js new file mode 100644 index 00000000..99b19cfa --- /dev/null +++ b/owl-bot-staging/v1/.jsdoc.js @@ -0,0 +1,55 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +'use strict'; + +module.exports = { + opts: { + readme: './README.md', + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + excludePattern: '(^|\\/|\\\\)[._]', + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2022 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/iot', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js new file mode 100644 index 00000000..481c522b --- /dev/null +++ b/owl-bot-staging/v1/.mocharc.js @@ -0,0 +1,33 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} +if (process.env.MOCHA_THROW_DEPRECATION === 'false') { + delete config['throw-deprecation']; +} +if (process.env.MOCHA_REPORTER) { + config.reporter = process.env.MOCHA_REPORTER; +} +if (process.env.MOCHA_REPORTER_OUTPUT) { + config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; +} +module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js new file mode 100644 index 00000000..494e1478 --- /dev/null +++ b/owl-bot-staging/v1/.prettierrc.js @@ -0,0 +1,22 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md new file mode 100644 index 00000000..e9217498 --- /dev/null +++ b/owl-bot-staging/v1/README.md @@ -0,0 +1 @@ +Iot: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json new file mode 100644 index 00000000..befd23c8 --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..298abaed --- /dev/null +++ b/owl-bot-staging/v1/package.json @@ -0,0 +1,64 @@ +{ + "name": "@google-cloud/iot", + "version": "0.1.0", + "description": "Iot client for Node.js", + "repository": "googleapis/nodejs-iot", + "license": "Apache-2.0", + "author": "Google LLC", + "main": "build/src/index.js", + "files": [ + "build/src", + "build/protos" + ], + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google iot", + "iot", + "device manager" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^2.29.4" + }, + "devDependencies": { + "@types/mocha": "^9.1.0", + "@types/node": "^16.0.0", + "@types/sinon": "^10.0.8", + "c8": "^7.11.0", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.1.1", + "jsdoc-region-tag": "^1.3.1", + "linkinator": "^3.0.0", + "mocha": "^9.1.4", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^13.0.0", + "ts-loader": "^9.2.6", + "typescript": "^4.5.5", + "webpack": "^5.67.0", + "webpack-cli": "^4.9.1" + }, + "engines": { + "node": ">=v10.24.0" + } +} diff --git a/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto b/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto new file mode 100644 index 00000000..dfd6c9b6 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto @@ -0,0 +1,652 @@ +// 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. + +syntax = "proto3"; + +package google.cloud.iot.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/cloud/iot/v1/resources.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; +option java_multiple_files = true; +option java_outer_classname = "DeviceManagerProto"; +option java_package = "com.google.cloud.iot.v1"; + +// Internet of Things (IoT) service. Securely connect and manage IoT devices. +service DeviceManager { + option (google.api.default_host) = "cloudiot.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/cloudiot"; + + // Creates a device registry that contains devices. + rpc CreateDeviceRegistry(CreateDeviceRegistryRequest) returns (DeviceRegistry) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*}/registries" + body: "device_registry" + }; + option (google.api.method_signature) = "parent,device_registry"; + } + + // Gets a device registry configuration. + rpc GetDeviceRegistry(GetDeviceRegistryRequest) returns (DeviceRegistry) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/registries/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a device registry configuration. + rpc UpdateDeviceRegistry(UpdateDeviceRegistryRequest) returns (DeviceRegistry) { + option (google.api.http) = { + patch: "/v1/{device_registry.name=projects/*/locations/*/registries/*}" + body: "device_registry" + }; + option (google.api.method_signature) = "device_registry,update_mask"; + } + + // Deletes a device registry configuration. + rpc DeleteDeviceRegistry(DeleteDeviceRegistryRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/registries/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists device registries. + rpc ListDeviceRegistries(ListDeviceRegistriesRequest) returns (ListDeviceRegistriesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/registries" + }; + option (google.api.method_signature) = "parent"; + } + + // Creates a device in a device registry. + rpc CreateDevice(CreateDeviceRequest) returns (Device) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/registries/*}/devices" + body: "device" + }; + option (google.api.method_signature) = "parent,device"; + } + + // Gets details about a device. + rpc GetDevice(GetDeviceRequest) returns (Device) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" + additional_bindings { + get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}" + } + }; + option (google.api.method_signature) = "name"; + } + + // Updates a device. + rpc UpdateDevice(UpdateDeviceRequest) returns (Device) { + option (google.api.http) = { + patch: "/v1/{device.name=projects/*/locations/*/registries/*/devices/*}" + body: "device" + additional_bindings { + patch: "/v1/{device.name=projects/*/locations/*/registries/*/groups/*/devices/*}" + body: "device" + } + }; + option (google.api.method_signature) = "device,update_mask"; + } + + // Deletes a device. + rpc DeleteDevice(DeleteDeviceRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List devices in a device registry. + rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*/registries/*}/devices" + additional_bindings { + get: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}/devices" + } + }; + option (google.api.method_signature) = "parent"; + } + + // Modifies the configuration for the device, which is eventually sent from + // the Cloud IoT Core servers. Returns the modified configuration version and + // its metadata. + rpc ModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest) returns (DeviceConfig) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:modifyCloudToDeviceConfig" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:modifyCloudToDeviceConfig" + body: "*" + } + }; + option (google.api.method_signature) = "name,binary_data"; + } + + // Lists the last few versions of the device configuration in descending + // order (i.e.: newest first). + rpc ListDeviceConfigVersions(ListDeviceConfigVersionsRequest) returns (ListDeviceConfigVersionsResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/configVersions" + additional_bindings { + get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/configVersions" + } + }; + option (google.api.method_signature) = "name"; + } + + // Lists the last few versions of the device state in descending order (i.e.: + // newest first). + rpc ListDeviceStates(ListDeviceStatesRequest) returns (ListDeviceStatesResponse) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/states" + additional_bindings { + get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/states" + } + }; + option (google.api.method_signature) = "name"; + } + + // Sets the access control policy on the specified resource. Replaces any + // existing policy. + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/registries/*}:setIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:setIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource,policy"; + } + + // Gets the access control policy for a resource. + // Returns an empty policy if the resource exists and does not have a policy + // set. + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/registries/*}:getIamPolicy" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:getIamPolicy" + body: "*" + } + }; + option (google.api.method_signature) = "resource"; + } + + // Returns permissions that a caller has on the specified resource. + // If the resource does not exist, this will return an empty set of + // permissions, not a NOT_FOUND error. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v1/{resource=projects/*/locations/*/registries/*}:testIamPermissions" + body: "*" + additional_bindings { + post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:testIamPermissions" + body: "*" + } + }; + option (google.api.method_signature) = "resource,permissions"; + } + + // Sends a command to the specified device. In order for a device to be able + // to receive commands, it must: + // 1) be connected to Cloud IoT Core using the MQTT protocol, and + // 2) be subscribed to the group of MQTT topics specified by + // /devices/{device-id}/commands/#. This subscription will receive commands + // at the top-level topic /devices/{device-id}/commands as well as commands + // for subfolders, like /devices/{device-id}/commands/subfolder. + // Note that subscribing to specific subfolders is not supported. + // If the command could not be delivered to the device, this method will + // return an error; in particular, if the device is not subscribed, this + // method will return FAILED_PRECONDITION. Otherwise, this method will + // return OK. If the subscription is QoS 1, at least once delivery will be + // guaranteed; for QoS 0, no acknowledgment will be expected from the device. + rpc SendCommandToDevice(SendCommandToDeviceRequest) returns (SendCommandToDeviceResponse) { + option (google.api.http) = { + post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:sendCommandToDevice" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:sendCommandToDevice" + body: "*" + } + }; + option (google.api.method_signature) = "name,binary_data"; + option (google.api.method_signature) = "name,binary_data,subfolder"; + } + + // Associates the device with the gateway. + rpc BindDeviceToGateway(BindDeviceToGatewayRequest) returns (BindDeviceToGatewayResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/registries/*}:bindDeviceToGateway" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:bindDeviceToGateway" + body: "*" + } + }; + option (google.api.method_signature) = "parent,gateway_id,device_id"; + } + + // Deletes the association between the device and the gateway. + rpc UnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest) returns (UnbindDeviceFromGatewayResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/locations/*/registries/*}:unbindDeviceFromGateway" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:unbindDeviceFromGateway" + body: "*" + } + }; + option (google.api.method_signature) = "parent,gateway_id,device_id"; + } +} + +// Request for `CreateDeviceRegistry`. +message CreateDeviceRegistryRequest { + // Required. The project and cloud region where this device registry must be created. + // For example, `projects/example-project/locations/us-central1`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // Required. The device registry. The field `name` must be empty. The server will + // generate that field from the device registry `id` provided and the + // `parent` field. + DeviceRegistry device_registry = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for `GetDeviceRegistry`. +message GetDeviceRegistryRequest { + // Required. The name of the device registry. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; +} + +// Request for `DeleteDeviceRegistry`. +message DeleteDeviceRegistryRequest { + // Required. The name of the device registry. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; +} + +// Request for `UpdateDeviceRegistry`. +message UpdateDeviceRegistryRequest { + // Required. The new values for the device registry. The `id` field must be empty, and + // the `name` field must indicate the path of the resource. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + DeviceRegistry device_registry = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. Only updates the `device_registry` fields indicated by this mask. + // The field mask must not be empty, and it must not contain fields that + // are immutable or only set by the server. + // Mutable top-level fields: `event_notification_config`, `http_config`, + // `mqtt_config`, and `state_notification_config`. + google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for `ListDeviceRegistries`. +message ListDeviceRegistriesRequest { + // Required. The project and cloud region path. For example, + // `projects/example-project/locations/us-central1`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "locations.googleapis.com/Location" + } + ]; + + // The maximum number of registries to return in the response. If this value + // is zero, the service will select a default size. A call may return fewer + // objects than requested. A non-empty `next_page_token` in the response + // indicates that more data is available. + int32 page_size = 2; + + // The value returned by the last `ListDeviceRegistriesResponse`; indicates + // that this is a continuation of a prior `ListDeviceRegistries` call and + // the system should return the next page of data. + string page_token = 3; +} + +// Response for `ListDeviceRegistries`. +message ListDeviceRegistriesResponse { + // The registries that matched the query. + repeated DeviceRegistry device_registries = 1; + + // If not empty, indicates that there may be more registries that match the + // request; this value should be passed in a new + // `ListDeviceRegistriesRequest`. + string next_page_token = 2; +} + +// Request for `CreateDevice`. +message CreateDeviceRequest { + // Required. The name of the device registry where this device should be created. + // For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; + + // Required. The device registration details. The field `name` must be empty. The server + // generates `name` from the device registry `id` and the + // `parent` field. + Device device = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for `GetDevice`. +message GetDeviceRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; + + // The fields of the `Device` resource to be returned in the response. If the + // field mask is unset or empty, all fields are returned. Fields have to be + // provided in snake_case format, for example: `last_heartbeat_time`. + google.protobuf.FieldMask field_mask = 2; +} + +// Request for `UpdateDevice`. +message UpdateDeviceRequest { + // Required. The new values for the device. The `id` and `num_id` fields must + // be empty, and the field `name` must specify the name path. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0`or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + Device device = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Only updates the `device` fields indicated by this mask. + // The field mask must not be empty, and it must not contain fields that + // are immutable or only set by the server. + // Mutable top-level fields: `credentials`, `blocked`, and `metadata` + google.protobuf.FieldMask update_mask = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for `DeleteDevice`. +message DeleteDeviceRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; +} + +// Request for `ListDevices`. +message ListDevicesRequest { + // Required. The device registry path. Required. For example, + // `projects/my-project/locations/us-central1/registries/my-registry`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; + + // A list of device numeric IDs. If empty, this field is ignored. Maximum + // IDs: 10,000. + repeated uint64 device_num_ids = 2; + + // A list of device string IDs. For example, `['device0', 'device12']`. + // If empty, this field is ignored. Maximum IDs: 10,000 + repeated string device_ids = 3; + + // The fields of the `Device` resource to be returned in the response. The + // fields `id` and `num_id` are always returned, along with any + // other fields specified in snake_case format, for example: + // `last_heartbeat_time`. + google.protobuf.FieldMask field_mask = 4; + + // Options related to gateways. + GatewayListOptions gateway_list_options = 6; + + // The maximum number of devices to return in the response. If this value + // is zero, the service will select a default size. A call may return fewer + // objects than requested. A non-empty `next_page_token` in the response + // indicates that more data is available. + int32 page_size = 100; + + // The value returned by the last `ListDevicesResponse`; indicates + // that this is a continuation of a prior `ListDevices` call and + // the system should return the next page of data. + string page_token = 101; +} + +// Options for limiting the list based on gateway type and associations. +message GatewayListOptions { + // If not set, all devices and gateways are returned. If set, the list is + // filtered based on gateway type and associations. + oneof filter { + // 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. + GatewayType gateway_type = 1; + + // 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. + string associations_gateway_id = 2; + + // 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. + string associations_device_id = 3; + } +} + +// Response for `ListDevices`. +message ListDevicesResponse { + // The devices that match the request. + repeated Device devices = 1; + + // If not empty, indicates that there may be more devices that match the + // request; this value should be passed in a new `ListDevicesRequest`. + string next_page_token = 2; +} + +// Request for `ModifyCloudToDeviceConfig`. +message ModifyCloudToDeviceConfigRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; + + // The version number to update. If this value is zero, it will not check the + // version number of the server and will always update the current version; + // otherwise, this update will fail if the version number found on the server + // does not match this version number. This is used to support multiple + // simultaneous updates without losing data. + int64 version_to_update = 2; + + // Required. The configuration data for the device. + bytes binary_data = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Request for `ListDeviceConfigVersions`. +message ListDeviceConfigVersionsRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; + + // The number of versions to list. Versions are listed in decreasing order of + // the version number. The maximum number of versions retained is 10. If this + // value is zero, it will return all the versions available. + int32 num_versions = 2; +} + +// Response for `ListDeviceConfigVersions`. +message ListDeviceConfigVersionsResponse { + // The device configuration for the last few versions. Versions are listed + // in decreasing order, starting from the most recent one. + repeated DeviceConfig device_configs = 1; +} + +// Request for `ListDeviceStates`. +message ListDeviceStatesRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; + + // The number of states to list. States are listed in descending order of + // update time. The maximum number of states retained is 10. If this + // value is zero, it will return all the states available. + int32 num_states = 2; +} + +// Response for `ListDeviceStates`. +message ListDeviceStatesResponse { + // The last few device states. States are listed in descending order of server + // update time, starting from the most recent one. + repeated DeviceState device_states = 1; +} + +// Request for `SendCommandToDevice`. +message SendCommandToDeviceRequest { + // Required. The name of the device. For example, + // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Device" + } + ]; + + // Required. The command data to send to the device. + bytes binary_data = 2 [(google.api.field_behavior) = REQUIRED]; + + // 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. + string subfolder = 3; +} + +// Response for `SendCommandToDevice`. +message SendCommandToDeviceResponse { + +} + +// Request for `BindDeviceToGateway`. +message BindDeviceToGatewayRequest { + // Required. The name of the registry. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; + + // Required. The value of `gateway_id` can be either the device numeric ID or the + // user-defined device identifier. + string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The device to associate with the specified gateway. The value of + // `device_id` can be either the device numeric ID or the user-defined device + // identifier. + string device_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for `BindDeviceToGateway`. +message BindDeviceToGatewayResponse { + +} + +// Request for `UnbindDeviceFromGateway`. +message UnbindDeviceFromGatewayRequest { + // Required. The name of the registry. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "cloudiot.googleapis.com/Registry" + } + ]; + + // Required. The value of `gateway_id` can be either the device numeric ID or the + // user-defined device identifier. + string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The device to disassociate from the specified gateway. The value of + // `device_id` can be either the device numeric ID or the user-defined device + // identifier. + string device_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Response for `UnbindDeviceFromGateway`. +message UnbindDeviceFromGatewayResponse { + +} diff --git a/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto b/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto new file mode 100644 index 00000000..a14fc027 --- /dev/null +++ b/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto @@ -0,0 +1,483 @@ +// 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. + +syntax = "proto3"; + +package google.cloud.iot.v1; + +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option cc_enable_arenas = true; +option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; +option java_multiple_files = true; +option java_outer_classname = "ResourcesProto"; +option java_package = "com.google.cloud.iot.v1"; + +// The device resource. +message Device { + option (google.api.resource) = { + type: "cloudiot.googleapis.com/Device" + pattern: "projects/{project}/locations/{location}/registries/{registry}/devices/{device}" + }; + + // The user-defined device identifier. The device ID must be unique + // within a device registry. + string id = 1; + + // The resource path name. For example, + // `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or + // `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. + // When `name` is populated as a response from the service, it always ends + // in the device numeric ID. + string name = 2; + + // [Output only] A server-defined unique numeric ID for the device. This is a + // more compact way to identify devices, and it is globally unique. + uint64 num_id = 3; + + // The credentials used to authenticate this device. To allow credential + // rotation without interruption, multiple device credentials can be bound to + // this device. No more than 3 credentials can be bound to a single device at + // a time. When new credentials are added to a device, they are verified + // against the registry credentials. For details, see the description of the + // `DeviceRegistry.credentials` field. + repeated DeviceCredential credentials = 12; + + // [Output only] The last time an MQTT `PINGREQ` was received. This field + // applies only to devices connecting through MQTT. MQTT clients usually only + // send `PINGREQ` messages if the connection is idle, and no other messages + // have been sent. Timestamps are periodically collected and written to + // storage; they may be stale by a few minutes. + google.protobuf.Timestamp last_heartbeat_time = 7; + + // [Output only] The last time a telemetry event was received. Timestamps are + // periodically collected and written to storage; they may be stale by a few + // minutes. + google.protobuf.Timestamp last_event_time = 8; + + // [Output only] The last time a state event was received. Timestamps are + // periodically collected and written to storage; they may be stale by a few + // minutes. + google.protobuf.Timestamp last_state_time = 20; + + // [Output only] The last time a cloud-to-device config version acknowledgment + // was received from the device. This field is only for configurations + // sent through MQTT. + google.protobuf.Timestamp last_config_ack_time = 14; + + // [Output only] The last time a cloud-to-device config version was sent to + // the device. + google.protobuf.Timestamp last_config_send_time = 18; + + // If a device is blocked, connections or requests from this device will fail. + // Can be used to temporarily prevent the device from connecting if, for + // example, the sensor is generating bad data and needs maintenance. + bool blocked = 19; + + // [Output only] The time the most recent error occurred, such as a failure to + // publish to Cloud Pub/Sub. This field is the timestamp of + // 'last_error_status'. + google.protobuf.Timestamp last_error_time = 10; + + // [Output only] The error message of the most recent error, such as a failure + // to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this + // field. If no errors have occurred, this field has an empty message + // and the status code 0 == OK. Otherwise, this field is expected to have a + // status code other than OK. + google.rpc.Status last_error_status = 11; + + // The most recent device configuration, which is eventually sent from + // Cloud IoT Core to the device. If not present on creation, the + // configuration will be initialized with an empty payload and version value + // of `1`. To update this field after creation, use the + // `DeviceManager.ModifyCloudToDeviceConfig` method. + DeviceConfig config = 13; + + // [Output only] The state most recently received from the device. If no state + // has been reported, this field is not present. + DeviceState state = 16; + + // **Beta Feature** + // + // The logging verbosity for device activity. If unspecified, + // DeviceRegistry.log_level will be used. + LogLevel log_level = 21; + + // The metadata key-value pairs assigned to the device. This metadata is not + // interpreted or indexed by Cloud IoT Core. It can be used to add contextual + // information for the device. + // + // Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and + // be less than 128 bytes in length. + // + // Values are free-form strings. Each value must be less than or equal to 32 + // KB in size. + // + // The total size of all keys and values must be less than 256 KB, and the + // maximum number of key-value pairs is 500. + map metadata = 17; + + // Gateway-related configuration and state. + GatewayConfig gateway_config = 24; +} + +// Gateway-related configuration and state. +message GatewayConfig { + // Indicates whether the device is a gateway. + GatewayType gateway_type = 1; + + // Indicates how to authorize and/or authenticate devices to access the + // gateway. + GatewayAuthMethod gateway_auth_method = 2; + + // [Output only] The ID of the gateway the device accessed most recently. + string last_accessed_gateway_id = 3; + + // [Output only] The most recent time at which the device accessed the gateway + // specified in `last_accessed_gateway`. + google.protobuf.Timestamp last_accessed_gateway_time = 4; +} + +// A container for a group of devices. +message DeviceRegistry { + option (google.api.resource) = { + type: "cloudiot.googleapis.com/Registry" + pattern: "projects/{project}/locations/{location}/registries/{registry}" + }; + + // The identifier of this device registry. For example, `myRegistry`. + string id = 1; + + // The resource path name. For example, + // `projects/example-project/locations/us-central1/registries/my-registry`. + string name = 2; + + // The configuration for notification of telemetry events received from the + // device. All telemetry events that were successfully published by the + // device and acknowledged by Cloud IoT Core are guaranteed to be + // delivered to Cloud Pub/Sub. If multiple configurations match a message, + // only the first matching configuration is used. If you try to publish a + // device telemetry event using MQTT without specifying a Cloud Pub/Sub topic + // for the device's registry, the connection closes automatically. If you try + // to do so using an HTTP connection, an error is returned. Up to 10 + // configurations may be provided. + repeated EventNotificationConfig event_notification_configs = 10; + + // The configuration for notification of new states received from the device. + // State updates are guaranteed to be stored in the state history, but + // notifications to Cloud Pub/Sub are not guaranteed. For example, if + // permissions are misconfigured or the specified topic doesn't exist, no + // notification will be published but the state will still be stored in Cloud + // IoT Core. + StateNotificationConfig state_notification_config = 7; + + // The MQTT configuration for this device registry. + MqttConfig mqtt_config = 4; + + // The DeviceService (HTTP) configuration for this device registry. + HttpConfig http_config = 9; + + // **Beta Feature** + // + // The default logging verbosity for activity from devices in this registry. + // The verbosity level can be overridden by Device.log_level. + LogLevel log_level = 11; + + // The credentials used to verify the device credentials. No more than 10 + // credentials can be bound to a single registry at a time. The verification + // process occurs at the time of device creation or update. If this field is + // empty, no verification is performed. Otherwise, the credentials of a newly + // created device or added credentials of an updated device should be signed + // with one of these registry credentials. + // + // Note, however, that existing devices will never be affected by + // modifications to this list of credentials: after a device has been + // successfully created in a registry, it should be able to connect even if + // its registry credentials are revoked, deleted, or modified. + repeated RegistryCredential credentials = 8; +} + +// The configuration of MQTT for a device registry. +message MqttConfig { + // If enabled, allows connections using the MQTT protocol. Otherwise, MQTT + // connections to this registry will fail. + MqttState mqtt_enabled_state = 1; +} + +// Indicates whether an MQTT connection is enabled or disabled. See the field +// description for details. +enum MqttState { + // No MQTT state specified. If not specified, MQTT will be enabled by default. + MQTT_STATE_UNSPECIFIED = 0; + + // Enables a MQTT connection. + MQTT_ENABLED = 1; + + // Disables a MQTT connection. + MQTT_DISABLED = 2; +} + +// The configuration of the HTTP bridge for a device registry. +message HttpConfig { + // If enabled, allows devices to use DeviceService via the HTTP protocol. + // Otherwise, any requests to DeviceService will fail for this registry. + HttpState http_enabled_state = 1; +} + +// Indicates whether DeviceService (HTTP) is enabled or disabled for the +// registry. See the field description for details. +enum HttpState { + // No HTTP state specified. If not specified, DeviceService will be + // enabled by default. + HTTP_STATE_UNSPECIFIED = 0; + + // Enables DeviceService (HTTP) service for the registry. + HTTP_ENABLED = 1; + + // Disables DeviceService (HTTP) service for the registry. + HTTP_DISABLED = 2; +} + +// **Beta Feature** +// +// The logging verbosity for device activity. Specifies which events should be +// written to logs. For example, if the LogLevel is ERROR, only events that +// terminate in errors will be logged. LogLevel is inclusive; enabling INFO +// logging will also enable ERROR logging. +enum LogLevel { + // No logging specified. If not specified, logging will be disabled. + LOG_LEVEL_UNSPECIFIED = 0; + + // Disables logging. + NONE = 10; + + // Error events will be logged. + ERROR = 20; + + // Informational events will be logged, such as connections and + // disconnections. + INFO = 30; + + // All events will be logged. + DEBUG = 40; +} + +// Gateway type. +enum GatewayType { + // If unspecified, the device is considered a non-gateway device. + GATEWAY_TYPE_UNSPECIFIED = 0; + + // The device is a gateway. + GATEWAY = 1; + + // The device is not a gateway. + NON_GATEWAY = 2; +} + +// The gateway authorization/authentication method. This setting determines how +// Cloud IoT Core authorizes/authenticate devices to access the gateway. +enum GatewayAuthMethod { + // No authentication/authorization method specified. No devices are allowed to + // access the gateway. + GATEWAY_AUTH_METHOD_UNSPECIFIED = 0; + + // The device is authenticated through the gateway association only. Device + // credentials are ignored even if provided. + ASSOCIATION_ONLY = 1; + + // The device is authenticated through its own credentials. Gateway + // association is not checked. + DEVICE_AUTH_TOKEN_ONLY = 2; + + // The device is authenticated through both device credentials and gateway + // association. The device must be bound to the gateway and must provide its + // own credentials. + ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 3; +} + +// The configuration for forwarding telemetry events. +message EventNotificationConfig { + // If the subfolder name matches this string exactly, this configuration will + // be used. The string must not include the leading '/' character. If empty, + // all strings are matched. This field is used only for telemetry events; + // subfolders are not supported for state changes. + string subfolder_matches = 2; + + // A Cloud Pub/Sub topic name. For example, + // `projects/myProject/topics/deviceEvents`. + string pubsub_topic_name = 1; +} + +// The configuration for notification of new states received from the device. +message StateNotificationConfig { + // A Cloud Pub/Sub topic name. For example, + // `projects/myProject/topics/deviceEvents`. + string pubsub_topic_name = 1; +} + +// A server-stored registry credential used to validate device credentials. +message RegistryCredential { + // The credential data. Reserved for expansion in the future. + oneof credential { + // A public key certificate used to verify the device credentials. + PublicKeyCertificate public_key_certificate = 1; + } +} + +// Details of an X.509 certificate. For informational purposes only. +message X509CertificateDetails { + // The entity that signed the certificate. + string issuer = 1; + + // The entity the certificate and public key belong to. + string subject = 2; + + // The time the certificate becomes valid. + google.protobuf.Timestamp start_time = 3; + + // The time the certificate becomes invalid. + google.protobuf.Timestamp expiry_time = 4; + + // The algorithm used to sign the certificate. + string signature_algorithm = 5; + + // The type of public key in the certificate. + string public_key_type = 6; +} + +// A public key certificate format and data. +message PublicKeyCertificate { + // The certificate format. + PublicKeyCertificateFormat format = 1; + + // The certificate data. + string certificate = 2; + + // [Output only] The certificate details. Used only for X.509 certificates. + X509CertificateDetails x509_details = 3; +} + +// The supported formats for the public key. +enum PublicKeyCertificateFormat { + // The format has not been specified. This is an invalid default value and + // must not be used. + UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = 0; + + // An X.509v3 certificate ([RFC5280](https://www.ietf.org/rfc/rfc5280.txt)), + // encoded in base64, and wrapped by `-----BEGIN CERTIFICATE-----` and + // `-----END CERTIFICATE-----`. + X509_CERTIFICATE_PEM = 1; +} + +// A server-stored device credential used for authentication. +message DeviceCredential { + // The credential data. Reserved for expansion in the future. + oneof credential { + // A public key used to verify the signature of JSON Web Tokens (JWTs). + // When adding a new device credential, either via device creation or via + // modifications, this public key credential may be required to be signed by + // one of the registry level certificates. More specifically, if the + // registry contains at least one certificate, any new device credential + // must be signed by one of the registry certificates. As a result, + // when the registry contains certificates, only X.509 certificates are + // accepted as device credentials. However, if the registry does + // not contain a certificate, self-signed certificates and public keys will + // be accepted. New device credentials must be different from every + // registry-level certificate. + PublicKeyCredential public_key = 2; + } + + // [Optional] The time at which this credential becomes invalid. This + // credential will be ignored for new client authentication requests after + // this timestamp; however, it will not be automatically deleted. + google.protobuf.Timestamp expiration_time = 6; +} + +// A public key format and data. +message PublicKeyCredential { + // The format of the key. + PublicKeyFormat format = 1; + + // The key data. + string key = 2; +} + +// The supported formats for the public key. +enum PublicKeyFormat { + // The format has not been specified. This is an invalid default value and + // must not be used. + UNSPECIFIED_PUBLIC_KEY_FORMAT = 0; + + // An RSA public key encoded in base64, and wrapped by + // `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`. This can be + // used to verify `RS256` signatures in JWT tokens ([RFC7518]( + // https://www.ietf.org/rfc/rfc7518.txt)). + RSA_PEM = 3; + + // As RSA_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( + // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by + // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. + RSA_X509_PEM = 1; + + // Public key for the ECDSA algorithm using P-256 and SHA-256, encoded in + // base64, and wrapped by `-----BEGIN PUBLIC KEY-----` and `-----END + // PUBLIC KEY-----`. This can be used to verify JWT tokens with the `ES256` + // algorithm ([RFC7518](https://www.ietf.org/rfc/rfc7518.txt)). This curve is + // defined in [OpenSSL](https://www.openssl.org/) as the `prime256v1` curve. + ES256_PEM = 2; + + // As ES256_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( + // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by + // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. + ES256_X509_PEM = 4; +} + +// The device configuration. Eventually delivered to devices. +message DeviceConfig { + // [Output only] The version of this update. The version number is assigned by + // the server, and is always greater than 0 after device creation. The + // version must be 0 on the `CreateDevice` request if a `config` is + // specified; the response of `CreateDevice` will always have a value of 1. + int64 version = 1; + + // [Output only] The time at which this configuration version was updated in + // Cloud IoT Core. This timestamp is set by the server. + google.protobuf.Timestamp cloud_update_time = 2; + + // [Output only] The time at which Cloud IoT Core received the + // acknowledgment from the device, indicating that the device has received + // this configuration version. If this field is not present, the device has + // not yet acknowledged that it received this version. Note that when + // the config was sent to the device, many config versions may have been + // available in Cloud IoT Core while the device was disconnected, and on + // connection, only the latest version is sent to the device. Some + // versions may never be sent to the device, and therefore are never + // acknowledged. This timestamp is set by Cloud IoT Core. + google.protobuf.Timestamp device_ack_time = 3; + + // The device configuration data. + bytes binary_data = 4; +} + +// The device state, as reported by the device. +message DeviceState { + // [Output only] The time at which this state version was updated in Cloud + // IoT Core. + google.protobuf.Timestamp update_time = 1; + + // The device state data. + bytes binary_data = 2; +} diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js new file mode 100644 index 00000000..e5d0348f --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js @@ -0,0 +1,72 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, gatewayId, deviceId) { + // [START cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const parent = 'abc123' + /** + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + */ + // const gatewayId = 'abc123' + /** + * Required. The device to associate with the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + */ + // const deviceId = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callBindDeviceToGateway() { + // Construct request + const request = { + parent, + gatewayId, + deviceId, + }; + + // Run request + const response = await iotClient.bindDeviceToGateway(request); + console.log(response); + } + + callBindDeviceToGateway(); + // [END cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js new file mode 100644 index 00000000..d38142b0 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js @@ -0,0 +1,67 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, device) { + // [START cloudiot_v1_generated_DeviceManager_CreateDevice_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device registry where this device should be created. + * For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const parent = 'abc123' + /** + * Required. The device registration details. The field `name` must be empty. The server + * generates `name` from the device registry `id` and the + * `parent` field. + */ + // const device = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callCreateDevice() { + // Construct request + const request = { + parent, + device, + }; + + // Run request + const response = await iotClient.createDevice(request); + console.log(response); + } + + callCreateDevice(); + // [END cloudiot_v1_generated_DeviceManager_CreateDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js new file mode 100644 index 00000000..6248800b --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js @@ -0,0 +1,66 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, deviceRegistry) { + // [START cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and cloud region where this device registry must be created. + * For example, `projects/example-project/locations/us-central1`. + */ + // const parent = 'abc123' + /** + * Required. The device registry. The field `name` must be empty. The server will + * generate that field from the device registry `id` provided and the + * `parent` field. + */ + // const deviceRegistry = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callCreateDeviceRegistry() { + // Construct request + const request = { + parent, + deviceRegistry, + }; + + // Run request + const response = await iotClient.createDeviceRegistry(request); + console.log(response); + } + + callCreateDeviceRegistry(); + // [END cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js new file mode 100644 index 00000000..ab1999e2 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js @@ -0,0 +1,60 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_DeleteDevice_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callDeleteDevice() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.deleteDevice(request); + console.log(response); + } + + callDeleteDevice(); + // [END cloudiot_v1_generated_DeviceManager_DeleteDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js new file mode 100644 index 00000000..663be451 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js @@ -0,0 +1,59 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const name = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callDeleteDeviceRegistry() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.deleteDeviceRegistry(request); + console.log(response); + } + + callDeleteDeviceRegistry(); + // [END cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js new file mode 100644 index 00000000..db5022fb --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js @@ -0,0 +1,66 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_GetDevice_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + /** + * The fields of the `Device` resource to be returned in the response. If the + * field mask is unset or empty, all fields are returned. Fields have to be + * provided in snake_case format, for example: `last_heartbeat_time`. + */ + // const fieldMask = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callGetDevice() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.getDevice(request); + console.log(response); + } + + callGetDevice(); + // [END cloudiot_v1_generated_DeviceManager_GetDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js new file mode 100644 index 00000000..7cbb7241 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js @@ -0,0 +1,59 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const name = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callGetDeviceRegistry() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.getDeviceRegistry(request); + console.log(response); + } + + callGetDeviceRegistry(); + // [END cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js new file mode 100644 index 00000000..039b3941 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js @@ -0,0 +1,64 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource) { + // [START cloudiot_v1_generated_DeviceManager_GetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + */ + // const options = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callGetIamPolicy() { + // Construct request + const request = { + resource, + }; + + // Run request + const response = await iotClient.getIamPolicy(request); + console.log(response); + } + + callGetIamPolicy(); + // [END cloudiot_v1_generated_DeviceManager_GetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js new file mode 100644 index 00000000..be6a024d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js @@ -0,0 +1,66 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + /** + * The number of versions to list. Versions are listed in decreasing order of + * the version number. The maximum number of versions retained is 10. If this + * value is zero, it will return all the versions available. + */ + // const numVersions = 1234 + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callListDeviceConfigVersions() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.listDeviceConfigVersions(request); + console.log(response); + } + + callListDeviceConfigVersions(); + // [END cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js new file mode 100644 index 00000000..d7853e34 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js @@ -0,0 +1,74 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + */ + // const parent = 'abc123' + /** + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callListDeviceRegistries() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await iotClient.listDeviceRegistriesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDeviceRegistries(); + // [END cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js new file mode 100644 index 00000000..d9c8519d --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js @@ -0,0 +1,66 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name) { + // [START cloudiot_v1_generated_DeviceManager_ListDeviceStates_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + /** + * The number of states to list. States are listed in descending order of + * update time. The maximum number of states retained is 10. If this + * value is zero, it will return all the states available. + */ + // const numStates = 1234 + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callListDeviceStates() { + // Construct request + const request = { + name, + }; + + // Run request + const response = await iotClient.listDeviceStates(request); + console.log(response); + } + + callListDeviceStates(); + // [END cloudiot_v1_generated_DeviceManager_ListDeviceStates_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js new file mode 100644 index 00000000..7e33937a --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js @@ -0,0 +1,95 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent) { + // [START cloudiot_v1_generated_DeviceManager_ListDevices_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + */ + // const parent = 'abc123' + /** + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + */ + // const deviceNumIds = 1234 + /** + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + */ + // const deviceIds = 'abc123' + /** + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + */ + // const fieldMask = {} + /** + * Options related to gateways. + */ + // const gatewayListOptions = {} + /** + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + */ + // const pageSize = 1234 + /** + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + */ + // const pageToken = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callListDevices() { + // Construct request + const request = { + parent, + }; + + // Run request + const iterable = await iotClient.listDevicesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListDevices(); + // [END cloudiot_v1_generated_DeviceManager_ListDevices_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js new file mode 100644 index 00000000..9e415682 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js @@ -0,0 +1,73 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, binaryData) { + // [START cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + /** + * The version number to update. If this value is zero, it will not check the + * version number of the server and will always update the current version; + * otherwise, this update will fail if the version number found on the server + * does not match this version number. This is used to support multiple + * simultaneous updates without losing data. + */ + // const versionToUpdate = 1234 + /** + * Required. The configuration data for the device. + */ + // const binaryData = 'Buffer.from('string')' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callModifyCloudToDeviceConfig() { + // Construct request + const request = { + name, + binaryData, + }; + + // Run request + const response = await iotClient.modifyCloudToDeviceConfig(request); + console.log(response); + } + + callModifyCloudToDeviceConfig(); + // [END cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js new file mode 100644 index 00000000..df399716 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js @@ -0,0 +1,73 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(name, binaryData) { + // [START cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const name = 'abc123' + /** + * Required. The command data to send to the device. + */ + // const binaryData = 'Buffer.from('string')' + /** + * 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. + */ + // const subfolder = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callSendCommandToDevice() { + // Construct request + const request = { + name, + binaryData, + }; + + // Run request + const response = await iotClient.sendCommandToDevice(request); + console.log(response); + } + + callSendCommandToDevice(); + // [END cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js new file mode 100644 index 00000000..05ba74e3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js @@ -0,0 +1,74 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, policy) { + // [START cloudiot_v1_generated_DeviceManager_SetIamPolicy_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + */ + // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callSetIamPolicy() { + // Construct request + const request = { + resource, + policy, + }; + + // Run request + const response = await iotClient.setIamPolicy(request); + console.log(response); + } + + callSetIamPolicy(); + // [END cloudiot_v1_generated_DeviceManager_SetIamPolicy_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js new file mode 100644 index 00000000..81f299d3 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js @@ -0,0 +1,67 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(resource, permissions) { + // [START cloudiot_v1_generated_DeviceManager_TestIamPermissions_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + */ + // const resource = 'abc123' + /** + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). + */ + // const permissions = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callTestIamPermissions() { + // Construct request + const request = { + resource, + permissions, + }; + + // Run request + const response = await iotClient.testIamPermissions(request); + console.log(response); + } + + callTestIamPermissions(); + // [END cloudiot_v1_generated_DeviceManager_TestIamPermissions_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js new file mode 100644 index 00000000..37fb81b5 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js @@ -0,0 +1,72 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, gatewayId, deviceId) { + // [START cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const parent = 'abc123' + /** + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + */ + // const gatewayId = 'abc123' + /** + * Required. The device to disassociate from the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + */ + // const deviceId = 'abc123' + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callUnbindDeviceFromGateway() { + // Construct request + const request = { + parent, + gatewayId, + deviceId, + }; + + // Run request + const response = await iotClient.unbindDeviceFromGateway(request); + console.log(response); + } + + callUnbindDeviceFromGateway(); + // [END cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js new file mode 100644 index 00000000..f2c21788 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js @@ -0,0 +1,69 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(device, updateMask) { + // [START cloudiot_v1_generated_DeviceManager_UpdateDevice_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new values for the device. The `id` and `num_id` fields must + * be empty, and the field `name` must specify the name path. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + */ + // const device = {} + /** + * Required. Only updates the `device` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `credentials`, `blocked`, and `metadata` + */ + // const updateMask = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callUpdateDevice() { + // Construct request + const request = { + device, + updateMask, + }; + + // Run request + const response = await iotClient.updateDevice(request); + console.log(response); + } + + callUpdateDevice(); + // [END cloudiot_v1_generated_DeviceManager_UpdateDevice_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js new file mode 100644 index 00000000..c3a34b16 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js @@ -0,0 +1,69 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(deviceRegistry, updateMask) { + // [START cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The new values for the device registry. The `id` field must be empty, and + * the `name` field must indicate the path of the resource. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + */ + // const deviceRegistry = {} + /** + * Required. Only updates the `device_registry` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `event_notification_config`, `http_config`, + * `mqtt_config`, and `state_notification_config`. + */ + // const updateMask = {} + + // Imports the Iot library + const {DeviceManagerClient} = require('@google-cloud/iot').v1; + + // Instantiates a client + const iotClient = new DeviceManagerClient(); + + async function callUpdateDeviceRegistry() { + // Construct request + const request = { + deviceRegistry, + updateMask, + }; + + // Run request + const response = await iotClient.updateDeviceRegistry(request); + console.log(response); + } + + callUpdateDeviceRegistry(); + // [END cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json new file mode 100644 index 00000000..f70dc8b9 --- /dev/null +++ b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json @@ -0,0 +1,883 @@ +{ + "clientLibrary": { + "name": "nodejs-iot", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.cloud.iot.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async", + "title": "iot createDeviceRegistry Sample", + "origin": "API_DEFINITION", + "description": " Creates a device registry that contains devices.", + "canonical": true, + "file": "device_manager.create_device_registry.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.CreateDeviceRegistry", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "device_registry", + "type": ".google.cloud.iot.v1.DeviceRegistry" + } + ], + "resultType": ".google.cloud.iot.v1.DeviceRegistry", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "CreateDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.CreateDeviceRegistry", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async", + "title": "iot getDeviceRegistry Sample", + "origin": "API_DEFINITION", + "description": " Gets a device registry configuration.", + "canonical": true, + "file": "device_manager.get_device_registry.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.GetDeviceRegistry", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.DeviceRegistry", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "GetDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.GetDeviceRegistry", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async", + "title": "iot updateDeviceRegistry Sample", + "origin": "API_DEFINITION", + "description": " Updates a device registry configuration.", + "canonical": true, + "file": "device_manager.update_device_registry.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDeviceRegistry", + "async": true, + "parameters": [ + { + "name": "device_registry", + "type": ".google.cloud.iot.v1.DeviceRegistry" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.iot.v1.DeviceRegistry", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "UpdateDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDeviceRegistry", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async", + "title": "iot deleteDeviceRegistry Sample", + "origin": "API_DEFINITION", + "description": " Deletes a device registry configuration.", + "canonical": true, + "file": "device_manager.delete_device_registry.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 51, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDeviceRegistry", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "DeleteDeviceRegistry", + "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDeviceRegistry", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async", + "title": "iot listDeviceRegistries Sample", + "origin": "API_DEFINITION", + "description": " Lists device registries.", + "canonical": true, + "file": "device_manager.list_device_registries.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDeviceRegistries", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceRegistries", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.ListDeviceRegistriesResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "ListDeviceRegistries", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceRegistries", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_CreateDevice_async", + "title": "iot createDevice Sample", + "origin": "API_DEFINITION", + "description": " Creates a device in a device registry.", + "canonical": true, + "file": "device_manager.create_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.CreateDevice", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "device", + "type": ".google.cloud.iot.v1.Device" + } + ], + "resultType": ".google.cloud.iot.v1.Device", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "CreateDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.CreateDevice", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_GetDevice_async", + "title": "iot getDevice Sample", + "origin": "API_DEFINITION", + "description": " Gets details about a device.", + "canonical": true, + "file": "device_manager.get_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.GetDevice", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "field_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.iot.v1.Device", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "GetDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.GetDevice", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_UpdateDevice_async", + "title": "iot updateDevice Sample", + "origin": "API_DEFINITION", + "description": " Updates a device.", + "canonical": true, + "file": "device_manager.update_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 61, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UpdateDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDevice", + "async": true, + "parameters": [ + { + "name": "device", + "type": ".google.cloud.iot.v1.Device" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.cloud.iot.v1.Device", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "UpdateDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDevice", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_DeleteDevice_async", + "title": "iot deleteDevice Sample", + "origin": "API_DEFINITION", + "description": " Deletes a device.", + "canonical": true, + "file": "device_manager.delete_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 52, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDevice", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.protobuf.Empty", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "DeleteDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDevice", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_ListDevices_async", + "title": "iot listDevices Sample", + "origin": "API_DEFINITION", + "description": " List devices in a device registry.", + "canonical": true, + "file": "device_manager.list_devices.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 87, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDevices", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDevices", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "device_num_ids", + "type": "TYPE_UINT64[]" + }, + { + "name": "device_ids", + "type": "TYPE_STRING[]" + }, + { + "name": "field_mask", + "type": ".google.protobuf.FieldMask" + }, + { + "name": "gateway_list_options", + "type": ".google.cloud.iot.v1.GatewayListOptions" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.ListDevicesResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "ListDevices", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDevices", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async", + "title": "iot modifyCloudToDeviceConfig Sample", + "origin": "API_DEFINITION", + "description": " Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.", + "canonical": true, + "file": "device_manager.modify_cloud_to_device_config.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ModifyCloudToDeviceConfig", + "fullName": "google.cloud.iot.v1.DeviceManager.ModifyCloudToDeviceConfig", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "version_to_update", + "type": "TYPE_INT64" + }, + { + "name": "binary_data", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.cloud.iot.v1.DeviceConfig", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "ModifyCloudToDeviceConfig", + "fullName": "google.cloud.iot.v1.DeviceManager.ModifyCloudToDeviceConfig", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async", + "title": "iot listDeviceConfigVersions Sample", + "origin": "API_DEFINITION", + "description": " Lists the last few versions of the device configuration in descending order (i.e.: newest first).", + "canonical": true, + "file": "device_manager.list_device_config_versions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDeviceConfigVersions", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceConfigVersions", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "num_versions", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.iot.v1.ListDeviceConfigVersionsResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "ListDeviceConfigVersions", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceConfigVersions", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceStates_async", + "title": "iot listDeviceStates Sample", + "origin": "API_DEFINITION", + "description": " Lists the last few versions of the device state in descending order (i.e.: newest first).", + "canonical": true, + "file": "device_manager.list_device_states.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListDeviceStates", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceStates", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "num_states", + "type": "TYPE_INT32" + } + ], + "resultType": ".google.cloud.iot.v1.ListDeviceStatesResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "ListDeviceStates", + "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceStates", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_SetIamPolicy_async", + "title": "iot setIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", + "canonical": true, + "file": "device_manager.set_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.iot.v1.DeviceManager.SetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "policy", + "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "SetIamPolicy", + "fullName": "google.cloud.iot.v1.DeviceManager.SetIamPolicy", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_GetIamPolicy_async", + "title": "iot getIamPolicy Sample", + "origin": "API_DEFINITION", + "description": " Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.", + "canonical": true, + "file": "device_manager.get_iam_policy.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.iot.v1.DeviceManager.GetIamPolicy", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "options", + "type": ".google.iam.v1.GetPolicyOptions" + } + ], + "resultType": ".google.iam.v1.Policy", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "GetIamPolicy", + "fullName": "google.cloud.iot.v1.DeviceManager.GetIamPolicy", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_TestIamPermissions_async", + "title": "iot testIamPermissions Sample", + "origin": "API_DEFINITION", + "description": " Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.", + "canonical": true, + "file": "device_manager.test_iam_permissions.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 59, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.iot.v1.DeviceManager.TestIamPermissions", + "async": true, + "parameters": [ + { + "name": "resource", + "type": "TYPE_STRING" + }, + { + "name": "permissions", + "type": "TYPE_STRING[]" + } + ], + "resultType": ".google.iam.v1.TestIamPermissionsResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "TestIamPermissions", + "fullName": "google.cloud.iot.v1.DeviceManager.TestIamPermissions", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async", + "title": "iot sendCommandToDevice Sample", + "origin": "API_DEFINITION", + "description": " Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.", + "canonical": true, + "file": "device_manager.send_command_to_device.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "SendCommandToDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.SendCommandToDevice", + "async": true, + "parameters": [ + { + "name": "name", + "type": "TYPE_STRING" + }, + { + "name": "binary_data", + "type": "TYPE_BYTES" + }, + { + "name": "subfolder", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.SendCommandToDeviceResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "SendCommandToDevice", + "fullName": "google.cloud.iot.v1.DeviceManager.SendCommandToDevice", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async", + "title": "iot bindDeviceToGateway Sample", + "origin": "API_DEFINITION", + "description": " Associates the device with the gateway.", + "canonical": true, + "file": "device_manager.bind_device_to_gateway.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BindDeviceToGateway", + "fullName": "google.cloud.iot.v1.DeviceManager.BindDeviceToGateway", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "gateway_id", + "type": "TYPE_STRING" + }, + { + "name": "device_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.BindDeviceToGatewayResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "BindDeviceToGateway", + "fullName": "google.cloud.iot.v1.DeviceManager.BindDeviceToGateway", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + }, + { + "regionTag": "cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async", + "title": "iot unbindDeviceFromGateway Sample", + "origin": "API_DEFINITION", + "description": " Deletes the association between the device and the gateway.", + "canonical": true, + "file": "device_manager.unbind_device_from_gateway.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 64, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "UnbindDeviceFromGateway", + "fullName": "google.cloud.iot.v1.DeviceManager.UnbindDeviceFromGateway", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "gateway_id", + "type": "TYPE_STRING" + }, + { + "name": "device_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.cloud.iot.v1.UnbindDeviceFromGatewayResponse", + "client": { + "shortName": "DeviceManagerClient", + "fullName": "google.cloud.iot.v1.DeviceManagerClient" + }, + "method": { + "shortName": "UnbindDeviceFromGateway", + "fullName": "google.cloud.iot.v1.DeviceManager.UnbindDeviceFromGateway", + "service": { + "shortName": "DeviceManager", + "fullName": "google.cloud.iot.v1.DeviceManager" + } + } + } + } + ] +} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..f4921a62 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v1 from './v1'; +const DeviceManagerClient = v1.DeviceManagerClient; +type DeviceManagerClient = v1.DeviceManagerClient; +export {v1, DeviceManagerClient}; +export default {v1, DeviceManagerClient}; +import * as protos from '../protos/protos'; +export {protos} diff --git a/owl-bot-staging/v1/src/v1/device_manager_client.ts b/owl-bot-staging/v1/src/v1/device_manager_client.ts new file mode 100644 index 00000000..fed11a36 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/device_manager_client.ts @@ -0,0 +1,2229 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +/* global window */ +import * as gax from 'google-gax'; +import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; + +import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +/** + * Client JSON configuration object, loaded from + * `src/v1/device_manager_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './device_manager_client_config.json'; + +const version = require('../../../package.json').version; + +/** + * Internet of Things (IoT) service. Securely connect and manage IoT devices. + * @class + * @memberof v1 + */ +export class DeviceManagerClient { + private _terminated = false; + private _opts: ClientOptions; + private _providedCustomServicePath: boolean; + private _gaxModule: typeof gax | typeof gax.fallback; + private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; + private _protos: {}; + private _defaults: {[method: string]: gax.CallSettings}; + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + pathTemplates: {[name: string]: gax.PathTemplate}; + deviceManagerStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DeviceManagerClient. + * + * @param {object} [options] - The configuration object. + * The options accepted by the constructor are described in detail + * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). + * The common options are: + * @param {object} [options.credentials] - Credentials object. + * @param {string} [options.credentials.client_email] + * @param {string} [options.credentials.private_key] + * @param {string} [options.email] - Account email address. Required when + * using a .pem or .p12 keyFilename. + * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or + * .p12 key downloaded from the Google Developers Console. If you provide + * a path to a JSON file, the projectId option below is not necessary. + * NOTE: .pem and .p12 require you to specify options.email as well. + * @param {number} [options.port] - The port on which to connect to + * the remote host. + * @param {string} [options.projectId] - The project ID from the Google + * Developer's Console, e.g. 'grape-spaceship-123'. We will also check + * the environment variable GCLOUD_PROJECT for your project ID. If your + * app is running in an environment which supports + * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, + * your project ID will be detected automatically. + * @param {string} [options.apiEndpoint] - The domain name of the + * API remote host. + * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. + * Follows the structure of {@link gapicConfig}. + * @param {boolean} [options.fallback] - Use HTTP fallback mode. + * In fallback mode, a special browser-compatible transport implementation is used + * instead of gRPC transport. In browser context (if the `window` object is defined) + * the fallback mode is enabled automatically; set `options.fallback` to `false` + * if you need to override this behavior. + */ + constructor(opts?: ClientOptions) { + // Ensure that options include all the required fields. + const staticMembers = this.constructor as typeof DeviceManagerClient; + const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const port = opts?.port || staticMembers.port; + const clientConfig = opts?.clientConfig ?? {}; + const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. + if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { + opts['scopes'] = staticMembers.scopes; + } + + // Choose either gRPC or proto-over-HTTP implementation of google-gax. + this._gaxModule = opts.fallback ? gax.fallback : gax; + + // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. + this._gaxGrpc = new this._gaxModule.GrpcClient(opts); + + // Save options to use in initialize() method. + this._opts = opts; + + // Save the auth object to the client, for use by other methods. + this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + + // Set useJWTAccessWithScope on the auth object. + this.auth.useJWTAccessWithScope = true; + + // Set defaultServicePath on the auth object. + this.auth.defaultServicePath = staticMembers.servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === staticMembers.servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [ + `gax/${this._gaxModule.version}`, + `gapic/${version}`, + ]; + if (typeof process !== 'undefined' && 'versions' in process) { + clientHeader.push(`gl-node/${process.versions.node}`); + } else { + clientHeader.push(`gl-web/${this._gaxModule.version}`); + } + if (!opts.fallback) { + clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); + } else if (opts.fallback === 'rest' ) { + clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); + } + if (opts.libName && opts.libVersion) { + clientHeader.push(`${opts.libName}/${opts.libVersion}`); + } + // Load the applicable protos. + this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); + + // This API contains "path templates"; forward-slash-separated + // identifiers to uniquely identify resources within the API. + // Create useful helper objects for these. + this.pathTemplates = { + devicePathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/registries/{registry}/devices/{device}' + ), + locationPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}' + ), + registryPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/registries/{registry}' + ), + }; + + // Some of the methods on this service return "paged" results, + // (e.g. 50 results at a time, with tokens to get subsequent + // pages). Denote the keys used for pagination and results. + this.descriptors.page = { + listDeviceRegistries: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deviceRegistries'), + listDevices: + new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'devices') + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.cloud.iot.v1.DeviceManager', gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + + // Set up a dictionary of "inner API calls"; the core implementation + // of calling the API is handled in `google-gax`, with this code + // merely providing the destination and request information. + this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; + } + + /** + * Initialize the client. + * Performs asynchronous operations (such as authentication) and prepares the client. + * This function will be called automatically when any class method is called for the + * first time, but if you need to initialize it before calling an actual method, + * feel free to call initialize() directly. + * + * You can await on this method if you want to make sure the client is initialized. + * + * @returns {Promise} A promise that resolves to an authenticated service stub. + */ + initialize() { + // If the client stub promise is already initialized, return immediately. + if (this.deviceManagerStub) { + return this.deviceManagerStub; + } + + // Put together the "service stub" for + // google.cloud.iot.v1.DeviceManager. + this.deviceManagerStub = this._gaxGrpc.createStub( + this._opts.fallback ? + (this._protos as protobuf.Root).lookupService('google.cloud.iot.v1.DeviceManager') : + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.cloud.iot.v1.DeviceManager, + this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + + // Iterate over each of the methods that the service provides + // and create an API call method for each. + const deviceManagerStubMethods = + ['createDeviceRegistry', 'getDeviceRegistry', 'updateDeviceRegistry', 'deleteDeviceRegistry', 'listDeviceRegistries', 'createDevice', 'getDevice', 'updateDevice', 'deleteDevice', 'listDevices', 'modifyCloudToDeviceConfig', 'listDeviceConfigVersions', 'listDeviceStates', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'sendCommandToDevice', 'bindDeviceToGateway', 'unbindDeviceFromGateway']; + for (const methodName of deviceManagerStubMethods) { + const callPromise = this.deviceManagerStub.then( + stub => (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error|null|undefined) => () => { + throw err; + }); + + const descriptor = + this.descriptors.page[methodName] || + undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.deviceManagerStub; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + return 'cloudiot.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + return 'cloudiot.googleapis.com'; + } + + /** + * The port for this API service. + * @returns {number} The default port for this service. + */ + static get port() { + return 443; + } + + /** + * The scopes needed to make gRPC calls for every method defined + * in this service. + * @returns {string[]} List of default scopes. + */ + static get scopes() { + return [ + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloudiot' + ]; + } + + getProjectId(): Promise; + getProjectId(callback: Callback): void; + /** + * Return the project ID used by this class. + * @returns {Promise} A promise that resolves to string containing the project ID. + */ + getProjectId(callback?: Callback): + Promise|void { + if (callback) { + this.auth.getProjectId(callback); + return; + } + return this.auth.getProjectId(); + } + + // ------------------- + // -- Service calls -- + // ------------------- +/** + * Creates a device registry that contains devices. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region where this device registry must be created. + * For example, `projects/example-project/locations/us-central1`. + * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry + * Required. The device registry. The field `name` must be empty. The server will + * generate that field from the device registry `id` provided and the + * `parent` field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.create_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async + */ + createDeviceRegistry( + request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined + ]>; + createDeviceRegistry( + request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + createDeviceRegistry( + request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + createDeviceRegistry( + request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createDeviceRegistry(request, options, callback); + } +/** + * Gets a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.get_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async + */ + getDeviceRegistry( + request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined + ]>; + getDeviceRegistry( + request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + getDeviceRegistry( + request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + getDeviceRegistry( + request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getDeviceRegistry(request, options, callback); + } +/** + * Updates a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry + * Required. The new values for the device registry. The `id` field must be empty, and + * the `name` field must indicate the path of the resource. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Only updates the `device_registry` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `event_notification_config`, `http_config`, + * `mqtt_config`, and `state_notification_config`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.update_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async + */ + updateDeviceRegistry( + request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined + ]>; + updateDeviceRegistry( + request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + updateDeviceRegistry( + request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + updateDeviceRegistry( + request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry, + protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'device_registry.name': request.deviceRegistry!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateDeviceRegistry(request, options, callback); + } +/** + * Deletes a device registry configuration. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.delete_device_registry.js + * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async + */ + deleteDeviceRegistry( + request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined + ]>; + deleteDeviceRegistry( + request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + deleteDeviceRegistry( + request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, + {}|null|undefined>): void; + deleteDeviceRegistry( + request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteDeviceRegistry(request, options, callback); + } +/** + * Creates a device in a device registry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the device registry where this device should be created. + * For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {google.cloud.iot.v1.Device} request.device + * Required. The device registration details. The field `name` must be empty. The server + * generates `name` from the device registry `id` and the + * `parent` field. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.create_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_CreateDevice_async + */ + createDevice( + request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined + ]>; + createDevice( + request: protos.google.cloud.iot.v1.ICreateDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, + {}|null|undefined>): void; + createDevice( + request: protos.google.cloud.iot.v1.ICreateDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, + {}|null|undefined>): void; + createDevice( + request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.createDevice(request, options, callback); + } +/** + * Gets details about a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. If the + * field mask is unset or empty, all fields are returned. Fields have to be + * provided in snake_case format, for example: `last_heartbeat_time`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.get_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_GetDevice_async + */ + getDevice( + request?: protos.google.cloud.iot.v1.IGetDeviceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined + ]>; + getDevice( + request: protos.google.cloud.iot.v1.IGetDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, + {}|null|undefined>): void; + getDevice( + request: protos.google.cloud.iot.v1.IGetDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, + {}|null|undefined>): void; + getDevice( + request?: protos.google.cloud.iot.v1.IGetDeviceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.getDevice(request, options, callback); + } +/** + * Updates a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.cloud.iot.v1.Device} request.device + * Required. The new values for the device. The `id` and `num_id` fields must + * be empty, and the field `name` must specify the name path. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. Only updates the `device` fields indicated by this mask. + * The field mask must not be empty, and it must not contain fields that + * are immutable or only set by the server. + * Mutable top-level fields: `credentials`, `blocked`, and `metadata` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.update_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDevice_async + */ + updateDevice( + request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined + ]>; + updateDevice( + request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, + {}|null|undefined>): void; + updateDevice( + request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, + {}|null|undefined>): void; + updateDevice( + request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDevice, + protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'device.name': request.device!.name || '', + }); + this.initialize(); + return this.innerApiCalls.updateDevice(request, options, callback); + } +/** + * Deletes a device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.delete_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDevice_async + */ + deleteDevice( + request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + options?: CallOptions): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined + ]>; + deleteDevice( + request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, + {}|null|undefined>): void; + deleteDevice( + request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, + {}|null|undefined>): void; + deleteDevice( + request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.protobuf.IEmpty, + protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.deleteDevice(request, options, callback); + } +/** + * Modifies the configuration for the device, which is eventually sent from + * the Cloud IoT Core servers. Returns the modified configuration version and + * its metadata. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.versionToUpdate + * The version number to update. If this value is zero, it will not check the + * version number of the server and will always update the current version; + * otherwise, this update will fail if the version number found on the server + * does not match this version number. This is used to support multiple + * simultaneous updates without losing data. + * @param {Buffer} request.binaryData + * Required. The configuration data for the device. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [DeviceConfig]{@link google.cloud.iot.v1.DeviceConfig}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.modify_cloud_to_device_config.js + * region_tag:cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async + */ + modifyCloudToDeviceConfig( + request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined + ]>; + modifyCloudToDeviceConfig( + request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, + {}|null|undefined>): void; + modifyCloudToDeviceConfig( + request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + callback: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, + {}|null|undefined>): void; + modifyCloudToDeviceConfig( + request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IDeviceConfig, + protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.modifyCloudToDeviceConfig(request, options, callback); + } +/** + * Lists the last few versions of the device configuration in descending + * order (i.e.: newest first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.numVersions + * The number of versions to list. Versions are listed in decreasing order of + * the version number. The maximum number of versions retained is 10. If this + * value is zero, it will return all the versions available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListDeviceConfigVersionsResponse]{@link google.cloud.iot.v1.ListDeviceConfigVersionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_device_config_versions.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async + */ + listDeviceConfigVersions( + request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined + ]>; + listDeviceConfigVersions( + request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, + {}|null|undefined>): void; + listDeviceConfigVersions( + request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, + {}|null|undefined>): void; + listDeviceConfigVersions( + request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, + protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.listDeviceConfigVersions(request, options, callback); + } +/** + * Lists the last few versions of the device state in descending order (i.e.: + * newest first). + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {number} request.numStates + * The number of states to list. States are listed in descending order of + * update time. The maximum number of states retained is 10. If this + * value is zero, it will return all the states available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListDeviceStatesResponse]{@link google.cloud.iot.v1.ListDeviceStatesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_device_states.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceStates_async + */ + listDeviceStates( + request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined + ]>; + listDeviceStates( + request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, + {}|null|undefined>): void; + listDeviceStates( + request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + callback: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, + {}|null|undefined>): void; + listDeviceStates( + request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IListDeviceStatesResponse, + protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.listDeviceStates(request, options, callback); + } +/** + * Sets the access control policy on the specified resource. Replaces any + * existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.set_iam_policy.js + * region_tag:cloudiot_v1_generated_DeviceManager_SetIamPolicy_async + */ + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + setIamPolicy( + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.setIamPolicy(request, options, callback); + } +/** + * Gets the access control policy for a resource. + * Returns an empty policy if the resource exists and does not have a policy + * set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.get_iam_policy.js + * region_tag:cloudiot_v1_generated_DeviceManager_GetIamPolicy_async + */ + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): void; + getIamPolicy( + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.getIamPolicy(request, options, callback); + } +/** + * Returns permissions that a caller has on the specified resource. + * If the resource does not exist, this will return an empty set of + * permissions, not a NOT_FOUND error. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.test_iam_permissions.js + * region_tag:cloudiot_v1_generated_DeviceManager_TestIamPermissions_async + */ + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): void; + testIamPermissions( + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'resource': request.resource || '', + }); + this.initialize(); + return this.innerApiCalls.testIamPermissions(request, options, callback); + } +/** + * Sends a command to the specified device. In order for a device to be able + * to receive commands, it must: + * 1) be connected to Cloud IoT Core using the MQTT protocol, and + * 2) be subscribed to the group of MQTT topics specified by + * /devices/{device-id}/commands/#. This subscription will receive commands + * at the top-level topic /devices/{device-id}/commands as well as commands + * for subfolders, like /devices/{device-id}/commands/subfolder. + * Note that subscribing to specific subfolders is not supported. + * If the command could not be delivered to the device, this method will + * return an error; in particular, if the device is not subscribed, this + * method will return FAILED_PRECONDITION. Otherwise, this method will + * return OK. If the subscription is QoS 1, at least once delivery will be + * guaranteed; for QoS 0, no acknowledgment will be expected from the device. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The name of the device. For example, + * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or + * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. + * @param {Buffer} request.binaryData + * Required. The command data to send to the device. + * @param {string} request.subfolder + * 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. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SendCommandToDeviceResponse]{@link google.cloud.iot.v1.SendCommandToDeviceResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.send_command_to_device.js + * region_tag:cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async + */ + sendCommandToDevice( + request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined + ]>; + sendCommandToDevice( + request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, + {}|null|undefined>): void; + sendCommandToDevice( + request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + callback: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, + {}|null|undefined>): void; + sendCommandToDevice( + request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, + protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + this.initialize(); + return this.innerApiCalls.sendCommandToDevice(request, options, callback); + } +/** + * Associates the device with the gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {string} request.gatewayId + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + * @param {string} request.deviceId + * Required. The device to associate with the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [BindDeviceToGatewayResponse]{@link google.cloud.iot.v1.BindDeviceToGatewayResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.bind_device_to_gateway.js + * region_tag:cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async + */ + bindDeviceToGateway( + request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined + ]>; + bindDeviceToGateway( + request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, + {}|null|undefined>): void; + bindDeviceToGateway( + request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + callback: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, + {}|null|undefined>): void; + bindDeviceToGateway( + request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, + protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.bindDeviceToGateway(request, options, callback); + } +/** + * Deletes the association between the device and the gateway. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the registry. For example, + * `projects/example-project/locations/us-central1/registries/my-registry`. + * @param {string} request.gatewayId + * Required. The value of `gateway_id` can be either the device numeric ID or the + * user-defined device identifier. + * @param {string} request.deviceId + * Required. The device to disassociate from the specified gateway. The value of + * `device_id` can be either the device numeric ID or the user-defined device + * identifier. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [UnbindDeviceFromGatewayResponse]{@link google.cloud.iot.v1.UnbindDeviceFromGatewayResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.unbind_device_from_gateway.js + * region_tag:cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async + */ + unbindDeviceFromGateway( + request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined + ]>; + unbindDeviceFromGateway( + request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, + {}|null|undefined>): void; + unbindDeviceFromGateway( + request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + callback: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, + {}|null|undefined>): void; + unbindDeviceFromGateway( + request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, + optionsOrCallback?: CallOptions|Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, + {}|null|undefined>, + callback?: Callback< + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, + {}|null|undefined>): + Promise<[ + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, + protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.unbindDeviceFromGateway(request, options, callback); + } + + /** + * Lists device registries. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDeviceRegistriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDeviceRegistries( + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry[], + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + ]>; + listDeviceRegistries( + request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, + protos.google.cloud.iot.v1.IDeviceRegistry>): void; + listDeviceRegistries( + request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, + protos.google.cloud.iot.v1.IDeviceRegistry>): void; + listDeviceRegistries( + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, + protos.google.cloud.iot.v1.IDeviceRegistry>, + callback?: PaginationCallback< + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, + protos.google.cloud.iot.v1.IDeviceRegistry>): + Promise<[ + protos.google.cloud.iot.v1.IDeviceRegistry[], + protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, + protos.google.cloud.iot.v1.IListDeviceRegistriesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listDeviceRegistries(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDeviceRegistriesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDeviceRegistriesStream( + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDeviceRegistries']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDeviceRegistries.createStream( + this.innerApiCalls.listDeviceRegistries as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDeviceRegistries`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project and cloud region path. For example, + * `projects/example-project/locations/us-central1`. + * @param {number} request.pageSize + * The maximum number of registries to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDeviceRegistriesResponse`; indicates + * that this is a continuation of a prior `ListDeviceRegistries` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_device_registries.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async + */ + listDeviceRegistriesAsync( + request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDeviceRegistries']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDeviceRegistries.asyncIterate( + this.innerApiCalls['listDeviceRegistries'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** + * List devices in a device registry. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Device]{@link google.cloud.iot.v1.Device}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listDevicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDevices( + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + options?: CallOptions): + Promise<[ + protos.google.cloud.iot.v1.IDevice[], + protos.google.cloud.iot.v1.IListDevicesRequest|null, + protos.google.cloud.iot.v1.IListDevicesResponse + ]>; + listDevices( + request: protos.google.cloud.iot.v1.IListDevicesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, + protos.google.cloud.iot.v1.IDevice>): void; + listDevices( + request: protos.google.cloud.iot.v1.IListDevicesRequest, + callback: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, + protos.google.cloud.iot.v1.IDevice>): void; + listDevices( + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + optionsOrCallback?: CallOptions|PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, + protos.google.cloud.iot.v1.IDevice>, + callback?: PaginationCallback< + protos.google.cloud.iot.v1.IListDevicesRequest, + protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, + protos.google.cloud.iot.v1.IDevice>): + Promise<[ + protos.google.cloud.iot.v1.IDevice[], + protos.google.cloud.iot.v1.IListDevicesRequest|null, + protos.google.cloud.iot.v1.IListDevicesResponse + ]>|void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } + else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + this.initialize(); + return this.innerApiCalls.listDevices(request, options, callback); + } + +/** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Device]{@link google.cloud.iot.v1.Device} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listDevicesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ + listDevicesStream( + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + options?: CallOptions): + Transform{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDevices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDevices.createStream( + this.innerApiCalls.listDevices as gax.GaxCall, + request, + callSettings + ); + } + +/** + * Equivalent to `listDevices`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The device registry path. Required. For example, + * `projects/my-project/locations/us-central1/registries/my-registry`. + * @param {number[]} request.deviceNumIds + * A list of device numeric IDs. If empty, this field is ignored. Maximum + * IDs: 10,000. + * @param {string[]} request.deviceIds + * A list of device string IDs. For example, `['device0', 'device12']`. + * If empty, this field is ignored. Maximum IDs: 10,000 + * @param {google.protobuf.FieldMask} request.fieldMask + * The fields of the `Device` resource to be returned in the response. The + * fields `id` and `num_id` are always returned, along with any + * other fields specified in snake_case format, for example: + * `last_heartbeat_time`. + * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions + * Options related to gateways. + * @param {number} request.pageSize + * The maximum number of devices to return in the response. If this value + * is zero, the service will select a default size. A call may return fewer + * objects than requested. A non-empty `next_page_token` in the response + * indicates that more data is available. + * @param {string} request.pageToken + * The value returned by the last `ListDevicesResponse`; indicates + * that this is a continuation of a prior `ListDevices` call and + * the system should return the next page of data. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Device]{@link google.cloud.iot.v1.Device}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v1/device_manager.list_devices.js + * region_tag:cloudiot_v1_generated_DeviceManager_ListDevices_async + */ + listDevicesAsync( + request?: protos.google.cloud.iot.v1.IListDevicesRequest, + options?: CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + const defaultCallSettings = this._defaults['listDevices']; + const callSettings = defaultCallSettings.merge(options); + this.initialize(); + return this.descriptors.page.listDevices.asyncIterate( + this.innerApiCalls['listDevices'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + // -------------------- + // -- Path templates -- + // -------------------- + + /** + * Return a fully-qualified device resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} registry + * @param {string} device + * @returns {string} Resource name string. + */ + devicePath(project:string,location:string,registry:string,device:string) { + return this.pathTemplates.devicePathTemplate.render({ + project: project, + location: location, + registry: registry, + device: device, + }); + } + + /** + * Parse the project from Device resource. + * + * @param {string} deviceName + * A fully-qualified path representing Device resource. + * @returns {string} A string representing the project. + */ + matchProjectFromDeviceName(deviceName: string) { + return this.pathTemplates.devicePathTemplate.match(deviceName).project; + } + + /** + * Parse the location from Device resource. + * + * @param {string} deviceName + * A fully-qualified path representing Device resource. + * @returns {string} A string representing the location. + */ + matchLocationFromDeviceName(deviceName: string) { + return this.pathTemplates.devicePathTemplate.match(deviceName).location; + } + + /** + * Parse the registry from Device resource. + * + * @param {string} deviceName + * A fully-qualified path representing Device resource. + * @returns {string} A string representing the registry. + */ + matchRegistryFromDeviceName(deviceName: string) { + return this.pathTemplates.devicePathTemplate.match(deviceName).registry; + } + + /** + * Parse the device from Device resource. + * + * @param {string} deviceName + * A fully-qualified path representing Device resource. + * @returns {string} A string representing the device. + */ + matchDeviceFromDeviceName(deviceName: string) { + return this.pathTemplates.devicePathTemplate.match(deviceName).device; + } + + /** + * Return a fully-qualified location resource name string. + * + * @param {string} project + * @param {string} location + * @returns {string} Resource name string. + */ + locationPath(project:string,location:string) { + return this.pathTemplates.locationPathTemplate.render({ + project: project, + location: location, + }); + } + + /** + * Parse the project from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the project. + */ + matchProjectFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).project; + } + + /** + * Parse the location from Location resource. + * + * @param {string} locationName + * A fully-qualified path representing Location resource. + * @returns {string} A string representing the location. + */ + matchLocationFromLocationName(locationName: string) { + return this.pathTemplates.locationPathTemplate.match(locationName).location; + } + + /** + * Return a fully-qualified registry resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} registry + * @returns {string} Resource name string. + */ + registryPath(project:string,location:string,registry:string) { + return this.pathTemplates.registryPathTemplate.render({ + project: project, + location: location, + registry: registry, + }); + } + + /** + * Parse the project from Registry resource. + * + * @param {string} registryName + * A fully-qualified path representing Registry resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRegistryName(registryName: string) { + return this.pathTemplates.registryPathTemplate.match(registryName).project; + } + + /** + * Parse the location from Registry resource. + * + * @param {string} registryName + * A fully-qualified path representing Registry resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRegistryName(registryName: string) { + return this.pathTemplates.registryPathTemplate.match(registryName).location; + } + + /** + * Parse the registry from Registry resource. + * + * @param {string} registryName + * A fully-qualified path representing Registry resource. + * @returns {string} A string representing the registry. + */ + matchRegistryFromRegistryName(registryName: string) { + return this.pathTemplates.registryPathTemplate.match(registryName).registry; + } + + /** + * Terminate the gRPC channel and close the client. + * + * The client will no longer be usable and all future behavior is undefined. + * @returns {Promise} A promise that resolves when the client is closed. + */ + close(): Promise { + if (this.deviceManagerStub && !this._terminated) { + return this.deviceManagerStub.then(stub => { + this._terminated = true; + stub.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/owl-bot-staging/v1/src/v1/device_manager_client_config.json b/owl-bot-staging/v1/src/v1/device_manager_client_config.json new file mode 100644 index 00000000..5ded0fd1 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/device_manager_client_config.json @@ -0,0 +1,135 @@ +{ + "interfaces": { + "google.cloud.iot.v1.DeviceManager": { + "retry_codes": { + "non_idempotent": [], + "idempotent": [ + "DEADLINE_EXCEEDED", + "UNAVAILABLE" + ], + "deadline_exceeded_resource_exhausted_unavailable": [ + "DEADLINE_EXCEEDED", + "RESOURCE_EXHAUSTED", + "UNAVAILABLE" + ] + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + }, + "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { + "initial_retry_delay_millis": 1000, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 60000, + "rpc_timeout_multiplier": 1, + "max_rpc_timeout_millis": 60000, + "total_timeout_millis": 600000 + } + }, + "methods": { + "CreateDeviceRegistry": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDeviceRegistry": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateDeviceRegistry": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteDeviceRegistry": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDeviceRegistries": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "CreateDevice": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetDevice": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "UpdateDevice": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteDevice": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDevices": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ModifyCloudToDeviceConfig": { + "timeout_millis": 120000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "ListDeviceConfigVersions": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListDeviceStates": { + "timeout_millis": 120000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "SetIamPolicy": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIamPolicy": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "TestIamPermissions": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "SendCommandToDevice": { + "timeout_millis": 120000, + "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", + "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" + }, + "BindDeviceToGateway": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "UnbindDeviceFromGateway": { + "timeout_millis": 120000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/device_manager_proto_list.json b/owl-bot-staging/v1/src/v1/device_manager_proto_list.json new file mode 100644 index 00000000..95cf5597 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/device_manager_proto_list.json @@ -0,0 +1,4 @@ +[ + "../../protos/google/cloud/iot/v1/device_manager.proto", + "../../protos/google/cloud/iot/v1/resources.proto" +] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json new file mode 100644 index 00000000..28ab3c5d --- /dev/null +++ b/owl-bot-staging/v1/src/v1/gapic_metadata.json @@ -0,0 +1,221 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.cloud.iot.v1", + "libraryPackage": "@google-cloud/iot", + "services": { + "DeviceManager": { + "clients": { + "grpc": { + "libraryClient": "DeviceManagerClient", + "rpcs": { + "CreateDeviceRegistry": { + "methods": [ + "createDeviceRegistry" + ] + }, + "GetDeviceRegistry": { + "methods": [ + "getDeviceRegistry" + ] + }, + "UpdateDeviceRegistry": { + "methods": [ + "updateDeviceRegistry" + ] + }, + "DeleteDeviceRegistry": { + "methods": [ + "deleteDeviceRegistry" + ] + }, + "CreateDevice": { + "methods": [ + "createDevice" + ] + }, + "GetDevice": { + "methods": [ + "getDevice" + ] + }, + "UpdateDevice": { + "methods": [ + "updateDevice" + ] + }, + "DeleteDevice": { + "methods": [ + "deleteDevice" + ] + }, + "ModifyCloudToDeviceConfig": { + "methods": [ + "modifyCloudToDeviceConfig" + ] + }, + "ListDeviceConfigVersions": { + "methods": [ + "listDeviceConfigVersions" + ] + }, + "ListDeviceStates": { + "methods": [ + "listDeviceStates" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SendCommandToDevice": { + "methods": [ + "sendCommandToDevice" + ] + }, + "BindDeviceToGateway": { + "methods": [ + "bindDeviceToGateway" + ] + }, + "UnbindDeviceFromGateway": { + "methods": [ + "unbindDeviceFromGateway" + ] + }, + "ListDeviceRegistries": { + "methods": [ + "listDeviceRegistries", + "listDeviceRegistriesStream", + "listDeviceRegistriesAsync" + ] + }, + "ListDevices": { + "methods": [ + "listDevices", + "listDevicesStream", + "listDevicesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DeviceManagerClient", + "rpcs": { + "CreateDeviceRegistry": { + "methods": [ + "createDeviceRegistry" + ] + }, + "GetDeviceRegistry": { + "methods": [ + "getDeviceRegistry" + ] + }, + "UpdateDeviceRegistry": { + "methods": [ + "updateDeviceRegistry" + ] + }, + "DeleteDeviceRegistry": { + "methods": [ + "deleteDeviceRegistry" + ] + }, + "CreateDevice": { + "methods": [ + "createDevice" + ] + }, + "GetDevice": { + "methods": [ + "getDevice" + ] + }, + "UpdateDevice": { + "methods": [ + "updateDevice" + ] + }, + "DeleteDevice": { + "methods": [ + "deleteDevice" + ] + }, + "ModifyCloudToDeviceConfig": { + "methods": [ + "modifyCloudToDeviceConfig" + ] + }, + "ListDeviceConfigVersions": { + "methods": [ + "listDeviceConfigVersions" + ] + }, + "ListDeviceStates": { + "methods": [ + "listDeviceStates" + ] + }, + "SetIamPolicy": { + "methods": [ + "setIamPolicy" + ] + }, + "GetIamPolicy": { + "methods": [ + "getIamPolicy" + ] + }, + "TestIamPermissions": { + "methods": [ + "testIamPermissions" + ] + }, + "SendCommandToDevice": { + "methods": [ + "sendCommandToDevice" + ] + }, + "BindDeviceToGateway": { + "methods": [ + "bindDeviceToGateway" + ] + }, + "UnbindDeviceFromGateway": { + "methods": [ + "unbindDeviceFromGateway" + ] + }, + "ListDeviceRegistries": { + "methods": [ + "listDeviceRegistries", + "listDeviceRegistriesStream", + "listDeviceRegistriesAsync" + ] + }, + "ListDevices": { + "methods": [ + "listDevices", + "listDevicesStream", + "listDevicesAsync" + ] + } + } + } + } + } + } +} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts new file mode 100644 index 00000000..49977b40 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +export {DeviceManagerClient} from './device_manager_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000..f71018b9 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const iot = require('@google-cloud/iot'); + +function main() { + const deviceManagerClient = new iot.DeviceManagerClient(); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000..7b3c0747 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {DeviceManagerClient} from '@google-cloud/iot'; + +// check that the client class type name can be used +function doStuffWithDeviceManagerClient(client: DeviceManagerClient) { + client.close(); +} + +function main() { + // check that the client instance can be created + const deviceManagerClient = new DeviceManagerClient(); + doStuffWithDeviceManagerClient(deviceManagerClient); +} + +main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts new file mode 100644 index 00000000..8ec45222 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('📦 pack-n-play test', () => { + + it('TypeScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'TypeScript user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); + }); + + it('JavaScript code', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), + sample: { + description: 'JavaScript user can use the library', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); + }); + +}); diff --git a/owl-bot-staging/v1/test/gapic_device_manager_v1.ts b/owl-bot-staging/v1/test/gapic_device_manager_v1.ts new file mode 100644 index 00000000..f20565b8 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_device_manager_v1.ts @@ -0,0 +1,2426 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as protos from '../protos/protos'; +import * as assert from 'assert'; +import * as sinon from 'sinon'; +import {SinonStub} from 'sinon'; +import { describe, it } from 'mocha'; +import * as devicemanagerModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf} from 'google-gax'; + +function generateSampleMessage(instance: T) { + const filledObject = (instance.constructor as typeof protobuf.Message) + .toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; +} + +function stubSimpleCall(response?: ResponseType, error?: Error) { + return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); +} + +function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { + return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +} + +function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); + } + } + const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { mockStream.write({}); }); + } + setImmediate(() => { mockStream.end(); }); + } else { + setImmediate(() => { mockStream.write({}); }); + setImmediate(() => { mockStream.end(); }); + } + return sinon.stub().returns(mockStream); +} + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + +describe('v1.DeviceManagerClient', () => { + it('has servicePath', () => { + const servicePath = devicemanagerModule.v1.DeviceManagerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = devicemanagerModule.v1.DeviceManagerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = devicemanagerModule.v1.DeviceManagerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new devicemanagerModule.v1.DeviceManagerClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.deviceManagerStub, undefined); + await client.initialize(); + assert(client.deviceManagerStub); + }); + + it('has close method for the initialized client', done => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.deviceManagerStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.deviceManagerStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error|null, projectId?: string|null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createDeviceRegistry', () => { + it('invokes createDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.createDeviceRegistry = stubSimpleCall(expectedResponse); + const [response] = await client.createDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.createDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDeviceRegistry( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDeviceRegistry = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDeviceRegistry(request), expectedError); + assert((client.innerApiCalls.createDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDeviceRegistry(request), expectedError); + }); + }); + + describe('getDeviceRegistry', () => { + it('invokes getDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.getDeviceRegistry = stubSimpleCall(expectedResponse); + const [response] = await client.getDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.getDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDeviceRegistry( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDeviceRegistry = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDeviceRegistry(request), expectedError); + assert((client.innerApiCalls.getDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDeviceRegistry(request), expectedError); + }); + }); + + describe('updateDeviceRegistry', () => { + it('invokes updateDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); + request.deviceRegistry = {}; + request.deviceRegistry.name = ''; + const expectedHeaderRequestParams = "device_registry.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(expectedResponse); + const [response] = await client.updateDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); + request.deviceRegistry = {}; + request.deviceRegistry.name = ''; + const expectedHeaderRequestParams = "device_registry.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); + client.innerApiCalls.updateDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDeviceRegistry( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); + request.deviceRegistry = {}; + request.deviceRegistry.name = ''; + const expectedHeaderRequestParams = "device_registry.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDeviceRegistry(request), expectedError); + assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); + request.deviceRegistry = {}; + request.deviceRegistry.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDeviceRegistry(request), expectedError); + }); + }); + + describe('deleteDeviceRegistry', () => { + it('invokes deleteDeviceRegistry without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDeviceRegistry(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDeviceRegistry without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDeviceRegistry( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteDeviceRegistry with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDeviceRegistry(request), expectedError); + assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDeviceRegistry with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDeviceRegistry(request), expectedError); + }); + }); + + describe('createDevice', () => { + it('invokes createDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.createDevice = stubSimpleCall(expectedResponse); + const [response] = await client.createDevice(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.createDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createDevice( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.createDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes createDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.createDevice(request), expectedError); + assert((client.innerApiCalls.createDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes createDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createDevice(request), expectedError); + }); + }); + + describe('getDevice', () => { + it('invokes getDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.getDevice = stubSimpleCall(expectedResponse); + const [response] = await client.getDevice(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.getDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getDevice( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getDevice(request), expectedError); + assert((client.innerApiCalls.getDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getDevice(request), expectedError); + }); + }); + + describe('updateDevice', () => { + it('invokes updateDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); + request.device = {}; + request.device.name = ''; + const expectedHeaderRequestParams = "device.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.updateDevice = stubSimpleCall(expectedResponse); + const [response] = await client.updateDevice(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); + request.device = {}; + request.device.name = ''; + const expectedHeaderRequestParams = "device.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); + client.innerApiCalls.updateDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateDevice( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.updateDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes updateDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); + request.device = {}; + request.device.name = ''; + const expectedHeaderRequestParams = "device.name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.updateDevice(request), expectedError); + assert((client.innerApiCalls.updateDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes updateDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); + request.device = {}; + request.device.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateDevice(request), expectedError); + }); + }); + + describe('deleteDevice', () => { + it('invokes deleteDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDevice = stubSimpleCall(expectedResponse); + const [response] = await client.deleteDevice(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); + client.innerApiCalls.deleteDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteDevice( + request, + (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.deleteDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes deleteDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.deleteDevice(request), expectedError); + assert((client.innerApiCalls.deleteDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes deleteDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteDevice(request), expectedError); + }); + }); + + describe('modifyCloudToDeviceConfig', () => { + it('invokes modifyCloudToDeviceConfig without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceConfig()); + client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(expectedResponse); + const [response] = await client.modifyCloudToDeviceConfig(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes modifyCloudToDeviceConfig without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceConfig()); + client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.modifyCloudToDeviceConfig( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceConfig|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes modifyCloudToDeviceConfig with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); + assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes modifyCloudToDeviceConfig with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); + }); + }); + + describe('listDeviceConfigVersions', () => { + it('invokes listDeviceConfigVersions without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse()); + client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceConfigVersions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceConfigVersions without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse()); + client.innerApiCalls.listDeviceConfigVersions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceConfigVersions( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDeviceConfigVersions with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDeviceConfigVersions(request), expectedError); + assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceConfigVersions with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listDeviceConfigVersions(request), expectedError); + }); + }); + + describe('listDeviceStates', () => { + it('invokes listDeviceStates without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesResponse()); + client.innerApiCalls.listDeviceStates = stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceStates(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceStates as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceStates without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesResponse()); + client.innerApiCalls.listDeviceStates = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceStates( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceStatesResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceStates as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDeviceStates with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceStates = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDeviceStates(request), expectedError); + assert((client.innerApiCalls.listDeviceStates as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceStates with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listDeviceStates(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes setIamPolicy with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert((client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); + client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes getIamPolicy with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert((client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); + client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes testIamPermissions with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedHeaderRequestParams = "resource="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert((client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('sendCommandToDevice', () => { + it('invokes sendCommandToDevice without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceResponse()); + client.innerApiCalls.sendCommandToDevice = stubSimpleCall(expectedResponse); + const [response] = await client.sendCommandToDevice(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.sendCommandToDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes sendCommandToDevice without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceResponse()); + client.innerApiCalls.sendCommandToDevice = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.sendCommandToDevice( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.ISendCommandToDeviceResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.sendCommandToDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes sendCommandToDevice with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.sendCommandToDevice = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.sendCommandToDevice(request), expectedError); + assert((client.innerApiCalls.sendCommandToDevice as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes sendCommandToDevice with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.sendCommandToDevice(request), expectedError); + }); + }); + + describe('bindDeviceToGateway', () => { + it('invokes bindDeviceToGateway without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse()); + client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(expectedResponse); + const [response] = await client.bindDeviceToGateway(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes bindDeviceToGateway without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse()); + client.innerApiCalls.bindDeviceToGateway = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.bindDeviceToGateway( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes bindDeviceToGateway with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.bindDeviceToGateway(request), expectedError); + assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes bindDeviceToGateway with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.bindDeviceToGateway(request), expectedError); + }); + }); + + describe('unbindDeviceFromGateway', () => { + it('invokes unbindDeviceFromGateway without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse()); + client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(expectedResponse); + const [response] = await client.unbindDeviceFromGateway(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes unbindDeviceFromGateway without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse()); + client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.unbindDeviceFromGateway( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes unbindDeviceFromGateway with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); + assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes unbindDeviceFromGateway with closed client', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); + }); + }); + + describe('listDeviceRegistries', () => { + it('invokes listDeviceRegistries without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.innerApiCalls.listDeviceRegistries = stubSimpleCall(expectedResponse); + const [response] = await client.listDeviceRegistries(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceRegistries as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceRegistries without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.innerApiCalls.listDeviceRegistries = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDeviceRegistries( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDeviceRegistries as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDeviceRegistries with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDeviceRegistries = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDeviceRegistries(request), expectedError); + assert((client.innerApiCalls.listDeviceRegistries as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDeviceRegistriesStream without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDeviceRegistriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); + assert.strictEqual( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listDeviceRegistriesStream with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDeviceRegistriesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); + assert.strictEqual( + (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDeviceRegistries without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), + ]; + client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; + const iterable = client.listDeviceRegistriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDeviceRegistries with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDeviceRegistriesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listDevices', () => { + it('invokes listDevices without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.innerApiCalls.listDevices = stubSimpleCall(expectedResponse); + const [response] = await client.listDevices(request); + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDevices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDevices without error using callback', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.innerApiCalls.listDevices = stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listDevices( + request, + (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice[]|null) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.innerApiCalls.listDevices as SinonStub) + .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); + }); + + it('invokes listDevices with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listDevices = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.listDevices(request), expectedError); + assert((client.innerApiCalls.listDevices as SinonStub) + .getCall(0).calledWith(request, expectedOptions, undefined)); + }); + + it('invokes listDevicesStream without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.descriptors.page.listDevices.createStream = stubPageStreamingCall(expectedResponse); + const stream = client.listDevicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.Device[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert((client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); + assert.strictEqual( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listDevicesStream with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedError = new Error('expected'); + client.descriptors.page.listDevices.createStream = stubPageStreamingCall(undefined, expectedError); + const stream = client.listDevicesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.cloud.iot.v1.Device[] = []; + stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert((client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); + assert.strictEqual( + (client.descriptors.page.listDevices.createStream as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDevices without error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent="; + const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + generateSampleMessage(new protos.google.cloud.iot.v1.Device()), + ]; + client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.iot.v1.IDevice[] = []; + const iterable = client.listDevicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDevices with error', async () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDevicesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.cloud.iot.v1.IDevice[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDevices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('Path templates', () => { + + describe('device', () => { + const fakePath = "/rendered/path/device"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + registry: "registryValue", + device: "deviceValue", + }; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.devicePathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.devicePathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('devicePath', () => { + const result = client.devicePath("projectValue", "locationValue", "registryValue", "deviceValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.devicePathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromDeviceName', () => { + const result = client.matchProjectFromDeviceName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromDeviceName', () => { + const result = client.matchLocationFromDeviceName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRegistryFromDeviceName', () => { + const result = client.matchRegistryFromDeviceName(fakePath); + assert.strictEqual(result, "registryValue"); + assert((client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchDeviceFromDeviceName', () => { + const result = client.matchDeviceFromDeviceName(fakePath); + assert.strictEqual(result, "deviceValue"); + assert((client.pathTemplates.devicePathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('location', () => { + const fakePath = "/rendered/path/location"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + }; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.locationPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.locationPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('locationPath', () => { + const result = client.locationPath("projectValue", "locationValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.locationPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromLocationName', () => { + const result = client.matchProjectFromLocationName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromLocationName', () => { + const result = client.matchLocationFromLocationName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.locationPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + + describe('registry', () => { + const fakePath = "/rendered/path/registry"; + const expectedParameters = { + project: "projectValue", + location: "locationValue", + registry: "registryValue", + }; + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.registryPathTemplate.render = + sinon.stub().returns(fakePath); + client.pathTemplates.registryPathTemplate.match = + sinon.stub().returns(expectedParameters); + + it('registryPath', () => { + const result = client.registryPath("projectValue", "locationValue", "registryValue"); + assert.strictEqual(result, fakePath); + assert((client.pathTemplates.registryPathTemplate.render as SinonStub) + .getCall(-1).calledWith(expectedParameters)); + }); + + it('matchProjectFromRegistryName', () => { + const result = client.matchProjectFromRegistryName(fakePath); + assert.strictEqual(result, "projectValue"); + assert((client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchLocationFromRegistryName', () => { + const result = client.matchLocationFromRegistryName(fakePath); + assert.strictEqual(result, "locationValue"); + assert((client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + + it('matchRegistryFromRegistryName', () => { + const result = client.matchRegistryFromRegistryName(fakePath); + assert.strictEqual(result, "registryValue"); + assert((client.pathTemplates.registryPathTemplate.match as SinonStub) + .getCall(-1).calledWith(fakePath)); + }); + }); + }); +}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json new file mode 100644 index 00000000..c78f1c88 --- /dev/null +++ b/owl-bot-staging/v1/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js new file mode 100644 index 00000000..7f6d8159 --- /dev/null +++ b/owl-bot-staging/v1/webpack.config.js @@ -0,0 +1,64 @@ +// 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 +// +// https://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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'iot', + filename: './iot.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; From 8df3bc060545631cd2ee016a37714b8c3aeab6dd Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 4 Apr 2022 20:06:29 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20po?= =?UTF-8?q?st-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- owl-bot-staging/v1/.eslintignore | 7 - owl-bot-staging/v1/.eslintrc.json | 3 - owl-bot-staging/v1/.gitignore | 14 - owl-bot-staging/v1/.jsdoc.js | 55 - owl-bot-staging/v1/.mocharc.js | 33 - owl-bot-staging/v1/.prettierrc.js | 22 - owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 16 - owl-bot-staging/v1/package.json | 64 - .../google/cloud/iot/v1/device_manager.proto | 652 ----- .../google/cloud/iot/v1/resources.proto | 483 ---- .../device_manager.bind_device_to_gateway.js | 72 - .../v1/device_manager.create_device.js | 67 - .../device_manager.create_device_registry.js | 66 - .../v1/device_manager.delete_device.js | 60 - .../device_manager.delete_device_registry.js | 59 - .../generated/v1/device_manager.get_device.js | 66 - .../v1/device_manager.get_device_registry.js | 59 - .../v1/device_manager.get_iam_policy.js | 64 - ...ice_manager.list_device_config_versions.js | 66 - .../device_manager.list_device_registries.js | 74 - .../v1/device_manager.list_device_states.js | 66 - .../v1/device_manager.list_devices.js | 95 - ...e_manager.modify_cloud_to_device_config.js | 73 - .../device_manager.send_command_to_device.js | 73 - .../v1/device_manager.set_iam_policy.js | 74 - .../v1/device_manager.test_iam_permissions.js | 67 - ...vice_manager.unbind_device_from_gateway.js | 72 - .../v1/device_manager.update_device.js | 69 - .../device_manager.update_device_registry.js | 69 - .../snippet_metadata.google.cloud.iot.v1.json | 883 ------ owl-bot-staging/v1/src/index.ts | 25 - .../v1/src/v1/device_manager_client.ts | 2229 --------------- .../src/v1/device_manager_client_config.json | 135 - .../v1/src/v1/device_manager_proto_list.json | 4 - owl-bot-staging/v1/src/v1/gapic_metadata.json | 221 -- owl-bot-staging/v1/src/v1/index.ts | 19 - .../system-test/fixtures/sample/src/index.js | 27 - .../system-test/fixtures/sample/src/index.ts | 32 - owl-bot-staging/v1/system-test/install.ts | 49 - .../v1/test/gapic_device_manager_v1.ts | 2426 ----------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - .../v1/device_manager.get_iam_policy.js | 2 +- .../v1/device_manager.set_iam_policy.js | 7 + .../snippet_metadata.google.cloud.iot.v1.json | 6 +- src/v1/device_manager_client.ts | 8 +- 47 files changed, 20 insertions(+), 8797 deletions(-) delete mode 100644 owl-bot-staging/v1/.eslintignore delete mode 100644 owl-bot-staging/v1/.eslintrc.json delete mode 100644 owl-bot-staging/v1/.gitignore delete mode 100644 owl-bot-staging/v1/.jsdoc.js delete mode 100644 owl-bot-staging/v1/.mocharc.js delete mode 100644 owl-bot-staging/v1/.prettierrc.js delete mode 100644 owl-bot-staging/v1/README.md delete mode 100644 owl-bot-staging/v1/linkinator.config.json delete mode 100644 owl-bot-staging/v1/package.json delete mode 100644 owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto delete mode 100644 owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js delete mode 100644 owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json delete mode 100644 owl-bot-staging/v1/src/index.ts delete mode 100644 owl-bot-staging/v1/src/v1/device_manager_client.ts delete mode 100644 owl-bot-staging/v1/src/v1/device_manager_client_config.json delete mode 100644 owl-bot-staging/v1/src/v1/device_manager_proto_list.json delete mode 100644 owl-bot-staging/v1/src/v1/gapic_metadata.json delete mode 100644 owl-bot-staging/v1/src/v1/index.ts delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.js delete mode 100644 owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts delete mode 100644 owl-bot-staging/v1/system-test/install.ts delete mode 100644 owl-bot-staging/v1/test/gapic_device_manager_v1.ts delete mode 100644 owl-bot-staging/v1/tsconfig.json delete mode 100644 owl-bot-staging/v1/webpack.config.js diff --git a/owl-bot-staging/v1/.eslintignore b/owl-bot-staging/v1/.eslintignore deleted file mode 100644 index cfc348ec..00000000 --- a/owl-bot-staging/v1/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -**/node_modules -**/.coverage -build/ -docs/ -protos/ -system-test/ -samples/generated/ diff --git a/owl-bot-staging/v1/.eslintrc.json b/owl-bot-staging/v1/.eslintrc.json deleted file mode 100644 index 78215349..00000000 --- a/owl-bot-staging/v1/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "./node_modules/gts" -} diff --git a/owl-bot-staging/v1/.gitignore b/owl-bot-staging/v1/.gitignore deleted file mode 100644 index 5d32b237..00000000 --- a/owl-bot-staging/v1/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -**/*.log -**/node_modules -.coverage -coverage -.nyc_output -docs/ -out/ -build/ -system-test/secrets.js -system-test/*key.json -*.lock -.DS_Store -package-lock.json -__pycache__ diff --git a/owl-bot-staging/v1/.jsdoc.js b/owl-bot-staging/v1/.jsdoc.js deleted file mode 100644 index 99b19cfa..00000000 --- a/owl-bot-staging/v1/.jsdoc.js +++ /dev/null @@ -1,55 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -'use strict'; - -module.exports = { - opts: { - readme: './README.md', - package: './package.json', - template: './node_modules/jsdoc-fresh', - recurse: true, - verbose: true, - destination: './docs/' - }, - plugins: [ - 'plugins/markdown', - 'jsdoc-region-tag' - ], - source: { - excludePattern: '(^|\\/|\\\\)[._]', - include: [ - 'build/src', - 'protos' - ], - includePattern: '\\.js$' - }, - templates: { - copyright: 'Copyright 2022 Google LLC', - includeDate: false, - sourceFiles: false, - systemName: '@google-cloud/iot', - theme: 'lumen', - default: { - outputSourceFiles: false - } - }, - markdown: { - idInHeadings: true - } -}; diff --git a/owl-bot-staging/v1/.mocharc.js b/owl-bot-staging/v1/.mocharc.js deleted file mode 100644 index 481c522b..00000000 --- a/owl-bot-staging/v1/.mocharc.js +++ /dev/null @@ -1,33 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -const config = { - "enable-source-maps": true, - "throw-deprecation": true, - "timeout": 10000 -} -if (process.env.MOCHA_THROW_DEPRECATION === 'false') { - delete config['throw-deprecation']; -} -if (process.env.MOCHA_REPORTER) { - config.reporter = process.env.MOCHA_REPORTER; -} -if (process.env.MOCHA_REPORTER_OUTPUT) { - config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; -} -module.exports = config diff --git a/owl-bot-staging/v1/.prettierrc.js b/owl-bot-staging/v1/.prettierrc.js deleted file mode 100644 index 494e1478..00000000 --- a/owl-bot-staging/v1/.prettierrc.js +++ /dev/null @@ -1,22 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -module.exports = { - ...require('gts/.prettierrc.json') -} diff --git a/owl-bot-staging/v1/README.md b/owl-bot-staging/v1/README.md deleted file mode 100644 index e9217498..00000000 --- a/owl-bot-staging/v1/README.md +++ /dev/null @@ -1 +0,0 @@ -Iot: Nodejs Client diff --git a/owl-bot-staging/v1/linkinator.config.json b/owl-bot-staging/v1/linkinator.config.json deleted file mode 100644 index befd23c8..00000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io", - "https://console.cloud.google.com/cloudshell", - "https://support.google.com" - ], - "silent": true, - "concurrency": 5, - "retry": true, - "retryErrors": true, - "retryErrorsCount": 5, - "retryErrorsJitter": 3000 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 298abaed..00000000 --- a/owl-bot-staging/v1/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "@google-cloud/iot", - "version": "0.1.0", - "description": "Iot client for Node.js", - "repository": "googleapis/nodejs-iot", - "license": "Apache-2.0", - "author": "Google LLC", - "main": "build/src/index.js", - "files": [ - "build/src", - "build/protos" - ], - "keywords": [ - "google apis client", - "google api client", - "google apis", - "google api", - "google", - "google cloud platform", - "google cloud", - "cloud", - "google iot", - "iot", - "device manager" - ], - "scripts": { - "clean": "gts clean", - "compile": "tsc -p . && cp -r protos build/", - "compile-protos": "compileProtos src", - "docs": "jsdoc -c .jsdoc.js", - "predocs-test": "npm run docs", - "docs-test": "linkinator docs", - "fix": "gts fix", - "lint": "gts check", - "prepare": "npm run compile-protos && npm run compile", - "system-test": "c8 mocha build/system-test", - "test": "c8 mocha build/test" - }, - "dependencies": { - "google-gax": "^2.29.4" - }, - "devDependencies": { - "@types/mocha": "^9.1.0", - "@types/node": "^16.0.0", - "@types/sinon": "^10.0.8", - "c8": "^7.11.0", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.1.1", - "jsdoc-region-tag": "^1.3.1", - "linkinator": "^3.0.0", - "mocha": "^9.1.4", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^13.0.0", - "ts-loader": "^9.2.6", - "typescript": "^4.5.5", - "webpack": "^5.67.0", - "webpack-cli": "^4.9.1" - }, - "engines": { - "node": ">=v10.24.0" - } -} diff --git a/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto b/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto deleted file mode 100644 index dfd6c9b6..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/iot/v1/device_manager.proto +++ /dev/null @@ -1,652 +0,0 @@ -// 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. - -syntax = "proto3"; - -package google.cloud.iot.v1; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/cloud/iot/v1/resources.proto"; -import "google/iam/v1/iam_policy.proto"; -import "google/iam/v1/policy.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/field_mask.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; -option java_multiple_files = true; -option java_outer_classname = "DeviceManagerProto"; -option java_package = "com.google.cloud.iot.v1"; - -// Internet of Things (IoT) service. Securely connect and manage IoT devices. -service DeviceManager { - option (google.api.default_host) = "cloudiot.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/cloudiot"; - - // Creates a device registry that contains devices. - rpc CreateDeviceRegistry(CreateDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*}/registries" - body: "device_registry" - }; - option (google.api.method_signature) = "parent,device_registry"; - } - - // Gets a device registry configuration. - rpc GetDeviceRegistry(GetDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Updates a device registry configuration. - rpc UpdateDeviceRegistry(UpdateDeviceRegistryRequest) returns (DeviceRegistry) { - option (google.api.http) = { - patch: "/v1/{device_registry.name=projects/*/locations/*/registries/*}" - body: "device_registry" - }; - option (google.api.method_signature) = "device_registry,update_mask"; - } - - // Deletes a device registry configuration. - rpc DeleteDeviceRegistry(DeleteDeviceRegistryRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/registries/*}" - }; - option (google.api.method_signature) = "name"; - } - - // Lists device registries. - rpc ListDeviceRegistries(ListDeviceRegistriesRequest) returns (ListDeviceRegistriesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*}/registries" - }; - option (google.api.method_signature) = "parent"; - } - - // Creates a device in a device registry. - rpc CreateDevice(CreateDeviceRequest) returns (Device) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}/devices" - body: "device" - }; - option (google.api.method_signature) = "parent,device"; - } - - // Gets details about a device. - rpc GetDevice(GetDeviceRequest) returns (Device) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}" - } - }; - option (google.api.method_signature) = "name"; - } - - // Updates a device. - rpc UpdateDevice(UpdateDeviceRequest) returns (Device) { - option (google.api.http) = { - patch: "/v1/{device.name=projects/*/locations/*/registries/*/devices/*}" - body: "device" - additional_bindings { - patch: "/v1/{device.name=projects/*/locations/*/registries/*/groups/*/devices/*}" - body: "device" - } - }; - option (google.api.method_signature) = "device,update_mask"; - } - - // Deletes a device. - rpc DeleteDevice(DeleteDeviceRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - delete: "/v1/{name=projects/*/locations/*/registries/*/devices/*}" - }; - option (google.api.method_signature) = "name"; - } - - // List devices in a device registry. - rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse) { - option (google.api.http) = { - get: "/v1/{parent=projects/*/locations/*/registries/*}/devices" - additional_bindings { - get: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}/devices" - } - }; - option (google.api.method_signature) = "parent"; - } - - // Modifies the configuration for the device, which is eventually sent from - // the Cloud IoT Core servers. Returns the modified configuration version and - // its metadata. - rpc ModifyCloudToDeviceConfig(ModifyCloudToDeviceConfigRequest) returns (DeviceConfig) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:modifyCloudToDeviceConfig" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:modifyCloudToDeviceConfig" - body: "*" - } - }; - option (google.api.method_signature) = "name,binary_data"; - } - - // Lists the last few versions of the device configuration in descending - // order (i.e.: newest first). - rpc ListDeviceConfigVersions(ListDeviceConfigVersionsRequest) returns (ListDeviceConfigVersionsResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/configVersions" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/configVersions" - } - }; - option (google.api.method_signature) = "name"; - } - - // Lists the last few versions of the device state in descending order (i.e.: - // newest first). - rpc ListDeviceStates(ListDeviceStatesRequest) returns (ListDeviceStatesResponse) { - option (google.api.http) = { - get: "/v1/{name=projects/*/locations/*/registries/*/devices/*}/states" - additional_bindings { - get: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}/states" - } - }; - option (google.api.method_signature) = "name"; - } - - // Sets the access control policy on the specified resource. Replaces any - // existing policy. - rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:setIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:setIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource,policy"; - } - - // Gets the access control policy for a resource. - // Returns an empty policy if the resource exists and does not have a policy - // set. - rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:getIamPolicy" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:getIamPolicy" - body: "*" - } - }; - option (google.api.method_signature) = "resource"; - } - - // Returns permissions that a caller has on the specified resource. - // If the resource does not exist, this will return an empty set of - // permissions, not a NOT_FOUND error. - rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { - option (google.api.http) = { - post: "/v1/{resource=projects/*/locations/*/registries/*}:testIamPermissions" - body: "*" - additional_bindings { - post: "/v1/{resource=projects/*/locations/*/registries/*/groups/*}:testIamPermissions" - body: "*" - } - }; - option (google.api.method_signature) = "resource,permissions"; - } - - // Sends a command to the specified device. In order for a device to be able - // to receive commands, it must: - // 1) be connected to Cloud IoT Core using the MQTT protocol, and - // 2) be subscribed to the group of MQTT topics specified by - // /devices/{device-id}/commands/#. This subscription will receive commands - // at the top-level topic /devices/{device-id}/commands as well as commands - // for subfolders, like /devices/{device-id}/commands/subfolder. - // Note that subscribing to specific subfolders is not supported. - // If the command could not be delivered to the device, this method will - // return an error; in particular, if the device is not subscribed, this - // method will return FAILED_PRECONDITION. Otherwise, this method will - // return OK. If the subscription is QoS 1, at least once delivery will be - // guaranteed; for QoS 0, no acknowledgment will be expected from the device. - rpc SendCommandToDevice(SendCommandToDeviceRequest) returns (SendCommandToDeviceResponse) { - option (google.api.http) = { - post: "/v1/{name=projects/*/locations/*/registries/*/devices/*}:sendCommandToDevice" - body: "*" - additional_bindings { - post: "/v1/{name=projects/*/locations/*/registries/*/groups/*/devices/*}:sendCommandToDevice" - body: "*" - } - }; - option (google.api.method_signature) = "name,binary_data"; - option (google.api.method_signature) = "name,binary_data,subfolder"; - } - - // Associates the device with the gateway. - rpc BindDeviceToGateway(BindDeviceToGatewayRequest) returns (BindDeviceToGatewayResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}:bindDeviceToGateway" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:bindDeviceToGateway" - body: "*" - } - }; - option (google.api.method_signature) = "parent,gateway_id,device_id"; - } - - // Deletes the association between the device and the gateway. - rpc UnbindDeviceFromGateway(UnbindDeviceFromGatewayRequest) returns (UnbindDeviceFromGatewayResponse) { - option (google.api.http) = { - post: "/v1/{parent=projects/*/locations/*/registries/*}:unbindDeviceFromGateway" - body: "*" - additional_bindings { - post: "/v1/{parent=projects/*/locations/*/registries/*/groups/*}:unbindDeviceFromGateway" - body: "*" - } - }; - option (google.api.method_signature) = "parent,gateway_id,device_id"; - } -} - -// Request for `CreateDeviceRegistry`. -message CreateDeviceRegistryRequest { - // Required. The project and cloud region where this device registry must be created. - // For example, `projects/example-project/locations/us-central1`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // Required. The device registry. The field `name` must be empty. The server will - // generate that field from the device registry `id` provided and the - // `parent` field. - DeviceRegistry device_registry = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `GetDeviceRegistry`. -message GetDeviceRegistryRequest { - // Required. The name of the device registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; -} - -// Request for `DeleteDeviceRegistry`. -message DeleteDeviceRegistryRequest { - // Required. The name of the device registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; -} - -// Request for `UpdateDeviceRegistry`. -message UpdateDeviceRegistryRequest { - // Required. The new values for the device registry. The `id` field must be empty, and - // the `name` field must indicate the path of the resource. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - DeviceRegistry device_registry = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. Only updates the `device_registry` fields indicated by this mask. - // The field mask must not be empty, and it must not contain fields that - // are immutable or only set by the server. - // Mutable top-level fields: `event_notification_config`, `http_config`, - // `mqtt_config`, and `state_notification_config`. - google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `ListDeviceRegistries`. -message ListDeviceRegistriesRequest { - // Required. The project and cloud region path. For example, - // `projects/example-project/locations/us-central1`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "locations.googleapis.com/Location" - } - ]; - - // The maximum number of registries to return in the response. If this value - // is zero, the service will select a default size. A call may return fewer - // objects than requested. A non-empty `next_page_token` in the response - // indicates that more data is available. - int32 page_size = 2; - - // The value returned by the last `ListDeviceRegistriesResponse`; indicates - // that this is a continuation of a prior `ListDeviceRegistries` call and - // the system should return the next page of data. - string page_token = 3; -} - -// Response for `ListDeviceRegistries`. -message ListDeviceRegistriesResponse { - // The registries that matched the query. - repeated DeviceRegistry device_registries = 1; - - // If not empty, indicates that there may be more registries that match the - // request; this value should be passed in a new - // `ListDeviceRegistriesRequest`. - string next_page_token = 2; -} - -// Request for `CreateDevice`. -message CreateDeviceRequest { - // Required. The name of the device registry where this device should be created. - // For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The device registration details. The field `name` must be empty. The server - // generates `name` from the device registry `id` and the - // `parent` field. - Device device = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `GetDevice`. -message GetDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The fields of the `Device` resource to be returned in the response. If the - // field mask is unset or empty, all fields are returned. Fields have to be - // provided in snake_case format, for example: `last_heartbeat_time`. - google.protobuf.FieldMask field_mask = 2; -} - -// Request for `UpdateDevice`. -message UpdateDeviceRequest { - // Required. The new values for the device. The `id` and `num_id` fields must - // be empty, and the field `name` must specify the name path. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - Device device = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. Only updates the `device` fields indicated by this mask. - // The field mask must not be empty, and it must not contain fields that - // are immutable or only set by the server. - // Mutable top-level fields: `credentials`, `blocked`, and `metadata` - google.protobuf.FieldMask update_mask = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `DeleteDevice`. -message DeleteDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; -} - -// Request for `ListDevices`. -message ListDevicesRequest { - // Required. The device registry path. Required. For example, - // `projects/my-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // A list of device numeric IDs. If empty, this field is ignored. Maximum - // IDs: 10,000. - repeated uint64 device_num_ids = 2; - - // A list of device string IDs. For example, `['device0', 'device12']`. - // If empty, this field is ignored. Maximum IDs: 10,000 - repeated string device_ids = 3; - - // The fields of the `Device` resource to be returned in the response. The - // fields `id` and `num_id` are always returned, along with any - // other fields specified in snake_case format, for example: - // `last_heartbeat_time`. - google.protobuf.FieldMask field_mask = 4; - - // Options related to gateways. - GatewayListOptions gateway_list_options = 6; - - // The maximum number of devices to return in the response. If this value - // is zero, the service will select a default size. A call may return fewer - // objects than requested. A non-empty `next_page_token` in the response - // indicates that more data is available. - int32 page_size = 100; - - // The value returned by the last `ListDevicesResponse`; indicates - // that this is a continuation of a prior `ListDevices` call and - // the system should return the next page of data. - string page_token = 101; -} - -// Options for limiting the list based on gateway type and associations. -message GatewayListOptions { - // If not set, all devices and gateways are returned. If set, the list is - // filtered based on gateway type and associations. - oneof filter { - // 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. - GatewayType gateway_type = 1; - - // 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. - string associations_gateway_id = 2; - - // 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. - string associations_device_id = 3; - } -} - -// Response for `ListDevices`. -message ListDevicesResponse { - // The devices that match the request. - repeated Device devices = 1; - - // If not empty, indicates that there may be more devices that match the - // request; this value should be passed in a new `ListDevicesRequest`. - string next_page_token = 2; -} - -// Request for `ModifyCloudToDeviceConfig`. -message ModifyCloudToDeviceConfigRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The version number to update. If this value is zero, it will not check the - // version number of the server and will always update the current version; - // otherwise, this update will fail if the version number found on the server - // does not match this version number. This is used to support multiple - // simultaneous updates without losing data. - int64 version_to_update = 2; - - // Required. The configuration data for the device. - bytes binary_data = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Request for `ListDeviceConfigVersions`. -message ListDeviceConfigVersionsRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The number of versions to list. Versions are listed in decreasing order of - // the version number. The maximum number of versions retained is 10. If this - // value is zero, it will return all the versions available. - int32 num_versions = 2; -} - -// Response for `ListDeviceConfigVersions`. -message ListDeviceConfigVersionsResponse { - // The device configuration for the last few versions. Versions are listed - // in decreasing order, starting from the most recent one. - repeated DeviceConfig device_configs = 1; -} - -// Request for `ListDeviceStates`. -message ListDeviceStatesRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // The number of states to list. States are listed in descending order of - // update time. The maximum number of states retained is 10. If this - // value is zero, it will return all the states available. - int32 num_states = 2; -} - -// Response for `ListDeviceStates`. -message ListDeviceStatesResponse { - // The last few device states. States are listed in descending order of server - // update time, starting from the most recent one. - repeated DeviceState device_states = 1; -} - -// Request for `SendCommandToDevice`. -message SendCommandToDeviceRequest { - // Required. The name of the device. For example, - // `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - // `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Device" - } - ]; - - // Required. The command data to send to the device. - bytes binary_data = 2 [(google.api.field_behavior) = REQUIRED]; - - // 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. - string subfolder = 3; -} - -// Response for `SendCommandToDevice`. -message SendCommandToDeviceResponse { - -} - -// Request for `BindDeviceToGateway`. -message BindDeviceToGatewayRequest { - // Required. The name of the registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The value of `gateway_id` can be either the device numeric ID or the - // user-defined device identifier. - string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The device to associate with the specified gateway. The value of - // `device_id` can be either the device numeric ID or the user-defined device - // identifier. - string device_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for `BindDeviceToGateway`. -message BindDeviceToGatewayResponse { - -} - -// Request for `UnbindDeviceFromGateway`. -message UnbindDeviceFromGatewayRequest { - // Required. The name of the registry. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string parent = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudiot.googleapis.com/Registry" - } - ]; - - // Required. The value of `gateway_id` can be either the device numeric ID or the - // user-defined device identifier. - string gateway_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // Required. The device to disassociate from the specified gateway. The value of - // `device_id` can be either the device numeric ID or the user-defined device - // identifier. - string device_id = 3 [(google.api.field_behavior) = REQUIRED]; -} - -// Response for `UnbindDeviceFromGateway`. -message UnbindDeviceFromGatewayResponse { - -} diff --git a/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto b/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto deleted file mode 100644 index a14fc027..00000000 --- a/owl-bot-staging/v1/protos/google/cloud/iot/v1/resources.proto +++ /dev/null @@ -1,483 +0,0 @@ -// 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. - -syntax = "proto3"; - -package google.cloud.iot.v1; - -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/rpc/status.proto"; - -option cc_enable_arenas = true; -option go_package = "google.golang.org/genproto/googleapis/cloud/iot/v1;iot"; -option java_multiple_files = true; -option java_outer_classname = "ResourcesProto"; -option java_package = "com.google.cloud.iot.v1"; - -// The device resource. -message Device { - option (google.api.resource) = { - type: "cloudiot.googleapis.com/Device" - pattern: "projects/{project}/locations/{location}/registries/{registry}/devices/{device}" - }; - - // The user-defined device identifier. The device ID must be unique - // within a device registry. - string id = 1; - - // The resource path name. For example, - // `projects/p1/locations/us-central1/registries/registry0/devices/dev0` or - // `projects/p1/locations/us-central1/registries/registry0/devices/{num_id}`. - // When `name` is populated as a response from the service, it always ends - // in the device numeric ID. - string name = 2; - - // [Output only] A server-defined unique numeric ID for the device. This is a - // more compact way to identify devices, and it is globally unique. - uint64 num_id = 3; - - // The credentials used to authenticate this device. To allow credential - // rotation without interruption, multiple device credentials can be bound to - // this device. No more than 3 credentials can be bound to a single device at - // a time. When new credentials are added to a device, they are verified - // against the registry credentials. For details, see the description of the - // `DeviceRegistry.credentials` field. - repeated DeviceCredential credentials = 12; - - // [Output only] The last time an MQTT `PINGREQ` was received. This field - // applies only to devices connecting through MQTT. MQTT clients usually only - // send `PINGREQ` messages if the connection is idle, and no other messages - // have been sent. Timestamps are periodically collected and written to - // storage; they may be stale by a few minutes. - google.protobuf.Timestamp last_heartbeat_time = 7; - - // [Output only] The last time a telemetry event was received. Timestamps are - // periodically collected and written to storage; they may be stale by a few - // minutes. - google.protobuf.Timestamp last_event_time = 8; - - // [Output only] The last time a state event was received. Timestamps are - // periodically collected and written to storage; they may be stale by a few - // minutes. - google.protobuf.Timestamp last_state_time = 20; - - // [Output only] The last time a cloud-to-device config version acknowledgment - // was received from the device. This field is only for configurations - // sent through MQTT. - google.protobuf.Timestamp last_config_ack_time = 14; - - // [Output only] The last time a cloud-to-device config version was sent to - // the device. - google.protobuf.Timestamp last_config_send_time = 18; - - // If a device is blocked, connections or requests from this device will fail. - // Can be used to temporarily prevent the device from connecting if, for - // example, the sensor is generating bad data and needs maintenance. - bool blocked = 19; - - // [Output only] The time the most recent error occurred, such as a failure to - // publish to Cloud Pub/Sub. This field is the timestamp of - // 'last_error_status'. - google.protobuf.Timestamp last_error_time = 10; - - // [Output only] The error message of the most recent error, such as a failure - // to publish to Cloud Pub/Sub. 'last_error_time' is the timestamp of this - // field. If no errors have occurred, this field has an empty message - // and the status code 0 == OK. Otherwise, this field is expected to have a - // status code other than OK. - google.rpc.Status last_error_status = 11; - - // The most recent device configuration, which is eventually sent from - // Cloud IoT Core to the device. If not present on creation, the - // configuration will be initialized with an empty payload and version value - // of `1`. To update this field after creation, use the - // `DeviceManager.ModifyCloudToDeviceConfig` method. - DeviceConfig config = 13; - - // [Output only] The state most recently received from the device. If no state - // has been reported, this field is not present. - DeviceState state = 16; - - // **Beta Feature** - // - // The logging verbosity for device activity. If unspecified, - // DeviceRegistry.log_level will be used. - LogLevel log_level = 21; - - // The metadata key-value pairs assigned to the device. This metadata is not - // interpreted or indexed by Cloud IoT Core. It can be used to add contextual - // information for the device. - // - // Keys must conform to the regular expression [a-zA-Z][a-zA-Z0-9-_.+~%]+ and - // be less than 128 bytes in length. - // - // Values are free-form strings. Each value must be less than or equal to 32 - // KB in size. - // - // The total size of all keys and values must be less than 256 KB, and the - // maximum number of key-value pairs is 500. - map metadata = 17; - - // Gateway-related configuration and state. - GatewayConfig gateway_config = 24; -} - -// Gateway-related configuration and state. -message GatewayConfig { - // Indicates whether the device is a gateway. - GatewayType gateway_type = 1; - - // Indicates how to authorize and/or authenticate devices to access the - // gateway. - GatewayAuthMethod gateway_auth_method = 2; - - // [Output only] The ID of the gateway the device accessed most recently. - string last_accessed_gateway_id = 3; - - // [Output only] The most recent time at which the device accessed the gateway - // specified in `last_accessed_gateway`. - google.protobuf.Timestamp last_accessed_gateway_time = 4; -} - -// A container for a group of devices. -message DeviceRegistry { - option (google.api.resource) = { - type: "cloudiot.googleapis.com/Registry" - pattern: "projects/{project}/locations/{location}/registries/{registry}" - }; - - // The identifier of this device registry. For example, `myRegistry`. - string id = 1; - - // The resource path name. For example, - // `projects/example-project/locations/us-central1/registries/my-registry`. - string name = 2; - - // The configuration for notification of telemetry events received from the - // device. All telemetry events that were successfully published by the - // device and acknowledged by Cloud IoT Core are guaranteed to be - // delivered to Cloud Pub/Sub. If multiple configurations match a message, - // only the first matching configuration is used. If you try to publish a - // device telemetry event using MQTT without specifying a Cloud Pub/Sub topic - // for the device's registry, the connection closes automatically. If you try - // to do so using an HTTP connection, an error is returned. Up to 10 - // configurations may be provided. - repeated EventNotificationConfig event_notification_configs = 10; - - // The configuration for notification of new states received from the device. - // State updates are guaranteed to be stored in the state history, but - // notifications to Cloud Pub/Sub are not guaranteed. For example, if - // permissions are misconfigured or the specified topic doesn't exist, no - // notification will be published but the state will still be stored in Cloud - // IoT Core. - StateNotificationConfig state_notification_config = 7; - - // The MQTT configuration for this device registry. - MqttConfig mqtt_config = 4; - - // The DeviceService (HTTP) configuration for this device registry. - HttpConfig http_config = 9; - - // **Beta Feature** - // - // The default logging verbosity for activity from devices in this registry. - // The verbosity level can be overridden by Device.log_level. - LogLevel log_level = 11; - - // The credentials used to verify the device credentials. No more than 10 - // credentials can be bound to a single registry at a time. The verification - // process occurs at the time of device creation or update. If this field is - // empty, no verification is performed. Otherwise, the credentials of a newly - // created device or added credentials of an updated device should be signed - // with one of these registry credentials. - // - // Note, however, that existing devices will never be affected by - // modifications to this list of credentials: after a device has been - // successfully created in a registry, it should be able to connect even if - // its registry credentials are revoked, deleted, or modified. - repeated RegistryCredential credentials = 8; -} - -// The configuration of MQTT for a device registry. -message MqttConfig { - // If enabled, allows connections using the MQTT protocol. Otherwise, MQTT - // connections to this registry will fail. - MqttState mqtt_enabled_state = 1; -} - -// Indicates whether an MQTT connection is enabled or disabled. See the field -// description for details. -enum MqttState { - // No MQTT state specified. If not specified, MQTT will be enabled by default. - MQTT_STATE_UNSPECIFIED = 0; - - // Enables a MQTT connection. - MQTT_ENABLED = 1; - - // Disables a MQTT connection. - MQTT_DISABLED = 2; -} - -// The configuration of the HTTP bridge for a device registry. -message HttpConfig { - // If enabled, allows devices to use DeviceService via the HTTP protocol. - // Otherwise, any requests to DeviceService will fail for this registry. - HttpState http_enabled_state = 1; -} - -// Indicates whether DeviceService (HTTP) is enabled or disabled for the -// registry. See the field description for details. -enum HttpState { - // No HTTP state specified. If not specified, DeviceService will be - // enabled by default. - HTTP_STATE_UNSPECIFIED = 0; - - // Enables DeviceService (HTTP) service for the registry. - HTTP_ENABLED = 1; - - // Disables DeviceService (HTTP) service for the registry. - HTTP_DISABLED = 2; -} - -// **Beta Feature** -// -// The logging verbosity for device activity. Specifies which events should be -// written to logs. For example, if the LogLevel is ERROR, only events that -// terminate in errors will be logged. LogLevel is inclusive; enabling INFO -// logging will also enable ERROR logging. -enum LogLevel { - // No logging specified. If not specified, logging will be disabled. - LOG_LEVEL_UNSPECIFIED = 0; - - // Disables logging. - NONE = 10; - - // Error events will be logged. - ERROR = 20; - - // Informational events will be logged, such as connections and - // disconnections. - INFO = 30; - - // All events will be logged. - DEBUG = 40; -} - -// Gateway type. -enum GatewayType { - // If unspecified, the device is considered a non-gateway device. - GATEWAY_TYPE_UNSPECIFIED = 0; - - // The device is a gateway. - GATEWAY = 1; - - // The device is not a gateway. - NON_GATEWAY = 2; -} - -// The gateway authorization/authentication method. This setting determines how -// Cloud IoT Core authorizes/authenticate devices to access the gateway. -enum GatewayAuthMethod { - // No authentication/authorization method specified. No devices are allowed to - // access the gateway. - GATEWAY_AUTH_METHOD_UNSPECIFIED = 0; - - // The device is authenticated through the gateway association only. Device - // credentials are ignored even if provided. - ASSOCIATION_ONLY = 1; - - // The device is authenticated through its own credentials. Gateway - // association is not checked. - DEVICE_AUTH_TOKEN_ONLY = 2; - - // The device is authenticated through both device credentials and gateway - // association. The device must be bound to the gateway and must provide its - // own credentials. - ASSOCIATION_AND_DEVICE_AUTH_TOKEN = 3; -} - -// The configuration for forwarding telemetry events. -message EventNotificationConfig { - // If the subfolder name matches this string exactly, this configuration will - // be used. The string must not include the leading '/' character. If empty, - // all strings are matched. This field is used only for telemetry events; - // subfolders are not supported for state changes. - string subfolder_matches = 2; - - // A Cloud Pub/Sub topic name. For example, - // `projects/myProject/topics/deviceEvents`. - string pubsub_topic_name = 1; -} - -// The configuration for notification of new states received from the device. -message StateNotificationConfig { - // A Cloud Pub/Sub topic name. For example, - // `projects/myProject/topics/deviceEvents`. - string pubsub_topic_name = 1; -} - -// A server-stored registry credential used to validate device credentials. -message RegistryCredential { - // The credential data. Reserved for expansion in the future. - oneof credential { - // A public key certificate used to verify the device credentials. - PublicKeyCertificate public_key_certificate = 1; - } -} - -// Details of an X.509 certificate. For informational purposes only. -message X509CertificateDetails { - // The entity that signed the certificate. - string issuer = 1; - - // The entity the certificate and public key belong to. - string subject = 2; - - // The time the certificate becomes valid. - google.protobuf.Timestamp start_time = 3; - - // The time the certificate becomes invalid. - google.protobuf.Timestamp expiry_time = 4; - - // The algorithm used to sign the certificate. - string signature_algorithm = 5; - - // The type of public key in the certificate. - string public_key_type = 6; -} - -// A public key certificate format and data. -message PublicKeyCertificate { - // The certificate format. - PublicKeyCertificateFormat format = 1; - - // The certificate data. - string certificate = 2; - - // [Output only] The certificate details. Used only for X.509 certificates. - X509CertificateDetails x509_details = 3; -} - -// The supported formats for the public key. -enum PublicKeyCertificateFormat { - // The format has not been specified. This is an invalid default value and - // must not be used. - UNSPECIFIED_PUBLIC_KEY_CERTIFICATE_FORMAT = 0; - - // An X.509v3 certificate ([RFC5280](https://www.ietf.org/rfc/rfc5280.txt)), - // encoded in base64, and wrapped by `-----BEGIN CERTIFICATE-----` and - // `-----END CERTIFICATE-----`. - X509_CERTIFICATE_PEM = 1; -} - -// A server-stored device credential used for authentication. -message DeviceCredential { - // The credential data. Reserved for expansion in the future. - oneof credential { - // A public key used to verify the signature of JSON Web Tokens (JWTs). - // When adding a new device credential, either via device creation or via - // modifications, this public key credential may be required to be signed by - // one of the registry level certificates. More specifically, if the - // registry contains at least one certificate, any new device credential - // must be signed by one of the registry certificates. As a result, - // when the registry contains certificates, only X.509 certificates are - // accepted as device credentials. However, if the registry does - // not contain a certificate, self-signed certificates and public keys will - // be accepted. New device credentials must be different from every - // registry-level certificate. - PublicKeyCredential public_key = 2; - } - - // [Optional] The time at which this credential becomes invalid. This - // credential will be ignored for new client authentication requests after - // this timestamp; however, it will not be automatically deleted. - google.protobuf.Timestamp expiration_time = 6; -} - -// A public key format and data. -message PublicKeyCredential { - // The format of the key. - PublicKeyFormat format = 1; - - // The key data. - string key = 2; -} - -// The supported formats for the public key. -enum PublicKeyFormat { - // The format has not been specified. This is an invalid default value and - // must not be used. - UNSPECIFIED_PUBLIC_KEY_FORMAT = 0; - - // An RSA public key encoded in base64, and wrapped by - // `-----BEGIN PUBLIC KEY-----` and `-----END PUBLIC KEY-----`. This can be - // used to verify `RS256` signatures in JWT tokens ([RFC7518]( - // https://www.ietf.org/rfc/rfc7518.txt)). - RSA_PEM = 3; - - // As RSA_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( - // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by - // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. - RSA_X509_PEM = 1; - - // Public key for the ECDSA algorithm using P-256 and SHA-256, encoded in - // base64, and wrapped by `-----BEGIN PUBLIC KEY-----` and `-----END - // PUBLIC KEY-----`. This can be used to verify JWT tokens with the `ES256` - // algorithm ([RFC7518](https://www.ietf.org/rfc/rfc7518.txt)). This curve is - // defined in [OpenSSL](https://www.openssl.org/) as the `prime256v1` curve. - ES256_PEM = 2; - - // As ES256_PEM, but wrapped in an X.509v3 certificate ([RFC5280]( - // https://www.ietf.org/rfc/rfc5280.txt)), encoded in base64, and wrapped by - // `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----`. - ES256_X509_PEM = 4; -} - -// The device configuration. Eventually delivered to devices. -message DeviceConfig { - // [Output only] The version of this update. The version number is assigned by - // the server, and is always greater than 0 after device creation. The - // version must be 0 on the `CreateDevice` request if a `config` is - // specified; the response of `CreateDevice` will always have a value of 1. - int64 version = 1; - - // [Output only] The time at which this configuration version was updated in - // Cloud IoT Core. This timestamp is set by the server. - google.protobuf.Timestamp cloud_update_time = 2; - - // [Output only] The time at which Cloud IoT Core received the - // acknowledgment from the device, indicating that the device has received - // this configuration version. If this field is not present, the device has - // not yet acknowledged that it received this version. Note that when - // the config was sent to the device, many config versions may have been - // available in Cloud IoT Core while the device was disconnected, and on - // connection, only the latest version is sent to the device. Some - // versions may never be sent to the device, and therefore are never - // acknowledged. This timestamp is set by Cloud IoT Core. - google.protobuf.Timestamp device_ack_time = 3; - - // The device configuration data. - bytes binary_data = 4; -} - -// The device state, as reported by the device. -message DeviceState { - // [Output only] The time at which this state version was updated in Cloud - // IoT Core. - google.protobuf.Timestamp update_time = 1; - - // The device state data. - bytes binary_data = 2; -} diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js deleted file mode 100644 index e5d0348f..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.bind_device_to_gateway.js +++ /dev/null @@ -1,72 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, gatewayId, deviceId) { - // [START cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const parent = 'abc123' - /** - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - */ - // const gatewayId = 'abc123' - /** - * Required. The device to associate with the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - */ - // const deviceId = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callBindDeviceToGateway() { - // Construct request - const request = { - parent, - gatewayId, - deviceId, - }; - - // Run request - const response = await iotClient.bindDeviceToGateway(request); - console.log(response); - } - - callBindDeviceToGateway(); - // [END cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js deleted file mode 100644 index d38142b0..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device.js +++ /dev/null @@ -1,67 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, device) { - // [START cloudiot_v1_generated_DeviceManager_CreateDevice_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device registry where this device should be created. - * For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const parent = 'abc123' - /** - * Required. The device registration details. The field `name` must be empty. The server - * generates `name` from the device registry `id` and the - * `parent` field. - */ - // const device = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callCreateDevice() { - // Construct request - const request = { - parent, - device, - }; - - // Run request - const response = await iotClient.createDevice(request); - console.log(response); - } - - callCreateDevice(); - // [END cloudiot_v1_generated_DeviceManager_CreateDevice_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js deleted file mode 100644 index 6248800b..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.create_device_registry.js +++ /dev/null @@ -1,66 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, deviceRegistry) { - // [START cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and cloud region where this device registry must be created. - * For example, `projects/example-project/locations/us-central1`. - */ - // const parent = 'abc123' - /** - * Required. The device registry. The field `name` must be empty. The server will - * generate that field from the device registry `id` provided and the - * `parent` field. - */ - // const deviceRegistry = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callCreateDeviceRegistry() { - // Construct request - const request = { - parent, - deviceRegistry, - }; - - // Run request - const response = await iotClient.createDeviceRegistry(request); - console.log(response); - } - - callCreateDeviceRegistry(); - // [END cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js deleted file mode 100644 index ab1999e2..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device.js +++ /dev/null @@ -1,60 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_DeleteDevice_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callDeleteDevice() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.deleteDevice(request); - console.log(response); - } - - callDeleteDevice(); - // [END cloudiot_v1_generated_DeviceManager_DeleteDevice_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js deleted file mode 100644 index 663be451..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.delete_device_registry.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const name = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callDeleteDeviceRegistry() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.deleteDeviceRegistry(request); - console.log(response); - } - - callDeleteDeviceRegistry(); - // [END cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js deleted file mode 100644 index db5022fb..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device.js +++ /dev/null @@ -1,66 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_GetDevice_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - /** - * The fields of the `Device` resource to be returned in the response. If the - * field mask is unset or empty, all fields are returned. Fields have to be - * provided in snake_case format, for example: `last_heartbeat_time`. - */ - // const fieldMask = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callGetDevice() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.getDevice(request); - console.log(response); - } - - callGetDevice(); - // [END cloudiot_v1_generated_DeviceManager_GetDevice_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js deleted file mode 100644 index 7cbb7241..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_device_registry.js +++ /dev/null @@ -1,59 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const name = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callGetDeviceRegistry() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.getDeviceRegistry(request); - console.log(response); - } - - callGetDeviceRegistry(); - // [END cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js deleted file mode 100644 index 039b3941..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.get_iam_policy.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource) { - // [START cloudiot_v1_generated_DeviceManager_GetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - */ - // const options = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callGetIamPolicy() { - // Construct request - const request = { - resource, - }; - - // Run request - const response = await iotClient.getIamPolicy(request); - console.log(response); - } - - callGetIamPolicy(); - // [END cloudiot_v1_generated_DeviceManager_GetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js deleted file mode 100644 index be6a024d..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_config_versions.js +++ /dev/null @@ -1,66 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - /** - * The number of versions to list. Versions are listed in decreasing order of - * the version number. The maximum number of versions retained is 10. If this - * value is zero, it will return all the versions available. - */ - // const numVersions = 1234 - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callListDeviceConfigVersions() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.listDeviceConfigVersions(request); - console.log(response); - } - - callListDeviceConfigVersions(); - // [END cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js deleted file mode 100644 index d7853e34..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_registries.js +++ /dev/null @@ -1,74 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - */ - // const parent = 'abc123' - /** - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callListDeviceRegistries() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await iotClient.listDeviceRegistriesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDeviceRegistries(); - // [END cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js deleted file mode 100644 index d9c8519d..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_device_states.js +++ /dev/null @@ -1,66 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name) { - // [START cloudiot_v1_generated_DeviceManager_ListDeviceStates_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - /** - * The number of states to list. States are listed in descending order of - * update time. The maximum number of states retained is 10. If this - * value is zero, it will return all the states available. - */ - // const numStates = 1234 - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callListDeviceStates() { - // Construct request - const request = { - name, - }; - - // Run request - const response = await iotClient.listDeviceStates(request); - console.log(response); - } - - callListDeviceStates(); - // [END cloudiot_v1_generated_DeviceManager_ListDeviceStates_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js deleted file mode 100644 index 7e33937a..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.list_devices.js +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent) { - // [START cloudiot_v1_generated_DeviceManager_ListDevices_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - */ - // const parent = 'abc123' - /** - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - */ - // const deviceNumIds = 1234 - /** - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - */ - // const deviceIds = 'abc123' - /** - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - */ - // const fieldMask = {} - /** - * Options related to gateways. - */ - // const gatewayListOptions = {} - /** - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - */ - // const pageSize = 1234 - /** - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - */ - // const pageToken = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callListDevices() { - // Construct request - const request = { - parent, - }; - - // Run request - const iterable = await iotClient.listDevicesAsync(request); - for await (const response of iterable) { - console.log(response); - } - } - - callListDevices(); - // [END cloudiot_v1_generated_DeviceManager_ListDevices_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js deleted file mode 100644 index 9e415682..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.modify_cloud_to_device_config.js +++ /dev/null @@ -1,73 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, binaryData) { - // [START cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - /** - * The version number to update. If this value is zero, it will not check the - * version number of the server and will always update the current version; - * otherwise, this update will fail if the version number found on the server - * does not match this version number. This is used to support multiple - * simultaneous updates without losing data. - */ - // const versionToUpdate = 1234 - /** - * Required. The configuration data for the device. - */ - // const binaryData = 'Buffer.from('string')' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callModifyCloudToDeviceConfig() { - // Construct request - const request = { - name, - binaryData, - }; - - // Run request - const response = await iotClient.modifyCloudToDeviceConfig(request); - console.log(response); - } - - callModifyCloudToDeviceConfig(); - // [END cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js deleted file mode 100644 index df399716..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.send_command_to_device.js +++ /dev/null @@ -1,73 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(name, binaryData) { - // [START cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const name = 'abc123' - /** - * Required. The command data to send to the device. - */ - // const binaryData = 'Buffer.from('string')' - /** - * 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. - */ - // const subfolder = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callSendCommandToDevice() { - // Construct request - const request = { - name, - binaryData, - }; - - // Run request - const response = await iotClient.sendCommandToDevice(request); - console.log(response); - } - - callSendCommandToDevice(); - // [END cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js deleted file mode 100644 index 05ba74e3..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.set_iam_policy.js +++ /dev/null @@ -1,74 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, policy) { - // [START cloudiot_v1_generated_DeviceManager_SetIamPolicy_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - */ - // const policy = {} - /** - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * `paths: "bindings, etag"` - */ - // const updateMask = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callSetIamPolicy() { - // Construct request - const request = { - resource, - policy, - }; - - // Run request - const response = await iotClient.setIamPolicy(request); - console.log(response); - } - - callSetIamPolicy(); - // [END cloudiot_v1_generated_DeviceManager_SetIamPolicy_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js deleted file mode 100644 index 81f299d3..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.test_iam_permissions.js +++ /dev/null @@ -1,67 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(resource, permissions) { - // [START cloudiot_v1_generated_DeviceManager_TestIamPermissions_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - */ - // const resource = 'abc123' - /** - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * IAM Overview (https://cloud.google.com/iam/docs/overview#permissions). - */ - // const permissions = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callTestIamPermissions() { - // Construct request - const request = { - resource, - permissions, - }; - - // Run request - const response = await iotClient.testIamPermissions(request); - console.log(response); - } - - callTestIamPermissions(); - // [END cloudiot_v1_generated_DeviceManager_TestIamPermissions_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js deleted file mode 100644 index 37fb81b5..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.unbind_device_from_gateway.js +++ /dev/null @@ -1,72 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(parent, gatewayId, deviceId) { - // [START cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const parent = 'abc123' - /** - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - */ - // const gatewayId = 'abc123' - /** - * Required. The device to disassociate from the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - */ - // const deviceId = 'abc123' - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callUnbindDeviceFromGateway() { - // Construct request - const request = { - parent, - gatewayId, - deviceId, - }; - - // Run request - const response = await iotClient.unbindDeviceFromGateway(request); - console.log(response); - } - - callUnbindDeviceFromGateway(); - // [END cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js deleted file mode 100644 index f2c21788..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device.js +++ /dev/null @@ -1,69 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(device, updateMask) { - // [START cloudiot_v1_generated_DeviceManager_UpdateDevice_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new values for the device. The `id` and `num_id` fields must - * be empty, and the field `name` must specify the name path. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - */ - // const device = {} - /** - * Required. Only updates the `device` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `credentials`, `blocked`, and `metadata` - */ - // const updateMask = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callUpdateDevice() { - // Construct request - const request = { - device, - updateMask, - }; - - // Run request - const response = await iotClient.updateDevice(request); - console.log(response); - } - - callUpdateDevice(); - // [END cloudiot_v1_generated_DeviceManager_UpdateDevice_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js b/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js deleted file mode 100644 index c3a34b16..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/device_manager.update_device_registry.js +++ /dev/null @@ -1,69 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - - -'use strict'; - -function main(deviceRegistry, updateMask) { - // [START cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async] - /** - * TODO(developer): Uncomment these variables before running the sample. - */ - /** - * Required. The new values for the device registry. The `id` field must be empty, and - * the `name` field must indicate the path of the resource. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - */ - // const deviceRegistry = {} - /** - * Required. Only updates the `device_registry` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `event_notification_config`, `http_config`, - * `mqtt_config`, and `state_notification_config`. - */ - // const updateMask = {} - - // Imports the Iot library - const {DeviceManagerClient} = require('@google-cloud/iot').v1; - - // Instantiates a client - const iotClient = new DeviceManagerClient(); - - async function callUpdateDeviceRegistry() { - // Construct request - const request = { - deviceRegistry, - updateMask, - }; - - // Run request - const response = await iotClient.updateDeviceRegistry(request); - console.log(response); - } - - callUpdateDeviceRegistry(); - // [END cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async] -} - -process.on('unhandledRejection', err => { - console.error(err.message); - process.exitCode = 1; -}); -main(...process.argv.slice(2)); diff --git a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json b/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json deleted file mode 100644 index f70dc8b9..00000000 --- a/owl-bot-staging/v1/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json +++ /dev/null @@ -1,883 +0,0 @@ -{ - "clientLibrary": { - "name": "nodejs-iot", - "version": "0.1.0", - "language": "TYPESCRIPT", - "apis": [ - { - "id": "google.cloud.iot.v1", - "version": "v1" - } - ] - }, - "snippets": [ - { - "regionTag": "cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async", - "title": "iot createDeviceRegistry Sample", - "origin": "API_DEFINITION", - "description": " Creates a device registry that contains devices.", - "canonical": true, - "file": "device_manager.create_device_registry.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.CreateDeviceRegistry", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "device_registry", - "type": ".google.cloud.iot.v1.DeviceRegistry" - } - ], - "resultType": ".google.cloud.iot.v1.DeviceRegistry", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "CreateDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.CreateDeviceRegistry", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async", - "title": "iot getDeviceRegistry Sample", - "origin": "API_DEFINITION", - "description": " Gets a device registry configuration.", - "canonical": true, - "file": "device_manager.get_device_registry.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.GetDeviceRegistry", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.DeviceRegistry", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "GetDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.GetDeviceRegistry", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async", - "title": "iot updateDeviceRegistry Sample", - "origin": "API_DEFINITION", - "description": " Updates a device registry configuration.", - "canonical": true, - "file": "device_manager.update_device_registry.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDeviceRegistry", - "async": true, - "parameters": [ - { - "name": "device_registry", - "type": ".google.cloud.iot.v1.DeviceRegistry" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.iot.v1.DeviceRegistry", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "UpdateDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDeviceRegistry", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async", - "title": "iot deleteDeviceRegistry Sample", - "origin": "API_DEFINITION", - "description": " Deletes a device registry configuration.", - "canonical": true, - "file": "device_manager.delete_device_registry.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 51, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDeviceRegistry", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "DeleteDeviceRegistry", - "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDeviceRegistry", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async", - "title": "iot listDeviceRegistries Sample", - "origin": "API_DEFINITION", - "description": " Lists device registries.", - "canonical": true, - "file": "device_manager.list_device_registries.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDeviceRegistries", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceRegistries", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.ListDeviceRegistriesResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "ListDeviceRegistries", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceRegistries", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_CreateDevice_async", - "title": "iot createDevice Sample", - "origin": "API_DEFINITION", - "description": " Creates a device in a device registry.", - "canonical": true, - "file": "device_manager.create_device.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "CreateDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.CreateDevice", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "device", - "type": ".google.cloud.iot.v1.Device" - } - ], - "resultType": ".google.cloud.iot.v1.Device", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "CreateDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.CreateDevice", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_GetDevice_async", - "title": "iot getDevice Sample", - "origin": "API_DEFINITION", - "description": " Gets details about a device.", - "canonical": true, - "file": "device_manager.get_device.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.GetDevice", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "field_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.iot.v1.Device", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "GetDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.GetDevice", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_UpdateDevice_async", - "title": "iot updateDevice Sample", - "origin": "API_DEFINITION", - "description": " Updates a device.", - "canonical": true, - "file": "device_manager.update_device.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 61, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UpdateDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDevice", - "async": true, - "parameters": [ - { - "name": "device", - "type": ".google.cloud.iot.v1.Device" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.cloud.iot.v1.Device", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "UpdateDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.UpdateDevice", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_DeleteDevice_async", - "title": "iot deleteDevice Sample", - "origin": "API_DEFINITION", - "description": " Deletes a device.", - "canonical": true, - "file": "device_manager.delete_device.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 52, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "DeleteDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDevice", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.protobuf.Empty", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "DeleteDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.DeleteDevice", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_ListDevices_async", - "title": "iot listDevices Sample", - "origin": "API_DEFINITION", - "description": " List devices in a device registry.", - "canonical": true, - "file": "device_manager.list_devices.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 87, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDevices", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDevices", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "device_num_ids", - "type": "TYPE_UINT64[]" - }, - { - "name": "device_ids", - "type": "TYPE_STRING[]" - }, - { - "name": "field_mask", - "type": ".google.protobuf.FieldMask" - }, - { - "name": "gateway_list_options", - "type": ".google.cloud.iot.v1.GatewayListOptions" - }, - { - "name": "page_size", - "type": "TYPE_INT32" - }, - { - "name": "page_token", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.ListDevicesResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "ListDevices", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDevices", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async", - "title": "iot modifyCloudToDeviceConfig Sample", - "origin": "API_DEFINITION", - "description": " Modifies the configuration for the device, which is eventually sent from the Cloud IoT Core servers. Returns the modified configuration version and its metadata.", - "canonical": true, - "file": "device_manager.modify_cloud_to_device_config.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ModifyCloudToDeviceConfig", - "fullName": "google.cloud.iot.v1.DeviceManager.ModifyCloudToDeviceConfig", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "version_to_update", - "type": "TYPE_INT64" - }, - { - "name": "binary_data", - "type": "TYPE_BYTES" - } - ], - "resultType": ".google.cloud.iot.v1.DeviceConfig", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "ModifyCloudToDeviceConfig", - "fullName": "google.cloud.iot.v1.DeviceManager.ModifyCloudToDeviceConfig", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async", - "title": "iot listDeviceConfigVersions Sample", - "origin": "API_DEFINITION", - "description": " Lists the last few versions of the device configuration in descending order (i.e.: newest first).", - "canonical": true, - "file": "device_manager.list_device_config_versions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDeviceConfigVersions", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceConfigVersions", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "num_versions", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.iot.v1.ListDeviceConfigVersionsResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "ListDeviceConfigVersions", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceConfigVersions", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_ListDeviceStates_async", - "title": "iot listDeviceStates Sample", - "origin": "API_DEFINITION", - "description": " Lists the last few versions of the device state in descending order (i.e.: newest first).", - "canonical": true, - "file": "device_manager.list_device_states.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 58, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "ListDeviceStates", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceStates", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "num_states", - "type": "TYPE_INT32" - } - ], - "resultType": ".google.cloud.iot.v1.ListDeviceStatesResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "ListDeviceStates", - "fullName": "google.cloud.iot.v1.DeviceManager.ListDeviceStates", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_SetIamPolicy_async", - "title": "iot setIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Sets the access control policy on the specified resource. Replaces any existing policy.", - "canonical": true, - "file": "device_manager.set_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 66, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.iot.v1.DeviceManager.SetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "policy", - "type": ".google.iam.v1.Policy" - }, - { - "name": "update_mask", - "type": ".google.protobuf.FieldMask" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "SetIamPolicy", - "fullName": "google.cloud.iot.v1.DeviceManager.SetIamPolicy", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_GetIamPolicy_async", - "title": "iot getIamPolicy Sample", - "origin": "API_DEFINITION", - "description": " Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.", - "canonical": true, - "file": "device_manager.get_iam_policy.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 56, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.iot.v1.DeviceManager.GetIamPolicy", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "options", - "type": ".google.iam.v1.GetPolicyOptions" - } - ], - "resultType": ".google.iam.v1.Policy", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "GetIamPolicy", - "fullName": "google.cloud.iot.v1.DeviceManager.GetIamPolicy", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_TestIamPermissions_async", - "title": "iot testIamPermissions Sample", - "origin": "API_DEFINITION", - "description": " Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.", - "canonical": true, - "file": "device_manager.test_iam_permissions.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 59, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.iot.v1.DeviceManager.TestIamPermissions", - "async": true, - "parameters": [ - { - "name": "resource", - "type": "TYPE_STRING" - }, - { - "name": "permissions", - "type": "TYPE_STRING[]" - } - ], - "resultType": ".google.iam.v1.TestIamPermissionsResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "TestIamPermissions", - "fullName": "google.cloud.iot.v1.DeviceManager.TestIamPermissions", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async", - "title": "iot sendCommandToDevice Sample", - "origin": "API_DEFINITION", - "description": " Sends a command to the specified device. In order for a device to be able to receive commands, it must: 1) be connected to Cloud IoT Core using the MQTT protocol, and 2) be subscribed to the group of MQTT topics specified by /devices/{device-id}/commands/#. This subscription will receive commands at the top-level topic /devices/{device-id}/commands as well as commands for subfolders, like /devices/{device-id}/commands/subfolder. Note that subscribing to specific subfolders is not supported. If the command could not be delivered to the device, this method will return an error; in particular, if the device is not subscribed, this method will return FAILED_PRECONDITION. Otherwise, this method will return OK. If the subscription is QoS 1, at least once delivery will be guaranteed; for QoS 0, no acknowledgment will be expected from the device.", - "canonical": true, - "file": "device_manager.send_command_to_device.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 65, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "SendCommandToDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.SendCommandToDevice", - "async": true, - "parameters": [ - { - "name": "name", - "type": "TYPE_STRING" - }, - { - "name": "binary_data", - "type": "TYPE_BYTES" - }, - { - "name": "subfolder", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.SendCommandToDeviceResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "SendCommandToDevice", - "fullName": "google.cloud.iot.v1.DeviceManager.SendCommandToDevice", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async", - "title": "iot bindDeviceToGateway Sample", - "origin": "API_DEFINITION", - "description": " Associates the device with the gateway.", - "canonical": true, - "file": "device_manager.bind_device_to_gateway.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "BindDeviceToGateway", - "fullName": "google.cloud.iot.v1.DeviceManager.BindDeviceToGateway", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "gateway_id", - "type": "TYPE_STRING" - }, - { - "name": "device_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.BindDeviceToGatewayResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "BindDeviceToGateway", - "fullName": "google.cloud.iot.v1.DeviceManager.BindDeviceToGateway", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - }, - { - "regionTag": "cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async", - "title": "iot unbindDeviceFromGateway Sample", - "origin": "API_DEFINITION", - "description": " Deletes the association between the device and the gateway.", - "canonical": true, - "file": "device_manager.unbind_device_from_gateway.js", - "language": "JAVASCRIPT", - "segments": [ - { - "start": 25, - "end": 64, - "type": "FULL" - } - ], - "clientMethod": { - "shortName": "UnbindDeviceFromGateway", - "fullName": "google.cloud.iot.v1.DeviceManager.UnbindDeviceFromGateway", - "async": true, - "parameters": [ - { - "name": "parent", - "type": "TYPE_STRING" - }, - { - "name": "gateway_id", - "type": "TYPE_STRING" - }, - { - "name": "device_id", - "type": "TYPE_STRING" - } - ], - "resultType": ".google.cloud.iot.v1.UnbindDeviceFromGatewayResponse", - "client": { - "shortName": "DeviceManagerClient", - "fullName": "google.cloud.iot.v1.DeviceManagerClient" - }, - "method": { - "shortName": "UnbindDeviceFromGateway", - "fullName": "google.cloud.iot.v1.DeviceManager.UnbindDeviceFromGateway", - "service": { - "shortName": "DeviceManager", - "fullName": "google.cloud.iot.v1.DeviceManager" - } - } - } - } - ] -} diff --git a/owl-bot-staging/v1/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index f4921a62..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as v1 from './v1'; -const DeviceManagerClient = v1.DeviceManagerClient; -type DeviceManagerClient = v1.DeviceManagerClient; -export {v1, DeviceManagerClient}; -export default {v1, DeviceManagerClient}; -import * as protos from '../protos/protos'; -export {protos} diff --git a/owl-bot-staging/v1/src/v1/device_manager_client.ts b/owl-bot-staging/v1/src/v1/device_manager_client.ts deleted file mode 100644 index fed11a36..00000000 --- a/owl-bot-staging/v1/src/v1/device_manager_client.ts +++ /dev/null @@ -1,2229 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -/* global window */ -import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; -import * as protos from '../../protos/protos'; -import jsonProtos = require('../../protos/protos.json'); -/** - * Client JSON configuration object, loaded from - * `src/v1/device_manager_client_config.json`. - * This file defines retry strategy and timeouts for all API methods in this library. - */ -import * as gapicConfig from './device_manager_client_config.json'; - -const version = require('../../../package.json').version; - -/** - * Internet of Things (IoT) service. Securely connect and manage IoT devices. - * @class - * @memberof v1 - */ -export class DeviceManagerClient { - private _terminated = false; - private _opts: ClientOptions; - private _providedCustomServicePath: boolean; - private _gaxModule: typeof gax | typeof gax.fallback; - private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; - private _protos: {}; - private _defaults: {[method: string]: gax.CallSettings}; - auth: gax.GoogleAuth; - descriptors: Descriptors = { - page: {}, - stream: {}, - longrunning: {}, - batching: {}, - }; - warn: (code: string, message: string, warnType?: string) => void; - innerApiCalls: {[name: string]: Function}; - pathTemplates: {[name: string]: gax.PathTemplate}; - deviceManagerStub?: Promise<{[name: string]: Function}>; - - /** - * Construct an instance of DeviceManagerClient. - * - * @param {object} [options] - The configuration object. - * The options accepted by the constructor are described in detail - * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance). - * The common options are: - * @param {object} [options.credentials] - Credentials object. - * @param {string} [options.credentials.client_email] - * @param {string} [options.credentials.private_key] - * @param {string} [options.email] - Account email address. Required when - * using a .pem or .p12 keyFilename. - * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or - * .p12 key downloaded from the Google Developers Console. If you provide - * a path to a JSON file, the projectId option below is not necessary. - * NOTE: .pem and .p12 require you to specify options.email as well. - * @param {number} [options.port] - The port on which to connect to - * the remote host. - * @param {string} [options.projectId] - The project ID from the Google - * Developer's Console, e.g. 'grape-spaceship-123'. We will also check - * the environment variable GCLOUD_PROJECT for your project ID. If your - * app is running in an environment which supports - * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, - * your project ID will be detected automatically. - * @param {string} [options.apiEndpoint] - The domain name of the - * API remote host. - * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. - * Follows the structure of {@link gapicConfig}. - * @param {boolean} [options.fallback] - Use HTTP fallback mode. - * In fallback mode, a special browser-compatible transport implementation is used - * instead of gRPC transport. In browser context (if the `window` object is defined) - * the fallback mode is enabled automatically; set `options.fallback` to `false` - * if you need to override this behavior. - */ - constructor(opts?: ClientOptions) { - // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof DeviceManagerClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); - const port = opts?.port || staticMembers.port; - const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); - opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); - - // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. - if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { - opts['scopes'] = staticMembers.scopes; - } - - // Choose either gRPC or proto-over-HTTP implementation of google-gax. - this._gaxModule = opts.fallback ? gax.fallback : gax; - - // Create a `gaxGrpc` object, with any grpc-specific options sent to the client. - this._gaxGrpc = new this._gaxModule.GrpcClient(opts); - - // Save options to use in initialize() method. - this._opts = opts; - - // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); - - // Set useJWTAccessWithScope on the auth object. - this.auth.useJWTAccessWithScope = true; - - // Set defaultServicePath on the auth object. - this.auth.defaultServicePath = staticMembers.servicePath; - - // Set the default scopes in auth client if needed. - if (servicePath === staticMembers.servicePath) { - this.auth.defaultScopes = staticMembers.scopes; - } - - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; - if (typeof process !== 'undefined' && 'versions' in process) { - clientHeader.push(`gl-node/${process.versions.node}`); - } else { - clientHeader.push(`gl-web/${this._gaxModule.version}`); - } - if (!opts.fallback) { - clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { - clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); - } - if (opts.libName && opts.libVersion) { - clientHeader.push(`${opts.libName}/${opts.libVersion}`); - } - // Load the applicable protos. - this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos); - - // This API contains "path templates"; forward-slash-separated - // identifiers to uniquely identify resources within the API. - // Create useful helper objects for these. - this.pathTemplates = { - devicePathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/registries/{registry}/devices/{device}' - ), - locationPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}' - ), - registryPathTemplate: new this._gaxModule.PathTemplate( - 'projects/{project}/locations/{location}/registries/{registry}' - ), - }; - - // Some of the methods on this service return "paged" results, - // (e.g. 50 results at a time, with tokens to get subsequent - // pages). Denote the keys used for pagination and results. - this.descriptors.page = { - listDeviceRegistries: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'deviceRegistries'), - listDevices: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'devices') - }; - - // Put together the default options sent with requests. - this._defaults = this._gaxGrpc.constructSettings( - 'google.cloud.iot.v1.DeviceManager', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); - - // Set up a dictionary of "inner API calls"; the core implementation - // of calling the API is handled in `google-gax`, with this code - // merely providing the destination and request information. - this.innerApiCalls = {}; - - // Add a warn function to the client constructor so it can be easily tested. - this.warn = gax.warn; - } - - /** - * Initialize the client. - * Performs asynchronous operations (such as authentication) and prepares the client. - * This function will be called automatically when any class method is called for the - * first time, but if you need to initialize it before calling an actual method, - * feel free to call initialize() directly. - * - * You can await on this method if you want to make sure the client is initialized. - * - * @returns {Promise} A promise that resolves to an authenticated service stub. - */ - initialize() { - // If the client stub promise is already initialized, return immediately. - if (this.deviceManagerStub) { - return this.deviceManagerStub; - } - - // Put together the "service stub" for - // google.cloud.iot.v1.DeviceManager. - this.deviceManagerStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.cloud.iot.v1.DeviceManager') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (this._protos as any).google.cloud.iot.v1.DeviceManager, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; - - // Iterate over each of the methods that the service provides - // and create an API call method for each. - const deviceManagerStubMethods = - ['createDeviceRegistry', 'getDeviceRegistry', 'updateDeviceRegistry', 'deleteDeviceRegistry', 'listDeviceRegistries', 'createDevice', 'getDevice', 'updateDevice', 'deleteDevice', 'listDevices', 'modifyCloudToDeviceConfig', 'listDeviceConfigVersions', 'listDeviceStates', 'setIamPolicy', 'getIamPolicy', 'testIamPermissions', 'sendCommandToDevice', 'bindDeviceToGateway', 'unbindDeviceFromGateway']; - for (const methodName of deviceManagerStubMethods) { - const callPromise = this.deviceManagerStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { - throw err; - }); - - const descriptor = - this.descriptors.page[methodName] || - undefined; - const apiCall = this._gaxModule.createApiCall( - callPromise, - this._defaults[methodName], - descriptor - ); - - this.innerApiCalls[methodName] = apiCall; - } - - return this.deviceManagerStub; - } - - /** - * The DNS address for this API service. - * @returns {string} The DNS address for this service. - */ - static get servicePath() { - return 'cloudiot.googleapis.com'; - } - - /** - * The DNS address for this API service - same as servicePath(), - * exists for compatibility reasons. - * @returns {string} The DNS address for this service. - */ - static get apiEndpoint() { - return 'cloudiot.googleapis.com'; - } - - /** - * The port for this API service. - * @returns {number} The default port for this service. - */ - static get port() { - return 443; - } - - /** - * The scopes needed to make gRPC calls for every method defined - * in this service. - * @returns {string[]} List of default scopes. - */ - static get scopes() { - return [ - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloudiot' - ]; - } - - getProjectId(): Promise; - getProjectId(callback: Callback): void; - /** - * Return the project ID used by this class. - * @returns {Promise} A promise that resolves to string containing the project ID. - */ - getProjectId(callback?: Callback): - Promise|void { - if (callback) { - this.auth.getProjectId(callback); - return; - } - return this.auth.getProjectId(); - } - - // ------------------- - // -- Service calls -- - // ------------------- -/** - * Creates a device registry that contains devices. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region where this device registry must be created. - * For example, `projects/example-project/locations/us-central1`. - * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry - * Required. The device registry. The field `name` must be empty. The server will - * generate that field from the device registry `id` provided and the - * `parent` field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.create_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_CreateDeviceRegistry_async - */ - createDeviceRegistry( - request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined - ]>; - createDeviceRegistry( - request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - createDeviceRegistry( - request: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - createDeviceRegistry( - request?: protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.ICreateDeviceRegistryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createDeviceRegistry(request, options, callback); - } -/** - * Gets a device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.get_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetDeviceRegistry_async - */ - getDeviceRegistry( - request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined - ]>; - getDeviceRegistry( - request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - getDeviceRegistry( - request: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - getDeviceRegistry( - request?: protos.google.cloud.iot.v1.IGetDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IGetDeviceRegistryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getDeviceRegistry(request, options, callback); - } -/** - * Updates a device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iot.v1.DeviceRegistry} request.deviceRegistry - * Required. The new values for the device registry. The `id` field must be empty, and - * the `name` field must indicate the path of the resource. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Only updates the `device_registry` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `event_notification_config`, `http_config`, - * `mqtt_config`, and `state_notification_config`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.update_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDeviceRegistry_async - */ - updateDeviceRegistry( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined - ]>; - updateDeviceRegistry( - request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - updateDeviceRegistry( - request: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - updateDeviceRegistry( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry, - protos.google.cloud.iot.v1.IUpdateDeviceRegistryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'device_registry.name': request.deviceRegistry!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateDeviceRegistry(request, options, callback); - } -/** - * Deletes a device registry configuration. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.delete_device_registry.js - * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDeviceRegistry_async - */ - deleteDeviceRegistry( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined - ]>; - deleteDeviceRegistry( - request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - deleteDeviceRegistry( - request: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): void; - deleteDeviceRegistry( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRegistryRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteDeviceRegistry(request, options, callback); - } -/** - * Creates a device in a device registry. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the device registry where this device should be created. - * For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {google.cloud.iot.v1.Device} request.device - * Required. The device registration details. The field `name` must be empty. The server - * generates `name` from the device registry `id` and the - * `parent` field. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.create_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_CreateDevice_async - */ - createDevice( - request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined - ]>; - createDevice( - request: protos.google.cloud.iot.v1.ICreateDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): void; - createDevice( - request: protos.google.cloud.iot.v1.ICreateDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): void; - createDevice( - request?: protos.google.cloud.iot.v1.ICreateDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.ICreateDeviceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.createDevice(request, options, callback); - } -/** - * Gets details about a device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. If the - * field mask is unset or empty, all fields are returned. Fields have to be - * provided in snake_case format, for example: `last_heartbeat_time`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.get_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetDevice_async - */ - getDevice( - request?: protos.google.cloud.iot.v1.IGetDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined - ]>; - getDevice( - request: protos.google.cloud.iot.v1.IGetDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): void; - getDevice( - request: protos.google.cloud.iot.v1.IGetDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): void; - getDevice( - request?: protos.google.cloud.iot.v1.IGetDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IGetDeviceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.getDevice(request, options, callback); - } -/** - * Updates a device. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.cloud.iot.v1.Device} request.device - * Required. The new values for the device. The `id` and `num_id` fields must - * be empty, and the field `name` must specify the name path. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0`or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. Only updates the `device` fields indicated by this mask. - * The field mask must not be empty, and it must not contain fields that - * are immutable or only set by the server. - * Mutable top-level fields: `credentials`, `blocked`, and `metadata` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Device]{@link google.cloud.iot.v1.Device}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.update_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_UpdateDevice_async - */ - updateDevice( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined - ]>; - updateDevice( - request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): void; - updateDevice( - request: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): void; - updateDevice( - request?: protos.google.cloud.iot.v1.IUpdateDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDevice, - protos.google.cloud.iot.v1.IUpdateDeviceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'device.name': request.device!.name || '', - }); - this.initialize(); - return this.innerApiCalls.updateDevice(request, options, callback); - } -/** - * Deletes a device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.delete_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_DeleteDevice_async - */ - deleteDevice( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined - ]>; - deleteDevice( - request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): void; - deleteDevice( - request: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): void; - deleteDevice( - request?: protos.google.cloud.iot.v1.IDeleteDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.cloud.iot.v1.IDeleteDeviceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.deleteDevice(request, options, callback); - } -/** - * Modifies the configuration for the device, which is eventually sent from - * the Cloud IoT Core servers. Returns the modified configuration version and - * its metadata. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.versionToUpdate - * The version number to update. If this value is zero, it will not check the - * version number of the server and will always update the current version; - * otherwise, this update will fail if the version number found on the server - * does not match this version number. This is used to support multiple - * simultaneous updates without losing data. - * @param {Buffer} request.binaryData - * Required. The configuration data for the device. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [DeviceConfig]{@link google.cloud.iot.v1.DeviceConfig}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.modify_cloud_to_device_config.js - * region_tag:cloudiot_v1_generated_DeviceManager_ModifyCloudToDeviceConfig_async - */ - modifyCloudToDeviceConfig( - request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined - ]>; - modifyCloudToDeviceConfig( - request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): void; - modifyCloudToDeviceConfig( - request: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - callback: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): void; - modifyCloudToDeviceConfig( - request?: protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceConfig, - protos.google.cloud.iot.v1.IModifyCloudToDeviceConfigRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.modifyCloudToDeviceConfig(request, options, callback); - } -/** - * Lists the last few versions of the device configuration in descending - * order (i.e.: newest first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.numVersions - * The number of versions to list. Versions are listed in decreasing order of - * the version number. The maximum number of versions retained is 10. If this - * value is zero, it will return all the versions available. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListDeviceConfigVersionsResponse]{@link google.cloud.iot.v1.ListDeviceConfigVersionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_device_config_versions.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceConfigVersions_async - */ - listDeviceConfigVersions( - request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined - ]>; - listDeviceConfigVersions( - request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): void; - listDeviceConfigVersions( - request: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): void; - listDeviceConfigVersions( - request?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse, - protos.google.cloud.iot.v1.IListDeviceConfigVersionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.listDeviceConfigVersions(request, options, callback); - } -/** - * Lists the last few versions of the device state in descending order (i.e.: - * newest first). - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {number} request.numStates - * The number of states to list. States are listed in descending order of - * update time. The maximum number of states retained is 10. If this - * value is zero, it will return all the states available. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListDeviceStatesResponse]{@link google.cloud.iot.v1.ListDeviceStatesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_device_states.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceStates_async - */ - listDeviceStates( - request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined - ]>; - listDeviceStates( - request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): void; - listDeviceStates( - request: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - callback: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): void; - listDeviceStates( - request?: protos.google.cloud.iot.v1.IListDeviceStatesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IListDeviceStatesResponse, - protos.google.cloud.iot.v1.IListDeviceStatesRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.listDeviceStates(request, options, callback); - } -/** - * Sets the access control policy on the specified resource. Replaces any - * existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {google.protobuf.FieldMask} request.updateMask - * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only - * the fields in the mask will be modified. If no mask is provided, the - * following default mask is used: - * - * `paths: "bindings, etag"` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.set_iam_policy.js - * region_tag:cloudiot_v1_generated_DeviceManager_SetIamPolicy_async - */ - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.setIamPolicy(request, options, callback); - } -/** - * Gets the access control policy for a resource. - * Returns an empty policy if the resource exists and does not have a policy - * set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.get_iam_policy.js - * region_tag:cloudiot_v1_generated_DeviceManager_GetIamPolicy_async - */ - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; - getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.getIamPolicy(request, options, callback); - } -/** - * Returns permissions that a caller has on the specified resource. - * If the resource does not exist, this will return an empty set of - * permissions, not a NOT_FOUND error. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.test_iam_permissions.js - * region_tag:cloudiot_v1_generated_DeviceManager_TestIamPermissions_async - */ - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; - testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); - this.initialize(); - return this.innerApiCalls.testIamPermissions(request, options, callback); - } -/** - * Sends a command to the specified device. In order for a device to be able - * to receive commands, it must: - * 1) be connected to Cloud IoT Core using the MQTT protocol, and - * 2) be subscribed to the group of MQTT topics specified by - * /devices/{device-id}/commands/#. This subscription will receive commands - * at the top-level topic /devices/{device-id}/commands as well as commands - * for subfolders, like /devices/{device-id}/commands/subfolder. - * Note that subscribing to specific subfolders is not supported. - * If the command could not be delivered to the device, this method will - * return an error; in particular, if the device is not subscribed, this - * method will return FAILED_PRECONDITION. Otherwise, this method will - * return OK. If the subscription is QoS 1, at least once delivery will be - * guaranteed; for QoS 0, no acknowledgment will be expected from the device. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The name of the device. For example, - * `projects/p0/locations/us-central1/registries/registry0/devices/device0` or - * `projects/p0/locations/us-central1/registries/registry0/devices/{num_id}`. - * @param {Buffer} request.binaryData - * Required. The command data to send to the device. - * @param {string} request.subfolder - * 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. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [SendCommandToDeviceResponse]{@link google.cloud.iot.v1.SendCommandToDeviceResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.send_command_to_device.js - * region_tag:cloudiot_v1_generated_DeviceManager_SendCommandToDevice_async - */ - sendCommandToDevice( - request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined - ]>; - sendCommandToDevice( - request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): void; - sendCommandToDevice( - request: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - callback: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): void; - sendCommandToDevice( - request?: protos.google.cloud.iot.v1.ISendCommandToDeviceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.ISendCommandToDeviceResponse, - protos.google.cloud.iot.v1.ISendCommandToDeviceRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'name': request.name || '', - }); - this.initialize(); - return this.innerApiCalls.sendCommandToDevice(request, options, callback); - } -/** - * Associates the device with the gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {string} request.gatewayId - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param {string} request.deviceId - * Required. The device to associate with the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [BindDeviceToGatewayResponse]{@link google.cloud.iot.v1.BindDeviceToGatewayResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.bind_device_to_gateway.js - * region_tag:cloudiot_v1_generated_DeviceManager_BindDeviceToGateway_async - */ - bindDeviceToGateway( - request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined - ]>; - bindDeviceToGateway( - request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): void; - bindDeviceToGateway( - request: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - callback: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): void; - bindDeviceToGateway( - request?: protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse, - protos.google.cloud.iot.v1.IBindDeviceToGatewayRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.bindDeviceToGateway(request, options, callback); - } -/** - * Deletes the association between the device and the gateway. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the registry. For example, - * `projects/example-project/locations/us-central1/registries/my-registry`. - * @param {string} request.gatewayId - * Required. The value of `gateway_id` can be either the device numeric ID or the - * user-defined device identifier. - * @param {string} request.deviceId - * Required. The device to disassociate from the specified gateway. The value of - * `device_id` can be either the device numeric ID or the user-defined device - * identifier. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [UnbindDeviceFromGatewayResponse]{@link google.cloud.iot.v1.UnbindDeviceFromGatewayResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.unbind_device_from_gateway.js - * region_tag:cloudiot_v1_generated_DeviceManager_UnbindDeviceFromGateway_async - */ - unbindDeviceFromGateway( - request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined - ]>; - unbindDeviceFromGateway( - request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - options: CallOptions, - callback: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): void; - unbindDeviceFromGateway( - request: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - callback: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): void; - unbindDeviceFromGateway( - request?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse, - protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.unbindDeviceFromGateway(request, options, callback); - } - - /** - * Lists device registries. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDeviceRegistriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDeviceRegistries( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry[], - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse - ]>; - listDeviceRegistries( - request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): void; - listDeviceRegistries( - request: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): void; - listDeviceRegistries( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>, - callback?: PaginationCallback< - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse|null|undefined, - protos.google.cloud.iot.v1.IDeviceRegistry>): - Promise<[ - protos.google.cloud.iot.v1.IDeviceRegistry[], - protos.google.cloud.iot.v1.IListDeviceRegistriesRequest|null, - protos.google.cloud.iot.v1.IListDeviceRegistriesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listDeviceRegistries(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDeviceRegistriesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDeviceRegistriesStream( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDeviceRegistries']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDeviceRegistries.createStream( - this.innerApiCalls.listDeviceRegistries as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDeviceRegistries`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The project and cloud region path. For example, - * `projects/example-project/locations/us-central1`. - * @param {number} request.pageSize - * The maximum number of registries to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDeviceRegistriesResponse`; indicates - * that this is a continuation of a prior `ListDeviceRegistries` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [DeviceRegistry]{@link google.cloud.iot.v1.DeviceRegistry}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_device_registries.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDeviceRegistries_async - */ - listDeviceRegistriesAsync( - request?: protos.google.cloud.iot.v1.IListDeviceRegistriesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDeviceRegistries']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDeviceRegistries.asyncIterate( - this.innerApiCalls['listDeviceRegistries'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - /** - * List devices in a device registry. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Device]{@link google.cloud.iot.v1.Device}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listDevicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDevices( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - Promise<[ - protos.google.cloud.iot.v1.IDevice[], - protos.google.cloud.iot.v1.IListDevicesRequest|null, - protos.google.cloud.iot.v1.IListDevicesResponse - ]>; - listDevices( - request: protos.google.cloud.iot.v1.IListDevicesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): void; - listDevices( - request: protos.google.cloud.iot.v1.IListDevicesRequest, - callback: PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): void; - listDevices( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>, - callback?: PaginationCallback< - protos.google.cloud.iot.v1.IListDevicesRequest, - protos.google.cloud.iot.v1.IListDevicesResponse|null|undefined, - protos.google.cloud.iot.v1.IDevice>): - Promise<[ - protos.google.cloud.iot.v1.IDevice[], - protos.google.cloud.iot.v1.IListDevicesRequest|null, - protos.google.cloud.iot.v1.IListDevicesResponse - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { - options = optionsOrCallback as CallOptions; - } - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - this.initialize(); - return this.innerApiCalls.listDevices(request, options, callback); - } - -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Device]{@link google.cloud.iot.v1.Device} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listDevicesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ - listDevicesStream( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - Transform{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDevices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDevices.createStream( - this.innerApiCalls.listDevices as gax.GaxCall, - request, - callSettings - ); - } - -/** - * Equivalent to `listDevices`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The device registry path. Required. For example, - * `projects/my-project/locations/us-central1/registries/my-registry`. - * @param {number[]} request.deviceNumIds - * A list of device numeric IDs. If empty, this field is ignored. Maximum - * IDs: 10,000. - * @param {string[]} request.deviceIds - * A list of device string IDs. For example, `['device0', 'device12']`. - * If empty, this field is ignored. Maximum IDs: 10,000 - * @param {google.protobuf.FieldMask} request.fieldMask - * The fields of the `Device` resource to be returned in the response. The - * fields `id` and `num_id` are always returned, along with any - * other fields specified in snake_case format, for example: - * `last_heartbeat_time`. - * @param {google.cloud.iot.v1.GatewayListOptions} request.gatewayListOptions - * Options related to gateways. - * @param {number} request.pageSize - * The maximum number of devices to return in the response. If this value - * is zero, the service will select a default size. A call may return fewer - * objects than requested. A non-empty `next_page_token` in the response - * indicates that more data is available. - * @param {string} request.pageToken - * The value returned by the last `ListDevicesResponse`; indicates - * that this is a continuation of a prior `ListDevices` call and - * the system should return the next page of data. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Object} - * An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Device]{@link google.cloud.iot.v1.Device}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v1/device_manager.list_devices.js - * region_tag:cloudiot_v1_generated_DeviceManager_ListDevices_async - */ - listDevicesAsync( - request?: protos.google.cloud.iot.v1.IListDevicesRequest, - options?: CallOptions): - AsyncIterable{ - request = request || {}; - options = options || {}; - options.otherArgs = options.otherArgs || {}; - options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'parent': request.parent || '', - }); - const defaultCallSettings = this._defaults['listDevices']; - const callSettings = defaultCallSettings.merge(options); - this.initialize(); - return this.descriptors.page.listDevices.asyncIterate( - this.innerApiCalls['listDevices'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - // -------------------- - // -- Path templates -- - // -------------------- - - /** - * Return a fully-qualified device resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} registry - * @param {string} device - * @returns {string} Resource name string. - */ - devicePath(project:string,location:string,registry:string,device:string) { - return this.pathTemplates.devicePathTemplate.render({ - project: project, - location: location, - registry: registry, - device: device, - }); - } - - /** - * Parse the project from Device resource. - * - * @param {string} deviceName - * A fully-qualified path representing Device resource. - * @returns {string} A string representing the project. - */ - matchProjectFromDeviceName(deviceName: string) { - return this.pathTemplates.devicePathTemplate.match(deviceName).project; - } - - /** - * Parse the location from Device resource. - * - * @param {string} deviceName - * A fully-qualified path representing Device resource. - * @returns {string} A string representing the location. - */ - matchLocationFromDeviceName(deviceName: string) { - return this.pathTemplates.devicePathTemplate.match(deviceName).location; - } - - /** - * Parse the registry from Device resource. - * - * @param {string} deviceName - * A fully-qualified path representing Device resource. - * @returns {string} A string representing the registry. - */ - matchRegistryFromDeviceName(deviceName: string) { - return this.pathTemplates.devicePathTemplate.match(deviceName).registry; - } - - /** - * Parse the device from Device resource. - * - * @param {string} deviceName - * A fully-qualified path representing Device resource. - * @returns {string} A string representing the device. - */ - matchDeviceFromDeviceName(deviceName: string) { - return this.pathTemplates.devicePathTemplate.match(deviceName).device; - } - - /** - * Return a fully-qualified location resource name string. - * - * @param {string} project - * @param {string} location - * @returns {string} Resource name string. - */ - locationPath(project:string,location:string) { - return this.pathTemplates.locationPathTemplate.render({ - project: project, - location: location, - }); - } - - /** - * Parse the project from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the project. - */ - matchProjectFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).project; - } - - /** - * Parse the location from Location resource. - * - * @param {string} locationName - * A fully-qualified path representing Location resource. - * @returns {string} A string representing the location. - */ - matchLocationFromLocationName(locationName: string) { - return this.pathTemplates.locationPathTemplate.match(locationName).location; - } - - /** - * Return a fully-qualified registry resource name string. - * - * @param {string} project - * @param {string} location - * @param {string} registry - * @returns {string} Resource name string. - */ - registryPath(project:string,location:string,registry:string) { - return this.pathTemplates.registryPathTemplate.render({ - project: project, - location: location, - registry: registry, - }); - } - - /** - * Parse the project from Registry resource. - * - * @param {string} registryName - * A fully-qualified path representing Registry resource. - * @returns {string} A string representing the project. - */ - matchProjectFromRegistryName(registryName: string) { - return this.pathTemplates.registryPathTemplate.match(registryName).project; - } - - /** - * Parse the location from Registry resource. - * - * @param {string} registryName - * A fully-qualified path representing Registry resource. - * @returns {string} A string representing the location. - */ - matchLocationFromRegistryName(registryName: string) { - return this.pathTemplates.registryPathTemplate.match(registryName).location; - } - - /** - * Parse the registry from Registry resource. - * - * @param {string} registryName - * A fully-qualified path representing Registry resource. - * @returns {string} A string representing the registry. - */ - matchRegistryFromRegistryName(registryName: string) { - return this.pathTemplates.registryPathTemplate.match(registryName).registry; - } - - /** - * Terminate the gRPC channel and close the client. - * - * The client will no longer be usable and all future behavior is undefined. - * @returns {Promise} A promise that resolves when the client is closed. - */ - close(): Promise { - if (this.deviceManagerStub && !this._terminated) { - return this.deviceManagerStub.then(stub => { - this._terminated = true; - stub.close(); - }); - } - return Promise.resolve(); - } -} diff --git a/owl-bot-staging/v1/src/v1/device_manager_client_config.json b/owl-bot-staging/v1/src/v1/device_manager_client_config.json deleted file mode 100644 index 5ded0fd1..00000000 --- a/owl-bot-staging/v1/src/v1/device_manager_client_config.json +++ /dev/null @@ -1,135 +0,0 @@ -{ - "interfaces": { - "google.cloud.iot.v1.DeviceManager": { - "retry_codes": { - "non_idempotent": [], - "idempotent": [ - "DEADLINE_EXCEEDED", - "UNAVAILABLE" - ], - "deadline_exceeded_resource_exhausted_unavailable": [ - "DEADLINE_EXCEEDED", - "RESOURCE_EXHAUSTED", - "UNAVAILABLE" - ] - }, - "retry_params": { - "default": { - "initial_retry_delay_millis": 100, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - }, - "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c": { - "initial_retry_delay_millis": 1000, - "retry_delay_multiplier": 1.3, - "max_retry_delay_millis": 60000, - "initial_rpc_timeout_millis": 60000, - "rpc_timeout_multiplier": 1, - "max_rpc_timeout_millis": 60000, - "total_timeout_millis": 600000 - } - }, - "methods": { - "CreateDeviceRegistry": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDeviceRegistry": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateDeviceRegistry": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteDeviceRegistry": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListDeviceRegistries": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "CreateDevice": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetDevice": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "UpdateDevice": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "DeleteDevice": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListDevices": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ModifyCloudToDeviceConfig": { - "timeout_millis": 120000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "ListDeviceConfigVersions": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "ListDeviceStates": { - "timeout_millis": 120000, - "retry_codes_name": "idempotent", - "retry_params_name": "default" - }, - "SetIamPolicy": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "GetIamPolicy": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "TestIamPermissions": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "SendCommandToDevice": { - "timeout_millis": 120000, - "retry_codes_name": "deadline_exceeded_resource_exhausted_unavailable", - "retry_params_name": "01d6d956b4dadd7e38ee9dec12ed8720e6e6f90c" - }, - "BindDeviceToGateway": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - }, - "UnbindDeviceFromGateway": { - "timeout_millis": 120000, - "retry_codes_name": "non_idempotent", - "retry_params_name": "default" - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/device_manager_proto_list.json b/owl-bot-staging/v1/src/v1/device_manager_proto_list.json deleted file mode 100644 index 95cf5597..00000000 --- a/owl-bot-staging/v1/src/v1/device_manager_proto_list.json +++ /dev/null @@ -1,4 +0,0 @@ -[ - "../../protos/google/cloud/iot/v1/device_manager.proto", - "../../protos/google/cloud/iot/v1/resources.proto" -] diff --git a/owl-bot-staging/v1/src/v1/gapic_metadata.json b/owl-bot-staging/v1/src/v1/gapic_metadata.json deleted file mode 100644 index 28ab3c5d..00000000 --- a/owl-bot-staging/v1/src/v1/gapic_metadata.json +++ /dev/null @@ -1,221 +0,0 @@ -{ - "schema": "1.0", - "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", - "language": "typescript", - "protoPackage": "google.cloud.iot.v1", - "libraryPackage": "@google-cloud/iot", - "services": { - "DeviceManager": { - "clients": { - "grpc": { - "libraryClient": "DeviceManagerClient", - "rpcs": { - "CreateDeviceRegistry": { - "methods": [ - "createDeviceRegistry" - ] - }, - "GetDeviceRegistry": { - "methods": [ - "getDeviceRegistry" - ] - }, - "UpdateDeviceRegistry": { - "methods": [ - "updateDeviceRegistry" - ] - }, - "DeleteDeviceRegistry": { - "methods": [ - "deleteDeviceRegistry" - ] - }, - "CreateDevice": { - "methods": [ - "createDevice" - ] - }, - "GetDevice": { - "methods": [ - "getDevice" - ] - }, - "UpdateDevice": { - "methods": [ - "updateDevice" - ] - }, - "DeleteDevice": { - "methods": [ - "deleteDevice" - ] - }, - "ModifyCloudToDeviceConfig": { - "methods": [ - "modifyCloudToDeviceConfig" - ] - }, - "ListDeviceConfigVersions": { - "methods": [ - "listDeviceConfigVersions" - ] - }, - "ListDeviceStates": { - "methods": [ - "listDeviceStates" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SendCommandToDevice": { - "methods": [ - "sendCommandToDevice" - ] - }, - "BindDeviceToGateway": { - "methods": [ - "bindDeviceToGateway" - ] - }, - "UnbindDeviceFromGateway": { - "methods": [ - "unbindDeviceFromGateway" - ] - }, - "ListDeviceRegistries": { - "methods": [ - "listDeviceRegistries", - "listDeviceRegistriesStream", - "listDeviceRegistriesAsync" - ] - }, - "ListDevices": { - "methods": [ - "listDevices", - "listDevicesStream", - "listDevicesAsync" - ] - } - } - }, - "grpc-fallback": { - "libraryClient": "DeviceManagerClient", - "rpcs": { - "CreateDeviceRegistry": { - "methods": [ - "createDeviceRegistry" - ] - }, - "GetDeviceRegistry": { - "methods": [ - "getDeviceRegistry" - ] - }, - "UpdateDeviceRegistry": { - "methods": [ - "updateDeviceRegistry" - ] - }, - "DeleteDeviceRegistry": { - "methods": [ - "deleteDeviceRegistry" - ] - }, - "CreateDevice": { - "methods": [ - "createDevice" - ] - }, - "GetDevice": { - "methods": [ - "getDevice" - ] - }, - "UpdateDevice": { - "methods": [ - "updateDevice" - ] - }, - "DeleteDevice": { - "methods": [ - "deleteDevice" - ] - }, - "ModifyCloudToDeviceConfig": { - "methods": [ - "modifyCloudToDeviceConfig" - ] - }, - "ListDeviceConfigVersions": { - "methods": [ - "listDeviceConfigVersions" - ] - }, - "ListDeviceStates": { - "methods": [ - "listDeviceStates" - ] - }, - "SetIamPolicy": { - "methods": [ - "setIamPolicy" - ] - }, - "GetIamPolicy": { - "methods": [ - "getIamPolicy" - ] - }, - "TestIamPermissions": { - "methods": [ - "testIamPermissions" - ] - }, - "SendCommandToDevice": { - "methods": [ - "sendCommandToDevice" - ] - }, - "BindDeviceToGateway": { - "methods": [ - "bindDeviceToGateway" - ] - }, - "UnbindDeviceFromGateway": { - "methods": [ - "unbindDeviceFromGateway" - ] - }, - "ListDeviceRegistries": { - "methods": [ - "listDeviceRegistries", - "listDeviceRegistriesStream", - "listDeviceRegistriesAsync" - ] - }, - "ListDevices": { - "methods": [ - "listDevices", - "listDevicesStream", - "listDevicesAsync" - ] - } - } - } - } - } - } -} diff --git a/owl-bot-staging/v1/src/v1/index.ts b/owl-bot-staging/v1/src/v1/index.ts deleted file mode 100644 index 49977b40..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -export {DeviceManagerClient} from './device_manager_client'; diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js deleted file mode 100644 index f71018b9..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - - -/* eslint-disable node/no-missing-require, no-unused-vars */ -const iot = require('@google-cloud/iot'); - -function main() { - const deviceManagerClient = new iot.DeviceManagerClient(); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts deleted file mode 100644 index 7b3c0747..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import {DeviceManagerClient} from '@google-cloud/iot'; - -// check that the client class type name can be used -function doStuffWithDeviceManagerClient(client: DeviceManagerClient) { - client.close(); -} - -function main() { - // check that the client instance can be created - const deviceManagerClient = new DeviceManagerClient(); - doStuffWithDeviceManagerClient(deviceManagerClient); -} - -main(); diff --git a/owl-bot-staging/v1/system-test/install.ts b/owl-bot-staging/v1/system-test/install.ts deleted file mode 100644 index 8ec45222..00000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import { packNTest } from 'pack-n-play'; -import { readFileSync } from 'fs'; -import { describe, it } from 'mocha'; - -describe('📦 pack-n-play test', () => { - - it('TypeScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'TypeScript user can use the type definitions', - ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() - } - }; - await packNTest(options); - }); - - it('JavaScript code', async function() { - this.timeout(300000); - const options = { - packageDir: process.cwd(), - sample: { - description: 'JavaScript user can use the library', - ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() - } - }; - await packNTest(options); - }); - -}); diff --git a/owl-bot-staging/v1/test/gapic_device_manager_v1.ts b/owl-bot-staging/v1/test/gapic_device_manager_v1.ts deleted file mode 100644 index f20565b8..00000000 --- a/owl-bot-staging/v1/test/gapic_device_manager_v1.ts +++ /dev/null @@ -1,2426 +0,0 @@ -// 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 -// -// https://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. -// -// ** This file is automatically generated by gapic-generator-typescript. ** -// ** https://github.com/googleapis/gapic-generator-typescript ** -// ** All changes to this file may be overwritten. ** - -import * as protos from '../protos/protos'; -import * as assert from 'assert'; -import * as sinon from 'sinon'; -import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; -import * as devicemanagerModule from '../src'; - -import {PassThrough} from 'stream'; - -import {protobuf} from 'google-gax'; - -function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; -} - -function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); -} - -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); -} - -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } - } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); - } - return sinon.stub().returns(mockStream); -} - -function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { - let counter = 0; - const asyncIterable = { - [Symbol.asyncIterator]() { - return { - async next() { - if (error) { - return Promise.reject(error); - } - if (counter >= responses!.length) { - return Promise.resolve({done: true, value: undefined}); - } - return Promise.resolve({done: false, value: responses![counter++]}); - } - }; - } - }; - return sinon.stub().returns(asyncIterable); -} - -describe('v1.DeviceManagerClient', () => { - it('has servicePath', () => { - const servicePath = devicemanagerModule.v1.DeviceManagerClient.servicePath; - assert(servicePath); - }); - - it('has apiEndpoint', () => { - const apiEndpoint = devicemanagerModule.v1.DeviceManagerClient.apiEndpoint; - assert(apiEndpoint); - }); - - it('has port', () => { - const port = devicemanagerModule.v1.DeviceManagerClient.port; - assert(port); - assert(typeof port === 'number'); - }); - - it('should create a client with no option', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient(); - assert(client); - }); - - it('should create a client with gRPC fallback', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - fallback: true, - }); - assert(client); - }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.deviceManagerStub, undefined); - await client.initialize(); - assert(client.deviceManagerStub); - }); - - it('has close method for the initialized client', done => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.deviceManagerStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.deviceManagerStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('createDeviceRegistry', () => { - it('invokes createDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.createDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.createDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.createDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDeviceRegistry(request), expectedError); - assert((client.innerApiCalls.createDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRegistryRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDeviceRegistry(request), expectedError); - }); - }); - - describe('getDeviceRegistry', () => { - it('invokes getDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.getDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.getDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.getDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDeviceRegistry(request), expectedError); - assert((client.innerApiCalls.getDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRegistryRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDeviceRegistry(request), expectedError); - }); - }); - - describe('updateDeviceRegistry', () => { - it('invokes updateDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); - request.deviceRegistry = {}; - request.deviceRegistry.name = ''; - const expectedHeaderRequestParams = "device_registry.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.updateDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); - request.deviceRegistry = {}; - request.deviceRegistry.name = ''; - const expectedHeaderRequestParams = "device_registry.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); - request.deviceRegistry = {}; - request.deviceRegistry.name = ''; - const expectedHeaderRequestParams = "device_registry.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDeviceRegistry(request), expectedError); - assert((client.innerApiCalls.updateDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRegistryRequest()); - request.deviceRegistry = {}; - request.deviceRegistry.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDeviceRegistry(request), expectedError); - }); - }); - - describe('deleteDeviceRegistry', () => { - it('invokes deleteDeviceRegistry without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDeviceRegistry(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDeviceRegistry without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDeviceRegistry( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteDeviceRegistry with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDeviceRegistry = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDeviceRegistry(request), expectedError); - assert((client.innerApiCalls.deleteDeviceRegistry as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDeviceRegistry with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRegistryRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDeviceRegistry(request), expectedError); - }); - }); - - describe('createDevice', () => { - it('invokes createDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.createDevice = stubSimpleCall(expectedResponse); - const [response] = await client.createDevice(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.createDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createDevice(request), expectedError); - assert((client.innerApiCalls.createDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.CreateDeviceRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createDevice(request), expectedError); - }); - }); - - describe('getDevice', () => { - it('invokes getDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.getDevice = stubSimpleCall(expectedResponse); - const [response] = await client.getDevice(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.getDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getDevice(request), expectedError); - assert((client.innerApiCalls.getDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.GetDeviceRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getDevice(request), expectedError); - }); - }); - - describe('updateDevice', () => { - it('invokes updateDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); - request.device = {}; - request.device.name = ''; - const expectedHeaderRequestParams = "device.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.updateDevice = stubSimpleCall(expectedResponse); - const [response] = await client.updateDevice(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); - request.device = {}; - request.device.name = ''; - const expectedHeaderRequestParams = "device.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.Device()); - client.innerApiCalls.updateDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); - request.device = {}; - request.device.name = ''; - const expectedHeaderRequestParams = "device.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateDevice(request), expectedError); - assert((client.innerApiCalls.updateDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UpdateDeviceRequest()); - request.device = {}; - request.device.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateDevice(request), expectedError); - }); - }); - - describe('deleteDevice', () => { - it('invokes deleteDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDevice = stubSimpleCall(expectedResponse); - const [response] = await client.deleteDevice(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteDevice( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteDevice(request), expectedError); - assert((client.innerApiCalls.deleteDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.DeleteDeviceRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteDevice(request), expectedError); - }); - }); - - describe('modifyCloudToDeviceConfig', () => { - it('invokes modifyCloudToDeviceConfig without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceConfig()); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(expectedResponse); - const [response] = await client.modifyCloudToDeviceConfig(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes modifyCloudToDeviceConfig without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.DeviceConfig()); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.modifyCloudToDeviceConfig( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceConfig|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes modifyCloudToDeviceConfig with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.modifyCloudToDeviceConfig = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); - assert((client.innerApiCalls.modifyCloudToDeviceConfig as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes modifyCloudToDeviceConfig with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ModifyCloudToDeviceConfigRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.modifyCloudToDeviceConfig(request), expectedError); - }); - }); - - describe('listDeviceConfigVersions', () => { - it('invokes listDeviceConfigVersions without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse()); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceConfigVersions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceConfigVersions without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsResponse()); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceConfigVersions( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceConfigVersionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDeviceConfigVersions with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceConfigVersions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceConfigVersions(request), expectedError); - assert((client.innerApiCalls.listDeviceConfigVersions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceConfigVersions with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceConfigVersionsRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listDeviceConfigVersions(request), expectedError); - }); - }); - - describe('listDeviceStates', () => { - it('invokes listDeviceStates without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesResponse()); - client.innerApiCalls.listDeviceStates = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceStates(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceStates without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesResponse()); - client.innerApiCalls.listDeviceStates = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceStates( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IListDeviceStatesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDeviceStates with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceStates = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceStates(request), expectedError); - assert((client.innerApiCalls.listDeviceStates as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceStates with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceStatesRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listDeviceStates(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('sendCommandToDevice', () => { - it('invokes sendCommandToDevice without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceResponse()); - client.innerApiCalls.sendCommandToDevice = stubSimpleCall(expectedResponse); - const [response] = await client.sendCommandToDevice(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes sendCommandToDevice without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceResponse()); - client.innerApiCalls.sendCommandToDevice = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.sendCommandToDevice( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.ISendCommandToDeviceResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes sendCommandToDevice with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.sendCommandToDevice = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.sendCommandToDevice(request), expectedError); - assert((client.innerApiCalls.sendCommandToDevice as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes sendCommandToDevice with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.SendCommandToDeviceRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.sendCommandToDevice(request), expectedError); - }); - }); - - describe('bindDeviceToGateway', () => { - it('invokes bindDeviceToGateway without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse()); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(expectedResponse); - const [response] = await client.bindDeviceToGateway(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes bindDeviceToGateway without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayResponse()); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.bindDeviceToGateway( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IBindDeviceToGatewayResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes bindDeviceToGateway with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.bindDeviceToGateway = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.bindDeviceToGateway(request), expectedError); - assert((client.innerApiCalls.bindDeviceToGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes bindDeviceToGateway with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.BindDeviceToGatewayRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.bindDeviceToGateway(request), expectedError); - }); - }); - - describe('unbindDeviceFromGateway', () => { - it('invokes unbindDeviceFromGateway without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse()); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(expectedResponse); - const [response] = await client.unbindDeviceFromGateway(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes unbindDeviceFromGateway without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayResponse()); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.unbindDeviceFromGateway( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IUnbindDeviceFromGatewayResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes unbindDeviceFromGateway with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.unbindDeviceFromGateway = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); - assert((client.innerApiCalls.unbindDeviceFromGateway as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes unbindDeviceFromGateway with closed client', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.UnbindDeviceFromGatewayRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.unbindDeviceFromGateway(request), expectedError); - }); - }); - - describe('listDeviceRegistries', () => { - it('invokes listDeviceRegistries without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.innerApiCalls.listDeviceRegistries = stubSimpleCall(expectedResponse); - const [response] = await client.listDeviceRegistries(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceRegistries without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.innerApiCalls.listDeviceRegistries = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDeviceRegistries( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDeviceRegistry[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDeviceRegistries with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDeviceRegistries = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDeviceRegistries(request), expectedError); - assert((client.innerApiCalls.listDeviceRegistries as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDeviceRegistriesStream without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDeviceRegistriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); - assert.strictEqual( - (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listDeviceRegistriesStream with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listDeviceRegistries.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDeviceRegistriesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.DeviceRegistry[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.DeviceRegistry) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDeviceRegistries, request)); - assert.strictEqual( - (client.descriptors.page.listDeviceRegistries.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDeviceRegistries without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - generateSampleMessage(new protos.google.cloud.iot.v1.DeviceRegistry()), - ]; - client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; - const iterable = client.listDeviceRegistriesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDeviceRegistries with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDeviceRegistriesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listDeviceRegistries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDeviceRegistriesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iot.v1.IDeviceRegistry[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDeviceRegistries.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listDevices', () => { - it('invokes listDevices without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.innerApiCalls.listDevices = stubSimpleCall(expectedResponse); - const [response] = await client.listDevices(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDevices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDevices without error using callback', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.innerApiCalls.listDevices = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listDevices( - request, - (err?: Error|null, result?: protos.google.cloud.iot.v1.IDevice[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listDevices as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listDevices with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listDevices = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listDevices(request), expectedError); - assert((client.innerApiCalls.listDevices as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listDevicesStream without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.descriptors.page.listDevices.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listDevicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.Device[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); - assert.strictEqual( - (client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listDevicesStream with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listDevices.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listDevicesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.cloud.iot.v1.Device[] = []; - stream.on('data', (response: protos.google.cloud.iot.v1.Device) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listDevices, request)); - assert.strictEqual( - (client.descriptors.page.listDevices.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDevices without error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - generateSampleMessage(new protos.google.cloud.iot.v1.Device()), - ]; - client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.cloud.iot.v1.IDevice[] = []; - const iterable = client.listDevicesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); - } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listDevices with error', async () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.cloud.iot.v1.ListDevicesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listDevices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listDevicesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.cloud.iot.v1.IDevice[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listDevices.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('Path templates', () => { - - describe('device', () => { - const fakePath = "/rendered/path/device"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - registry: "registryValue", - device: "deviceValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.devicePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.devicePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('devicePath', () => { - const result = client.devicePath("projectValue", "locationValue", "registryValue", "deviceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.devicePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromDeviceName', () => { - const result = client.matchProjectFromDeviceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromDeviceName', () => { - const result = client.matchLocationFromDeviceName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegistryFromDeviceName', () => { - const result = client.matchRegistryFromDeviceName(fakePath); - assert.strictEqual(result, "registryValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchDeviceFromDeviceName', () => { - const result = client.matchDeviceFromDeviceName(fakePath); - assert.strictEqual(result, "deviceValue"); - assert((client.pathTemplates.devicePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('location', () => { - const fakePath = "/rendered/path/location"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.locationPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.locationPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('locationPath', () => { - const result = client.locationPath("projectValue", "locationValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.locationPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromLocationName', () => { - const result = client.matchProjectFromLocationName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromLocationName', () => { - const result = client.matchLocationFromLocationName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.locationPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('registry', () => { - const fakePath = "/rendered/path/registry"; - const expectedParameters = { - project: "projectValue", - location: "locationValue", - registry: "registryValue", - }; - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.registryPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.registryPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('registryPath', () => { - const result = client.registryPath("projectValue", "locationValue", "registryValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.registryPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromRegistryName', () => { - const result = client.matchProjectFromRegistryName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchLocationFromRegistryName', () => { - const result = client.matchLocationFromRegistryName(fakePath); - assert.strictEqual(result, "locationValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchRegistryFromRegistryName', () => { - const result = client.matchRegistryFromRegistryName(fakePath); - assert.strictEqual(result, "registryValue"); - assert((client.pathTemplates.registryPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - }); -}); diff --git a/owl-bot-staging/v1/tsconfig.json b/owl-bot-staging/v1/tsconfig.json deleted file mode 100644 index c78f1c88..00000000 --- a/owl-bot-staging/v1/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "./node_modules/gts/tsconfig-google.json", - "compilerOptions": { - "rootDir": ".", - "outDir": "build", - "resolveJsonModule": true, - "lib": [ - "es2018", - "dom" - ] - }, - "include": [ - "src/*.ts", - "src/**/*.ts", - "test/*.ts", - "test/**/*.ts", - "system-test/*.ts" - ] -} diff --git a/owl-bot-staging/v1/webpack.config.js b/owl-bot-staging/v1/webpack.config.js deleted file mode 100644 index 7f6d8159..00000000 --- a/owl-bot-staging/v1/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -// 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 -// -// https://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. - -const path = require('path'); - -module.exports = { - entry: './src/index.ts', - output: { - library: 'iot', - filename: './iot.js', - }, - node: { - child_process: 'empty', - fs: 'empty', - crypto: 'empty', - }, - resolve: { - alias: { - '../../../package.json': path.resolve(__dirname, 'package.json'), - }, - extensions: ['.js', '.json', '.ts'], - }, - module: { - rules: [ - { - test: /\.tsx?$/, - use: 'ts-loader', - exclude: /node_modules/ - }, - { - test: /node_modules[\\/]@grpc[\\/]grpc-js/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]grpc/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]retry-request/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]https?-proxy-agent/, - use: 'null-loader' - }, - { - test: /node_modules[\\/]gtoken/, - use: 'null-loader' - }, - ], - }, - mode: 'production', -}; diff --git a/samples/generated/v1/device_manager.get_iam_policy.js b/samples/generated/v1/device_manager.get_iam_policy.js index 2bbdc4c5..039b3941 100644 --- a/samples/generated/v1/device_manager.get_iam_policy.js +++ b/samples/generated/v1/device_manager.get_iam_policy.js @@ -32,7 +32,7 @@ function main(resource) { // const resource = 'abc123' /** * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. + * `GetIamPolicy`. */ // const options = {} diff --git a/samples/generated/v1/device_manager.set_iam_policy.js b/samples/generated/v1/device_manager.set_iam_policy.js index 69a8c763..05ba74e3 100644 --- a/samples/generated/v1/device_manager.set_iam_policy.js +++ b/samples/generated/v1/device_manager.set_iam_policy.js @@ -37,6 +37,13 @@ function main(resource, policy) { * might reject them. */ // const policy = {} + /** + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * `paths: "bindings, etag"` + */ + // const updateMask = {} // Imports the Iot library const {DeviceManagerClient} = require('@google-cloud/iot').v1; diff --git a/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json b/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json index 74f68c7c..f70dc8b9 100644 --- a/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json +++ b/samples/generated/v1/snippet_metadata.google.cloud.iot.v1.json @@ -610,7 +610,7 @@ "segments": [ { "start": 25, - "end": 59, + "end": 66, "type": "FULL" } ], @@ -626,6 +626,10 @@ { "name": "policy", "type": ".google.iam.v1.Policy" + }, + { + "name": "update_mask", + "type": ".google.protobuf.FieldMask" } ], "resultType": ".google.iam.v1.Policy", diff --git a/src/v1/device_manager_client.ts b/src/v1/device_manager_client.ts index c22f5c4a..b73c1164 100644 --- a/src/v1/device_manager_client.ts +++ b/src/v1/device_manager_client.ts @@ -1387,6 +1387,12 @@ export class DeviceManagerClient { * the policy is limited to a few 10s of KB. An empty policy is a * valid policy but certain Cloud Platform services (such as Projects) * might reject them. + * @param {google.protobuf.FieldMask} request.updateMask + * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only + * the fields in the mask will be modified. If no mask is provided, the + * following default mask is used: + * + * `paths: "bindings, etag"` * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -1475,7 +1481,7 @@ export class DeviceManagerClient { * See the operation documentation for the appropriate value for this field. * @param {google.iam.v1.GetPolicyOptions} request.options * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. + * `GetIamPolicy`. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array.