-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoci-get-api-deployment.py
More file actions
44 lines (31 loc) · 1.15 KB
/
oci-get-api-deployment.py
File metadata and controls
44 lines (31 loc) · 1.15 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
from oci.config import validate_config
from oci.config import from_file
from oci.apigateway import ApiGatewayClient, DeploymentClient
import argparse
### MAIN CODE ###
# Parse Args
# Parse Arguments
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true")
parser.add_argument("-pr", "--profile", help="Config Profile, named", default="DEFAULT")
parser.add_argument("-c", "--compartment", help="Comaprtment OCID", required=True)
args = parser.parse_args()
verbose = args.verbose
profile = args.profile
comp_ocid = args.compartment
# Create / Validate Config
config = from_file(profile_name=profile)
validate_config(config)
apigw_client = ApiGatewayClient(config)
dep_client = DeploymentClient(config)
try:
deployments = dep_client.list_deployments(
compartment_id=comp_ocid,
lifecycle_state="ACTIVE"
).data
for dep in deployments.items:
print(f"--=--Deployment: {dep}")
spec = dep_client.get_deployment(deployment_id=dep.id).data.specification
print(f"--=--Spec: {spec}")
except Exception as e:
raise RuntimeError("\nError - " + str(e))