Introduction

Users who want to export scheduling objects from the JOC Cockpit inventory find a number of options:

Export Inventory Script

The script is provided for download and can be used to automate export of Agents.

  • The script is available for Linux and MacOS® using bash, ksz, zsh, dash shell.
  • The script is intended as a baseline example for customization by JS7 users and by SOS within the scope of professional services.

Download

Download: export-inventory.sh


Sample how to export the JOC Cockpit inventory
#!/bin/sh

# ----------------------------------------
# Protocol, host and port of JOC Cockpit
JS_URL="http://localhost:7446"

# Folder that should be exported
JS_EXPORT_FOLDER="/"

# Export file
JS_EXPORT_FILE=export.zip

# Authentication (default account)
JS_USER=root
JS_PASSWORD=root
# -----------------------------------------


# -----------------------------------------
# Perform login
echo ""
echo "PERFORMING LOGIN"
JS_JSON=$(curl -k -L -s -S -X POST -m 15 --user "$JS_USER:$JS_PASSWORD" -H "Accept: application/json" -H "Content-Type: application/json" $JS_URL/joc/api/authentication/login)
JS_ACCESS_TOKEN=$(echo "$JS_JSON" | grep -Po '"accessToken":.*?[^\\]"' | awk -F ':' '{print $2}' | tr -d \" )
# -----------------------------------------


# -----------------------------------------
# Export folder
echo ""
echo "Export inventory folder: $JS_FOLDER"
# Execute web service request
JS_REST_BODY="{ \"exportFile\": {\"filename\": \"$JS_EXPORT_FILE\", \"format\": \"ZIP\"}, \"shallowCopy\": { \"objectTypes\": [\"WORKFLOW\",\"FILEORDERSOURCE\",\"JOBRESOURCE\",\"LOCK\",\"WORKINGDAYSCALENDAR\",\"SCHEDULE\",\"INCLUDESCRIPT\",\"JOBTEMPLATE\"], \"folders\": [\"$JS_EXPORT_FOLDER\"], \"recursive\": true } }"
echo "----"
echo $JS_REST_BODY
echo "----"
echo "curl -k -L -s -S -X POST -m 60 -d '$JS_REST_BODY' -H 'X-Access-Token: $JS_ACCESS_TOKEN' -H 'Accept: */*' -H 'Content-Type: application/json' -H 'Accept-Encoding: gzip, deflate' -o $JS_EXPORT_FILE.out $JS_URL/joc/api/inventory/export/folder"
curl -k -L -s -S -X POST -m 60 -d "$JS_REST_BODY" -H "X-Access-Token: $JS_ACCESS_TOKEN" -H "Accept: */*" -H "Content-Type: application/json" -H "Accept-Encoding: gzip, deflate" -o $JS_EXPORT_FILE $JS_URL/joc/api/inventory/export/folder
# -----------------------------------------


# -----------------------------------------
# Perform logout
echo ""
echo "PERFORMING LOGOUT"
curl -k -L -s -S -X POST -m 15 -H "X-Access-Token: $JS_ACCESS_TOKEN" -H "Accept: application/json" -H "Content-Type: application/json" $JS_URL/joc/api/authentication/logout
# -----------------------------------------
echo ""