-
Notifications
You must be signed in to change notification settings - Fork 8
/
users_example.py
40 lines (29 loc) · 1.15 KB
/
users_example.py
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
39
40
import logging
from pprint import pformat
import traceback
import intersight.api.iam_api
import credentials
FORMAT = '%(asctime)-15s [%(levelname)s] [%(filename)s:%(lineno)s] %(message)s'
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
logger = logging.getLogger('openapi')
def get_users(apiClient):
###################################################################################
api_instance = intersight.api.iam_api.IamApi(apiClient)
logger.info("Query Users")
results = api_instance.get_iam_user_list()
logger.info("User response: %s" % pformat(results))
logger.info("ANCESTORS: %s" % results.results[0].ancestors)
logger.info("Query Users with expand")
results = api_instance.get_iam_user_list(expand='Ancestors')
logger.info("Users: {}", pformat(results))
def main():
# Configure API key settings for authentication
apiClient = credentials.config_credentials()
try:
# Get list of users
get_users(apiClient)
except intersight.OpenApiException as e:
logger.error("Exception when calling API: %s\n" % e)
traceback.print_exc()
if __name__ == "__main__":
main()