Query related Approve Apps in Developer Portal

Hi,

There are following two queries i am having

1.Is there any built-in proxies to get approved apps of corresponding user

2.How can i use function to get approved apps in custom module e.g in my Apps menu

0 2 325
2 REPLIES 2

Hi Haider

I'm not clear on exactly what you're asking. I think you want to determine the list of apps registered to a developer. There is a way to do that using the Administrative API for Apigee Edge. For example:

curl -i -n $mgmtserver/v1/o/ORG/developers/joeyd@example.org/apps?expand=true

You will replace $mgmtserver with the API endpoint for the management server. In the cloud-based Apigee Edge SaaS product, that endpoint is https://api.enterprise.apigee.com .

But this isn't exactly what you asked for. This query returns all developer apps for a particular developer. Some of those apps may be "revoked", while some may be "pending" and others "approved". It is up to you (or the client) to filter the list of apps to find only the approved apps. But that's pretty simple.

But you asked if there were any "built in proxies" to do this task. That question doesn't make sense to me, but because you asked it, I think you might be looking for something other than an administrative API call. Maybe what you want is a Drupal module that does this?

The devconnect module that ships in the Apigee Edge developer portal performs THAT call ^^ that I've shown above. BUT, the default module does not show the pending / revoked / approved status of each app it lists. It should be pretty easy for you to extend or replace the template for the apps list page (Specifically the file devconnect_developer_apps_list.tpl.php), with something suitable. Basically you want another column for credential status.

I use a modified version of that file to display credential and app status in the list. The results look like this:

4121-screenshot-20161221-122533.png

As you can see, there are three different apps listed, and each one has a different credential, a different API Product, a different expiry, and a different status (Pending, Revoked, Approved).

To get the status of the credential, you need code to walk the hierarchy. The app itself may be revoked; in that case Apigee Edge would reject the credentials, even though the credential itself is marked "approved". Second, the credential could be approved or revoked. And finally the specific API Product attached to the credential could be marked approved, revoked, or pending. So to show correct, meaningful information in this table under all conditions, you need to consider all of those settings. The code I use for that is like this:

if (!function_exists('array_any')) {
        function array_any($callback, $array) {
                foreach ($array as $val) {
                        if ($callback($val)) {
                                return true;
                        }
                }
                return false;
        }
}

function _cred_apiproduct_is_pending($cred_apiproduct) {
        return $cred_apiproduct['status'] == 'pending';
}

function _cred_status_ex($app,$cred) {
  $status = ucfirst($app['status']);
  if ($status != "Pending" && $status != "Revoked") {
      $status = ucfirst($cred['status']);
  }
  if ($status != "Revoked") {
          if (array_any(_cred_apiproduct_is_pending, $cred['apiProducts'])) {
                  $status = 'Pending';
          }
  }
  return $status;
}


Hi Dino,

Basically i wanted to get all approved apps of particular authenticated users through Developer Portal, I have been succeeded in getting particular authenticated users Products and their Application Status but I am unable to fetch API's been used in those Products, If you could help in that.

I am sharing my code in which i have successfully fetched particular users Products and its Application Status all i want now is to get their APIs been patched in those products.

Code:

global $user;


 $app_entities = entity_load('developer_app', FALSE, array('mail' => $user->mail));


  if (count($app_entities) == 0) {
    $parameters = array(
      'application_count' => 0,
      'applications' => array(),
      'user' => $user,
    );
  }
else
{
   foreach ($app_entities as $entity) {
   $display_name=$entity->name;
   $org_name=$entity->orgName;
	$status=$entity->overallStatus;
drupal_set_message(t("This is the app name: $display_name"));
drupal_set_message(t("This is the status name: $status"));






foreach($entity->apiProducts as $api_product=>$value){
drupal_set_message(t("This is the apps products name:  $value"));




}


//foreach($entity->apiProducts as $api_product=>$value1){
//drupal_set_message(t("This is the product proxies name:  $value1"));




}
 
}


}