Update license
[multicloud/framework.git] / multivimbroker / multivimbroker / swagger / views.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 logging
15 import os
16 # import traceback
17
18 # from rest_framework import status
19 from rest_framework.response import Response
20 from rest_framework.views import APIView
21
22 # from multivimbroker.pub.exceptions import VimBrokerException
23
24 logger = logging.getLogger(__name__)
25
26
27 class SwaggerJsonView(APIView):
28     def get(self, request):
29         json_file = os.path.join(os.path.dirname(__file__),
30                                  'multivim.flavor.swagger.json')
31         f = open(json_file)
32         json_data = json.JSONDecoder().decode(f.read())
33         f.close()
34         json_file = os.path.join(os.path.dirname(__file__),
35                                  'multivim.image.swagger.json')
36         f = open(json_file)
37         json_data_temp = json.JSONDecoder().decode(f.read())
38         f.close()
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')
43         f = open(json_file)
44         json_data_temp = json.JSONDecoder().decode(f.read())
45         f.close()
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')
50         f = open(json_file)
51         json_data_temp = json.JSONDecoder().decode(f.read())
52         f.close()
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')
57         f = open(json_file)
58         json_data_temp = json.JSONDecoder().decode(f.read())
59         f.close()
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')
64         f = open(json_file)
65         json_data_temp = json.JSONDecoder().decode(f.read())
66         f.close()
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')
71         f = open(json_file)
72         json_data_temp = json.JSONDecoder().decode(f.read())
73         f.close()
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')
78         f = open(json_file)
79         json_data_temp = json.JSONDecoder().decode(f.read())
80         f.close()
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')
85         f = open(json_file)
86         json_data_temp = json.JSONDecoder().decode(f.read())
87         f.close()
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')
92         f = open(json_file)
93         json_data_temp = json.JSONDecoder().decode(f.read())
94         f.close()
95         json_data["paths"].update(json_data_temp["paths"])
96         json_data["definitions"].update(json_data_temp["definitions"])
97         #
98         json_file = os.path.join(os.path.dirname(__file__),
99                                  'multivim.identity.swagger.json')
100         f = open(json_file)
101         json_data_temp = json.JSONDecoder().decode(f.read())
102         f.close()
103         json_data["paths"].update(json_data_temp["paths"])
104         json_data["definitions"].update(json_data_temp["definitions"])
105         return Response(json_data)