-
Notifications
You must be signed in to change notification settings - Fork 0
/
RestAPI_Creation.py
39 lines (27 loc) · 973 Bytes
/
RestAPI_Creation.py
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
import boto3
# This method find existing API-Gateway
def find_rest_api(client,ApiGatewayName):
response = client.get_rest_apis()
for items in response['items']:
if items['name'] == ApiGatewayName:
return (items['id'])
return None
# This method create Rest-API
def create_rest_api(client,data):
RestAPIId = find_rest_api(client, data['APIGW_Name'])
if RestAPIId is None:
restAPIResponce = client.create_rest_api(
name = data['APIGW_Name'],
description = data['APIGW_Des'],
version = 'V1',
apiKeySource = data['APIKeySource'],
endpointConfiguration={
'types': [
data['EndPointConfig']
]
}
)
RestAPIId = restAPIResponce['id']
print('Rest API Created With ID: ' , RestAPIId)
return RestAPIId
return RestAPIId