ae699f4dfc1bfaf90fc7ab51d88468ebff8be0b3
[pti/o2.git] / o2dms / api / dms_dto.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
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
15 from flask_restx import fields
16 from o2dms.api.dms_api_ns import api_dms_lcm_v1
17 from o2common.helper import o2logging
18 logger = o2logging.get_logger(__name__)
19
20
21 class DmsDTO:
22     profile = api_dms_lcm_v1.model("DMSGetDtoProfile", {
23         'cluster_api_endpoint': fields.String(
24             attributes='cluster_api_endpoint'),
25         'cluster_ca_cert': fields.String(attributes='cluster_ca_cert'),
26         'admin_user': fields.String(attributes='admin_user'),
27         'admin_client_cert': fields.String(attributes='admin_client_cert'),
28         'admin_client_key': fields.String(attributes='admin_client_key'),
29         'kube_config_file': fields.String(attributes='kube_config_file')
30     })
31
32     dms_get = api_dms_lcm_v1.model(
33         "DmsGetDto",
34         {
35             'deploymentManagerId': fields.String(
36                 required=True,
37                 description='Deployment manager ID'),
38             'name': fields.String,
39             'description': fields.String,
40             'supportedLocations': fields.String,
41             'capabilities': fields.String,
42             'capacity': fields.String,
43             'profile': fields.Nested(profile, False, True),
44         }
45     )
46
47
48 class DmsLcmNfDeploymentDescriptorDTO:
49     NfDeploymentDescriptor_get = api_dms_lcm_v1.model(
50         "NfDeploymentDescriptorGetDto",
51         {
52             'id': fields.String(
53                 required=True,
54                 description='NfDeploymentDescriptor ID'),
55             'name': fields.String,
56             'description': fields.String,
57             'inputParams': fields.String,
58             'outputParams': fields.String,
59             'artifactRepoUrl': fields.String,
60             'artifactName': fields.String
61         }
62     )
63
64     NfDeploymentDescriptor_create = api_dms_lcm_v1.model(
65         "NfDeploymentDescriptorCreateDto",
66         {
67             'name': fields.String,
68             'description': fields.String,
69             'artifactRepoUrl': fields.String,
70             'artifactName': fields.String,
71             'inputParams': fields.String,
72             'outputParams': fields.String
73         }
74     )
75
76     NfDeploymentDescriptor_create_post_resp = api_dms_lcm_v1.model(
77         "NfDeploymentDescriptorCreateRespDto",
78         {
79             'id': fields.String(
80                 required=True, description='NfDeploymentDescriptor ID'),
81         }
82     )
83
84     NfDeploymentDescriptor_update = api_dms_lcm_v1.model(
85         "NfDeploymentDescriptorUpdateDto",
86         {
87             'name': fields.String,
88             'description': fields.String,
89             'artifactRepoUrl': fields.String,
90             'artifactName': fields.String,
91             'inputParams': fields.String,
92             'outputParams': fields.String
93         }
94     )
95
96
97 class DmsLcmNfDeploymentDTO:
98     NfDeployment_get = api_dms_lcm_v1.model(
99         "NfDeploymentGetDto",
100         {
101             'id': fields.String(
102                 required=True,
103                 description='NfDeployment ID'),
104             'name': fields.String,
105             'description': fields.String,
106             'descriptorId': fields.String,
107             'parentDeploymentId': fields.String,
108             'status': fields.Integer
109         }
110     )
111
112     NfDeployment_create = api_dms_lcm_v1.model(
113         "NfDeploymentCreateDto",
114         {
115             'name': fields.String,
116             'description': fields.String,
117             'descriptorId': fields.String,
118             'parentDeploymentId': fields.String
119         }
120     )
121
122     NfDeployment_create_post_resp = api_dms_lcm_v1.model(
123         "NfDeploymentCreateRespDto",
124         {
125             'id': fields.String(
126                 required=True, description='NfDeployment ID'),
127         }
128     )
129
130     NfDeployment_update = api_dms_lcm_v1.model(
131         "NfDeploymentUpdateDto",
132         {
133             'name': fields.String,
134             'description': fields.String,
135             'parentDeploymentId': fields.String
136         }
137     )
138
139
140 class DmsLcmNfOCloudVResourceDTO:
141     NfOCloudVResource_get = api_dms_lcm_v1.model(
142         "NfOCloudVResourceGetDto",
143         {
144             'id': fields.String(
145                 required=True,
146                 description='NfOCloudVResource ID'),
147             'name': fields.String,
148             'description': fields.String,
149             'descriptorId': fields.String,
150             'vresourceType': fields.String,
151             'status': fields.Integer,
152             'metadata': fields.String
153         }
154     )