diff --git a/CHANGELOG.md b/CHANGELOG.md index 365b4a08..fcd99217 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # CHANGELOG +## 2.0.0-alpha3 - 2018-07-26 + +* As CPS pagination got supported in the Management API for listing API products and Companies we also added it to API client. +* `getEntities()` and `getEntityIds()` load all entities and entity ids +from Apigee Edge by default, even if it requires multiple API calls +because of CPS pagination. +* Classes and interfaces related to CPS and non CPS entity listing got renamed: + * CpsLimitEntityController => PaginatedEntityController + * CpsLimitEntityControllerInterface => PaginatedEntityControllerInterface + * CpsLimitEntityController => PaginatedEntityController + * CpsListingEntityControllerInterface => PaginatedEntityListingControllerInterface + * CpsListingEntityControllerTrait => PaginatedEntityListingControllerTrait + * NonCpsListingEntityControllerTrait => NoPaginationEntityListingControllerTrait + * NonCpsListingEntityControllerInterface => NonPaginatedEntityListingControllerInterface + * CpsListLimitInterface => PagerInterface +* OAuth: Fixed re-authentication with client credentials if refresh token has expired. +* [Changed return types](https://github.com/apigee/apigee-client-php/commit/a3b51721a5a9d937d978490ae7e7ee6601b8a3b8) in AppCredentialController as it does not inherit from EntityCrudOperationsControllerTrait anymore. +* Constants that represents constant state of the Management API now defined in interfaces instead of classes. +* Also the visibility of some constants changed to public from private or protected. +* Added support to add [Retry plugin](http://docs.php-http.org/en/latest/plugins/retry.html) configuration to the client. +* Renamed environment variables used in tests for authentication from APIGEE_EDGE_PHP_SDK_* to APIGEE_EDGE_PHP_CLIENT_*. +* Improved test coverage. +* Better configuration in .gitattributes to exclude more unnecessary files from prefer-dist install. + ## 2.0.0-alpha2 - 2018-05-24 * Added CHANGELOG.md. diff --git a/README.md b/README.md index a5c3676c..f1059117 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ categories: * [Stats](https://apidocs.apigee.com/api/stats) For more information about the Apigee Edge Management APIs, see [Getting started with the API Edge Management APIs](https://apidocs.apigee.com/api-reference/content/api-reference-getting-started) -in the Apigee documentation. +in the Apigee documentation. The Apigee API Client Library for PHP, built using the HTTPlug library, provides an HTTP client implementation-independent library. You choose the client that best fits your project requirements. If you need PHP < 7.1 or Monetization API support please install the older [edge-php-sdk version](https://github.com/apigee/edge-php-sdk). -We are planning to add Monetization API support to this library in the near future. +We are planning to add Monetization API support to this library in the near future. ## Installing the client library @@ -52,7 +52,7 @@ If you would like to use [OAuth (SAML) authentication](https://docs.apigee.com/a then you have to install [this patch](https://patch-diff.githubusercontent.com/raw/php-http/client-common/pull/103.diff) from [this php-http/client-common pull request](https://github.com/php-http/client-common/pull/103). If you use [composer-patches](https://github.com/cweagans/composer-patches) plugin and you [allowed dependencies to apply patches](https://github.com/cweagans/composer-patches#allowing-patches-to-be-applied-from-dependencies) -then this patch is automatically gets applied when this library is installed. +then this patch is automatically gets applied when this library is installed. ## Usage examples @@ -134,11 +134,11 @@ Testing of new changes does not require Apigee Edge connection. By default, unit tests with a real Apigee Edge instance you have to specify the following environment variables (without brackets): ```shell -APIGEE_EDGE_PHP_SDK_HTTP_CLIENT=\Http\Adapter\Guzzle6\Client -APIGEE_EDGE_PHP_SDK_BASIC_AUTH_USER=[YOUR-EMAIL-ADDRESS@HOST.COM] -APIGEE_EDGE_PHP_SDK_BASIC_AUTH_PASSWORD=[PASSWORD] -APIGEE_EDGE_PHP_SDK_ORGANIZATION=[ORGANIZATION] -APIGEE_EDGE_PHP_SDK_ENVIRONMENT=[ENVIRONMENT] +APIGEE_EDGE_PHP_CLIENT_HTTP_CLIENT=\Http\Adapter\Guzzle6\Client +APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_USER=[YOUR-EMAIL-ADDRESS@HOST.COM] +APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_PASSWORD=[PASSWORD] +APIGEE_EDGE_PHP_CLIENT_ORGANIZATION=[ORGANIZATION] +APIGEE_EDGE_PHP_CLIENT_ENVIRONMENT=[ENVIRONMENT] ``` There are multiple ways to set these environment variables, but probably the easiest is creating a copy from the @@ -146,7 +146,7 @@ phpunit.xml.dist file as phpunit.xml and add these variables one-by-one inside t with an element. It is also possible to create and use your own data set. If you would like to use your own offline test data set then -you just need to define the `APIGEE_EDGE_PHP_SDK_OFFLINE_TEST_DATA_FOLDER` environment variable set its value to the parent +you just need to define the `APIGEE_EDGE_PHP_CLIENT_OFFLINE_TEST_DATA_FOLDER` environment variable set its value to the parent folder of your own test data set. PS.: Some unit tests cannot be executed when the offline test data set is in use, those are automatically marked as @@ -154,6 +154,6 @@ skipped. ## Support -This is not an officially supported Google product. Please file issues in our GitHub Issue Queue. We would love to -accept contributions to this project, please see the [contribution guidelines for this project](CONTRIBUTING.md) for +This is not an officially supported Google product. Please file issues in our GitHub Issue Queue. We would love to +accept contributions to this project, please see the [contribution guidelines for this project](CONTRIBUTING.md) for more details. diff --git a/examples/authentication.inc b/examples/authentication.inc index f739c770..796ecfcb 100644 --- a/examples/authentication.inc +++ b/examples/authentication.inc @@ -20,13 +20,13 @@ * Provides a client factory that can build a API client. It reads necessary credentials from environment variables. * * Requires the following environment variables to be set on your system: - * - APIGEE_EDGE_PHP_SDK_BASIC_AUTH_USER - * - APIGEE_EDGE_PHP_SDK_BASIC_AUTH_PASSWORD - * - APIGEE_EDGE_PHP_SDK_ORGANIZATION + * - APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_USER + * - APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_PASSWORD + * - APIGEE_EDGE_PHP_CLIENT_ORGANIZATION * * Optional: - * - APIGEE_EDGE_PHP_SDK_ENDPOINT - * - APIGEE_EDGE_PHP_SDK_ENVIRONMENT + * - APIGEE_EDGE_PHP_CLIENT_ENDPOINT + * - APIGEE_EDGE_PHP_CLIENT_ENVIRONMENT */ use Apigee\Edge\Client; use Apigee\Edge\ClientInterface; @@ -71,7 +71,7 @@ class EnvironmentCredentialProvider implements CredentialProvider */ public function getOrganization(): string { - return getenv('APIGEE_EDGE_PHP_SDK_ORGANIZATION') ?: 'my-organization'; + return getenv('APIGEE_EDGE_PHP_CLIENT_ORGANIZATION') ?: 'my-organization'; } /** @@ -79,7 +79,7 @@ class EnvironmentCredentialProvider implements CredentialProvider */ public function getUsername(): string { - return getenv('APIGEE_EDGE_PHP_SDK_BASIC_AUTH_USER') ?: 'my-email-address@example.com'; + return getenv('APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_USER') ?: 'my-email-address@example.com'; } /** @@ -87,7 +87,7 @@ class EnvironmentCredentialProvider implements CredentialProvider */ public function getPassword(): string { - return getenv('APIGEE_EDGE_PHP_SDK_BASIC_AUTH_PASSWORD') ?: 'my-secure-password'; + return getenv('APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_PASSWORD') ?: 'my-secure-password'; } } @@ -115,7 +115,7 @@ class ClientFactory */ public function __construct(CredentialProvider $credential, ?string $endpoint = null) { - $this->endpoint = $endpoint ?: getenv('APIGEE_EDGE_PHP_SDK_ENDPOINT') ?: null; + $this->endpoint = $endpoint ?: getenv('APIGEE_EDGE_PHP_CLIENT_ENDPOINT') ?: null; $this->credential = $credential; } diff --git a/examples/developer_app_analytics.php b/examples/developer_app_analytics.php index 92a46258..c387c1a6 100644 --- a/examples/developer_app_analytics.php +++ b/examples/developer_app_analytics.php @@ -26,7 +26,7 @@ require_once 'authentication.inc'; -$environment = getenv('APIGEE_EDGE_PHP_SDK_ENVIRONMENT') ?: 'test'; +$environment = getenv('APIGEE_EDGE_PHP_CLIENT_ENVIRONMENT') ?: 'test'; $developerMail = getenv('APIGEE_EDGE_PHP_EXAMPLE_DEVELOPER_MAIL') ?: 'developer1@example.com'; $developerAppName = getenv('APIGEE_EDGE_PHP_EXAMPLE_DEVELOPER_APP_NAME') ?: 'test_app'; diff --git a/src/Client.php b/src/Client.php index f3f48a01..207df8d0 100644 --- a/src/Client.php +++ b/src/Client.php @@ -63,8 +63,6 @@ class Client implements ClientInterface public const CONFIG_RETRY_PLUGIN_CONFIG = 'retry_plugin_config'; - protected const VERSION = '2.0.0-alpha2'; - /** @var \Http\Message\UriFactory */ private $uriFactory; diff --git a/src/ClientInterface.php b/src/ClientInterface.php index 16b7039b..5c3a4502 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -32,6 +32,8 @@ interface ClientInterface extends HttpClient { public const DEFAULT_ENDPOINT = 'https://api.enterprise.apigee.com/v1'; + public const VERSION = '2.0.0-alpha3'; + /** * Allows access to the last request, response and exception. * diff --git a/tests/Test/Controller/EnvironmentAwareEntityControllerValidatorTrait.php b/tests/Test/Controller/EnvironmentAwareEntityControllerValidatorTrait.php index 44478a93..e738a574 100644 --- a/tests/Test/Controller/EnvironmentAwareEntityControllerValidatorTrait.php +++ b/tests/Test/Controller/EnvironmentAwareEntityControllerValidatorTrait.php @@ -32,6 +32,6 @@ protected static function getEnvironment(ClientInterface $client) return 'test'; } - return getenv('APIGEE_EDGE_PHP_SDK_ENVIRONMENT') ?: 'test'; + return getenv('APIGEE_EDGE_PHP_CLIENT_ENVIRONMENT') ?: 'test'; } } diff --git a/tests/Test/Controller/OrganizationAwareEntityControllerValidatorTrait.php b/tests/Test/Controller/OrganizationAwareEntityControllerValidatorTrait.php index d4a44958..d910d3bd 100644 --- a/tests/Test/Controller/OrganizationAwareEntityControllerValidatorTrait.php +++ b/tests/Test/Controller/OrganizationAwareEntityControllerValidatorTrait.php @@ -32,6 +32,6 @@ protected static function getOrganization(ClientInterface $client) return 'phpunit'; } - return getenv('APIGEE_EDGE_PHP_SDK_ORGANIZATION') ?: 'phpunit'; + return getenv('APIGEE_EDGE_PHP_CLIENT_ORGANIZATION') ?: 'phpunit'; } } diff --git a/tests/Test/TestClientFactory.php b/tests/Test/TestClientFactory.php index 17e67505..8900a04c 100644 --- a/tests/Test/TestClientFactory.php +++ b/tests/Test/TestClientFactory.php @@ -59,7 +59,7 @@ class TestClientFactory */ public function getClient(string $fqcn = null): ClientInterface { - $fqcn = $fqcn ?: getenv('APIGEE_EDGE_PHP_SDK_HTTP_CLIENT') ?: FileSystemMockClient::class; + $fqcn = $fqcn ?: getenv('APIGEE_EDGE_PHP_CLIENT_HTTP_CLIENT') ?: FileSystemMockClient::class; $rc = new \ReflectionClass($fqcn); if (!$rc->implementsInterface(MockClientInterface::class) && !$rc->implementsInterface(HttpClient::class)) { throw new \InvalidArgumentException( @@ -76,12 +76,12 @@ public function getClient(string $fqcn = null): ClientInterface $userAgentPrefix = self::OFFLINE_CLIENT_USER_AGENT_PREFIX; } $auth = new NullAuthentication(); - $user = getenv('APIGEE_EDGE_PHP_SDK_BASIC_AUTH_USER') ?: ''; - $password = getenv('APIGEE_EDGE_PHP_SDK_BASIC_AUTH_PASSWORD') ?: ''; + $user = getenv('APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_USER') ?: ''; + $password = getenv('APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_PASSWORD') ?: ''; if ($user || $password) { $auth = new BasicAuth($user, $password); } - $endpoint = getenv('APIGEE_EDGE_PHP_SDK_ENDPOINT') ?: null; + $endpoint = getenv('APIGEE_EDGE_PHP_CLIENT_ENDPOINT') ?: null; if (DebuggerClient::class == $rc->getName()) { $logHandler = new StreamHandler(__DIR__ . '/../../debug.log'); // Only print the message.