-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdelete_network_area.py
More file actions
27 lines (21 loc) · 938 Bytes
/
delete_network_area.py
File metadata and controls
27 lines (21 loc) · 938 Bytes
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
import os
import time
from stackit.iaas.api.default_api import DefaultApi
from stackit.core.configuration import Configuration
organization_id = os.getenv("ORGANIZATION_ID")
network_area_id = os.getenv("NETWORK_AREA_ID")
# Create a new API client, that uses default authentication and configuration
config = Configuration()
client = DefaultApi(config)
# Delete all configured network area regions first
list_regions_resp = client.list_network_area_regions(organization_id, network_area_id)
for region_id in list_regions_resp.regions:
client.delete_network_area_region(organization_id, network_area_id, region_id)
# wait for all network area regions to be deleted
while True:
list_regions_resp = client.list_network_area_regions(organization_id, network_area_id)
if len(list_regions_resp.regions) < 1:
break
time.sleep(3)
# Delete the network area
client.delete_network_area(organization_id, network_area_id)