Skip to content

Commit

Permalink
Merge pull request #66 from DaleBinghamSoteriaSoft/main
Browse files Browse the repository at this point in the history
Fixing the update checklist and upload approvedPPS file calls
  • Loading branch information
DaleBinghamSoteriaSoft authored Jul 4, 2024
2 parents 7bdb1d0 + ebcf792 commit b708e10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions python/checklist/updateChecklistDetailsAndMetadata.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions python/patch/uploadApprovedPortsAndProtocolsListFile.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit b708e10

Please sign in to comment.