Skip to content

Commit e4da389

Browse files
committed
added pull report sample
1 parent feb92b6 commit e4da389

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

miscellaneous/pull_js_report.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import requests
2+
3+
PORTAL_SERVER = "qs-il-lt-nattik"
4+
EXECUTION_ID = "96303587-8a06-45d2-a9db-728368aa4cb7"
5+
6+
REPORT_LINK = F"http://{PORTAL_SERVER}/Test/Report?reportId={EXECUTION_ID}"
7+
8+
9+
response = requests.get(REPORT_LINK)
10+
11+
with open(f'report_{EXECUTION_ID}.pdf', 'wb') as f:
12+
f.write(response.content)
13+
14+
print("done")
23.3 KB
Binary file not shown.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import json
2+
3+
from cloudshell.sandbox_rest.sandbox_api import SandboxRestApiSession
4+
5+
# pull in api user credentials
6+
CS_SERVER = "localhost"
7+
CS_USER = "admin"
8+
CS_PASSWORD = "admin"
9+
CS_DOMAIN = "Global"
10+
11+
WHITELISTED_PERSISTENT_BP_IDS = []
12+
13+
api = SandboxRestApiSession(host=CS_SERVER, username=CS_USER, password=CS_PASSWORD, domain=CS_DOMAIN)
14+
active_sandboxes = api.get_sandboxes()
15+
16+
illegal_persistent_sandboxes = []
17+
for sandbox in active_sandboxes:
18+
sandbox_details = api.get_sandbox_details(sandbox["id"])
19+
if sandbox_details["blueprint_id"] in WHITELISTED_PERSISTENT_BP_IDS:
20+
continue
21+
22+
if not sandbox_details["end_time"]:
23+
illegal_persistent_sandboxes.append(sandbox_details)
24+
25+
if not illegal_persistent_sandboxes:
26+
print("no unauthorized persistent sandboxes found")
27+
else:
28+
print("Found unauthorized persistent sandboxes")
29+
print(json.dumps(illegal_persistent_sandboxes, indent=4))

0 commit comments

Comments
 (0)