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 deleteUptimeCheckConfig(projectId, uptimeCheckConfigId) {
// [START monitoring_uptime_check_delete]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
/**
* TODO(developer): Uncomment and edit the following lines of code.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const uptimeCheckConfigId = 'YOUR_UPTIME_CHECK_CONFIG_ID';
const request = {
// i.e. name: 'projects/my-project-id/uptimeCheckConfigs/My-Uptime-Check
name: client.uptimeCheckConfigPath(projectId, uptimeCheckConfigId),
};
console.log(`Deleting ${request.name}`);
// Delete an uptime check config
await client.deleteUptimeCheckConfig(request);
async function updateUptimeCheckConfigDisplayName(
projectId,
uptimeCheckConfigId,
displayName,
path
) {
// [START monitoring_uptime_check_update]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
/**
* TODO(developer): Uncomment and edit the following lines of code.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const uptimeCheckConfigId = 'YOUR_UPTIME_CHECK_CONFIG_ID';
// const displayName = 'A New Display Name';
// const path = '/some/path';
const request = {
// i.e. name: 'projects/my-project-id/uptimeCheckConfigs/My-Uptime-Check
name: client.uptimeCheckConfigPath(projectId, uptimeCheckConfigId),
};
console.log(`Updating ${request.name} to ${displayName}`);
async function listUptimeCheckIps() {
// [START monitoring_uptime_check_list_ips]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
// List uptime check IPs
const [uptimeCheckIps] = await client.listUptimeCheckIps();
uptimeCheckIps.forEach(uptimeCheckIp => {
console.log(
uptimeCheckIp.region,
uptimeCheckIp.location,
uptimeCheckIp.ipAddress
);
});
// [END monitoring_uptime_check_list_ips]
}
async function getUptimeCheckConfig(projectId, uptimeCheckConfigId) {
// [START monitoring_uptime_check_get]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
/**
* TODO(developer): Uncomment and edit the following lines of code.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const uptimeCheckConfigId = 'YOUR_UPTIME_CHECK_CONFIG_ID';
const request = {
// i.e. name: 'projects/my-project-id/uptimeCheckConfigs/My-Uptime-Check
name: client.uptimeCheckConfigPath(projectId, uptimeCheckConfigId),
};
console.log(`Retrieving ${request.name}`);
// Retrieves an uptime check config
const [uptimeCheckConfig] = await client.getUptimeCheckConfig(request);
async function listUptimeCheckConfigs(projectId) {
// [START monitoring_uptime_check_list_configs]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
/**
* TODO(developer): Uncomment and edit the following lines of code.
*/
// const projectId = 'YOUR_PROJECT_ID';
const request = {
parent: client.projectPath(projectId),
};
// Retrieves an uptime check config
const [uptimeCheckConfigs] = await client.listUptimeCheckConfigs(request);
uptimeCheckConfigs.forEach(uptimeCheckConfig => {
console.log(`ID: ${uptimeCheckConfig.name}`);
console.log(` Display Name: ${uptimeCheckConfig.displayName}`);
async function createUptimeCheckConfig(projectId, hostname) {
// [START monitoring_uptime_check_create]
// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');
// Creates a client
const client = new monitoring.UptimeCheckServiceClient();
/**
* TODO(developer): Uncomment and edit the following lines of code.
*/
// const projectId = 'YOUR_PROJECT_ID';
// const hostname = 'mydomain.com';
const request = {
// i.e. parent: 'projects/my-project-id'
parent: client.projectPath(projectId),
uptimeCheckConfig: {
displayName: 'My Uptime Check',
monitoredResource: {
// See the Uptime Check docs for supported MonitoredResource types
type: 'uptime_url',
labels: {host: hostname},