Stored Procedures

Overview

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

POST /redrock/query

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

Stored procedures can also be executed 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 executed 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":"[email protected]",
   	  "Subject": "Test report",
   	  "ReportFormat": "html",
   	  "ReportName" : "MyReport"
   }   
}

Note: 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

The following is a list of available stored procedures.

Stored Procedures Executed through /RedRock/Query

NameDescription
All_roles_with_membersGets all roles with members.
app_accessGets app access.
applistGets a list of apps.
devices_by_stateGets devices that are in a specific state.
email_reportEmails a report.
get_account_checkoutGets account checkout.
get_account_checkout_check
get_accounts_count_check
get_all_user_activityGets all user activity.
get_app_launches_last7daysGets all application launches in the last seven days.
get_applicationsGets all applications.
get_application_inventoryGets application inventory.
get_app_launchesGets application launches.
get_app_launches_with_iconGets application launches with icon.
get_app_deployment_to_devicesGets app deployment to devices.
get_application_launch_eventsGets all application launch events.
get_device_activityGets all device activity.
get_device_breakdownGets the device breakdown.
get_device_enrollmentsGets the device enrollments.
get_favorite_dashboardsGets favourite dashboards.
get_favorite_reportsGets favourite reports.
get_mfa_eventsGets all multi-factor authentication events.
get_mfa_success_eventsGets all multi-factor authentication success events.
get_role_apps_check
get_role_appsGets role apps.
get_servers_top_activityGets the servers that have the most activity.
get_servers_top_checkouts_check
get_servers_top_checkoutsGets the servers with the most checkouts.
get_servers_typeGet servers by type.
get_superrightsGets superrights.
get_user_activityGet all user activity.
get_user_activity_eventsGet all user activity events.
get_user_activity_for_adminGet all user activity for an admin.
get_user_devsGets a user's devices.
get_user_rolesGets all user roles.
get_user_role_namesGets the names of all user roles.
polsample
get_accountsGets accounts.
get_accounts_count_checkGet the members of a role.
get_activity_for_account_check
get_activity_for_account
get_activity_for_collectionGets activity for a collection.
get_activity_for_collection_check
get_activity_for_database_check
get_activity_for_databaseGet activity for a database.
get_activity_for_discoveryprofileGets activity for a discovery profile.
get_activity_for_domain_check
get_activity_for_domainGets activity for a domain.
get_activity_for_generic_secret_check
get_activity_for_generic_secretGets activity for a generic secret.
get_activity_for_mpaccount_check
get_activity_for_mpaccountGets activity for an mpaccount.
get_activity_for_server_check
get_activity_for_serverGets activity for a server.
get_activity_for_servers_check
get_activity_for_serversGets activity for servers.
get_activity_for_subscription_check
get_activity_for_subscriptionGets activity for a subscription.
get_logins_for_server_check
get_logins_for_serverGets logins for a server.
get_servers_count_check
get_servers_countGets a server count.
role_member_listGets the members of a role.
server_account_accessRequests access to a computer.
server_admin_activityGets server admin activity.
server_user_activityGets server user activity.

Stored Procedures Executed through /JobFlow/StartJob

NameDescription
cps_assign_computer_roleAssigns a computer role.
job_historyGets the history of jobs.