Fix INF-375 get default mask strip failed
[pti/o2.git] / o2ims / views / ocloud_dto.py
index 14d9873..078064b 100644 (file)
@@ -15,6 +15,7 @@
 from flask_restx import fields
 
 from o2ims.views.api_ns import api_ims_inventory as api_ims_inventory_v1
+from o2common.views.flask_restx_fields import Json2Dict
 
 
 class OcloudDTO:
@@ -23,6 +24,7 @@ class OcloudDTO:
         "OcloudDto",
         {
             'oCloudId': fields.String(required=True),
+            'globalCloudId': fields.String,
             'globalcloudId': fields.String(attribute='globalCloudId'),
             'name': fields.String,
             'description': fields.String,
@@ -37,22 +39,41 @@ class OcloudDTO:
             # 'smoRegistrationService': fields.String
             'extensions': fields.String
         },
-        mask='{oCloudId,globalcloudId,name,description,serviceUri}'
+        mask='{oCloudId,globalCloudId,globalcloudId,name,description,' +\
+        'serviceUri}'
     )
 
 
 class ResourceTypeDTO:
+    alarm_definition = api_ims_inventory_v1.model(
+        "AlarmDefinitionDto",
+        {
+            'alarmDefinitionId': fields.String,
+            'alarmName': fields.String,
+            'alarmLastChange': fields.String,
+            'alarmChangeType': fields.String,
+            'alarmDescription': fields.String,
+            'proposedRepairActions': fields.String,
+            'clearingType': fields.String,
+            'managementInterfaceId': fields.String,
+            'pkNotificationField': fields.String,
+            'alarmAdditionalFields': fields.String,
+        }
+
+    )
     alarm_dictionary = api_ims_inventory_v1.model(
         "AlarmDictionaryDto",
         {
             'id': fields.String,
             'alarmDictionaryVersion': fields.String,
-            'alarmDictionarySchemVersion': fields.String,
+            'alarmDictionarySchemaVersion': fields.String,
             'entityType': fields.String,
             'vendor': fields.String,
             'managementInterfaceId': fields.String,
             'pkNotificationField': fields.String,
-            'alarmDefinition': fields.String,
+            # 'alarmDefinition': fields.String,
+            'alarmDefinition': fields.List(fields.Nested(alarm_definition),
+                                           attribute='alarmDefinition'),
         }
     )
 
@@ -107,7 +128,9 @@ class ResourceDTO:
             'parentId': fields.String,
             'description': fields.String,
             # 'elements': fields.String,
-            'extensions': fields.String
+            # 'extensions': fields.String
+            'extensions': Json2Dict(attribute='extensions')
+            # 'extensions': fields.Raw(attribute='extensions')
         },
         mask='{resourceId,resourcePoolId,resourceTypeId,description,parentId}'
     )
@@ -123,7 +146,9 @@ class ResourceDTO:
             'parentId': fields.String,
             'description': fields.String,
             # 'elements': fields.String,
-            'extensions': fields.String
+            # 'extensions': fields.String
+            'extensions': Json2Dict(attribute='extensions')
+            # 'extensions': fields.Raw(attribute='extensions')
         }
         if iteration_number:
             resource_json_mapping['elements'] = fields.List(
@@ -177,6 +202,11 @@ class DeploymentManagerDTO:
         'helmcli_kubeconfig': fields.String(attribute='helmcli_kubeconfig'),
     })
 
+    extensions = api_ims_inventory_v1.model("DeploymentManagerExtensions", {
+        'profileName': fields.String,
+        'profileData': fields.Nested(profile, False, True),
+    })
+
     deployment_manager_get = api_ims_inventory_v1.model(
         "DeploymentManagerGetDto",
         {
@@ -192,12 +222,10 @@ class DeploymentManagerDTO:
             # 'supportedLocations': fields.String,
             # 'capabilities': fields.String,
             # 'capacity': fields.String,
-            'profileName': fields.String,
-            'profileData': fields.Nested(profile, False, True),
-            'extensions': fields.String
+            'extensions': fields.Nested(extensions, True, True)
         },
         mask='{deploymentManagerId,name,description,oCloudId,serviceUri,' +\
-        'profileName,profileData}'
+        'extensions/profileName,extensions/profileData}'
     )
 
 
@@ -215,7 +243,7 @@ class SubscriptionDTO:
         mask='{subscriptionId,callback}'
     )
 
-    subscription = api_ims_inventory_v1.model(
+    subscription_create = api_ims_inventory_v1.model(
         "SubscriptionCreateDto",
         {
             'callback': fields.String(
@@ -224,11 +252,3 @@ class SubscriptionDTO:
             'filter': fields.String,
         }
     )
-
-    subscription_post_resp = api_ims_inventory_v1.model(
-        "SubscriptionCreatedRespDto",
-        {
-            'subscriptionId': fields.String(required=True,
-                                            description='Subscription ID'),
-        }
-    )