1 # Copyright (c) 2017 Wind River Systems, Inc.
2 # Copyright (c) 2017-2018 VMware, Inc.
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
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.
18 # from rest_framework import status
19 from rest_framework.response import Response
20 from rest_framework.views import APIView
22 # from multivimbroker.pub.exceptions import VimBrokerException
24 logger = logging.getLogger(__name__)
27 class SwaggerJsonView(APIView):
28 def get(self, request):
29 json_file = os.path.join(os.path.dirname(__file__),
30 'multivim.flavor.swagger.json')
32 json_data = json.JSONDecoder().decode(f.read())
34 json_file = os.path.join(os.path.dirname(__file__),
35 'multivim.image.swagger.json')
37 json_data_temp = json.JSONDecoder().decode(f.read())
39 json_data["paths"].update(json_data_temp["paths"])
40 json_data["definitions"].update(json_data_temp["definitions"])
41 json_file = os.path.join(os.path.dirname(__file__),
42 'multivim.network.swagger.json')
44 json_data_temp = json.JSONDecoder().decode(f.read())
46 json_data["paths"].update(json_data_temp["paths"])
47 json_data["definitions"].update(json_data_temp["definitions"])
48 json_file = os.path.join(os.path.dirname(__file__),
49 'multivim.subnet.swagger.json')
51 json_data_temp = json.JSONDecoder().decode(f.read())
53 json_data["paths"].update(json_data_temp["paths"])
54 json_data["definitions"].update(json_data_temp["definitions"])
55 json_file = os.path.join(os.path.dirname(__file__),
56 'multivim.server.swagger.json')
58 json_data_temp = json.JSONDecoder().decode(f.read())
60 json_data["paths"].update(json_data_temp["paths"])
61 json_data["definitions"].update(json_data_temp["definitions"])
62 json_file = os.path.join(os.path.dirname(__file__),
63 'multivim.volume.swagger.json')
65 json_data_temp = json.JSONDecoder().decode(f.read())
67 json_data["paths"].update(json_data_temp["paths"])
68 json_data["definitions"].update(json_data_temp["definitions"])
69 json_file = os.path.join(os.path.dirname(__file__),
70 'multivim.vport.swagger.json')
72 json_data_temp = json.JSONDecoder().decode(f.read())
74 json_data["paths"].update(json_data_temp["paths"])
75 json_data["definitions"].update(json_data_temp["definitions"])
76 json_file = os.path.join(os.path.dirname(__file__),
77 'multivim.tenant.swagger.json')
79 json_data_temp = json.JSONDecoder().decode(f.read())
81 json_data["paths"].update(json_data_temp["paths"])
82 json_data["definitions"].update(json_data_temp["definitions"])
83 json_file = os.path.join(os.path.dirname(__file__),
84 'multivim.host.swagger.json')
86 json_data_temp = json.JSONDecoder().decode(f.read())
88 json_data["paths"].update(json_data_temp["paths"])
89 json_data["definitions"].update(json_data_temp["definitions"])
90 json_file = os.path.join(os.path.dirname(__file__),
91 'multivim.limit.swagger.json')
93 json_data_temp = json.JSONDecoder().decode(f.read())
95 json_data["paths"].update(json_data_temp["paths"])
96 json_data["definitions"].update(json_data_temp["definitions"])
98 json_file = os.path.join(os.path.dirname(__file__),
99 'multivim.identity.swagger.json')
101 json_data_temp = json.JSONDecoder().decode(f.read())
103 json_data["paths"].update(json_data_temp["paths"])
104 json_data["definitions"].update(json_data_temp["definitions"])
105 return Response(json_data)