Skip to content

Commit

Permalink
Checking if the organisation is ApigeeX for AppGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
shishir-intelli committed Feb 28, 2023
1 parent b71f8a9 commit 44cd724
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/SDKConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Drupal\apigee_edge\Exception\AuthenticationKeyNotFoundException;
use Drupal\apigee_edge\Exception\InvalidArgumentException;
use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\apigee_edge\Entity\Controller\OrganizationController as EdgeOrganizationController;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\InfoParserInterface;
Expand Down Expand Up @@ -158,6 +159,19 @@ public function getOrganization(): string {
return $credentials->getKeyType()->getOrganization($credentials->getKey());
}

/**
* {@inheritdoc}
*/
public function isOrganizationApigeeX(EdgeOrganizationController $organizationController): bool {
try {
$this->organization = $organizationController->load($this->getOrganization());
return ($this->organization && ('CLOUD' === $this->organization->getRuntimeType() || 'HYBRID' === $this->organization->getRuntimeType()));
}
catch (\Exception $e) {
$this->messenger->addError($e->getMessage());
}
}

/**
* {@inheritdoc}
*/
Expand Down
9 changes: 9 additions & 0 deletions src/SDKConnectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace Drupal\apigee_edge;

use Apigee\Edge\ClientInterface;
use Drupal\apigee_edge\Entity\Controller\OrganizationController;
use Drupal\key\KeyInterface;
use Http\Message\Authentication;

Expand All @@ -36,6 +37,14 @@ interface SDKConnectorInterface {
*/
public function getOrganization(): string;

/**
* Checking if the Organisation is ApigeeX..
*
* @return bool
* TRUE if given Organisation is ApigeeX. FALSE otherwise.
*/
public function isOrganizationApigeeX(OrganizationController $organizationController): bool;

/**
* Returns the http client.
*
Expand Down

0 comments on commit 44cd724

Please sign in to comment.