List PagerDuty Users with Contact Information
List all users within a PagerDuty account, including their phone numbers
by Ryan Hoskin
HTML
<script src="https://eurica.github.io/pdjs/js/pdjs.js"></script>
<div id="users"></div>
JavaScript
//List all users within a PagerDuty account, including their phone numbers
PDJS = new PDJSobj({
subdomain: "pdt-ryan",
token: "g7yGM_kMC5jbpBTbXbC3",
})
PDJS.api_all({
res: "users",
data: {
"include[]": "contact_methods"
},
final_success: function(data) {
console.log(data.total + " objects!");
jQuery.each(data.users, function(index, user) {
found = false;
jQuery.each(user.contact_methods, function(index, contact_method) {
if(contact_method.type == "phone" || contact_method.type == "SMS") {
found = true;
}
})
if (found == false) {
$("#users").append(user.name+"<br/>");
}
})
},
incremental_success: function(data) {
console.log("Got data");
}
})