-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example for getting App id and sandbox id using legacy XML API
- Loading branch information
Boy Baukema
committed
Oct 13, 2023
1 parent
a74d834
commit cacd332
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |