You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by di...@apache.org on 2021/01/19 20:00:00 UTC

[airavata-mft] branch master updated: Python http download example

This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-mft.git


The following commit(s) were added to refs/heads/master by this push:
     new bcad5d2  Python http download example
bcad5d2 is described below

commit bcad5d2338cccf33355b465a4066a3b9d7174e98
Author: Dimuthu Wannipurage <di...@gmail.com>
AuthorDate: Tue Jan 19 14:59:44 2021 -0500

    Python http download example
---
 .../mft-python-sdk/samples/mft_api_client_sample.py   |  0
 examples/src/main/python/.gitignore                   |  4 ++++
 examples/src/main/python/download_http.py             | 19 +++++++++++++++++++
 examples/src/main/python/readme.md                    | 10 ++++++++++
 examples/src/main/python/requirements.txt             |  3 +++
 5 files changed, 36 insertions(+)

diff --git a/client-sdk/mft-python-sdk/samples/mft_api_client_sample.py b/client-sdk/mft-python-sdk/samples/mft_api_client_sample.py
deleted file mode 100644
index e69de29..0000000
diff --git a/examples/src/main/python/.gitignore b/examples/src/main/python/.gitignore
new file mode 100644
index 0000000..6e2313d
--- /dev/null
+++ b/examples/src/main/python/.gitignore
@@ -0,0 +1,4 @@
+venv
+MFTApi_pb2.py
+MFTApi_pb2_grpc.py
+google/*
\ No newline at end of file
diff --git a/examples/src/main/python/download_http.py b/examples/src/main/python/download_http.py
new file mode 100644
index 0000000..15af21b
--- /dev/null
+++ b/examples/src/main/python/download_http.py
@@ -0,0 +1,19 @@
+import grpc
+import MFTApi_pb2
+import MFTApi_pb2_grpc
+
+channel = grpc.insecure_channel('localhost:7004')
+stub = MFTApi_pb2_grpc.MFTApiServiceStub(channel)
+download_request = MFTApi_pb2.HttpDownloadApiRequest(sourceStoreId ="remote-ssh-storage",
+                                  sourcePath= "/tmp/a.txt",
+                                  sourceToken = "local-ssh-cred",
+                                  sourceType= "SCP",
+                                  targetAgent = "agent0",
+                                  mftAuthorizationToken = "")
+
+result = stub.submitHttpDownload(download_request)
+print(result)
+
+## Sample output ##
+# url: "http://localhost:3333/53937f40-d545-4180-967c-ddb193d672d8"
+# targetAgent: "agent0"
\ No newline at end of file
diff --git a/examples/src/main/python/readme.md b/examples/src/main/python/readme.md
new file mode 100644
index 0000000..1077d60
--- /dev/null
+++ b/examples/src/main/python/readme.md
@@ -0,0 +1,10 @@
+python3 -m venv venv
+source venv/bin/activate
+pip install --upgrade pip
+pip install -r requirements.txt
+
+mkdir -p google/api    
+curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > google/api/annotations.proto     
+curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > google/api/http.proto
+
+python -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. --proto_path=../../../../api/stub/src/main/proto/ MFTApi.proto 
diff --git a/examples/src/main/python/requirements.txt b/examples/src/main/python/requirements.txt
new file mode 100644
index 0000000..3128456
--- /dev/null
+++ b/examples/src/main/python/requirements.txt
@@ -0,0 +1,3 @@
+grpcio==1.34.1
+google-api-python-client==1.12.8
+grpcio-tools==1.34.1
\ No newline at end of file