Date: Fri, 29 Mar 2024 10:25:25 +0000 (UTC) Message-ID: <1520012755.12751.1711707925742@change.sos-berlin.com> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_12750_577746295.1711707925742" ------=_Part_12750_577746295.1711707925742 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The JOC Cockpit comes with a REST Web Service interface for JSON. This i= nterface is used for access to the job inventory and the job history as wel= l as individual objects such as jobs, job chains and orders and provides cu= rrent status information.
joc/api/security/login
shiro.ini
configuration file. See the Authentication and Authorization - Confi=
guration article and the example api_user
c=
onfiguration for further information.joc/api/security/joc_cockpit_permissions
 =
;URL to retrieve the permissions for the current user.joc/api/*
joc/api/security/logout
#!/usr/bin/sh # ----------------------------------------- # MODIFY FOR YOUR ENVIRONMENT # Protocol, host and port of JOC Cockpit JS_URL=3D"https://localhost:4446" # Identification of JobScheduler instance JS_ID=3D"apmacwin_4444" # Path and name of Job Chain JS_JOB_CHAIN=3D"/product_demo/shell_chain" # Path and name of Job JS_JOB=3D"/product_demo/shell_job" # Base64 encoded string "user:password" for JOC Cockpit authentication. The= below string represents "root:root" JS_BASIC_AUTHENTICATION=3D"`echo "root:root" | base64`" JS_BASIC_AUTHENTICATION=3D"${JS_BASIC_AUTHENTICATION:0:${#JS_BASIC_AUTHENTI= CATION}-4}" # ----------------------------------------- # ----------------------------------------- # Perform login echo "" echo "PERFORMING LOGIN" JS_JSON=3D"`curl -k -s -S -X POST -i -m 15 -H "Authorization: Basic $JS_BAS= IC_AUTHENTICATION" -H "Accept: application/json" -H "Content-Type: applicat= ion/json" $JS_URL/joc/api/security/login`" JS_ACCESS_TOKEN=3D$(echo $JS_JSON | grep -Po '"accessToken":.*?[^\\]"' | aw= k -F ':' '{print $2}' | tr -d \" ) # ----------------------------------------- # ----------------------------------------- # Get the status of a job chain echo "" echo "Get the status of a job chain" # Execute web service request JS_REST_BODY=3D"{ \"jobschedulerId\": \"$JS_ID\", \"compact\": true, \"jobC= hain\": \"$JS_JOB_CHAIN\" }" JS_JSON=3D"`curl -k -s -S -X POST -d "$JS_REST_BODY" -i -m 15 -H "X-Access-= Token: $JS_ACCESS_TOKEN" -H "Accept: application/json" -H "Content-Type: ap= plication/xml" $JS_URL/joc/api/job_chain`" echo $JS_JSON # ----------------------------------------- # ----------------------------------------- # Get the status of a job echo "" echo "Get the status of a job" # Execute web service request JS_REST_BODY=3D"{ \"jobschedulerId\": \"$JS_ID\", \"compact\": true, \"job\= ": \"$JS_JOB\" }" JS_JSON=3D"`curl -k -s -S -X POST -d "$JS_REST_BODY" -i -m 15 -H "X-Access-= Token: $JS_ACCESS_TOKEN" -H "Accept: application/json" -H "Content-Type: ap= plication/xml" $JS_URL/joc/api/job`" echo $JS_JSON # ----------------------------------------- # ----------------------------------------- # Perform logout echo "" echo "PERFORMING LOGOUT" curl -k -s -S -X POST -i -m 15 -H "X-Access-Token: $JS_ACCESS_TOKEN" -H "Ac= cept: application/json" -H "Content-Type: application/json" $JS_URL/joc/api= /security/logout # ----------------------------------------- echo ""
=
p>
#!/usr/bin/sh # ----------------------------------------- # MODIFY FOR YOUR ENVIRONMENT # Protocol, host and port of JOC Cockpit JS_URL=3D"http://localhost:4446" # Identification of JobScheduler instance JS_ID=3D"apmaccs_4444" # ----------------------------------------- # ----------------------------------------- # Base64 encoded string "user:password" for JOC Cockpit authentication. The= below string represents "root:root" # JS_BASIC_AUTHENTICATION=3D"cm9vdDpyb290" # Alternatively base64 encode and strip the last 4 bytes JS_BASIC_AUTHENTICATION=3D"`echo "root:root" | base64`" JS_BASIC_AUTHENTICATION=3D"${JS_BASIC_AUTHENTICATION:0:${#JS_BASIC_AUTHENTI= CATION}-4}" # ----------------------------------------- # ----------------------------------------- # Perform login echo "" echo "PERFORMING LOGIN" JS_JSON=3D"`curl -k -s -S -X POST -i -m 15 -H "Authorization: Basic $JS_BAS= IC_AUTHENTICATION" -H "Accept: application/json" -H "Content-Type: applicat= ion/json" $JS_URL/joc/api/security/login`" JS_ACCESS_TOKEN=3D$(echo $JS_JSON | grep -Po '"accessToken":.*?[^\\]"' | aw= k -F ':' '{print $2}' | tr -d \" ) # ----------------------------------------- # ----------------------------------------- # Suspend a specific order identified by its ID from a given job chain spec= ified by its full path echo "" echo "SUSPENDING AN ORDER" JS_REST_BODY=3D"{ \"jobschedulerId\": \"$JS_ID\", \"orders\": [{ \"orderId\= ": \"order1\", \"jobChain\": \"/agent/job_chain1\" }] }" # Execute web service request curl -k -s -S -X POST -d "$JS_REST_BODY" -i -m 15 -H "X-Access-Token: $JS_A= CCESS_TOKEN" -H "Accept: application/json" -H "Content-Type: application/js= on" $JS_URL/joc/api/orders/suspend # ----------------------------------------- # ----------------------------------------- # Perform logout echo "" echo "PERFORMING LOGOUT" curl -k -s -S -X POST -i -m 15 -H "X-Access-Token: $JS_ACCESS_TOKEN" -H "Ac= cept: application/json" -H "Content-Type: application/json" $JS_URL/joc/api= /security/logout # ----------------------------------------- echo ""
Find attached example <=
a href=3D"/download/attachments/16909907/suspended_orders.sh?version=3D1&am=
p;modificationDate=3D1591657043000&api=3Dv2" data-linked-resource-id=3D=
"46825571" data-linked-resource-version=3D"1" data-linked-resource-type=3D"=
attachment" data-linked-resource-default-alias=3D"suspended_orders.sh" data=
-linked-resource-content-type=3D"application/x-sh" data-linked-resource-con=
tainer-id=3D"16909907" data-linked-resource-container-version=3D"19">suspen=
ded_orders.sh for use with curl
# ---------------------------------------- # Protocol, host and port of JOC Cockpit JS_URL=3D"http://localhost:5446" # Identification of JobScheduler instance JS_ID=3D"testsuite" # ----------------------------------------- # ----------------------------------------- # Base64 encoded string "user:password" for JOC Cockpit authentication. The= below string represents "root:root" JS_BASIC_AUTHENTICATION=3D"`echo "root:root" | base64`" JS_BASIC_AUTHENTICATION=3D"${JS_BASIC_AUTHENTICATION:0:${#JS_BASIC_AUTHENTI= CATION}-4}" # ----------------------------------------- # Perform login echo "" echo "PERFORMING LOGIN" JS_JSON=3D"`curl -k -s -S -X POST -i -m 15 -H "Authorization: Basic $JS_BAS= IC_AUTHENTICATION" -H "Accept: application/json" -H "Content-Type: applicat= ion/json" $JS_URL/joc/api/security/login`" JS_ACCESS_TOKEN=3D$(echo $JS_JSON | grep -Po '"accessToken":.*?[^\\]"' | aw= k -F ':' '{print $2}' | tr -d \" ) # ----------------------------------------- # ----------------------------------------- # Get orders with status "suspended" echo "" echo "Get suspended orders" # Execute web service request JS_REST_BODY=3D"{ \"jobschedulerId\": \"$JS_ID\", \"compact\": true, \"proc= essingStates\": [\"SUSPENDED\"] }" JS_JSON=3D"`curl -k -s -S -X POST -d "$JS_REST_BODY" -i -m 15 -H "X-Access-= Token: $JS_ACCESS_TOKEN" -H "Accept: application/json" -H "Content-Type: ap= plication/xml" $JS_URL/joc/api/orders`" echo $JS_JSON # ----------------------------------------- # ----------------------------------------- # ----------------------------------------- # Perform logout echo "" echo "PERFORMING LOGOUT" curl -k -s -S -X POST -i -m 15 -H "X-Access-Token: $JS_ACCESS_TOKEN" -H "Ac= cept: application/json" -H "Content-Type: application/json" $JS_URL/joc/api= /security/logout # ----------------------------------------- echo ""