Merge "edit activity workflow plan for NS INIT"
[vfc/nfvo/lcm.git] / lcm / swagger / views.py
1 # Copyright 2016-2017 ZTE Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
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 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import json
15 import logging
16 import os
17
18 from rest_framework.response import Response
19 from rest_framework.views import APIView
20
21 logger = logging.getLogger(__name__)
22
23
24 class SwaggerJsonView(APIView):
25
26     def get(self, request):
27         json_file = os.path.join(os.path.dirname(__file__), 'vfc.nslcm.swagger.json')
28         f = open(json_file)
29         json_data = json.JSONDecoder().decode(f.read())
30         f.close()
31
32         json_file = os.path.join(os.path.dirname(__file__), 'vfc.vnflcm.swagger.json')
33         f = open(json_file)
34         json_data_temp = json.JSONDecoder().decode(f.read())
35         f.close()
36
37         json_data["paths"].update(json_data_temp["paths"])
38         json_data["definitions"].update(json_data_temp["definitions"])
39
40         json_file = os.path.join(os.path.dirname(__file__), 'vfc.vllcm.swagger.json')
41         f = open(json_file)
42         json_data_temp = json.JSONDecoder().decode(f.read())
43         f.close()
44
45         json_data["paths"].update(json_data_temp["paths"])
46         json_data["definitions"].update(json_data_temp["definitions"])
47
48         json_file = os.path.join(os.path.dirname(__file__), 'vfc.sfclcm.swagger.json')
49         f = open(json_file)
50         json_data_temp = json.JSONDecoder().decode(f.read())
51         f.close()
52
53         json_data["paths"].update(json_data_temp["paths"])
54         json_data["definitions"].update(json_data_temp["definitions"])
55
56         json_file = os.path.join(os.path.dirname(__file__), 'vfc.others.swagger.json')
57         f = open(json_file)
58         json_data_temp = json.JSONDecoder().decode(f.read())
59         f.close()
60
61         json_data_jobtemp = json_data["paths"]["/jobs/{jobId}"]
62         json_data["paths"].update(json_data_temp["paths"])
63         json_data["paths"]["/jobs/{jobId}"].update(json_data_jobtemp)
64         json_data["definitions"].update(json_data_temp["definitions"])
65         return Response(json_data)