Merge "Spec for elastic API exposure"
[multicloud/framework.git] / multivimbroker / multivimbroker / swagger / utils.py
1 # Copyright (c) 2017 Wind River Systems, Inc.
2 # Copyright (c) 2017-2018 VMware, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13 import json
14 import os
15
16
17 def get_swagger_json_data():
18     json_file = os.path.join(os.path.dirname(__file__),
19                              'multivim.flavor.swagger.json')
20     f = open(json_file)
21     json_data = json.JSONDecoder().decode(f.read())
22     f.close()
23     json_file = os.path.join(os.path.dirname(__file__),
24                              'multivim.image.swagger.json')
25     f = open(json_file)
26     json_data_temp = json.JSONDecoder().decode(f.read())
27     f.close()
28     json_data["paths"].update(json_data_temp["paths"])
29     json_data["definitions"].update(json_data_temp["definitions"])
30     json_file = os.path.join(os.path.dirname(__file__),
31                              'multivim.network.swagger.json')
32     f = open(json_file)
33     json_data_temp = json.JSONDecoder().decode(f.read())
34     f.close()
35     json_data["paths"].update(json_data_temp["paths"])
36     json_data["definitions"].update(json_data_temp["definitions"])
37     json_file = os.path.join(os.path.dirname(__file__),
38                              'multivim.subnet.swagger.json')
39     f = open(json_file)
40     json_data_temp = json.JSONDecoder().decode(f.read())
41     f.close()
42     json_data["paths"].update(json_data_temp["paths"])
43     json_data["definitions"].update(json_data_temp["definitions"])
44     json_file = os.path.join(os.path.dirname(__file__),
45                              'multivim.server.swagger.json')
46     f = open(json_file)
47     json_data_temp = json.JSONDecoder().decode(f.read())
48     f.close()
49     json_data["paths"].update(json_data_temp["paths"])
50     json_data["definitions"].update(json_data_temp["definitions"])
51     json_file = os.path.join(os.path.dirname(__file__),
52                              'multivim.volume.swagger.json')
53     f = open(json_file)
54     json_data_temp = json.JSONDecoder().decode(f.read())
55     f.close()
56     json_data["paths"].update(json_data_temp["paths"])
57     json_data["definitions"].update(json_data_temp["definitions"])
58     json_file = os.path.join(os.path.dirname(__file__),
59                              'multivim.vport.swagger.json')
60     f = open(json_file)
61     json_data_temp = json.JSONDecoder().decode(f.read())
62     f.close()
63     json_data["paths"].update(json_data_temp["paths"])
64     json_data["definitions"].update(json_data_temp["definitions"])
65     json_file = os.path.join(os.path.dirname(__file__),
66                              'multivim.tenant.swagger.json')
67     f = open(json_file)
68     json_data_temp = json.JSONDecoder().decode(f.read())
69     f.close()
70     json_data["paths"].update(json_data_temp["paths"])
71     json_data["definitions"].update(json_data_temp["definitions"])
72     json_file = os.path.join(os.path.dirname(__file__),
73                              'multivim.host.swagger.json')
74     f = open(json_file)
75     json_data_temp = json.JSONDecoder().decode(f.read())
76     f.close()
77     json_data["paths"].update(json_data_temp["paths"])
78     json_data["definitions"].update(json_data_temp["definitions"])
79     json_file = os.path.join(os.path.dirname(__file__),
80                              'multivim.limit.swagger.json')
81     f = open(json_file)
82     json_data_temp = json.JSONDecoder().decode(f.read())
83     f.close()
84     json_data["paths"].update(json_data_temp["paths"])
85     json_data["definitions"].update(json_data_temp["definitions"])
86     json_file = os.path.join(os.path.dirname(__file__),
87                              'multivim.identity.swagger.json')
88     f = open(json_file)
89     json_data_temp = json.JSONDecoder().decode(f.read())
90     f.close()
91     json_data["paths"].update(json_data_temp["paths"])
92     json_data["definitions"].update(json_data_temp["definitions"])
93
94     return json_data