Skip to content

Commit

Permalink
Added Cognito Identity and Sync clients, tests, and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremeamia committed Jul 10, 2014
1 parent ec2f26a commit c40a2dc
Show file tree
Hide file tree
Showing 16 changed files with 1,769 additions and 1 deletion.
10 changes: 10 additions & 0 deletions docs/index.rst
Expand Up @@ -31,6 +31,8 @@ AWS SDK for PHP
service-cloudsearchdomain
service-cloudtrail
service-cloudwatch
service-cognitoidentity
service-cognitosync
service-datapipeline
service-directconnect
service-dynamodb
Expand Down Expand Up @@ -129,6 +131,14 @@ Service-Specific Guides

.. indexlinks:: CloudWatch

* Amazon Cognito Identity

.. indexlinks:: CognitoIdentity

* Amazon Cognito Sync

.. indexlinks:: CognitoSync

* Amazon DynamoDB

.. indexlinks:: DynamoDb
Expand Down
3 changes: 3 additions & 0 deletions docs/service-cognitoidentity.rst
@@ -0,0 +1,3 @@
.. service:: CognitoIdentity

.. apiref:: CognitoIdentity
3 changes: 3 additions & 0 deletions docs/service-cognitosync.rst
@@ -0,0 +1,3 @@
.. service:: CognitoSync

.. apiref:: CognitoSync
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -37,6 +37,8 @@
<directory suffix="Exception.php">./src/Aws/CloudSearchDomain/Exception</directory>
<directory suffix="Exception.php">./src/Aws/CloudTrail/Exception</directory>
<directory suffix="Exception.php">./src/Aws/CloudWatch/Exception</directory>
<directory suffix="Exception.php">./src/Aws/CognitoIdentity/Exception</directory>
<directory suffix="Exception.php">./src/Aws/CognitoSync/Exception</directory>
<directory suffix="Exception.php">./src/Aws/DataPipeline/Exception</directory>
<directory suffix="Exception.php">./src/Aws/DirectConnect/Exception</directory>
<directory suffix="Exception.php">./src/Aws/DynamoDb/Exception</directory>
Expand Down
75 changes: 75 additions & 0 deletions src/Aws/CognitoIdentity/CognitoIdentityClient.php
@@ -0,0 +1,75 @@
<?php

namespace Aws\CognitoIdentity;

use Aws\Common\Client\AbstractClient;
use Aws\Common\Client\ClientBuilder;
use Aws\Common\Enum\ClientOptions as Options;
use Aws\Common\Exception\Parser\JsonQueryExceptionParser;
use Aws\Common\Signature\SignatureListener;
use Guzzle\Common\Collection;
use Guzzle\Service\Command\AbstractCommand;
use Guzzle\Service\Resource\Model;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;

/**
* Client to interact with Amazon Cognito Identity
*
* @method Model createIdentityPool(array $args = array()) {@command CognitoIdentity CreateIdentityPool}
* @method Model deleteIdentityPool(array $args = array()) {@command CognitoIdentity DeleteIdentityPool}
* @method Model describeIdentityPool(array $args = array()) {@command CognitoIdentity DescribeIdentityPool}
* @method Model getId(array $args = array()) {@command CognitoIdentity GetId}
* @method Model getOpenIdToken(array $args = array()) {@command CognitoIdentity GetOpenIdToken}
* @method Model listIdentities(array $args = array()) {@command CognitoIdentity ListIdentities}
* @method Model listIdentityPools(array $args = array()) {@command CognitoIdentity ListIdentityPools}
* @method Model unlinkIdentity(array $args = array()) {@command CognitoIdentity UnlinkIdentity}
* @method Model updateIdentityPool(array $args = array()) {@command CognitoIdentity UpdateIdentityPool}
*
* @link http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-cognitoidentity.html User guide
* @link http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.CognitoIdentity.CognitoIdentityClient.html API docs
*/
class CognitoIdentityClient extends AbstractClient
{
const LATEST_API_VERSION = '2014-06-30';

/**
* Factory method to create a new Amazon Cognito Identity client using an array of configuration options.
*
* See http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options
*
* @param array|Collection $config Client configuration data
*
* @return self
* @link http://docs.aws.amazon.com/aws-sdk-php/guide/latest/configuration.html#client-configuration-options
*/
public static function factory($config = array())
{
$client = ClientBuilder::factory(__NAMESPACE__)
->setConfig($config)
->setConfigDefaults(array(
Options::VERSION => self::LATEST_API_VERSION,
Options::SERVICE_DESCRIPTION => __DIR__ . '/Resources/cognitoidentity-%s.php',
))
->setExceptionParser(new JsonQueryExceptionParser)
->build();

// Attach a listener to prevent some requests from being signed
$client->getEventDispatcher()->addListener('command.before_send', function (Event $event) {
/** @var AbstractCommand $command */
$command = $event['command'];
if (in_array($command->getName(), array('GetId', 'GetOpenIdToken', 'UnlinkIdentity'))) {
/** @var EventDispatcher $dispatcher */
$dispatcher = $command->getRequest()->getEventDispatcher();
foreach ($dispatcher->getListeners('request.before_send') as $listener) {
if (is_array($listener) && $listener[0] instanceof SignatureListener) {
$dispatcher->removeListener('request.before_send', $listener);
break;
}
}
}
});

return $client;
}
}
10 changes: 10 additions & 0 deletions src/Aws/CognitoIdentity/Exception/CognitoIdentityException.php
@@ -0,0 +1,10 @@
<?php

namespace Aws\CognitoIdentity\Exception;

use Aws\Common\Exception\ServiceResponseException;

/**
* Exception thrown by the CognitoIdentity service client.
*/
class CognitoIdentityException extends ServiceResponseException {}

0 comments on commit c40a2dc

Please sign in to comment.