This repository was archived by the owner on Apr 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveCalmProject.py
More file actions
58 lines (52 loc) · 1.41 KB
/
Copy pathRemoveCalmProject.py
File metadata and controls
58 lines (52 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#region headers
# escript-template v20190611 / stephane.bourdeaud@nutanix.com
# * author: MITU Bogdan Nicolae (EEAS-EXT) <Bogdan-Nicolae.MITU@ext.eeas.europa.eu>
# * version: 2019/09/18
# task_name: RemoveCalmProject
# description: Delete project from Calm.
# endregion
#region capture Calm variables
project_uuid = "@@{project_uuid}@@"
api_server = "@@{pc_ip}@@"
username = "@@{pc.username}@@"
username_secret = "@@{pc.secret}@@"
#endregion
#region prepare api call
api_server_port = "9440"
api_server_endpoint = "/api/nutanix/v3/projects_internal/{}".format(project_uuid)
url = "https://{}:{}{}".format(
api_server,
api_server_port,
api_server_endpoint
)
method = "DELETE"
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
# endregion
#region make the api call
print("Making a {} API call to {}".format(method, url))
resp = urlreq(
url,
verb=method,
auth='BASIC',
user=username,
passwd=username_secret,
headers=headers,
verify=False
)
# endregion
#region process the results
if resp.ok:
print("Project was successfully deleted.")
json_resp = json.loads(resp.content)
exit(0)
else:
#api call failed
print("Request failed")
print("Headers: {}".format(headers))
print('Status code: {}'.format(resp.status_code))
print('Response: {}'.format(json.dumps(json.loads(resp.content), indent=4)))
exit(1)
# endregion