Create and configure rules

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

The Drupal Rules module lets you define a rule that specifies the action that occurs automatically in response to an event on the portal. For example, you can create a rule to automatically add a default app (action) to all new developer accounts (event). Or, you can create a rule to redirect a user to a specific page (action) on log in (event). Add and manage user accounts shows how to define those two rules.

The Rules module is very flexible and you can use it to create many different types of rules. A subset of the events include:

  • Adding, updating or deleting a developer app
  • Changing the status of a developer app
  • Adding, updating, or deleting a developer account
  • Adding, updating, or deleting a portal node
  • Drupal is initialized
  • A Drupal log entry is created

A subset of the types of actions that can be performed include:

  • Sending an email to an individual or group
  • Blocking a user
  • Promoting content
  • Showing a message on the site
  • Performing a page redirect
  • Blocking an IP address

You can also add conditions to rules, for example to test the role of a developer, as part of processing the rule.

For a compete list of capabilities, see the documentation on the Drupal Rules module.

Enabling rules

Before you can create a rule, you muse ensure that all the necessary Drupal modules are enabled.

To enable the necessary Drupal modules:

  1. Log in to your portal as a user with admin privileges.
  2. Select Modules in the Drupal administration menu.
  3. Enable the following modules if they are not already enabled:
    • Rules
    • Rules UI
  4. Save the configuration.
    You might see other required modules being enabled automatically.

Creating a rule

In this example, you create a rule to notify administrators when a developer create a new app on the portal.

To create a rule:

  1. Log in to your portal as a user with admin privileges.
  2. Select Configuration > Workflow > Rules in the Drupal administration menu.
  3. Select + Add new rule on the Rules page.
  4. Specify the Name of the rule. For example Email on app creation.
  5. Optionally specify a tag as app_creation.
  6. In the React on event dropdown box, select Devconnect > Upon creation of a developer app.
  7. Select Save
    The Editing reaction rule page appears. You already set the event in the previous step, so it should say Upon creation of a developer app in under Events. Leave Conditions blank for this rule.
  8. Under Actions, select + Add action.
  9. Select System > Send mail in the dropdown.
    The Add a new action page changes its layout to let you specify email information.
  10. Edit all information including the email recipients, message body, sender, and other information.
  11. Click Save to return to the Editing reaction rule page.
  12. Click Save changes.

    Now when a developer creates an app, an email is automatically sent to the list of recipients specified by the rule.

Editing or deleting a rule

After you create a rule, you can later edit or delete the rule.

To edit or update a rule:

  1. Log in to your portal as a user with admin privileges.
  2. Select Configuration > Workflow > Rules in the Drupal administration menu.
  3. Select the rule to edit or delete.