@@ -71,7 +71,7 @@ def __init__(self, server, username="", password="", debug=False, verify=False):
7171
7272 self .debug = debug
7373 self .history = HistoryPlugin ()
74- self .API_VERSION = "0.0.8 " # TODO - Get the version from versioneer
74+ self .API_VERSION = "0.0.11 " # TODO - Get the version from versioneer
7575
7676 service_wsdl = '{}/cxf/OPDMSoapInterface?wsdl' .format (server )
7777 auth_wsdl = '{}/cxf/OPDMSoapInterface/SoapAuthentication?wsdl' .format (server )
@@ -156,7 +156,7 @@ class Operations:
156156 </sm:part>
157157 </sm:Query>"""
158158
159- GetContentResult = """<?xml version="1.0" encoding="UTF-8"?>
159+ GetContentResult_Profile = """<?xml version="1.0" encoding="UTF-8"?>
160160 <sm:GetContent xmlns="http://entsoe.eu/opde/ServiceModel/1/0"
161161 xmlns:sm="http://entsoe.eu/opde/ServiceModel/1/0"
162162 xmlns:opde="http://entsoe.eu/opde/ObjectModel/1/0"
@@ -169,6 +169,19 @@ class Operations:
169169 </sm:part>
170170 </sm:GetContent>"""
171171
172+ GetContentResult_OPDMObject = """<?xml version="1.0" encoding="UTF-8"?>
173+ <sm:GetContent xmlns="http://entsoe.eu/opde/ServiceModel/1/0"
174+ xmlns:sm="http://entsoe.eu/opde/ServiceModel/1/0"
175+ xmlns:opde="http://entsoe.eu/opde/ObjectModel/1/0"
176+ xmlns:opdm="http://entsoe.eu/opdm/ObjectModel/1/0">
177+ <sm:part name="identifier" type="opde:ShortMetaData">
178+ <sm:part name="content-return-mode">{return_mode}</sm:part><!-- PAYLOAD or FILE -->
179+ <opdm:OPDMObject>
180+ <opde:Id>{mRID}</opde:Id>
181+ </opdm:OPDMObject>
182+ </sm:part>
183+ </sm:GetContent>"""
184+
172185 PublicationsSubscriptionList = """<?xml version="1.0" encoding="UTF-8"?>
173186 <sm:PublicationsSubscriptionList xmlns:sm="http://entsoe.eu/opde/ServiceModel/1/0">
174187 <sm:part name="listType">AVAILABLE_PUBLICATIONS</sm:part>
@@ -310,10 +323,12 @@ def query_profile(self, metadata_dict):
310323
311324 return query_id , result
312325
313- def get_content (self , content_id , return_payload = False ):
326+ def get_content (self , content_id , return_payload = False , object_type = "file" ):
314327 """Downloads single file from OPDM Service Provider to OPDM Client local storage,
315328 to get the file binary as a response of set return_payload to True
316329
330+ supported object_types = [file, model]
331+
317332 Returns a dictionary with metadata and filename or content, to get the filename or content use:
318333 result['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content']
319334 """
@@ -324,13 +339,16 @@ def get_content(self, content_id, return_payload=False):
324339
325340 logger .debug (f"Return mode: { return_mode } " )
326341
327- get_content_result = self .Operations .GetContentResult .format (mRID = content_id , return_mode = return_mode )
342+ object_types = {"file" : self .Operations .GetContentResult_Profile ,
343+ "model" : self .Operations .GetContentResult_OPDMObject }
344+
345+ get_content_result = object_types [object_type ].format (mRID = content_id , return_mode = return_mode )
328346
329347 result = xmltodict .parse (etree .tostring (self .execute_operation (get_content_result .encode ())), xml_attribs = False )
330348
331349 if type (result ['sm:GetContentResult' ]['sm:part' ]) == list :
332350 logger .info ("File downloaded" )
333- logger .debug (result ['sm:GetContentResult' ]['sm:part' ][1 ]['opdm:Profile' ]['opde:Content' ])
351+ # logger.debug(result['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'])
334352
335353 else :
336354 logger .error ("File download failed" )
0 commit comments