initial commit

This commit is contained in:
Ray Elliott 2020-11-07 20:54:07 +00:00
commit 87ac9ae799
3 changed files with 65 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

17
README.md Normal file
View File

@ -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
```

47
add_todo.sh Executable file
View File

@ -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