From f7c760bcb6c8fdbdc64bb5309a07864501de6b19 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 25 May 2021 19:58:17 +0000 Subject: [PATCH 1/2] fix: GoogleAdsError missing using generator version after 1.3.0 [PR](https://github.com/googleapis/gapic-generator-typescript/pull/878) within updated gapic-generator-typescript version 1.4.0 Committer: @summer-ji-eng PiperOrigin-RevId: 375759421 Source-Link: https://github.com/googleapis/googleapis/commit/95fa72fdd0d69b02d72c33b37d1e4cc66d4b1446 Source-Link: https://github.com/googleapis/googleapis-gen/commit/f40a34377ad488a7c2bc3992b3c8d5faf5a15c46 --- owl-bot-staging/v1/README.md | 1 + owl-bot-staging/v1/linkinator.config.json | 10 + owl-bot-staging/v1/package.json | 64 + .../google/cloud/iot/v1/device_manager.proto | 652 +++++ .../google/cloud/iot/v1/resources.proto | 483 ++++ owl-bot-staging/v1/src/index.ts | 25 + .../v1/src/v1/device_manager_client.ts | 2216 +++++++++++++++++ .../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 | 2186 ++++++++++++++++ owl-bot-staging/v1/tsconfig.json | 19 + owl-bot-staging/v1/webpack.config.js | 64 + 17 files changed, 6207 insertions(+) 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/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/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..29a223b6 --- /dev/null +++ b/owl-bot-staging/v1/linkinator.config.json @@ -0,0 +1,10 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ], + "silent": true, + "concurrency": 10 +} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json new file mode 100644 index 00000000..50af08b5 --- /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.14.0" + }, + "devDependencies": { + "@types/mocha": "^8.2.2", + "@types/node": "^14.17.1", + "@types/sinon": "^10.0.0", + "c8": "^7.7.2", + "gts": "^3.1.0", + "jsdoc": "^3.6.7", + "jsdoc-fresh": "^1.0.2", + "jsdoc-region-tag": "^1.0.6", + "linkinator": "^2.13.6", + "mocha": "^8.4.0", + "null-loader": "^4.0.1", + "pack-n-play": "^1.0.0-2", + "sinon": "^10.0.0", + "ts-loader": "^9.2.2", + "typescript": "^4.2.4", + "webpack": "^5.37.1", + "webpack-cli": "^4.7.0" + }, + "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/src/index.ts b/owl-bot-staging/v1/src/index.ts new file mode 100644 index 00000000..3ad68358 --- /dev/null +++ b/owl-bot-staging/v1/src/index.ts @@ -0,0 +1,25 @@ +// 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. +// +// ** 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..1fca0179 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/device_manager_client.ts @@ -0,0 +1,2216 @@ +// 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. +// +// ** 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 _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: {}, + }; + 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; + 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 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 = {}; + } + + /** + * 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) 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 -- + // ------------------- + 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; +/** + * 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 + * const [response] = await client.createDeviceRegistry(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.getDeviceRegistry(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.updateDeviceRegistry(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.deleteDeviceRegistry(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.createDevice(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.getDevice(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.updateDevice(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.deleteDevice(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.modifyCloudToDeviceConfig(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.listDeviceConfigVersions(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.listDeviceStates(request); + */ + 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); + } + 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; +/** + * 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 {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 + * const [response] = await client.setIamPolicy(request); + */ + 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); + } + 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; +/** + * 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`. This field is only used by Cloud IAM. + * @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 + * const [response] = await client.getIamPolicy(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.testIamPermissions(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.sendCommandToDevice(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.bindDeviceToGateway(request); + */ + 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); + } + 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; +/** + * 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 + * const [response] = await client.unbindDeviceFromGateway(request); + */ + 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); + } + + 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; +/** + * 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, + 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 callSettings = new gax.CallSettings(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 + * const iterable = client.listDeviceRegistriesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + 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 || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listDeviceRegistries.asyncIterate( + this.innerApiCalls['listDeviceRegistries'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + 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; +/** + * 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, + 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 callSettings = new gax.CallSettings(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 + * const iterable = client.listDevicesAsync(request); + * for await (const response of iterable) { + * // process response + * } + */ + 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 || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(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 { + this.initialize(); + if (!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..803202a8 --- /dev/null +++ b/owl-bot-staging/v1/src/v1/index.ts @@ -0,0 +1,19 @@ +// 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. +// +// ** 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..17fe0e4c --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// 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. +// +// ** 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..67aa27d2 --- /dev/null +++ b/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// 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. +// +// ** 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..1f850b52 --- /dev/null +++ b/owl-bot-staging/v1/system-test/install.ts @@ -0,0 +1,49 @@ +// 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. +// +// ** 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..2d654312 --- /dev/null +++ b/owl-bot-staging/v1/test/gapic_device_manager_v1.ts @@ -0,0 +1,2186 @@ +// 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. +// +// ** 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', () => { + const client = new devicemanagerModule.v1.DeviceManagerClient({ + credentials: { client_email: 'bogus', private_key: 'bogus' }, + projectId: 'bogus', + }); + client.close(); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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)); + }); + }); + + 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 ce0255d3d22116d3b7589f63bfe5afc4de8e789c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Tue, 25 May 2021 19:59:18 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- owl-bot-staging/v1/README.md | 1 - owl-bot-staging/v1/linkinator.config.json | 10 - owl-bot-staging/v1/package.json | 64 - .../google/cloud/iot/v1/device_manager.proto | 652 ----- .../google/cloud/iot/v1/resources.proto | 483 ---- owl-bot-staging/v1/src/index.ts | 25 - .../v1/src/v1/device_manager_client.ts | 2216 ----------------- .../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 | 2186 ---------------- owl-bot-staging/v1/tsconfig.json | 19 - owl-bot-staging/v1/webpack.config.js | 64 - src/v1/device_manager_client.ts | 2 + 18 files changed, 2 insertions(+), 6207 deletions(-) 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/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/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 29a223b6..00000000 --- a/owl-bot-staging/v1/linkinator.config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "recurse": true, - "skip": [ - "https://codecov.io/gh/googleapis/", - "www.googleapis.com", - "img.shields.io" - ], - "silent": true, - "concurrency": 10 -} diff --git a/owl-bot-staging/v1/package.json b/owl-bot-staging/v1/package.json deleted file mode 100644 index 50af08b5..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.14.0" - }, - "devDependencies": { - "@types/mocha": "^8.2.2", - "@types/node": "^14.17.1", - "@types/sinon": "^10.0.0", - "c8": "^7.7.2", - "gts": "^3.1.0", - "jsdoc": "^3.6.7", - "jsdoc-fresh": "^1.0.2", - "jsdoc-region-tag": "^1.0.6", - "linkinator": "^2.13.6", - "mocha": "^8.4.0", - "null-loader": "^4.0.1", - "pack-n-play": "^1.0.0-2", - "sinon": "^10.0.0", - "ts-loader": "^9.2.2", - "typescript": "^4.2.4", - "webpack": "^5.37.1", - "webpack-cli": "^4.7.0" - }, - "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/src/index.ts b/owl-bot-staging/v1/src/index.ts deleted file mode 100644 index 3ad68358..00000000 --- a/owl-bot-staging/v1/src/index.ts +++ /dev/null @@ -1,25 +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. -// -// ** 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 1fca0179..00000000 --- a/owl-bot-staging/v1/src/v1/device_manager_client.ts +++ /dev/null @@ -1,2216 +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. -// -// ** 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 _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: {}, - }; - 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; - 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 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 = {}; - } - - /** - * 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) 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 -- - // ------------------- - 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; -/** - * 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 - * const [response] = await client.createDeviceRegistry(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.getDeviceRegistry(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.updateDeviceRegistry(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.deleteDeviceRegistry(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.createDevice(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.getDevice(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.updateDevice(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.deleteDevice(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.modifyCloudToDeviceConfig(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.listDeviceConfigVersions(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.listDeviceStates(request); - */ - 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); - } - 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; -/** - * 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 {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 - * const [response] = await client.setIamPolicy(request); - */ - 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); - } - 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; -/** - * 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`. This field is only used by Cloud IAM. - * @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 - * const [response] = await client.getIamPolicy(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.testIamPermissions(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.sendCommandToDevice(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.bindDeviceToGateway(request); - */ - 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); - } - 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; -/** - * 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 - * const [response] = await client.unbindDeviceFromGateway(request); - */ - 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); - } - - 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; -/** - * 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, - 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 callSettings = new gax.CallSettings(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 - * const iterable = client.listDeviceRegistriesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - 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 || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(options); - this.initialize(); - return this.descriptors.page.listDeviceRegistries.asyncIterate( - this.innerApiCalls['listDeviceRegistries'] as GaxCall, - request as unknown as RequestType, - callSettings - ) as AsyncIterable; - } - 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; -/** - * 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, - 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 callSettings = new gax.CallSettings(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 - * const iterable = client.listDevicesAsync(request); - * for await (const response of iterable) { - * // process response - * } - */ - 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 || '', - }); - options = options || {}; - const callSettings = new gax.CallSettings(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 { - this.initialize(); - if (!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 803202a8..00000000 --- a/owl-bot-staging/v1/src/v1/index.ts +++ /dev/null @@ -1,19 +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. -// -// ** 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 17fe0e4c..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.js +++ /dev/null @@ -1,27 +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. -// -// ** 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 67aa27d2..00000000 --- a/owl-bot-staging/v1/system-test/fixtures/sample/src/index.ts +++ /dev/null @@ -1,32 +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. -// -// ** 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 1f850b52..00000000 --- a/owl-bot-staging/v1/system-test/install.ts +++ /dev/null @@ -1,49 +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. -// -// ** 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 2d654312..00000000 --- a/owl-bot-staging/v1/test/gapic_device_manager_v1.ts +++ /dev/null @@ -1,2186 +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. -// -// ** 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', () => { - const client = new devicemanagerModule.v1.DeviceManagerClient({ - credentials: { client_email: 'bogus', private_key: 'bogus' }, - projectId: 'bogus', - }); - client.close(); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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)); - }); - }); - - 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/src/v1/device_manager_client.ts b/src/v1/device_manager_client.ts index e1edb6e9..008a8d9e 100644 --- a/src/v1/device_manager_client.ts +++ b/src/v1/device_manager_client.ts @@ -140,6 +140,8 @@ export class DeviceManagerClient { } 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}`);