forked from sysdiglabs/sysdig-sdk-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_users.py
More file actions
executable file
·38 lines (33 loc) · 856 Bytes
/
list_users.py
File metadata and controls
executable file
·38 lines (33 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
#
# List all the users in a Sysdig Monitor environment. The token you provide must
# have Admin rights.
#
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), '..'))
from sdcclient import SdcClient
#
# Parse arguments
#
if len(sys.argv) != 2:
print 'usage: %s <sysdig-token>' % sys.argv[0]
print 'You can find your token at https://app.sysdigcloud.com/#/settings/user'
print 'For this script to work, the user for the token must have Admin rights'
sys.exit(1)
sdc_token = sys.argv[1]
#
# Instantiate the SDC client
#
sdclient = SdcClient(sdc_token, 'https://app.sysdigcloud.com')
#
# Get the configuration
#
res = sdclient.get_users()
if res[0]:
print 'Users\n====='
for user in res[1]:
print user['username']
else:
print res[1]
sys.exit(1)