Difference between revisions of "Downloading Files via Java SDK in response to Instructions"

From Datonis
Jump to: navigation, search
(Created page with "== Introduction == This document describes the file download mechanism on the edge via the Java SDK. This download can be triggered from the platform by means of an instructio...")
 
m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
 
This document describes the file download mechanism on the edge via the Java SDK. This download can be triggered from the platform by means of an instruction. More details on how to achieve this are provided below
 
This document describes the file download mechanism on the edge via the Java SDK. This download can be triggered from the platform by means of an instruction. More details on how to achieve this are provided below
 +
 +
== Generate a new ssh key pair ==
 +
In case you have not done it already, you should generate a ssh key pair using instructions given in [https://confluence.atlassian.com/bitbucketserver/creating-ssh-keys-776639788.html this document].
 +
 +
Once you are done, share the public key with the Altizon team so that they can add access for you. Note that you do not need to share the private key.
  
 
== Download latest Java SDK ==
 
== Download latest Java SDK ==
Firstly, download the latest [https://github.com/Altizon/datonis-edge-sdk-java Java SDK] and make it ready for your use.
+
Next, download the latest [https://github.com/Altizon/datonis-edge-sdk-java Java SDK] and make it ready for your use.
 +
 
 +
Apart from the Standard configuration mentioned in the steps that come with the SDK, you will need to do following changes in addition to those:
 +
 
 +
=== Keep sftp details handy ===
 +
You will need to have following inputs
 +
* username to access the sftp server fs1.datonis.io
 +
* path to a file containing the host information (known hosts file) for fs1.datonis.io
 +
* path to a file containing the private key part from the key pair you generated for fs1.datonis.io
 +
In case you are using Windows and you do not know how to generate the host information file, you may want to try following unix command on a Unix box:
 +
ssh-keyscan -t rsa  fs1.datonis.io >> ~/.ssh/fs_known_hosts
 +
Alternatively, you can get it from Altizon team
 +
 
 +
=== Specifying configuration in the datonis-edge.properties ===
 +
Add following lines into your properties file
 +
"protocol": "mqtts",
 +
"ssh_host": "fs1.datonis.io",
 +
"ssh_username": "< your ssh username >",
 +
"ssh_known_hosts_path": "< path to known hosts file>",
 +
"ssh_private_key_path": "< path to private key file>"
 +
 
 +
=== Sample download program ===
 +
There is a new sample that showcases the mechanism to download files via an instruction handler: SampleAgentWithDownload. Modify it with thing keys corresponding to your things.
 +
 
 +
There is a special instruction handler (setupBiDirectionalCommunication) in this program that contains code to download files dynamically as per specified instruction. You may want to customize this logic (download path etc.) as per your needs. You may event want to add logic to restart services etc. within this handler.
 +
 
 +
== Creating an Instruction on cloud ==
 +
Now, you need to create an instruction on the cloud that indicates the path to download a file.
 +
 
 +
In the instructions section create a new instruction as per screenshot below:
 +
 
 +
[[File:Download-Instruction-example.png|800x800px]]
 +
 
 +
'''Note''' that the path has forward slashes replaced by pipe notation. This is a temporary workaround due to a known issue on the platform
 +
 
 +
== Executing the instruction ==
 +
Once you have defined the instruction, you can then try executing it against the thing configured in your SDK.
  
Apart from the Standard configuration mentioned in the steps, you will need to do following changes in addition to those:
+
This should trigger the download of the file at the required location

Latest revision as of 20:02, 25 September 2017

Introduction

This document describes the file download mechanism on the edge via the Java SDK. This download can be triggered from the platform by means of an instruction. More details on how to achieve this are provided below

Generate a new ssh key pair

In case you have not done it already, you should generate a ssh key pair using instructions given in this document.

Once you are done, share the public key with the Altizon team so that they can add access for you. Note that you do not need to share the private key.

Download latest Java SDK

Next, download the latest Java SDK and make it ready for your use.

Apart from the Standard configuration mentioned in the steps that come with the SDK, you will need to do following changes in addition to those:

Keep sftp details handy

You will need to have following inputs

  • username to access the sftp server fs1.datonis.io
  • path to a file containing the host information (known hosts file) for fs1.datonis.io
  • path to a file containing the private key part from the key pair you generated for fs1.datonis.io

In case you are using Windows and you do not know how to generate the host information file, you may want to try following unix command on a Unix box:

ssh-keyscan -t rsa  fs1.datonis.io >> ~/.ssh/fs_known_hosts

Alternatively, you can get it from Altizon team

Specifying configuration in the datonis-edge.properties

Add following lines into your properties file

"protocol": "mqtts",
"ssh_host": "fs1.datonis.io",
"ssh_username": "< your ssh username >",
"ssh_known_hosts_path": "< path to known hosts file>",
"ssh_private_key_path": "< path to private key file>"

Sample download program

There is a new sample that showcases the mechanism to download files via an instruction handler: SampleAgentWithDownload. Modify it with thing keys corresponding to your things.

There is a special instruction handler (setupBiDirectionalCommunication) in this program that contains code to download files dynamically as per specified instruction. You may want to customize this logic (download path etc.) as per your needs. You may event want to add logic to restart services etc. within this handler.

Creating an Instruction on cloud

Now, you need to create an instruction on the cloud that indicates the path to download a file.

In the instructions section create a new instruction as per screenshot below:

Download-Instruction-example.png

Note that the path has forward slashes replaced by pipe notation. This is a temporary workaround due to a known issue on the platform

Executing the instruction

Once you have defined the instruction, you can then try executing it against the thing configured in your SDK.

This should trigger the download of the file at the required location