Skip to content

Commit

Permalink
Merge pull request #11 from mxr576/2.x
Browse files Browse the repository at this point in the history
2.0.0-alpha3 preparations
  • Loading branch information
mxr576 authored Jul 26, 2018
2 parents a8995bb + 718bfa4 commit 641915a
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 29 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -134,26 +134,26 @@ 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=[[email protected]]
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=[[email protected]]
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
phpunit.xml.dist file as phpunit.xml and add these variables one-by-one inside the [<php> element](https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.php-ini-constants-variables)
with an <env> 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
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.
18 changes: 9 additions & 9 deletions examples/authentication.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,23 +71,23 @@ 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';
}

/**
* @inheritdoc
*/
public function getUsername(): string
{
return getenv('APIGEE_EDGE_PHP_SDK_BASIC_AUTH_USER') ?: '[email protected]';
return getenv('APIGEE_EDGE_PHP_CLIENT_BASIC_AUTH_USER') ?: '[email protected]';
}

/**
* @inheritdoc
*/
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';
}
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/developer_app_analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') ?: '[email protected]';
$developerAppName = getenv('APIGEE_EDGE_PHP_EXAMPLE_DEVELOPER_APP_NAME') ?: 'test_app';
Expand Down
2 changes: 0 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions src/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
8 changes: 4 additions & 4 deletions tests/Test/TestClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down

0 comments on commit 641915a

Please sign in to comment.