How to use @google-cloud/iot - 4 common examples

To help you get started, we’ve selected a few @google-cloud/iot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-iot / samples / quickstart.js View on Github external
async function main() {
  // [START iot_quickstart]
  const iot = require('@google-cloud/iot');
  const client = new iot.v1.DeviceManagerClient();

  async function quickstart() {
    const projectId = await client.getProjectId();
    const parent = client.locationPath(projectId, 'us-central1');
    const [resources] = await client.listDeviceRegistries({parent});
    console.log(`${resources.length} resource(s) found.`);
    for (const resource of resources) {
      console.log(resource);
    }
  }
  quickstart();
  // [END iot_quickstart]
}
main();
github GoogleCloudPlatform / community / tutorials / cloud-iot-firestore-config / functions / src / index.ts View on Github external
#   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.
*/
'use strict';

import cbor = require('cbor');

import * as admin from "firebase-admin";
import * as functions from 'firebase-functions';
const iot = require('@google-cloud/iot');
const client = new iot.v1.DeviceManagerClient();

// start cloud function
exports.configUpdate = functions.firestore
  // assumes a document whose ID is the same as the deviceid
  .document('device-configs/{deviceId}')
  .onWrite(async (change: functions.Change, context?: functions.EventContext) => {
    if (context) {
      console.log(context.params.deviceId);
      const request = generateRequest(context.params.deviceId, change.after.data(), false);
      return client.modifyCloudToDeviceConfig(request);
    } else {
      throw(Error("no context from trigger"));
    }
  });

exports.configUpdateBinary = functions.firestore
github googleapis / nodejs-iot / system-test / fixtures / sample / src / index.ts View on Github external
function main() {
  const deviceManagerClient = new DeviceManagerClient();
}
github googleapis / nodejs-iot / system-test / fixtures / sample / src / index.js View on Github external
function main() {
  const deviceManagerClient = new iot.DeviceManagerClient();
}

@google-cloud/iot

Cloud IoT API client for Node.js

Apache-2.0
Latest version published 2 months ago

Package Health Score

89 / 100
Full package analysis