-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaws_api_shapeshifter.py
40 lines (25 loc) · 945 Bytes
/
aws_api_shapeshifter.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
import json
import api
DEFAULT_DEF_LOCATION = "./aws-api-definition.json"
def new(definition=DEFAULT_DEF_LOCATION):
data = __read_api_definition(definition)
to_return = {}
for key, service in data.items():
# Cludgy, but let's make sure it's a v4 service
if service[list(service.keys())[0]]['metadata']['signatureVersion'] != "v4":
continue
to_return[key] = api.API(key, service)
return to_return
def convert_sts_to_cred_object(credentials):
return Credentials(
credentials['AccessKeyId'],
credentials['SecretAccessKey'],
credentials['SessionToken'])
def __read_api_definition(definition):
with open(definition, 'r') as r:
return json.loads(''.join(r.read()))
class Credentials():
def __init__(self, access_key, secret_key, token):
self.access_key = access_key
self.secret_key = secret_key
self.token = token