Ballerina can also become a useful tool for DevOps engineers who welcome the challenge of learning a new language. The example below shows how a ballerina script that uses the twitter API can be embedded into a shell script. Similarly you can avail any one of the ballerina connectors listed here[1].
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MSG="WSO2 Ballerina goes well with shell.." | |
ballerina_utility_function() | |
{ | |
BALLERINA_SCRIPT_LOCATION="$BALLERINA_HOME/samples/twitterConnector/twitterConnector.bal" | |
bash "$BALLERINA_HOME/bin/ballerina" "run" "main" "$BALLERINA_SCRIPT_LOCATION" "$1" "$2" "$3" "$4" "$MSG" | |
return | |
} | |
RESPONSE="$(ballerina_utility_function $1 $2 $3 $4 $MSG)" | |
echo "-----> $RESPONSE" |
Execute the script as follows,
./script.sh <consumerKey> <consumerSecret> <accessToken> <accessTokenSecret>
Look to the ballerina 0.8X twitter connector sample readme for further instructions. Find out more about ballerina here: http://ballerinalang.org
[1] - http://ballerinalang.org/docs/api/0.8/
Note: this example was written for ballerina 0.86 and may not work with other versions.
No comments:
Post a Comment