From b8120c6de0f7fc7b7360214e4111506073e31a78 Mon Sep 17 00:00:00 2001 From: Daniel Marquez Date: Wed, 25 Jul 2018 17:22:51 -0400 Subject: [PATCH 1/3] Updated name for pip. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e78e3e4..5071049 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from distutils.core import setup config = { - 'name' :'TR500HTTP', + 'name' :'devicewise', 'version':'1.0', 'description' : 'Sample code for communicating with the Telit IoT Platform via Python.', 'author' : 'Telit', From bfd68434949360ecd69e1e4bc32b5f2b0123ce31 Mon Sep 17 00:00:00 2001 From: Daniel Marquez Date: Wed, 25 Jul 2018 18:24:48 -0400 Subject: [PATCH 2/3] Added file_get() for file.get api to TR50httpWorker. --- TR50/TR50httpWorker.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/TR50/TR50httpWorker.py b/TR50/TR50httpWorker.py index 8d9e271..678ed35 100644 --- a/TR50/TR50httpWorker.py +++ b/TR50/TR50httpWorker.py @@ -73,6 +73,21 @@ def email_send(self, email_to, email_from, email_subject, email_body): result = self.execute("email.send", params) return (result == True and self.response["data"]["success"]) + # file.get : Reserves a file handle for a given file to be obtained via HTTP GET + # @param string file_name The name of the file to be retrieved from the M2M Service. + # @param string thing_key The Thing associated with the file. Defaults to the current session's Thing. + # @param bool global_file If set to true, the file is a global file and the thingKey parameter will be ignored. + # @return mixed Returns a dict with the fileId, fileSize and rcr32 or the failure code + def file_get(self, file_name, thing_key, global_file): + """This command reserves a file handle for a given file to be obtained via HTTP GET""" + params = { "fileName" : file_name, "global" : global_file } + if global_file == False: + params["thingKey"] = thing_key + result = self.execute("file.get", params) + if result == True and self.response["data"]["success"] == True: + return self.response["data"]["params"] + else: + return self.response["data"]["success"] # locale.get : This command is used to retrieve the current session's locale. # @return mixed Returns the dict of the session's locale on success, or the failure code. From 2fc9cc960b3968000bbb58707599e80f436a4f9b Mon Sep 17 00:00:00 2001 From: Daniel Marquez Date: Wed, 25 Jul 2018 18:57:37 -0400 Subject: [PATCH 3/3] Added file_put() for file.put api for TR50httpWorker. --- TR50/TR50httpWorker.py | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/TR50/TR50httpWorker.py b/TR50/TR50httpWorker.py index 678ed35..545e1c0 100644 --- a/TR50/TR50httpWorker.py +++ b/TR50/TR50httpWorker.py @@ -73,6 +73,51 @@ def email_send(self, email_to, email_from, email_subject, email_body): result = self.execute("email.send", params) return (result == True and self.response["data"]["success"]) + # file.put : Reserves a file handle to be used to upload a file via HTTP POST + # @param string file_name The name of the file to be uploaded to the platform. + # @param string thing_key The Thing that the file will be attached to. + # @param bool global_file If set to true, the file will be a global file and the thingKey parameter will be ignored. Defaults to false. + # @param bool public If true, identifies the file as publicly accessible outside of the organization. If false, the file is private to the organization. Defaults to false. + # @param int crc32 A IEEE CRC32 checksum of the file to be uploaded. When the file is subsequently sent via the HTTP interface, the checksum will be validated, and if incorrect, the file will be discarded an an error returned. + # @param mixed tags A list of tags to associate to the file. + # @param mixed sec_tags A list of tags to specify security access to the file. + # @param int ttl Specify an expect ttl (in seconds) for a file. If a file is uploaded partially and a ttl is set, partial file will be deleted after elapsed time. + # @param bool log_complete If set to true, creates an event log entry when the file upload is complete. + # @return mixed Returns a dict with the fileId or the failure code + def file_put(self, file_name, thing_key, global_file, public, crc32, tags, sec_tags, ttl, log_complete): + """This command reserves a file handle to be used to upload a file via HTTP POST""" + params = { "fileName" : file_name, "global" : global_file} + if global_file == False: + params["thingKey"] = thing_key + + if public: + params["public"] = public + + if type(tags) is list: + params["tags"] = tags + else: + params["tags"] = [ tags ] + + if type(sec_tags) is list: + params["secTags"] = sec_tags + else: + params["secTags"] = [ sec_tags ] + + if log_complete: + params["logComplete"] = log_complete + + if crc32 != False: + params["crc32"] = crc32 + + if ttl != False: + params["ttl"] = ttl + + result = self.execute("file.put", params) + if result == True and self.response["data"]["success"] == True: + return self.response["data"]["params"] + else: + return self.response["data"]["success"] + # file.get : Reserves a file handle for a given file to be obtained via HTTP GET # @param string file_name The name of the file to be retrieved from the M2M Service. # @param string thing_key The Thing associated with the file. Defaults to the current session's Thing.