Integrate Python with Rampiva Automate

The material in this document is for informational purposes only. 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 article describes how to write a Python script that will connect to Rampiva Automate using the API and perform various actions such as submit a new Job using the required settings and parameters, change the priority of a Job, and cancel all running Jobs.

When creating a Python script that performs other tasks, it can be useful to first manually perform the tasks in the Rampiva Automate web interface and to monitor the endpoints called and the responses received in the browser network tab. Additionally, the Rampiva API documentation is available at http://localhost/openapi, where localhost is the server where Automate is installed.

Prerequisites 


Instructions

A. Submit a Job and Monitor Its Progress

1

Log in to Rampiva Automate using an API Key and perform a test query retrieving the user settings.

The Internal scope can be used for testing and must first be enabled in the Scheduler configuration YAML file. See https://downloads.rampiva.com/scheduler-for-nuix/preview/guides/en_US/installation-guide.html#_scheduler_service_settings for details on how to configure Scheduler.

Update the serviceLocation variable to reflect the URL under which Scheduler is accessible.

import requests from datetime import datetime import time serviceLocation = 'http://localhost/api/v1' authHeader = 'Bearer 8fe0a872-f1d2-430a-931f-8aa61172fc19:Nx1f9JeKajeezt2BE6xO0AbvCq8RHNsr' headers = { 'Authorization': authHeader } userSettings = requests.get(serviceLocation+'/scheduler/userSettings', headers=headers).json() print (userSettings)
2

Define a function that will query Rampiva objects (such as Resource Pools) by name and return the object.

def getRampivaObject(endpoint,name): response = requests.get(serviceLocation+endpoint, headers=headers) json = response.json() if (response.status_code != 200): raise Exception('Query endpoint error',endpoint,json) print ('Endpoint',endpoint,'returned',str(len(json)),'object(s)') for item in response.json(): if item['name']==name: return item raise Exception('Could not find',name,'using',endpoint)
3

Get the IDs of the Rampiva objects that will be used for the Job submission.

resourcePoolName = 'Pool A' executionProfileName = 'Default Profile' clientName = 'Citrus Foods' matterName = 'Project Grapefruit' libraryName = 'Sample Library' workflowName = 'Sample eDiscovery Processing' resourcePool = getRampivaObject('/scheduler/resources/resourcePools',resourcePoolName) print('Resource Pool',resourcePoolName,'has ID',resourcePool['id']) executionProfile = getRampivaObject('/scheduler/resources/executionProfiles',executionProfileName) print('Execution Profile',executionProfileName,'has ID',executionProfile['id']) client = getRampivaObject('/scheduler/client',clientName) print('Client',clientName,'has ID',client['id']) matter = getRampivaObject('/scheduler/client/'+client['id']+'/matters',matterName) print('Matter',matterName,'has ID',matter['id']) library = getRampivaObject('/scheduler/library',libraryName) print('Library',libraryName,'has ID',library['id']) workflow = getRampivaObject('/scheduler/library/'+library['id']+'/workflows',workflowName) print('Workflow',workflowName,'has ID',workflow['id'])
4

Display the parameters that need to be filled out during the Job submission.

5

Prepare the Job submission.

6

Submit the Job.

7

Monitor the Job progress until it ends.

8

Sample full script.

B. Change the Priority of a Job

1

Log in to Rampiva Automate - see Section A.

 

2

Define a function that updates the priority of a Job.

3

Search for Jobs with the name containing the specific text from Powershell. If the Job is still in the NOT_STARTED state, then update the job priority to HIGH using the previously defined function.

4

Sample full script.

C. Stop All Running Jobs

1

Log in to Rampiva Automate - see Section A.

 

2

Define a function that stops a Job.

3

Search for running Jobs and stop them

4

Sample full script.