/**
  * @param Guzzle\Service\Builder\ServiceBuilder $awsClient AWS client.
  * @param string $awsRegion AWS region to use for API calls.
  */
 public function __construct(Guzzle\Service\Builder\ServiceBuilder $awsClient, $awsRegion)
 {
     $this->rds = $awsClient->get('rds');
     // The IAM API is only available in us-east-1.
     $this->iam = $awsClient->get('iam', ['region' => 'us-east-1']);
     $this->region = $awsRegion;
 }
 /**
  * @covers Guzzle\Service\Plugin\PluginCollectionPlugin
  */
 public function testPluginPassPluginsThroughToClients()
 {
     $s = new ServiceBuilder(array('michael.mock' => array('class' => 'Guzzle\\Tests\\Service\\Mock\\MockClient', 'params' => array('base_url' => 'http://www.test.com/', 'subdomain' => 'michael', 'password' => 'test', 'username' => 'michael'))));
     $plugin = $this->getMock('Symfony\\Component\\EventDispatcher\\EventSubscriberInterface');
     $plugin::staticExpects($this->any())->method('getSubscribedEvents')->will($this->returnValue(array('client.create_request' => 'onRequestCreate')));
     $s->addSubscriber(new PluginCollectionPlugin(array($plugin)));
     $c = $s->get('michael.mock');
     $this->assertTrue($c->getEventDispatcher()->hasListeners('client.create_request'));
     $listeners = $c->getEventDispatcher()->getListeners('client.create_request');
     $this->assertSame($plugin, $listeners[0][0]);
     $this->assertEquals('onRequestCreate', $listeners[0][1]);
 }
 public function testSetBuilder()
 {
     $services = new ServiceManager();
     $builder = ServiceBuilder::factory(array());
     $services->setBuilder('newbuilder', $builder);
     $this->assertEquals($builder, $services->getBuilder('newbuilder'));
 }
    /**
     * @param bool $useCertificatesWebServices
     * @return mixed
     */
    public static function getWebserviceClient( $useCertificatesWebServices = false )
    {
        $builder  = ServiceBuilder::factory( __DIR__ . '/../descriptor.php' );
        $wsClient = $useCertificatesWebServices ? $builder['certificates'] : $builder['learningtracker'];

        return $wsClient;
    }
 /**
  * {@inheritdoc}
  */
 public function build($config, array $options = null)
 {
     if (!$this->loader) {
         $this->loader = new JsonLoader();
     }
     return ServiceBuilder::factory($this->loader->parseJsonFile($config), $options);
 }
    /**
     * @return mixed
     */
    public static function getWebserviceClient( )
    {
        $builder  = ServiceBuilder::factory( __DIR__ . '/../descriptor.php' );
        $wsClient = $builder['learningneedsassessment'];

        return $wsClient;
    }
 /**
  * Build the Kinvey API client.
  *
  * @return Guzzle\Service\Client
  */
 public function buildKinveyAPIClient()
 {
     require __DIR__ . '/Client/Service/APIV2Description.php';
     require __DIR__ . '/Client/Service/ServiceBuilder.php';
     $client = ServiceBuilder::factory($serviceBuilder)->get('KinveyClient');
     $client->setDescription(ServiceDescription::factory($APIV2Description));
     return $client;
 }
 public static function factory($config = null)
 {
     $default = array('auth_token' => null, 'scheme' => 'http', 'base_url' => '{scheme}://{service}.3taps.com');
     $required = array('auth_token');
     $config = Collection::fromConfig($config, $default, $required);
     $services = array('services' => array('abstract_service' => array('params' => array('auth_token' => $config->get('auth_token'), 'base_url' => $config->get('base_url'), 'scheme' => $config->get('scheme'))), 'reference' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Reference\\ReferenceClient', 'params' => array('service' => 'reference')), 'search' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Search\\SearchClient', 'params' => array('service' => 'search')), 'polling' => array('extends' => 'abstract_service', 'class' => 'Rbaker\\ThreeTaps\\Polling\\PollingClient', 'params' => array('service' => 'polling'))));
     return ServiceBuilder::factory($services);
 }
 /**
  * set the api key for api key clients
  *
  * @param string $name
  * @param bool   $throwAway
  *
  * @return ClientInterface
  */
 public function get($name, $throwAway = false)
 {
     $client = parent::get($name, $throwAway);
     if ($client instanceof ApiKeyClientInterface) {
         $client->setApiKey(self::$apiKey);
     }
     return $client;
 }
 /**
  * @return \service\certificates\Client
  */
 public static function getWebserviceClient()
 {
     if ( !isset(self::$wsClient) )
     {
         // Guzzle RESTclient
         $builder        = ServiceBuilder::factory(__DIR__ . '/../descriptor.php');
         self::$wsClient = $builder['certificates'];
     }
     return self::$wsClient;
 }
 public function testServicesCanBeExtendedWithIncludes()
 {
     $data = array('services' => array('foo' => array('class' => 'stdClass', 'params' => array('baz' => 'bar')), 'bar' => array('extends' => 'foo', 'params' => array('test' => '123', 'ext' => 'abc'))));
     $file1 = tempnam(sys_get_temp_dir(), 'service_1') . '.json';
     file_put_contents($file1, json_encode($data));
     $data = array('includes' => array($file1), 'services' => array('bar' => array('extends' => 'bar', 'params' => array('test' => '456'))));
     $file2 = tempnam(sys_get_temp_dir(), 'service_2') . '.json';
     file_put_contents($file2, json_encode($data));
     $builder = ServiceBuilder::factory($file2);
     unlink($file1);
     unlink($file2);
     $this->assertEquals(array('bar' => array('class' => 'stdClass', 'extends' => 'foo', 'params' => array('test' => '456', 'baz' => 'bar', 'ext' => 'abc')), 'foo' => array('class' => 'stdClass', 'params' => array('baz' => 'bar'))), $this->readAttribute($builder, 'builderConfig'));
 }
Example #12
0
 public static function createClient($config = array())
 {
     $serviceDescriptionFile = __DIR__ . '/Resources/services.php';
     $serviceBuilder = ServiceBuilder::factory($serviceDescriptionFile);
     $client = $serviceBuilder->get('behave');
     if (isset($config['app_token'])) {
         $tokenPlugin = new TokenAuthPlugin($config['app_token']);
         $client->addSubscriber($tokenPlugin);
     } else {
         //TODO throught good exception
         exit(1);
     }
     return $client;
 }
    public function __construct()
    {
        // Guzzle RESTclient
        $this->builder = ServiceBuilder::factory(__DIR__ . '/../../classes/service/descriptor.php');


        $this->client = $this->builder['ldap'];

        // Logger
        $filter = new ezcLogFilter();
        $filter->severity = ezcLog::ERROR | ezcLog::INFO | ezcLog::WARNING;
        $this->logger = ezcLog::getInstance();
        $logFileName = "ws.log";
        if ( SolrSafeOperatorHelper::clusterIni('WebService', 'CountrySpecificLogs', 'merck.ini') == 'enabled' )
        {
            $clusterId = ClusterTool::clusterIdentifier();
            $logFileName = "ws_{$clusterId}.log";
        }
        $this->logger->getMapper()->appendRule(new ezcLogFilterRule( $filter, new ezcLogUnixFileWriter( "var/log/", $logFileName, 157286400, 3 ), true ) );
    }
Example #14
0
 /**
  * PHP 5.3 compatibility services
  *
  * @deprecated
  *
  * @param Application $app
  */
 private function compat(Application $app)
 {
     // Register a Guzzle ServiceBuilder
     $app['guzzle'] = $app->share(function () use($app) {
         if (!isset($app['guzzle.services'])) {
             $builder = new ServiceBuilder(array());
         } else {
             $builder = ServiceBuilder::factory($app['guzzle.services']);
         }
         return $builder;
     });
     // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset)
     $app['guzzle.client'] = $app->share(function () use($app) {
         $client = new ServiceClient($app['guzzle.base_url']);
         foreach ($app['guzzle.plugins'] as $plugin) {
             $client->addSubscriber($plugin);
         }
         return $client;
     });
 }
 /**
  * {@inheritdoc}
  *
  * @return \Guzzle\Service\Builder\ServiceBuilder
  */
 public static function factory($config = null, array $globalParameters = array())
 {
     if ($config instanceof Subscription) {
         $subscription = $config;
         if (!isset($subscription['derived_key_salt'])) {
             throw new \UnexpectedValueException('Derived key salt not found in subscription');
         }
         if (!isset($subscription['heartbeat_data']['search_service_colony'])) {
             throw new \UnexpectedValueException('Acquia Search hostname not found in subscription');
         }
         if (!isset($subscription['heartbeat_data']['search_cores'])) {
             throw new \UnexpectedValueException('Index data not found in subscription');
         }
         $derivedKey = new DerivedKey($subscription['derived_key_salt'], $subscription->getKey());
         $config = array('services' => array());
         foreach ($subscription['heartbeat_data']['search_cores'] as $indexInfo) {
             $config['services'][$indexInfo['core_id']] = array('class' => 'Acquia\\Search\\AcquiaSearchClient', 'params' => array('base_url' => 'https://' . $indexInfo['balancer'], 'index_id' => $indexInfo['core_id'], 'derived_key' => $derivedKey->generate($indexInfo['core_id'])));
         }
     }
     return parent::factory($config, $globalParameters);
 }
 public function __construct(TemplateExpansionService $templateExpansionService, AwsClient $awsClient)
 {
     $this->templateExpansionService = $templateExpansionService;
     $this->cloudFormation = $awsClient->get('CloudFormation');
 }
Example #17
0
<?php

use Guzzle\Tests\GuzzleTestCase;
use Guzzle\Service\Builder\ServiceBuilder;
error_reporting(E_ALL | E_STRICT);
define('APPLICATION_ENV', 'testing');
// pull in composer autloader
require_once __DIR__ . '/../../vendor/autoload.php';
// pull in our test client to interact with the service
require_once __DIR__ . '/TestClient.php';
// private key for testing
$GLOBALS['key'] = 'fbdce19f94b158e72ae6020cc5126642a9d42d086419c015ad2b6dd429312410';
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('test.api' => array('class' => 'TestClient', 'params' => array('base_url' => 'http://127.0.0.1/', 'api_id' => 1)))));
Example #18
0
 public function testServicesCanBeAddedToBuilderAfterInstantiationAndInjectedIntoServices()
 {
     // Grab the cache adapter and remove it from the config
     $cache = $this->arrayData['cache.adapter'];
     $data = $this->arrayData;
     unset($data['cache.adapter']);
     // Create the builder and add the cache adapter
     $builder = ServiceBuilder::factory($data);
     $builder['cache.adapter'] = $cache;
     $this->assertInstanceOf('Guzzle\\Common\\Cache\\DoctrineCacheAdapter', $builder['service_uses_cache']->getConfig('cache'));
 }
 public function testGettingAThrowawayClientWithParametersDoesNotAffectGettingOtherClients()
 {
     $b = new ServiceBuilder($this->arrayData);
     $c1 = $b->get('michael.mock', array('username' => 'jeremy'));
     $this->assertEquals('jeremy', $c1->getConfig('username'));
     $c2 = $b->get('michael.mock');
     $this->assertEquals('michael', $c2->getConfig('username'));
 }
 /**
  * @param Guzzle\Service\Builder\ServiceBuilder $awsClient AWS client.
  */
 public function __construct(Guzzle\Service\Builder\ServiceBuilder $awsClient)
 {
     $this->cloudFormation = $awsClient->get('cloudformation');
 }
Example #21
0
 public function testDescriptionIsCacheable()
 {
     $jsonFile = __DIR__ . '/../../TestData/test_service.json';
     $adapter = new DoctrineCacheAdapter(new ArrayCache());
     $builder = ServiceBuilder::factory($jsonFile, array('cache.adapter' => $adapter));
     // Ensure the cache key was set
     $this->assertTrue($adapter->contains('guzzle' . crc32($jsonFile)));
     // Grab the service from the cache
     $this->assertEquals($builder, ServiceBuilder::factory($jsonFile, array('cache.adapter' => $adapter)));
 }
Example #22
0
<?php

include __DIR__ . '/../vendor/autoload.php';
use Guzzle\Service\Builder\ServiceBuilder;
use Guzzle\Tests\GuzzleTestCase;
$builder = ServiceBuilder::factory(array('test.campbx' => array('class' => '\\Matmar10\\CampBX\\CampBXClient', 'params' => array()), 'test.campbx_auth' => array('class' => '\\Matmar10\\CampBX\\CampBXAuthClient', 'params' => array('username' => 'testuser', 'password' => 'testpassword'))));
Guzzle\Tests\GuzzleTestCase::setServiceBuilder($builder);
Example #23
0
<?php

date_default_timezone_set('America/Los_Angeles');
require __DIR__ . '/../vendor/autoload.php';
if (!file_exists(__DIR__ . '/config.json')) {
    throw new \RuntimeException('Please create config.json before running the examples.');
}
/*
 * Using the ServiceBuilder is not necessary,
 * it just simplifies loading configurations for the examples.
 * @var \Guzzle\Service\Builder\ServiceBuilder
 */
return \Guzzle\Service\Builder\ServiceBuilder::factory(__DIR__ . '/config.json')->get('phlack');
 /**
  * @param Guzzle\Service\Builder\ServiceBuilder $awsClient AWS client.
  */
 public function __construct(Guzzle\Service\Builder\ServiceBuilder $awsClient)
 {
     $this->ec2 = $awsClient->get('ec2');
 }
Example #25
0
<?php

use Desk\Test\Helper\TestCase;
use Guzzle\Service\Builder\ServiceBuilder;
ini_set('memory_limit', '256M');
error_reporting(-1);
$ds = DIRECTORY_SEPARATOR;
$autoloader = dirname(__DIR__) . "{$ds}vendor{$ds}autoload.php";
// Ensure that Composer dependencies have been installed locally
if (!file_exists($autoloader)) {
    die("Dependencies must be installed using Composer:\n\n" . "composer.phar install --dev\n\n" . "See https://github.com/composer/composer/blob/master/README.md " . "for help with installing composer\n");
}
// Include the Composer autoloader
require_once $autoloader;
// Configure Guzzle service builder
if (isset($_SERVER['DESK_TEST_CONFIG'])) {
    $config = $_SERVER['DESK_TEST_CONFIG'];
} else {
    $config = __DIR__ . '/service/mock.json';
}
TestCase::setServiceBuilder(ServiceBuilder::factory($config));
TestCase::setTestsBasePath(__DIR__);
TestCase::setMockBasePath(__DIR__ . '/mock');
<?php

$loader = (require __DIR__ . '/../vendor/autoload.php');
$loader->add('AdrienBrault', __DIR__);
Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . '/mock');
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('facebook' => array('class' => 'AdrienBrault\\FacebookClient\\FacebookClient'))));
Example #27
0
        $class = str_replace('Guzzle\\Openstack\\Tests', '', $class);
        if ('\\' != DIRECTORY_SEPARATOR) {
            $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Guzzle/Openstack/Tests' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
        } else {
            $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . 'Guzzle\\Openstack\\Tests' . DIRECTORY_SEPARATOR . $class . '.php';
        }
        if (file_exists($class)) {
            require $class;
            return true;
        }
    }
    if (0 === strpos($class, 'Guzzle\\Openstack')) {
        $class = str_replace('Guzzle\\Openstack', '', $class);
        if ('\\' != DIRECTORY_SEPARATOR) {
            $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Guzzle/Openstack' . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
        } else {
            $class = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Guzzle\\Openstack' . DIRECTORY_SEPARATOR . $class . '.php';
        }
        if (file_exists($class)) {
            require $class;
            return true;
        }
    }
    return false;
});
// Include the composer autoloader
$loader = (require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
// Register services with the GuzzleTestCase
Guzzle\Tests\GuzzleTestCase::setMockBasePath(__DIR__ . DIRECTORY_SEPARATOR . 'mock');
Guzzle\Tests\GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.abstract.os' => array('class' => '', 'params' => array('username' => 'admin', 'password' => 'openstack', 'token' => 'authenticationtoken')), 'test.identity' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Identity.IdentityClient', 'params' => array('base_url' => 'http://192.168.4.100:35357/v2.0/')), 'test.compute' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Compute.ComputeClient', 'params' => array('base_url' => 'http://192.168.4.100:8774/v2/', 'tenant_id' => 'tenantid')), 'test.storage' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Storage.StorageClient', 'params' => array('base_url' => 'http://192.168.4.100:8080/v1/', 'tenant_id' => 'tenantid')), 'test.openstack' => array('extends' => 'test.abstract.os', 'class' => 'Guzzle.Openstack.Openstack.OpenstackClient'))));
<?php

use Guzzle\Tests\GuzzleTestCase;
use Guzzle\Service\Builder\ServiceBuilder;
if (!file_exists(dirname(__DIR__) . '/composer.lock')) {
    die("Dependencies must be installed using composer:\n\nphp composer.phar install\n\n" . "See http://getcomposer.org for help with installing composer\n");
}
require dirname(__DIR__) . '/vendor/autoload.php';
GuzzleTestCase::setMockBasePath(__DIR__ . '/mock');
GuzzleTestCase::setServiceBuilder(ServiceBuilder::factory(array('ga_measurement_protocol' => array('class' => 'Krizon\\Google\\Analytics\\MeasurementProtocol\\MeasurementProtocolClient', 'params' => array()))));
 /**
  * @param AwsClient $awsClient AWS API client
  * @param string $s3BucketName Name of S3 bucket to upload templates to.
  */
 public function __construct(AwsClient $awsClient, $s3BucketName)
 {
     $this->s3 = $awsClient->get('S3');
     $this->s3BucketName = $s3BucketName;
 }
Example #30
0
 public function setup()
 {
     GuzzleTestCase::setServiceBuilder(\Guzzle\Service\Builder\ServiceBuilder::factory(array('test.twitter' => array('class' => "\\Parkji\\Twuzzle\\OAuth\\Client", 'params' => array('consumerKey' => 'foo', 'consumerSecret' => 'bar')))));
     $this->client = $this->getServiceBuilder()->get('test.twitter');
     $this->setMockResponse($this->client, 'tokenTest');
 }