From aad60881441b4017d2467567b590b283ae9b5ea8 Mon Sep 17 00:00:00 2001 From: Shishir Suvarna Date: Mon, 11 Sep 2023 18:15:03 +0530 Subject: [PATCH 1/2] Added pagination for AppGroups Apps-3x --- .../Controller/AppByOwnerController.php | 53 ++++++++++++ .../AppByOwnerControllerInterface.php | 46 ++++++++++ .../Controller/AppGroupAppController.php | 23 +---- .../AppGroupAppControllerInterface.php | 4 +- .../apps/GET_pageToken=4phpunit_test_app.json | 84 +++++++++++++++++++ .../apps/GET_pageToken=5phpunit_test_app.json | 42 ++++++++++ 6 files changed, 227 insertions(+), 25 deletions(-) create mode 100644 src/Api/ApigeeX/Controller/AppByOwnerController.php create mode 100644 src/Api/ApigeeX/Controller/AppByOwnerControllerInterface.php create mode 100644 tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=4phpunit_test_app.json create mode 100644 tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=5phpunit_test_app.json diff --git a/src/Api/ApigeeX/Controller/AppByOwnerController.php b/src/Api/ApigeeX/Controller/AppByOwnerController.php new file mode 100644 index 00000000..83a0b167 --- /dev/null +++ b/src/Api/ApigeeX/Controller/AppByOwnerController.php @@ -0,0 +1,53 @@ +getBaseEndpointUri(); - $response = $this->getClient()->get($uri); - $responseArray = $this->responseToArray($response); - // Ignore entity type key from response, ex.: apiProduct. - $responseArray = reset($responseArray); - - return $this->responseArrayToArrayOfEntities($responseArray); - } - /** * Override the getEntityIds() method, for AppGroup compatibility. * diff --git a/src/Api/ApigeeX/Controller/AppGroupAppControllerInterface.php b/src/Api/ApigeeX/Controller/AppGroupAppControllerInterface.php index 20a12164..20d2bac0 100644 --- a/src/Api/ApigeeX/Controller/AppGroupAppControllerInterface.php +++ b/src/Api/ApigeeX/Controller/AppGroupAppControllerInterface.php @@ -18,12 +18,10 @@ namespace Apigee\Edge\Api\ApigeeX\Controller; -use Apigee\Edge\Api\Management\Controller\AppByOwnerControllerInterface; - /** * Interface AppGroupAppControllerInterface. * - * @see https://apidocs.apigee.com/api/apps-appgroup + * @see https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.appgroups.apps */ interface AppGroupAppControllerInterface extends AppByOwnerControllerInterface, AppGroupAwareControllerInterface { diff --git a/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=4phpunit_test_app.json b/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=4phpunit_test_app.json new file mode 100644 index 00000000..b29c7b36 --- /dev/null +++ b/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=4phpunit_test_app.json @@ -0,0 +1,84 @@ +{ + "app": [ + { + "appFamily": "default", + "appId": "b3e71cbb-7eb5-4444-b384-ac82bca1d9dc", + "attributes": [ + { + "name": "DisplayName", + "value": "PHP Unit: Test app" + }, + { + "name": "Notes", + "value": "This is a test app created by PHP Unit." + }, + { + "name": "foo", + "value": "foo" + }, + { + "name": "bar", + "value": "baz" + } + ], + "callbackUrl": "http://example.com", + "createdAt": 648345600000, + "createdBy": "phpunit@example.com", + "credentials": [ + { + "apiProducts": [], + "attributes": [], + "consumerKey": "wAXAIiOr2oJOVGqFltnm3Jwr2LE0GEuY", + "consumerSecret": "S8YjnsjmdBqDAegR", + "issuedAt": 648345600000, + "scopes": [], + "status": "approved" + } + ], + "appGroup": "phpunit", + "lastModifiedAt": 648345600000, + "lastModifiedBy": "phpunit@example.com", + "name": "4phpunit_test_app", + "scopes": [], + "status": "approved" + }, + { + "appFamily": "default", + "appId": "b3e71cbb-7eb5-3333-b384-ac82bca1d9dc", + "attributes": [ + { + "name": "DisplayName", + "value": "PHP Unit: Test app" + }, + { + "name": "Notes", + "value": "This is a test app created by PHP Unit." + }, + { + "name": "foo", + "value": "bar" + } + ], + "callbackUrl": "http://example.com", + "createdAt": 648345600000, + "createdBy": "phpunit@example.com", + "credentials": [ + { + "apiProducts": [], + "attributes": [], + "consumerKey": "wAXAIiOr2oJOVGqFltnm3Jwr2LE0GEuY", + "consumerSecret": "S8YjnsjmdBqDAegR", + "issuedAt": 648345600000, + "scopes": [], + "status": "approved" + } + ], + "appGroup": "phpunit", + "lastModifiedAt": 648345600000, + "lastModifiedBy": "phpunit@example.com", + "name": "5phpunit_test_app", + "scopes": [], + "status": "approved" + } + ] +} diff --git a/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=5phpunit_test_app.json b/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=5phpunit_test_app.json new file mode 100644 index 00000000..2b6031ce --- /dev/null +++ b/tests/offline-test-data/v1/organizations/phpunit/appgroups/phpunit/apps/GET_pageToken=5phpunit_test_app.json @@ -0,0 +1,42 @@ +{ + "app": [ + { + "appFamily": "default", + "appId": "b3e71cbb-7eb5-3333-b384-ac82bca1d9dc", + "attributes": [ + { + "name": "DisplayName", + "value": "PHP Unit: Test app" + }, + { + "name": "Notes", + "value": "This is a test app created by PHP Unit." + }, + { + "name": "foo", + "value": "bar" + } + ], + "callbackUrl": "http://example.com", + "createdAt": 648345600000, + "createdBy": "phpunit@example.com", + "credentials": [ + { + "apiProducts": [], + "attributes": [], + "consumerKey": "wAXAIiOr2oJOVGqFltnm3Jwr2LE0GEuY", + "consumerSecret": "S8YjnsjmdBqDAegR", + "issuedAt": 648345600000, + "scopes": [], + "status": "approved" + } + ], + "appGroup": "phpunit", + "lastModifiedAt": 648345600000, + "lastModifiedBy": "phpunit@example.com", + "name": "5phpunit_test_app", + "scopes": [], + "status": "approved" + } + ] +} From 16e2305e99fd81af3b7d882d286572c52f975e46 Mon Sep 17 00:00:00 2001 From: Shishir Suvarna Date: Mon, 11 Sep 2023 18:26:30 +0530 Subject: [PATCH 2/2] fix nullable_type_declaration_for_default_null_value --- src/Api/ApigeeX/Controller/AppByOwnerController.php | 2 +- src/Api/ApigeeX/Controller/AppGroupAppController.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Api/ApigeeX/Controller/AppByOwnerController.php b/src/Api/ApigeeX/Controller/AppByOwnerController.php index 83a0b167..55a2f7fc 100644 --- a/src/Api/ApigeeX/Controller/AppByOwnerController.php +++ b/src/Api/ApigeeX/Controller/AppByOwnerController.php @@ -45,7 +45,7 @@ abstract class AppByOwnerController extends PaginatedEntityController implements * @param ClientInterface $client * @param EntitySerializerInterface|null $entitySerializer */ - public function __construct(string $organization, ClientInterface $client, ?EntitySerializerInterface $entitySerializer = null) + public function __construct(string $organization, ClientInterface $client, EntitySerializerInterface $entitySerializer = null) { $entitySerializer = $entitySerializer ?? new AppEntitySerializer(); parent::__construct($organization, $client, $entitySerializer); diff --git a/src/Api/ApigeeX/Controller/AppGroupAppController.php b/src/Api/ApigeeX/Controller/AppGroupAppController.php index 4c2b37e8..f7c18fc9 100644 --- a/src/Api/ApigeeX/Controller/AppGroupAppController.php +++ b/src/Api/ApigeeX/Controller/AppGroupAppController.php @@ -52,8 +52,8 @@ public function __construct( string $organization, string $appGroup, ClientInterface $client, - ?EntitySerializerInterface $entitySerializer = null, - ?OrganizationControllerInterface $organizationController = null + EntitySerializerInterface $entitySerializer = null, + OrganizationControllerInterface $organizationController = null ) { $this->appGroup = $appGroup; $entitySerializer = $entitySerializer ?? new AppGroupEntitySerializer();