diff --git a/python/checklist/updateChecklistDetailsAndMetadata.py b/python/checklist/updateChecklistDetailsAndMetadata.py index cf0071b..8191179 100644 --- a/python/checklist/updateChecklistDetailsAndMetadata.py +++ b/python/checklist/updateChecklistDetailsAndMetadata.py @@ -1,24 +1,29 @@ # Update the hostname, MAC, IP, role, Asset Type, and other data within the specified checklist +# Pass all the parameters or they will be put back to default # API call from Developer's Guide: /api/external/systempackage/{systemKey}/checklist/{checklistId}/details/?applicationKey={applicationKey} -# ex: python3 updateChecklistDetailsAndMetadata.py http://192.168.13.111:8080 companyinfra 627d44fbff17ea6dfdf0d702 "desktop" true openrmfprosvc hvs.xxxxxxxxxxxxxx +# See the Developers Guide on allowed Technology Area, Asset Type, and Role + +# ex: python3 updateChecklistDetailsAndMetadata.py http://192.168.13.111:8080 companyinfra 627d44fbff17ea6dfdf0d702 openrmfprosvc hvs.xxxxxxxxxxxxxx "MY-SERVER-NAME" "my-server-name.company.com" "Windows OS" "192.168.1.111" "" "false" "" "" "Computing" "Workstation" "desktop|windows" import sys import requests +import json from requests.structures import CaseInsensitiveDict from html import escape -url = sys.argv[1] + "/api/external/systempackage/" + sys.argv[2] + "/checklist/" + sys.argv[3] + "/details/?applicationKey=" + sys.argv[6] +url = sys.argv[1] + "/api/external/systempackage/" + sys.argv[2] + "/checklist/" + sys.argv[3] + "/details/?applicationKey=" + sys.argv[4] + +data = "&serverhostname=" + escape(sys.argv[6]) + "&fqdn=" + escape(sys.argv[7]) + "&techarea=" + escape(sys.argv[8]) + "&hostip=" + escape(sys.argv[9]) + "&hostmac=" + escape(sys.argv[10]) + "&webordatabase=" + escape(sys.argv[11]) + "&webdatabasesite=" + escape(sys.argv[12]) + "&webdatabaseinstance=" + escape(sys.argv[13]) + "&assettype=" + escape(sys.argv[14]) + "&machinerole=" + escape(sys.argv[15]) + "&tagList=" + escape(sys.argv[16]) -data = "tagList=" + escape(sys.argv[4]) + "&locked=" + escape(sys.argv[5]) # Assign the request headers for this particular API headers = CaseInsensitiveDict() # Does not change headers["Accept"] = "application/json" -headers["Authorization"] = "Bearer " + sys.argv[7] +headers["Authorization"] = "Bearer " + sys.argv[5] headers["Content-Type"] = "application/x-www-form-urlencoded" # Make the API request -resp = requests.put(url, headers=headers, data=data) +resp = requests.put(url, headers=headers, data=json.dumps(data)) # print to the screen the status code (i.e. 200, 400, 404, etc) print(resp.status_code) diff --git a/python/patch/uploadApprovedPortsAndProtocolsListFile.py b/python/patch/uploadApprovedPortsAndProtocolsListFile.py index f0c890c..167434e 100644 --- a/python/patch/uploadApprovedPortsAndProtocolsListFile.py +++ b/python/patch/uploadApprovedPortsAndProtocolsListFile.py @@ -1,12 +1,12 @@ #Post a JSON record array payload to add / update ports, protocols, and services items in the host scan area for your system package # API call from Developer's Guide:/api/external/systempackage/{systemKey}/ppsm/?applicationKey={applicationKey} -# ex: python3 uploadApprovedPortsAndProtocolsListFile.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxx +# ex: python3 uploadApprovedPortsAndProtocolsListFile.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxx ../../data/ApprovedPPS/ sample-approvedpps.json import sys import requests from requests.structures import CaseInsensitiveDict -url = sys.argv[1] + "/api/external/systempackage/" + sys.argv[2]+ "/ppsm/?applicationKey=" + sys.argv[3] +url = sys.argv[1] + "/api/external/systempackage/" + sys.argv[2]+ "/approvedpps//?applicationKey=" + sys.argv[3] headers = CaseInsensitiveDict() headers["Accept"] = "application/json"