async function doesAlertPolicyExist()

in monitoring/snippets/alerts.restorePolicies.js [64:77]


    async function doesAlertPolicyExist(name) {
      try {
        const [policy] = await client.getAlertPolicy({
          name,
        });
        return policy ? true : false;
      } catch (err) {
        if (err && err.code === 5) {
          // Error code 5 comes from the google.rpc.code.NOT_FOUND protobuf
          return false;
        }
        throw err;
      }
    }