From b7d1ed0bbb831664c8dab713783fdbde02187e59 Mon Sep 17 00:00:00 2001 From: Bryan <52042013+carbone84@users.noreply.github.com> Date: Fri, 20 Nov 2020 09:45:35 -0500 Subject: [PATCH 1/2] Create getOrgReport.py This is a sample script to get the organization report from pingid. It hits the 'rest/4/createjob/do' endpoint to create the job, the 'rest/4/getjobstatus/do' endpoint to check job status, and then the 'rest/4/getorgreport/do' to get the report. It then creates a csv file of the organization report. --- getOrgReport.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 getOrgReport.py diff --git a/getOrgReport.py b/getOrgReport.py new file mode 100644 index 0000000..db932ed --- /dev/null +++ b/getOrgReport.py @@ -0,0 +1,36 @@ +import pingid +import os + +PROPERTIES_FILE = 'pingid.properties' +org_report_file = "orgReport.csv" + +pingid = pingid.PingIDDriver(PROPERTIES_FILE, verbose=True) + +""" User Management API: Create Job """ +print("Calling Create Job...") +create_job_body = {'jobType': "USER_REPORTS", 'clientData': "Session data echoed back to the requestor"} +create_job_response = pingid.call('rest/4/createjob/do', create_job_body) +job_token = create_job_response['responseBody']['jobToken'] + +""" User Management API: Get Job Status""" +job_status_body = {'jobToken': job_token, 'clientData': "Session data echoed back to the requestor"} +job_status_response = 'PENDING' +while job_status_response != 'DONE': + job_status_response = pingid.call('rest/4/getjobstatus/do', job_status_body)['responseBody']['jobResult']['status'] + print(job_status_response) + if job_status_response == 'FAILURE': + print('Something went wrong...') + exit() + +""" User Mangement API: Get Organization Report """ +print("Calling Get Org Report...") +org_report_body = {'fileType': "CSV", 'clientData': "Session data echoed back to the requestor"} +org_report_response = pingid.call('rest/4/getorgreport/do', org_report_body) + +""" Writing report to CSV """ +print(f"Creating {org_report_file}...") +org_report_csv = open(org_report_file, 'w', newline='') +org_report_csv.write(org_report_response) +org_report_csv.close() + +print(f"Org report successfully created. Located at: {org_report_file}") From 8935007d74fa10b1e5a341515ef331eaee3678f1 Mon Sep 17 00:00:00 2001 From: Bryan <52042013+carbone84@users.noreply.github.com> Date: Mon, 28 Dec 2020 10:19:42 -0500 Subject: [PATCH 2/2] Update getOrgReport.py Remove clientData from body --- getOrgReport.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getOrgReport.py b/getOrgReport.py index db932ed..3e4feae 100644 --- a/getOrgReport.py +++ b/getOrgReport.py @@ -8,12 +8,12 @@ """ User Management API: Create Job """ print("Calling Create Job...") -create_job_body = {'jobType': "USER_REPORTS", 'clientData': "Session data echoed back to the requestor"} +create_job_body = {'jobType': "USER_REPORTS"} create_job_response = pingid.call('rest/4/createjob/do', create_job_body) job_token = create_job_response['responseBody']['jobToken'] """ User Management API: Get Job Status""" -job_status_body = {'jobToken': job_token, 'clientData': "Session data echoed back to the requestor"} +job_status_body = {'jobToken': job_token} job_status_response = 'PENDING' while job_status_response != 'DONE': job_status_response = pingid.call('rest/4/getjobstatus/do', job_status_body)['responseBody']['jobResult']['status'] @@ -24,7 +24,7 @@ """ User Mangement API: Get Organization Report """ print("Calling Get Org Report...") -org_report_body = {'fileType': "CSV", 'clientData': "Session data echoed back to the requestor"} +org_report_body = {'fileType': "CSV"} org_report_response = pingid.call('rest/4/getorgreport/do', org_report_body) """ Writing report to CSV """