Skip to content
Permalink
Browse files
Python http download example
  • Loading branch information
DImuthuUpe committed Jan 19, 2021
1 parent f7495b7 commit bcad5d2338cccf33355b465a4066a3b9d7174e98
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
Empty file.
@@ -0,0 +1,4 @@
venv
MFTApi_pb2.py
MFTApi_pb2_grpc.py
google/*
@@ -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"
@@ -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
@@ -0,0 +1,3 @@
grpcio==1.34.1
google-api-python-client==1.12.8
grpcio-tools==1.34.1

0 comments on commit bcad5d2

Please sign in to comment.