Stored procedures

This topic describes how to run stored procedures.

You can run stored procedures via the script field in Queries. For example, the following code shows a query where the get_mfa_events.js stored procedure is run:

POST /redrock/query

{  
	"Script":"@/lib/get_mfa_events.js",
	"Args":{  
		"PageNumber":1,
		"PageSize":100000,
		"Limit":100000,
		"SortBy":"",
		"direction":"False",
		"Caching":-1
	}
}

You can also run stored procedures via the script field in in the /JobFlow/StartJob endpoint. For example, the following code shows a query where the server_account_access.js stored procedure is run as a job:

POST /JobFlow/StartJob

{  
	"script":"/lib/jobs/server_account_access.js",
	"args":{  
		"PVID":"98765432-1118-4326-815a-d33abd18da26",
		"Reason":null,
		"AccessType":"Login",
		"RequestedOptions":{  
			"AssignmentType":"window",
			"StartTime":"Fri, 02 Feb 2018 20:11:00 GMT",
			"EndTime":"Fri, 02 Feb 2018 21:11:00 GMT"
		}
	}
}

Parameters

Some stored procedures take in parameters via an args field in the body and others take in parameters inline with the filename.

The following shows an example of passing multiple parameters via the args field:

POST /redrock/query

{  
	"Script":"@/lib/email_report.js",
	"Args":{  
		"SelectQuery": "Select ID from VaultAccount where User = \"Administrator\"",
		"Parameters":
		[
			{
				"Name" : "TestParam0",
				"DisplayValue" : "Test0",
				"Value" : "TestValue0",
			}
		],
		"To":"me@test.com",
		"Subject": "Test report",
		"ReportFormat": "html",
		"ReportName" : "MyReport"
	}   
}

The args field may also contain parameters for pagination.

The following shows an example of passing the id parameter inline with the filename:

POST /redrock/query

{
	"Script":"@/lib/server/get_activity_for_discoveryprofile.js(id:'b65cef...')"
}

Stored procedures run through /RedRock/Query

The following is a list of available stored procedures run through /RedRock/Query.

Stored procedures executed through /JobFlow/StartJob

The following is a list of available stored procedures executed through /JobFlow/StartJob.