From 7bae0d57d05e300c5211b45c52e27dc33ca6eb5d Mon Sep 17 00:00:00 2001 From: phdhiren Date: Mon, 13 Mar 2023 21:36:48 +0530 Subject: [PATCH 1/3] Support assigning API products to Apps on creation (#248) --- composer.json | 3 ++ src/Api/Management/Entity/App.php | 32 +++++++++++++++++++ .../Controller/AppControllerTestBase.php | 3 ++ 3 files changed, 38 insertions(+) diff --git a/composer.json b/composer.json index 4114e898..8c4ec25d 100644 --- a/composer.json +++ b/composer.json @@ -71,6 +71,9 @@ "preferred-install": { "symfony/property-access": "source", "*": "dist" + }, + "allow-plugins": { + "php-http/discovery": true } }, "minimum-stability": "dev", diff --git a/src/Api/Management/Entity/App.php b/src/Api/Management/Entity/App.php index 8ab74f4f..0b030015 100644 --- a/src/Api/Management/Entity/App.php +++ b/src/Api/Management/Entity/App.php @@ -58,6 +58,9 @@ abstract class App extends Entity implements AppInterface /** @var \Apigee\Edge\Api\Management\Entity\AppCredential[] */ protected $credentials = []; + /** @var string[] */ + protected $initialApiProducts = []; + /** * App constructor. * @@ -216,4 +219,33 @@ public function setScopes(string ...$scopes): void { $this->privateSetScopes(...$scopes); } + + /** + * Get Initial API Products only during app creation. + * + * @return array $initialApiProducts + * + * @internal + */ + final public function getApiProducts(): array + { + return $this->initialApiProducts; + } + + /** + * Set Initial API Products only during app creation. + * The method is not supported to update existing App. + * + * @param array $initialApiProducts + * + * @throws \LogicException If used to update existing App. + */ + final public function setInitialApiProducts(array $initialApiProducts): void + { + if (!$this->appId) { + $this->initialApiProducts = $initialApiProducts; + } else { + throw new \LogicException('This method is only supported for creating a new app.'); + } + } } diff --git a/tests/Api/Management/Controller/AppControllerTestBase.php b/tests/Api/Management/Controller/AppControllerTestBase.php index 355abc14..ee212f23 100644 --- a/tests/Api/Management/Controller/AppControllerTestBase.php +++ b/tests/Api/Management/Controller/AppControllerTestBase.php @@ -107,6 +107,7 @@ protected function alterArraysBeforeCompareSentAndReceivedPayloadsInCreate(array { // This is not returned in the POST/PUT API call responses only in GET. unset($sentEntityAsArray['appFamily']); + unset($sentEntityAsArray['apiProducts']); } /** @@ -116,6 +117,8 @@ protected function alterObjectsBeforeCompareResponseAndCreatedEntity(\stdClass & { /* @var \Apigee\Edge\Api\Management\Entity\DeveloperAppInterface $created */ $responseObject->appFamily = $created->getAppFamily(); + + $responseObject->apiProducts = $created->getApiProducts(); } /** From d9ebe72d24f0f2609ca373b019ce92e14c389a57 Mon Sep 17 00:00:00 2001 From: phdhiren Date: Wed, 15 Mar 2023 17:33:53 +0000 Subject: [PATCH 2/3] Bump version to 2.0.19 and change log (#250) --- CHANGELOG.md | 3 +++ src/ClientInterface.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9153413..286299cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # CHANGELOG +## [2.0.19](https://github.com/apigee/apigee-client-php/milestone/18?closed=1) +* [#248] Support assigning API products to Apps on creation, Introduced setInitialApiProducts only during app creation. This will be helpful for the organization having the features.keymanagement.disable.unbounded.permissions is TRUE + ## [2.0.18](https://github.com/apigee/apigee-client-php/milestone/17?closed=1) * [#243] Add additional organization type for Apigee X diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 76c02796..93912bce 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -64,7 +64,7 @@ interface ClientInterface extends HttpClient */ public const APIGEE_ON_GCP_ENDPOINT = 'https://apigee.googleapis.com/v1'; - public const VERSION = '2.0.18'; + public const VERSION = '2.0.19'; /** * Allows access to the last request, response and exception. From 7f6117d2e5259b1dcd4c27f5f307986aada28e0e Mon Sep 17 00:00:00 2001 From: Shishir <75600200+shishir-intelli@users.noreply.github.com> Date: Wed, 17 May 2023 14:38:15 +0530 Subject: [PATCH 3/3] Http\Client\HttpClient deprecated used Psr\Http\Client\ClientInterface (#261) --- src/Client.php | 2 +- src/ClientInterface.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index c0c49b63..9bf0a3f4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -33,11 +33,11 @@ use Http\Client\Common\Plugin\HistoryPlugin; use Http\Client\Common\Plugin\RetryPlugin; use Http\Client\Exception; -use Http\Client\HttpClient; use Http\Discovery\MessageFactoryDiscovery; use Http\Discovery\UriFactoryDiscovery; use Http\Message\Authentication; use Http\Message\UriFactory; +use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriInterface; diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 93912bce..cebaa88e 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -19,8 +19,8 @@ namespace Apigee\Edge; use Apigee\Edge\HttpClient\Utility\JournalInterface; -use Http\Client\HttpClient; use Http\Message\UriFactory; +use Psr\Http\Client\ClientInterface as HttpClient; use Psr\Http\Message\ResponseInterface; /**