commit 87ac9ae799b38c06b57199d0f8186c01a94ccdc9 Author: ray Date: Sat Nov 7 20:54:07 2020 +0000 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md new file mode 100644 index 0000000..a76f378 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +Basic shell scripts for interacting with a Kanboard installations API. + +## Usage + +API access credentials should be saved in a `.env` file in the form of: + +```sh +export _api_auth='jsonrpc:api_token' +``` + +Where `api_token` has the value given on Kanboard's settings page. + + +```sh +# add a 'todo' task: +./add_todo.sh title description +``` diff --git a/add_todo.sh b/add_todo.sh new file mode 100755 index 0000000..bab430d --- /dev/null +++ b/add_todo.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +if [ -f ./.env ] ; then + . ./.env +else + echo "add_todo.sh: Warning: no '.env' file found." +fi + +if [ -z "$_api_auth" ] ; then + echo "add_todo.sh: Error: No API authorisation credentials supplied." + exit 3 +fi + +_title="$1" +_description="$2" + +_api_url='http://kanboard.docker.home/jsonrpc.php' +_project_id=4 +_position=1 +_column_id=13 +_swimlane_id=15 + +_result="$(curl --user $_api_auth \ + --silent \ + --data '{"jsonrpc": "2.0", "method": "createTask", "id": 1, "params":{"project_id": '"$_project_id"', "title": "'"$_title"'","description": "'"$_description"'"}}' \ + $_api_url)" + +_task_id="$(echo "$_result" | jq '.result')" +if [ "$_task_id" != null ] ; then + echo "Task created: $_task_id" +else + echo "Error: $_result" + exit 6 +fi + +_result="$(curl --user $_api_auth \ + --silent \ + --data '{"jsonrpc": "2.0", "method": "moveTaskPosition", "id": 1, "params":{"project_id": '"$_project_id"', "task_id": '"$_task_id"',"column_id": '"$_column_id"',"position": '"$_position"',"swimlane_id": '"$_swimlane_id"'}}' \ + $_api_url)" + +_status="$(echo "$_result" | jq '.result')" +if [ "$_status" = true ] ; then + echo "Task moved: $_status" +else + echo "Error: $_result" + exit 9 +fi