Integrate PowerShell 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 PowerShell 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 PowerShell 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

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

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

Update the $authHeader variable with the value one obtained when configuring the Rampiva API Key. See https://rampiva.atlassian.net/wiki/spaces/KB/pages/1130921985 for instructions on how to create an API Key.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $ServiceLocation = "http://localhost/api/v1" $authHeader = "Bearer 265fa20a-ba69-47a0-aab5-034fba50e062:fzMQKFhuOb63ydsOFmJJtExe6mttWFSr" $headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]" $headers.Add('Authorization', $authHeader) $response = $null $response = Invoke-RestMethod "$ServiceLocation/scheduler/userSettings" -headers $headers -Method Get -ContentType "application/json" Write-Host "Querying the user settings endpoint returned $response"
2

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

function Get-Rampiva-Object { param( [Parameter(Mandatory=$true)] [string] $Name, [Parameter(Mandatory=$true)] [string] $Endpoint ) $response = $null $response = Invoke-RestMethod "$ServiceLocation/$Endpoint" -headers $headers -Method Get -ContentType "application/json" if ($response -eq $null) { Write-Error Querying endpoint $Endpoint failed } Write-Host "Endpoint $Endpoint returned $($response.Length) objects(s)" Foreach ($item in $response) { if ($item.name -eq $Name) { return $item } } Write-Error Could not find $Name using $Endpoint Exit }
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" # Get resources IDs $ResourcePool = Get-Rampiva-Object -Endpoint "scheduler/resources/resourcePools" -Name $ResourcePoolName Write-Host Resource Pool $ResourcePool.name has ID $ResourcePool.id $ExecutionProfile = Get-Rampiva-Object -Endpoint "scheduler/resources/executionProfiles" -Name $ExecutionProfileName Write-Host Execution Profile $ExecutionProfile.name has ID $ExecutionProfile.id $Client = Get-Rampiva-Object -Endpoint "scheduler/client" -Name $ClientName Write-Host Client $Client.name has ID $Client.id $Matter = Get-Rampiva-Object -Endpoint "scheduler/client/$($Client.id)/matters" -Name $MatterName Write-Host Matter $Matter.name has ID $Matter.id $Library = Get-Rampiva-Object -Endpoint "scheduler/library" -Name $LibraryName Write-Host Library $Library.name has ID $Library.id $Workflow = Get-Rampiva-Object -Endpoint "scheduler/library/$($Library.id)/workflows" -Name $WorkflowName Write-Host Workflow $Workflow.name 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.