On a REST Request
AMPS includes a module that allows you to configure an action to run when a specified resource underneath the /amps/administrator/actions
path in the admin interface is requested. The amps-action-on-admin
module allows you to add a custom action to the admin interface and provides the ability to pass parameters into the Do
step of those actions using query parameters in the HTTP request.
The module requires the Path
parameter, which specifies the path under /amps/administrator/actions
where this action should appear:
Path
(required)
Specifies the path under /amps/administrator/actions
where this action should appear. The action will run when a request for the specified path is received by the AMPS admin interface.
For entitlement purposes, the AMPS admin interface treats actions configured using this module identically to resources provided by AMPS. That is, the user requesting that the action run must have access to the appropriate admin resource for the action to run.
For example, to add an action that runs journal maintenance at the path /amps/administrator/actions/journal_cleanup
, you would use the following Path
element:
The Path
element should contain only a resource name. No /
character should appear in the Path
element.
Any query parameters provided as part of the request are added to the context before the Do
steps for the action are run. This module adds the names and values of the query parameters without adjusting the case of the items.
For some actions, it's important that a specific context value is present before the action runs. You can configure the module to require that the request provide one or more query parameters using the RequiredParameter
option to the module. When one or more RequiredParameter
is specified, the admin console will refuse any request for the resource that does not include all of the required parameters.
The action also provides support for a Name
element and a Description
element, which can be used to help tools that monitor or manage AMPS (such as the Galvanometer monitoring tool included with AMPS) provide information on the action.
RequiredParameter
Specifies that a request to run this action must include the specified query parameter. If the request does not include this item as part of the query parameters, the request will return an error rather than executing the action.
Name
Specifies the name to use for display purposes for this resource.
Description
Specifies a description to use for display purposes for this resource.
For an example of configuring an action using this module, see Archive Journals on RESTful Command.
The amps-action-on-admin
module should be used for ad hoc maintenance (such as responding to an unexpected increase in traffic by archiving journals ahead of schedule) or tasks that are triggered unpredictably by an external system. For tasks that need to run on a regular basis or frequently (for example, every few seconds), amps-action-on-schedule
is more efficient.
Last updated