From 44cd72475ed473a5fcbd1afb3749e2ff13ff60c9 Mon Sep 17 00:00:00 2001 From: Shishir Suvarna Date: Tue, 28 Feb 2023 13:43:40 +0530 Subject: [PATCH] Checking if the organisation is ApigeeX for AppGroup --- src/SDKConnector.php | 14 ++++++++++++++ src/SDKConnectorInterface.php | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/src/SDKConnector.php b/src/SDKConnector.php index df8282ca0..1b7ef4cbb 100644 --- a/src/SDKConnector.php +++ b/src/SDKConnector.php @@ -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; @@ -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} */ diff --git a/src/SDKConnectorInterface.php b/src/SDKConnectorInterface.php index 61e2fadfc..e96eeab6e 100644 --- a/src/SDKConnectorInterface.php +++ b/src/SDKConnectorInterface.php @@ -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; @@ -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. *