/
botoMunge.py
117 lines (94 loc) · 3.55 KB
/
botoMunge.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from botocore.loaders import Loader
#Make named tuple for operations:
#'http', 'name', 'documentation', 'output', 'input'
#Make named tuple for shapes:
#'required', 'members', 'member', 'type', 'min', 'enum', 'max', 'documentation', 'pattern'
#Mane named tuple for shapes.members:
#'locationName', 'shape', 'queryName', 'idempotencyToken', 'documentation'
l=Loader()
m=l.load_service_model('ec2','service-2')
kset=set()
def process_operations(v1):
'''v1 is a collection of operations entities for the service.
Inputs and outputs for c2s are regular, except:
{"CancelConversionTask,OrderedDict([('shape', 'CancelConversionRequest')])"}
'''
for k2,v2 in v1.items():
print(f'\n{k2}')
for k3,v3 in v2.items():
print(f'\n\t{k3}')
if k3 == 'http':
#OrderedDict([('method', 'POST'), ('requestUri', '/')])
#print(f'\n\t\thttp is {v3}')
#if v3["method"] != 'POST' or v3["requestUri"] != '/':
# kset.add(f'{k2} has http == {v3}')
pass
elif k3 == 'name': #k3 == k2
pass
elif k3 == 'documentation':
pass
elif k3 == 'output':
if v3['shape']==f"{k2}Result":
print('\n\t\texpected')
else:
print(f'\n\t\t => {v3["shape"]} or {k3}Result')
elif k3 == 'input':
if v3['shape']==f"{k2}Request":
print('\n\t\texpected')
else:
print(f'\n\t\t => {v3["shape"]} or {k3}Request')
kset.add(f'{k2},{v3}')
if 'output' not in v2:
print(f'\n\tno output for {k2}')
def process_shapes(v1):
'''v1 is a collection of shape entries for the service.
'''
for k2,v2 in v1.items():
print(f'\n{k2}')
for k3,v3 in v2.items():
print(f'\n\t{k3}')
if k3 == 'member':
for k4,v4 in v3.items():
if k4 =='shape':
print(f'\t\tshape is {v4}')
elif k4 =='locationName':
print(f'\t\tlocationName is {v4}')
else:
print('This is an error state')
elif k3 == 'required':
print(f'\t\trequired is {v3}')
elif k3 == 'members':
#need to note dependency
for k4,v4 in v3.items():
print(f'\t\t{k4}')
for k5,v5 in v4.items():
print(f'\t\t\t{k5} {v5}')
elif k3 == 'type':
#possibilities include ['list', 'double', 'integer', 'blob', 'timestamp', 'float', 'long', 'string', 'boolean', 'structure']
print(f'\t\ttype is {v3}')
elif k3 == 'min':
print(f'\t\tmin is {v3}')
elif k3 == 'enum':
print(f'\t\tenum is {v3}')
elif k3 == 'max':
print(f'\t\tmax is {v3}')
elif k3 == 'documentation':
pass
elif k3 == 'pattern':
print(f'\t\tpattern is {v3}')
for k1,v1 in m.items():
'''Process in this order: version, metadata, shapes, operations, documentation
'''
if k1=='version':
print(f'{k1}: {v1}')
elif k1=='metadata':
print(f'{k1}: {v1}')
elif k1=='operations':
process_operations(v1)
#pass
elif k1=='shapes':
#process_shapes(v1)
pass
elif k1=='documentation':
pass
print(kset)