Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
# 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