1 # Copyright (C) 2021 Wind River Systems, Inc.
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
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.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from flask_restx import fields
17 from o2ims.views.api_ns import api_ims_inventory as api_ims_inventory_v1
22 ocloud = api_ims_inventory_v1.model(
25 'oCloudId': fields.String(required=True),
26 'globalcloudId': fields.String(attribute='globalCloudId'),
27 'name': fields.String,
28 'description': fields.String,
29 'serviceUri': fields.String(attribute='serviceUri'),
30 # 'infrastructureManagementServiceEndpoint': fields.String(
31 # attribute='serviceUri'),
32 # 'infrastructureMangementServiceEndPoint': fields.String(
33 # attribute='serviceUri'),
34 # 'resourceTypes': fields.String,
35 # 'resourcePools': fields.String,
36 # 'deploymentManagers': fields.String,
37 # 'smoRegistrationService': fields.String
38 'extensions': fields.String
43 class ResourceTypeDTO:
44 alarm_dictionary = api_ims_inventory_v1.model(
48 'alarmDictionaryVersion': fields.String,
49 'alarmDictionarySchemVersion': fields.String,
50 'entityType': fields.String,
51 'vendor': fields.String,
52 'managementInterfaceId': fields.String,
53 'pkNotificationField': fields.String,
54 'alarmDefinition': fields.String,
58 resource_type_get = api_ims_inventory_v1.model(
61 'resourceTypeId': fields.String(required=True,
62 description='Resource type ID'),
63 'name': fields.String,
64 'description': fields.String,
65 'vendor': fields.String,
66 'model': fields.String,
67 'version': fields.String,
68 'alarmDictionary': fields.Nested(alarm_dictionary, False, True),
69 # 'resourceKind': fields.String,
70 # 'resourceClass': fields.String,
71 'extensions': fields.String
76 class ResourcePoolDTO:
78 resource_pool_get = api_ims_inventory_v1.model(
81 'resourcePoolId': fields.String(required=True,
82 description='Resource pool ID'),
83 'globalLocationId': fields.String,
84 'name': fields.String,
85 'description': fields.String,
86 'oCloudId': fields.String,
87 'location': fields.String,
88 # 'resources': fields.String,
89 'extensions': fields.String
95 resource_list = api_ims_inventory_v1.model(
98 'resourceId': fields.String(required=True,
99 description='Resource ID'),
100 'resourceTypeId': fields.String,
101 'resourcePoolId': fields.String,
102 'globalAssetId': fields.String,
103 # 'name': fields.String,
104 'parentId': fields.String,
105 'description': fields.String,
106 # 'elements': fields.String,
107 'extensions': fields.String
111 def recursive_resource_mapping(iteration_number=2):
112 resource_json_mapping = {
113 'resourceId': fields.String(required=True,
114 description='Resource ID'),
115 'resourceTypeId': fields.String,
116 'resourcePoolId': fields.String,
117 'globalAssetId': fields.String,
118 # 'name': fields.String,
119 'parentId': fields.String,
120 'description': fields.String,
121 # 'elements': fields.String,
122 'extensions': fields.String
125 resource_json_mapping['elements'] = fields.List(
126 fields.Nested(ResourceDTO.recursive_resource_mapping(
127 iteration_number-1)), attribute='children')
128 return api_ims_inventory_v1.model(
129 'ResourceGetDto' + str(iteration_number), resource_json_mapping)
132 class DeploymentManagerDTO:
134 deployment_manager_list = api_ims_inventory_v1.model(
135 "DeploymentManagerListDto",
137 'deploymentManagerId': fields.String(
139 description='Deployment manager ID'),
140 'name': fields.String,
141 'description': fields.String,
142 'oCloudId': fields.String,
143 'serviceUri': fields.String(attribute='serviceUri'),
144 # 'deploymentManagementServiceEndpoint': fields.String(
145 # attribute='serviceUri'),
146 # 'supportedLocations': fields.String,
147 # 'capabilities': fields.String,
148 # 'capacity': fields.String,
149 'profileSupportList': fields.List(
151 description='Profile support list, use default for the return \
153 'extensions': fields.String
157 profile = api_ims_inventory_v1.model("DeploymentManagerGetDtoProfile", {
158 'cluster_api_endpoint': fields.String(
159 attribute='cluster_api_endpoint'),
160 'cluster_ca_cert': fields.String(attribute='cluster_ca_cert'),
161 'admin_user': fields.String(attribute='admin_user'),
162 'admin_client_cert': fields.String(attribute='admin_client_cert'),
163 'admin_client_key': fields.String(attribute='admin_client_key'),
164 # 'kube_config_file': fields.String(attribute='kube_config_file')
165 'helmcli_host_with_port': fields.String(
166 attribute='helmcli_host_with_port'),
167 'helmcli_username': fields.String(attribute='helmcli_username'),
168 'helmcli_password': fields.String(attribute='helmcli_password'),
169 'helmcli_kubeconfig': fields.String(attribute='helmcli_kubeconfig'),
172 deployment_manager_get = api_ims_inventory_v1.model(
173 "DeploymentManagerGetDto",
175 'deploymentManagerId': fields.String(
177 description='Deployment manager ID'),
178 'name': fields.String,
179 'description': fields.String,
180 'oCloudId': fields.String,
181 'serviceUri': fields.String(attribute='serviceUri'),
182 # 'deploymentManagementServiceEndpoint': fields.String(
183 # attribute='serviceUri'),
184 # 'supportedLocations': fields.String,
185 # 'capabilities': fields.String,
186 # 'capacity': fields.String,
187 'profileName': fields.String,
188 'profileData': fields.Nested(profile, False, True),
189 'extensions': fields.String
194 class SubscriptionDTO:
196 subscription_get = api_ims_inventory_v1.model(
197 "SubscriptionGetDto",
199 'subscriptionId': fields.String(required=True,
200 description='Subscription ID'),
201 'callback': fields.String,
202 'consumerSubscriptionId': fields.String,
203 'filter': fields.String,
207 subscription = api_ims_inventory_v1.model(
208 "SubscriptionCreateDto",
210 'callback': fields.String(
211 required=True, description='Subscription callback address'),
212 'consumerSubscriptionId': fields.String,
213 'filter': fields.String,
217 subscription_post_resp = api_ims_inventory_v1.model(
218 "SubscriptionCreatedRespDto",
220 'subscriptionId': fields.String(required=True,
221 description='Subscription ID'),