Automate - Call Scheduler API from Job
The material in this document is for informational purposes only. This guide assumes that the most recent version of Rampiva Automate is in use unless otherwise noted in the prerequisites. The products it describes are subject to change without prior notice, due to the manufacturer’s continuous development program. Rampiva makes no representations or warranties with respect to this document or with respect to the products described herein. Rampiva shall not be liable for any damages, losses, costs or expenses, direct, indirect or incidental, consequential or special, arising out of, or related to the use of this material or the products described herein.
Introduction
This document shows how to make API calls to the Scheduler API from a Job using the Script operation. In this example, the script will list Jobs and move all Jobs that are in the Backlog laneto the Staging lane.
Prerequisites
Rampiva Automate v7.4 or later
Instructions
A. Create and Test the Workflow
1 | Create a Workflow with the Python script shown in the right pane The URL of the Scheduler instance and the authentication credentials do not need to be explicitly set when running the Job from Scheduler. These are automatically set by the platform and are valid for the duration of the execution of the Job.
| print("Listing Jobs")
response = restRampiva.get("/api/v1/scheduler/jobs")
# Raise an error if we could not list the Jobs
response.raise_for_status()
jobs = response.json()
# For each Job
for job in jobs:
# Print the Job details
print("Job ID: "+job["id"]+"\tState: "+job["executionState"])+"\tStaging: "+str(job["inStaging"])+"\tName: "+job["name"]
# Select the Job only if it's not started, and not already in the Staging lane
if job["executionState"]=="NOT_STARTED" and not job["inStaging"]:
print "\tDetected Backlog Job, moving to Staging ..."
# Prepare and send the command to move the Job to the Staging lane
executionCommand = {"command":"MOVE_TO_STAGING"}
response = restRampiva.put("/api/v1/scheduler/jobs/"+job["id"]+"/execution",executionCommand)
try:
# Detect if an error occured when sending the command
response.raise_for_status()
except Exception as err:
print("\tCannot move Job "+job["id"]+" to Staging, "+str(err))
else:
print "\tJob moved to Staging" |
2 | Test the Workflow. Sample excerpt from the Execution Log: Starting operation 1/1 Script on 7/10/23, 12:35 PM > Listing Jobs > Job ID: a14979ce-a69b-4f69-8cb7-e93af46be192 State: NOT_STARTED Staging: False Name: Testing - Sample eDiscovery Processing > Detected Backlog Job, moving to Staging ... > Job moved to Staging > Job ID: 1dddb063-7aa8-4a4c-8d4f-54e9b73c7201 State: NOT_STARTED Staging: True Name: Training - Purview - Download > Job ID: b9d99523-a30f-486a-b471-ae9efaaebbd5 State: RUNNING Staging: False Name: Testing - Move all Jobs to Staging Script completed successfully with return value: null Operation 1/1 Script completed on 7/10/23, 12:35 PM
|
|