Added loadbalancers class and tests
This commit is contained in:
178
src/Configurations/LoadBalancer.php
Normal file
178
src/Configurations/LoadBalancer.php
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martijn Smidt <martijn@squeezely.tech>
|
||||||
|
* User: HemeraOne
|
||||||
|
* Date: 13/05/2019
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Configurations;
|
||||||
|
|
||||||
|
class LoadBalancer implements Configurations
|
||||||
|
{
|
||||||
|
private $configs = [];
|
||||||
|
|
||||||
|
public function __construct(string $name, array $defaultPools, string $fallbackPool)
|
||||||
|
{
|
||||||
|
$this->setName($name);
|
||||||
|
$this->setDefaultPools($defaultPools);
|
||||||
|
$this->setFallbackPool($fallbackPool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setName(string $name)
|
||||||
|
{
|
||||||
|
$this->configs['name'] = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName():string
|
||||||
|
{
|
||||||
|
return $this->configs['name'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDefaultPools(array $default_pools)
|
||||||
|
{
|
||||||
|
$this->configs['default_pools'] = $default_pools;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDefaultPools():array
|
||||||
|
{
|
||||||
|
return $this->configs['default_pools'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFallbackPool(string $fallbackPool)
|
||||||
|
{
|
||||||
|
$this->configs['fallback_pools'] = $fallbackPool;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFallbackPool():string
|
||||||
|
{
|
||||||
|
return $this->configs['fallback_pools'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSteeringPolicy(string $steeringPolicy = '')
|
||||||
|
{
|
||||||
|
$allowedOptions = ['off', 'geo', 'random', 'dynamic_latency', ''];
|
||||||
|
if (!in_array($steeringPolicy, $allowedOptions)) {
|
||||||
|
throw new ConfigurationsException('Given steering policy value is not a valid option, valid options are: ' . implode(', ', $allowedOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->configs['steering_policy'] = $steeringPolicy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSteeringPolicy():string
|
||||||
|
{
|
||||||
|
return $this->configs['steering_policy'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function enable()
|
||||||
|
{
|
||||||
|
$this->configs['enabled'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isEnabled():bool
|
||||||
|
{
|
||||||
|
return $this->configs['enabled'] ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function disable()
|
||||||
|
{
|
||||||
|
$this->configs['enabled'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isDisabled():bool
|
||||||
|
{
|
||||||
|
return !$this->configs['enabled'] ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEnabled(bool $enabled = true)
|
||||||
|
{
|
||||||
|
$this->configs['enabled'] = $enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEnabled(bool $enabled = true):bool
|
||||||
|
{
|
||||||
|
return $this->configs['enabled'] ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPopPools(array $popPools)
|
||||||
|
{
|
||||||
|
$this->configs['pop_pools'] = $popPools;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPopPools():array
|
||||||
|
{
|
||||||
|
return $this->configs['pop_pools'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTtl(int $ttl)
|
||||||
|
{
|
||||||
|
$this->configs['ttl'] = $ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTtl():int
|
||||||
|
{
|
||||||
|
return $this->configs['ttl'] ?? 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setRegionPools(array $regionPools)
|
||||||
|
{
|
||||||
|
$this->configs['region_pools'] = $regionPools;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRegionPools():array
|
||||||
|
{
|
||||||
|
return $this->configs['region_pools'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSessionAffinity(string $sessionAffinity = '')
|
||||||
|
{
|
||||||
|
$allowedOptions = ['none', 'cookie', 'ip_cookie', ''];
|
||||||
|
if (!in_array($sessionAffinity, $allowedOptions)) {
|
||||||
|
throw new ConfigurationsException('Given session affinity value is not a valid option, valid options are: ' . implode(', ', $allowedOptions));
|
||||||
|
}
|
||||||
|
$this->configs['session_affinity'] = $sessionAffinity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSessionAffinity():string
|
||||||
|
{
|
||||||
|
return $this->configs['session_affinity'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDescription(string $description = '')
|
||||||
|
{
|
||||||
|
$this->configs['description'] = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDescription():string
|
||||||
|
{
|
||||||
|
return $this->configs['description'] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setProxied(bool $proxied = true)
|
||||||
|
{
|
||||||
|
$this->configs['proxied'] = $proxied;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isProxied():bool
|
||||||
|
{
|
||||||
|
return $this->configs['proxied'] ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSessionAffinityTtl(int $sessionAffinityTtl = 82800)
|
||||||
|
{
|
||||||
|
if ($sessionAffinityTtl > 604800 || $sessionAffinityTtl < 1800) {
|
||||||
|
throw new ConfigurationsException('The value of session affinity ttl must be between 1800 and 604800');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->configs['session_affinity_ttl'] = $sessionAffinityTtl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSessionAffinityTtl():int
|
||||||
|
{
|
||||||
|
return $this->configs['session_affinity_ttl'] ?? 82800;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArray(): array
|
||||||
|
{
|
||||||
|
return $this->configs;
|
||||||
|
}
|
||||||
|
}
|
||||||
149
src/Endpoints/LoadBalancers.php
Normal file
149
src/Endpoints/LoadBalancers.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martijn Smidt <martijn@squeezely.tech>
|
||||||
|
* User: HemeraOne
|
||||||
|
* Date: 13/05/2019
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Cloudflare\API\Endpoints;
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
use Cloudflare\API\Configurations\ConfigurationsException;
|
||||||
|
use Cloudflare\API\Configurations\LoadBalancer;
|
||||||
|
use Cloudflare\API\Traits\BodyAccessorTrait;
|
||||||
|
|
||||||
|
class LoadBalancers implements API
|
||||||
|
{
|
||||||
|
use BodyAccessorTrait;
|
||||||
|
|
||||||
|
private $adapter;
|
||||||
|
|
||||||
|
public function __construct(Adapter $adapter)
|
||||||
|
{
|
||||||
|
$this->adapter = $adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function listLoadBalancers(string $zoneID)
|
||||||
|
{
|
||||||
|
$loadBalancers = $this->adapter->get('zones/' . $zoneID . '/load_balancers');
|
||||||
|
$this->body = json_decode($loadBalancers->getBody());
|
||||||
|
|
||||||
|
return $this->body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $loadBalancerID
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getLoadBalancerDetails(string $zoneID, string $loadBalancerID)
|
||||||
|
{
|
||||||
|
$loadBalancer = $this->adapter->get('zones/' . $zoneID . '/load_balancers/' . $loadBalancerID);
|
||||||
|
$this->body = json_decode($loadBalancer->getBody());
|
||||||
|
return $this->body->result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $loadBalancerID
|
||||||
|
* @return LoadBalancer
|
||||||
|
* @throws ConfigurationsException
|
||||||
|
*/
|
||||||
|
public function getLoadBalancerConfiguration(string $zoneID, string $loadBalancerID)
|
||||||
|
{
|
||||||
|
$loadBalancer = $this->getLoadBalancerDetails($zoneID, $loadBalancerID);
|
||||||
|
|
||||||
|
$loadBalancerConfiguration = new LoadBalancer($loadBalancer->name, $loadBalancer->default_pools, $loadBalancer->fallback_pool);
|
||||||
|
$loadBalancerConfiguration->setSteeringPolicy($loadBalancer->steering_policy);
|
||||||
|
$loadBalancerConfiguration->setEnabled($loadBalancer->enabled);
|
||||||
|
|
||||||
|
if (is_array($loadBalancer->pop_pools)) {
|
||||||
|
$loadBalancerConfiguration->setPopPools($loadBalancer->pop_pools);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($loadBalancer->ttl)) {
|
||||||
|
$loadBalancerConfiguration->setTtl($loadBalancer->ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($loadBalancer->region_pools)) {
|
||||||
|
$loadBalancerConfiguration->setRegionPools($loadBalancer->region_pools);
|
||||||
|
}
|
||||||
|
$loadBalancerConfiguration->setSessionAffinity($loadBalancer->session_affinity);
|
||||||
|
$loadBalancerConfiguration->setDescription($loadBalancer->description);
|
||||||
|
$loadBalancerConfiguration->setProxied($loadBalancer->proxied);
|
||||||
|
|
||||||
|
if (isset($loadBalancer->session_affinity_ttl)) {
|
||||||
|
$loadBalancerConfiguration->setSessionAffinityTtl($loadBalancer->session_affinity_ttl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $loadBalancerConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $loadBalancerID
|
||||||
|
* @param LoadBalancer $loadBalancerConfiguration
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function updateLoadBalancer(
|
||||||
|
string $zoneID,
|
||||||
|
string $loadBalancerID,
|
||||||
|
LoadBalancer $loadBalancerConfiguration
|
||||||
|
): bool {
|
||||||
|
$options = $loadBalancerConfiguration->getArray();
|
||||||
|
|
||||||
|
$query = $this->adapter->patch('zones/' . $zoneID . '/load_balancers/' . $loadBalancerID, $options);
|
||||||
|
|
||||||
|
$this->body = json_decode($query->getBody());
|
||||||
|
|
||||||
|
if (isset($this->body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param LoadBalancer $loadBalancerConfiguration
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function createLoadBalancer(
|
||||||
|
string $zoneID,
|
||||||
|
LoadBalancer $loadBalancerConfiguration
|
||||||
|
): bool {
|
||||||
|
$options = $loadBalancerConfiguration->getArray();
|
||||||
|
|
||||||
|
$query = $this->adapter->post('zones/' . $zoneID . '/load_balancers', $options);
|
||||||
|
|
||||||
|
$this->body = json_decode($query->getBody());
|
||||||
|
|
||||||
|
if (isset($this->body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $zoneID
|
||||||
|
* @param string $loadBalancerID
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function deleteLoadBalancer(string $zoneID, string $loadBalancerID): bool
|
||||||
|
{
|
||||||
|
$loadBalancer = $this->adapter->delete('zones/' . $zoneID . '/load_balancers/' . $loadBalancerID);
|
||||||
|
|
||||||
|
$this->body = json_decode($loadBalancer->getBody());
|
||||||
|
|
||||||
|
if (isset($this->body->result->id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
57
tests/Configurations/LoadBalancerTest.php
Normal file
57
tests/Configurations/LoadBalancerTest.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martijn Smidt <martijn@squeezely.tech>
|
||||||
|
* User: HemeraOne
|
||||||
|
* Date: 13/05/2019
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Cloudflare\API\Configurations\ConfigurationsException;
|
||||||
|
use Cloudflare\API\Configurations\LoadBalancer;
|
||||||
|
|
||||||
|
class LoadBalancerTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider testArgumentsDataProvider
|
||||||
|
*/
|
||||||
|
public function testArguments($setFunction, $arguments, $getFunction, $invalid)
|
||||||
|
{
|
||||||
|
$lb = new LoadBalancer('bous', [], 'bogus');
|
||||||
|
foreach ($arguments as $argument) {
|
||||||
|
if ($invalid) {
|
||||||
|
try {
|
||||||
|
$lb->{$setFunction}($argument);
|
||||||
|
} catch (ConfigurationsException $e) {
|
||||||
|
$this->assertNotEquals($argument, $lb->{$getFunction}());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$lb->{$setFunction}($argument);
|
||||||
|
$this->assertEquals($argument, $lb->{$getFunction}());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testArgumentsDataProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'steeringPolicy arguments valid' => [
|
||||||
|
'setSteeringPolicy', ['off', 'geo', 'random', 'dynamic_latency', ''], 'getSteeringPolicy', false
|
||||||
|
],
|
||||||
|
'sessionAffinity arguments valid' => [
|
||||||
|
'setSessionAffinity', ['none', 'cookie', 'ip_cookie', ''], 'getSessionAffinity', false
|
||||||
|
],
|
||||||
|
'sessionAffinityTtl arguments valid' => [
|
||||||
|
'setSessionAffinityTtl', [3600], 'getSessionAffinityTtl', false
|
||||||
|
],
|
||||||
|
'steeringPolicy arguments invalid' => [
|
||||||
|
'setSteeringPolicy', ['invalid'], 'getSteeringPolicy', true
|
||||||
|
],
|
||||||
|
'sessionAffinity arguments invalid' => [
|
||||||
|
'setSessionAffinity', ['invalid'], 'getSessionAffinity', true
|
||||||
|
],
|
||||||
|
'sessionAffinityTtl arguments invalid' => [
|
||||||
|
'setSessionAffinityTtl', [1337], 'getSessionAffinityTtl', true
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
128
tests/Endpoints/LoadBalancersTest.php
Normal file
128
tests/Endpoints/LoadBalancersTest.php
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Cloudflare\API\Adapter\Adapter;
|
||||||
|
use Cloudflare\API\Configurations\LoadBalancer;
|
||||||
|
use Cloudflare\API\Endpoints\LoadBalancers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Martijn Smidt <martijn@squeezely.tech>
|
||||||
|
* User: HemeraOne
|
||||||
|
* Date: 13/05/2019
|
||||||
|
*/
|
||||||
|
|
||||||
|
class LoadBalancersTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testCreateLoadBalancer()
|
||||||
|
{
|
||||||
|
$pools = [
|
||||||
|
'17b5962d775c646f3f9725cbc7a53df4',
|
||||||
|
'9290f38c5d07c2e2f4df57b1f61d4196',
|
||||||
|
'00920f38ce07c2e2f4df50b1f61d4194'
|
||||||
|
];
|
||||||
|
|
||||||
|
$lbConfiguration = new LoadBalancer('www.example.com', $pools, '17b5962d775c646f3f9725cbc7a53df4');
|
||||||
|
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createLoadBalancer.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('post')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('post')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers'),
|
||||||
|
$lbConfiguration->getArray()
|
||||||
|
);
|
||||||
|
|
||||||
|
$loadBalancers = new LoadBalancers($mock);
|
||||||
|
$result = $loadBalancers->createLoadBalancer('699d98642c564d2e855e9661899b7252', $lbConfiguration);
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertEquals('699d98642c564d2e855e9661899b7252', $loadBalancers->getBody()->result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testListLoadBalancer()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listLoadBalancers.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers')
|
||||||
|
);
|
||||||
|
|
||||||
|
$loadBalancers = new LoadBalancers($mock);
|
||||||
|
$loadBalancers->listLoadBalancers('699d98642c564d2e855e9661899b7252');
|
||||||
|
$this->assertEquals('699d98642c564d2e855e9661899b7252', $loadBalancers->getBody()->result[0]->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetLoadBalancerDetails()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getLoadBalancerDetails.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('get')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers/699d98642c564d2e855e9661899b7252')
|
||||||
|
);
|
||||||
|
|
||||||
|
$loadBalancers = new LoadBalancers($mock);
|
||||||
|
$loadBalancers->getLoadBalancerDetails('699d98642c564d2e855e9661899b7252', '699d98642c564d2e855e9661899b7252');
|
||||||
|
$this->assertEquals('699d98642c564d2e855e9661899b7252', $loadBalancers->getBody()->result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpdateLoadBalancer()
|
||||||
|
{
|
||||||
|
$pools = [
|
||||||
|
'17b5962d775c646f3f9725cbc7a53df4',
|
||||||
|
'9290f38c5d07c2e2f4df57b1f61d4196',
|
||||||
|
'00920f38ce07c2e2f4df50b1f61d4194'
|
||||||
|
];
|
||||||
|
|
||||||
|
$lbConfiguration = new LoadBalancer('www.example.com', $pools, '17b5962d775c646f3f9725cbc7a53df4');
|
||||||
|
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateLoadBalancer.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('patch')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers/699d98642c564d2e855e9661899b7252'),
|
||||||
|
$this->equalTo($lbConfiguration->getArray())
|
||||||
|
);
|
||||||
|
|
||||||
|
$loadBalancers = new LoadBalancers($mock);
|
||||||
|
$result = $loadBalancers->updateLoadBalancer('699d98642c564d2e855e9661899b7252', '699d98642c564d2e855e9661899b7252', $lbConfiguration);
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertEquals('699d98642c564d2e855e9661899b7252', $loadBalancers->getBody()->result->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeleteLoadBalancer()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteLoadBalancer.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('delete')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('delete')
|
||||||
|
->with(
|
||||||
|
$this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers/699d98642c564d2e855e9661899b7252')
|
||||||
|
);
|
||||||
|
|
||||||
|
$loadBalancers = new LoadBalancers($mock);
|
||||||
|
$result = $loadBalancers->deleteLoadBalancer('699d98642c564d2e855e9661899b7252', '699d98642c564d2e855e9661899b7252');
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertEquals('699d98642c564d2e855e9661899b7252', $loadBalancers->getBody()->result->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
tests/Fixtures/Endpoints/createLoadBalancer.json
Normal file
46
tests/Fixtures/Endpoints/createLoadBalancer.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "699d98642c564d2e855e9661899b7252",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"description": "Load Balancer for www.example.com",
|
||||||
|
"name": "www.example.com",
|
||||||
|
"enabled": true,
|
||||||
|
"ttl": 30,
|
||||||
|
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"default_pools": [
|
||||||
|
"17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196",
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
],
|
||||||
|
"region_pools": {
|
||||||
|
"WNAM": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"ENAM": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pop_pools": {
|
||||||
|
"LAX": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"LHR": [
|
||||||
|
"abd90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"f9138c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"SJC": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"proxied": true,
|
||||||
|
"steering_policy": "dynamic_latency",
|
||||||
|
"session_affinity": "cookie",
|
||||||
|
"session_affinity_ttl": 5000
|
||||||
|
}
|
||||||
|
}
|
||||||
8
tests/Fixtures/Endpoints/deleteLoadBalancer.json
Normal file
8
tests/Fixtures/Endpoints/deleteLoadBalancer.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "699d98642c564d2e855e9661899b7252"
|
||||||
|
}
|
||||||
|
}
|
||||||
46
tests/Fixtures/Endpoints/getLoadBalancerDetails.json
Normal file
46
tests/Fixtures/Endpoints/getLoadBalancerDetails.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "699d98642c564d2e855e9661899b7252",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"description": "Load Balancer for www.example.com",
|
||||||
|
"name": "www.example.com",
|
||||||
|
"enabled": true,
|
||||||
|
"ttl": 30,
|
||||||
|
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"default_pools": [
|
||||||
|
"17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196",
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
],
|
||||||
|
"region_pools": {
|
||||||
|
"WNAM": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"ENAM": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pop_pools": {
|
||||||
|
"LAX": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"LHR": [
|
||||||
|
"abd90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"f9138c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"SJC": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"proxied": true,
|
||||||
|
"steering_policy": "dynamic_latency",
|
||||||
|
"session_affinity": "cookie",
|
||||||
|
"session_affinity_ttl": 5000
|
||||||
|
}
|
||||||
|
}
|
||||||
54
tests/Fixtures/Endpoints/listLoadbalancers.json
Normal file
54
tests/Fixtures/Endpoints/listLoadbalancers.json
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": [
|
||||||
|
{
|
||||||
|
"id": "699d98642c564d2e855e9661899b7252",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"description": "Load Balancer for www.example.com",
|
||||||
|
"name": "www.example.com",
|
||||||
|
"enabled": true,
|
||||||
|
"ttl": 30,
|
||||||
|
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"default_pools": [
|
||||||
|
"17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196",
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
],
|
||||||
|
"region_pools": {
|
||||||
|
"WNAM": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"ENAM": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pop_pools": {
|
||||||
|
"LAX": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"LHR": [
|
||||||
|
"abd90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"f9138c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"SJC": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"proxied": true,
|
||||||
|
"steering_policy": "dynamic_latency",
|
||||||
|
"session_affinity": "cookie",
|
||||||
|
"session_affinity_ttl": 5000
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result_info": {
|
||||||
|
"page": 1,
|
||||||
|
"per_page": 20,
|
||||||
|
"count": 1,
|
||||||
|
"total_count": 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
46
tests/Fixtures/Endpoints/updateLoadBalancer.json
Normal file
46
tests/Fixtures/Endpoints/updateLoadBalancer.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "699d98642c564d2e855e9661899b7252",
|
||||||
|
"created_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z",
|
||||||
|
"description": "Load Balancer for www.example.com",
|
||||||
|
"name": "www.example.com",
|
||||||
|
"enabled": true,
|
||||||
|
"ttl": 30,
|
||||||
|
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"default_pools": [
|
||||||
|
"17b5962d775c646f3f9725cbc7a53df4",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196",
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
],
|
||||||
|
"region_pools": {
|
||||||
|
"WNAM": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"ENAM": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pop_pools": {
|
||||||
|
"LAX": [
|
||||||
|
"de90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"9290f38c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"LHR": [
|
||||||
|
"abd90f38ced07c2e2f4df50b1f61d4194",
|
||||||
|
"f9138c5d07c2e2f4df57b1f61d4196"
|
||||||
|
],
|
||||||
|
"SJC": [
|
||||||
|
"00920f38ce07c2e2f4df50b1f61d4194"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"proxied": true,
|
||||||
|
"steering_policy": "dynamic_latency",
|
||||||
|
"session_affinity": "cookie",
|
||||||
|
"session_affinity_ttl": 5000
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user