From a10687b7ef08fa87766f51ce4066173ab1634a71 Mon Sep 17 00:00:00 2001
From: gifrerenom <lluis.gifre@cttc.es>
Date: Mon, 17 Mar 2025 12:54:03 +0000
Subject: [PATCH] Common - Object Factory tools:

- Added field name to json_service()
---
 src/common/tools/object_factory/Service.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/common/tools/object_factory/Service.py b/src/common/tools/object_factory/Service.py
index ab399adbe..74c183230 100644
--- a/src/common/tools/object_factory/Service.py
+++ b/src/common/tools/object_factory/Service.py
@@ -30,10 +30,10 @@ def json_service_id(service_uuid : str, context_id : Optional[Dict] = None):
 
 def json_service(
     service_uuid : str, service_type : ServiceTypeEnum, context_id : Optional[Dict] = None,
-    status : ServiceStatusEnum = ServiceStatusEnum.SERVICESTATUS_PLANNED,
-    endpoint_ids : List[Dict] = [], constraints : List[Dict] = [], config_rules : List[Dict] = []):
-
-    return {
+    name : Optional[str] = None, status : ServiceStatusEnum = ServiceStatusEnum.SERVICESTATUS_PLANNED,
+    endpoint_ids : List[Dict] = [], constraints : List[Dict] = [], config_rules : List[Dict] = []
+) -> Dict:
+    result = {
         'service_id'          : json_service_id(service_uuid, context_id=context_id),
         'service_type'        : service_type,
         'service_status'      : {'service_status': status},
@@ -41,6 +41,8 @@ def json_service(
         'service_constraints' : copy.deepcopy(constraints),
         'service_config'      : {'config_rules': copy.deepcopy(config_rules)},
     }
+    if name is not None: result['name'] = name
+    return result
 
 def json_service_qkd_planned(
         service_uuid : str, endpoint_ids : List[Dict] = [], constraints : List[Dict] = [],
-- 
GitLab