Skip to content

Commit

Permalink
Add example for getting App id and sandbox id using legacy XML API
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy Baukema committed Oct 13, 2023
1 parent a74d834 commit cacd332
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions samples/xml_sandbox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# a simple sample to get the sandbox id
from veracode_api_py import XMLAPI
import xml.etree.ElementTree as ET

xmlApi = XMLAPI()
appListXml = xmlApi.get_app_list()
appList = ET.fromstring(appListXml)

# CHANGE BELOW TO SEARCH FOR OTHER APP NAMES / SANDBOXES
searchAppName = "VeraDemo"
searchSandboxName = "POJOs"

foundAppId = 0
for app in appList:
appName = app.get("app_name")
appId = app.get("app_id")
if searchAppName == appName:
foundAppId = appId
break

if foundAppId == 0:
raise Exception("Did not find app id!")

sandboxListXml = xmlApi.get_sandbox_list(foundAppId)
sandboxList = ET.fromstring(sandboxListXml)

foundSandboxId = 0
for sandbox in sandboxList:
sandboxName = sandbox.get("sandbox_name")
sandboxId = sandbox.get("sandbox_id")
if searchSandboxName == sandboxName:
foundSandboxId = sandboxId
break

if foundSandboxId == 0:
raise Exception("Did not find sandbox id!")

print("App '" + searchAppName + "' ID: " + foundAppId + "\nSandbox '" + searchSandboxName + "' ID: " + foundSandboxId)

0 comments on commit cacd332

Please sign in to comment.