Great question. You can do it with the Drupal Rules module.
The Drupal Rules module is an optional part of Drupal. If the module is enabled, then the Apigee modules will “fire events” that can be handled by rules you set up. The Rules module is installed but not enabled in Apigee developer portal installations, by default.
There is an event that is fired within Drupal when a developer app is created, or updated. The code looks like this :
if (module_exists('rules')) {
$event = ($action_taken == 'Updated' ? 'devconnect_developer_app_update' : 'devconnect_developer_app_create');
rules_invoke_event($event, $entity);
}
(You probably don’t need to know this, but you can find that code in profiles/apigee/modules/custom/devconnect/devconnect_developer_apps/devconnect_developer_apps.module )
What you want to do is handle that event, and perform an action when it occurs. Here’s how you need to do that.
-
Login as administrator to the Drupal devportal.
-
Enable the rules module. (click Modules … search for “Rules”… make sure it’s enabled)
-
go to the Rules admin panel. Configuration > Workflow > Rules
- Add a new Rule
- Name your rule, and Select the appropriate event
- Click “Next” - and then attach the desired ACTION that should occur when a developer app gets created.
Now, what action do you want? There are a number of built-in actions, like “Send an email” and “post a message on the site”. But I think you want a custom action. So for that you need to write some PHP code in a custom module. You need to do this BEFORE all those other steps. Write a function with a name like MYMODULE_rules_action_info(), which is how your custom code registers a custom action with rules. Code like this:
<?php
/**
* Implementation of hook_rules_action_info().
*/
function MYMODULE_rules_action_info() {
return array(
'MYMODULE_handle_devconnect_app_create' => array(
'label' => t('Propagate the app'),
'arguments' => array(
'app' => array('type' => 'value', 'label' => t('The app entity.')),
),
'module' => 'MYMODULE',
),
);
}
function MYMODULE_handle_devconnect_app_create($app) {
// send consumerKey and consumerSecret to the external system
}
?>
Create your custom module and install it into sites/all/modules/custom/ . Then enable your module. This is required before you configure the rules. Really you need to do this first.
That’s going to work, for apps that get created from within the developer portal. As you know there are other ways to create apps - for example an administrator could invoke the Edge Admin API directly to create an app. Or, an administrator could use the Edge Administrative UI to create an App. When apps get created that way, this drupal rule approach will not be effective. Therefore I Think you may also want to consider a cron job to synchronize between the Edge db and the list of {id,secret} pairs stored in the external system. That is outside the scope of this answer, but it should be straightforward to do.
Good luck!