diff --git a/OPDM/OPDM_SOAP_API.py b/OPDM/OPDM_SOAP_API.py
index 78f2eae..c7a907a 100644
--- a/OPDM/OPDM_SOAP_API.py
+++ b/OPDM/OPDM_SOAP_API.py
@@ -138,31 +138,15 @@ class Operations:
"""
- GetContentResult_Profile = """
+ GetContentResult = """
-
{return_mode}
-
- {mRID}
-
-
+ {identifier_parts}
"""
- GetContentResult_OPDMObject = """
-
-
- {return_mode}
-
- {mRID}
-
-
- """
CreateSubscription = """
@@ -408,25 +392,51 @@ def query_profile(self, metadata_dict, raw_response=False):
return self.execute_operation(query_profile, return_raw_response=raw_response)
def get_content(self, content_id, return_payload=False, object_type="file", raw_response=False):
- """Downloads single file from OPDM Service Provider to OPDM Client local storage,
- to get the file binary as a response of set return_payload to True
+ """
+ Downloads one or multiple files or models from OPDM Service Provider to OPDM Client local storage.
- supported object_types = [file, model]
+ Args:
+ content_id (Union[str, List[str]]): The identifier(s) of the content to download. Can be a single string or a list of strings.
+ return_payload (bool): If True, returns the file content directly. Defaults to False.
+ object_type (str): Type of object to retrieve. Supported types are "file" and "model". Defaults to "file".
+ raw_response (bool): If True, returns the raw response from the service. Defaults to False.
- Returns a dictionary with metadata and filename or content, to get the filename or content use:
- result['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content']
- """
+ Returns:
+ Dict: A dictionary containing metadata and either the filename or the content itself based on `return_payload`.
+
+ Raises:
+ ValueError: If an unsupported `object_type` is provided.
- return_mode = "FILE"
- if return_payload:
- return_mode = "PAYLOAD"
+ Example:
+ result = get_content('', return_payload=True)
+ content = result['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content']
+ """
+ return_mode = "PAYLOAD" if return_payload else "FILE"
logger.debug(f"Return mode: {return_mode}")
- object_types = {"file": self.Operations.GetContentResult_Profile,
- "model": self.Operations.GetContentResult_OPDMObject}
+ # Map object types
+ object_types = {"file": "Profile", "model": "OPDMObject"}
+ if object_type not in object_types:
+ raise ValueError(f"Unsupported object_type. Choose from {list(object_types.keys())}")
+
+ # Ensure list of ID-s
+ if type(content_id) is str:
+ content_id = [content_id]
+
+ identifier_parts = [
+ f"""
+
+
+ {identifier}
+
+
+ """ for identifier in content_id
+ ]
+
+ identifier_parts_str = '\n'.join(identifier_parts)
- get_content_result = object_types[object_type].format(mRID=content_id, return_mode=return_mode)
+ get_content_result = self.Operations.GetContentResult.format(identifier_parts=identifier_parts_str, return_mode=return_mode)
return self.execute_operation(get_content_result, return_raw_response=raw_response)