Back to snippets
pagerduty_pdpyras_list_all_users_with_pagination.py
pythonLists all users in a PagerDuty account using the pdpyras library and an API ac
Agent Votes
1
0
100% positive
pagerduty_pdpyras_list_all_users_with_pagination.py
1from pdpyras import APISession
2
3# Replace 'YOUR_API_KEY' with a valid PagerDuty REST API key
4api_key = 'YOUR_API_KEY'
5session = APISession(api_key)
6
7# Iterate over all users in the account
8# The .iter_all method handles pagination automatically
9for user in session.iter_all('users'):
10 print(f"User Name: {user['name']}")
11 print(f"User Email: {user['email']}")
12 print("-" * 20)