Usage examples Sample Clauses

Usage examples. ‌ rinohtype supports three modes of operation, which are discussed in more detail in the Chapter
AutoNDA by SimpleDocs
Usage examples. ‌ In this section, an example of how to generate a simple message will be described.
Usage examples. The Python code to create a Handle in EPIC service offered by XXXX looks like Figure 12 (many details omitted): 8 xxxxx://xxx.xxxxx.xx/EUDAT/Services/DataManagement/PID/iRODS-Integration/C 9 xxxxx://xxx.xxxxx.xx/EUDAT/Services/DataManagement/PID/iRODS-Integration/Python def createHandle(self,prefix,keyValues,suffix=''): uri = self.baseuri + '/' + prefix if suffix != '': uri += "/" + suffix index = 1 json = {} for key in keyValues: json[str(index)] = {'type':key,'data':keyValues[key]} index += 1 new_handle_json = simplejson.dumps(json) hdrs = {'If-None-Match': '*', 'Content-Type':'application/json'} try: response,content = self.http.request(uri,method='PUT', headers=hdrs, body=new_handle_json) except: self._debugMsg('createHandleWithLocation', "An Exception occurred during Creation of " + uri) return None else: self._debugMsg('createHandleWithLocation', "Request completed") return response['location'] Figure 12: Example Python code to create a handle in the EPIC handle service The workflow is pretty simple: first a URL is created. This is composed of the service URL, a prefix (which is unique for each partner) and a suffix (which is unique for each object). Then a JSON document is prepared from the parameter array keyValues. Before the HTTP request PUT is sent, the HTTP headers are extended to include the information that the JSON representation will be using. Finally the whole HTTP message, composed of the header and body, is sent to the previously-prepared URL, and the service response is interpreted and returned. The method createHandle from the file epicclient.py can be included in an iRODS rule as shown in Figure 13. testCreateRetrieveDelete { msiPyInitialize; msiLocalPython4("/irods/pidservices/epicclient.py", "createHandle", "noRecursionTest", *prefix, *suffix, "{'URL':'xxxx://xxxx.xxxxxxx.xxx/loc1', 'CHECKSUM':'abcdef'}", *res); msiPyFinalize; } INPUT *prefix="9210",*suffix="TESTHANDLE3" OUTPUT *res Figure 13: Example code for creating an iRODS rule Firstly the Python interpreter is initialized, then the method "createHandle" (from the file epicclient.py) is called with following parameters: *prefix, *suffix, and JSON contents (as a string). The result of the operation can be accessed via the variable *res. If no more Python-based micro-services will be called, the Python interpreter can be finalized.
Draft better contracts in just 5 minutes Get the weekly Law Insider newsletter packed with expert videos, webinars, ebooks, and more!