From 99c174bcb3b3d24f59a03d9bb5135dccee40c8a4 Mon Sep 17 00:00:00 2001 From: Martijn Smidt Date: Mon, 13 May 2019 16:49:32 +0200 Subject: [PATCH] Added pools class and tests Small changes in loadbalancer configuration --- src/Configurations/LoadBalancer.php | 20 +-- src/Configurations/Pool.php | 111 +++++++++++++ src/Endpoints/LoadBalancers.php | 44 ++--- src/Endpoints/Pools.php | 152 ++++++++++++++++++ tests/Configurations/LoadBalancerTest.php | 15 +- tests/Configurations/PoolTest.php | 53 ++++++ tests/Endpoints/LoadBalancersTest.php | 4 +- tests/Endpoints/PoolsTest.php | 133 +++++++++++++++ tests/Fixtures/Endpoints/createPool.json | 28 ++++ tests/Fixtures/Endpoints/deletePool.json | 8 + tests/Fixtures/Endpoints/getPoolDetails.json | 28 ++++ ...dbalancers.json => listLoadBalancers.json} | 0 tests/Fixtures/Endpoints/listPools.json | 36 +++++ tests/Fixtures/Endpoints/updatePool.json | 28 ++++ 14 files changed, 622 insertions(+), 38 deletions(-) create mode 100644 src/Configurations/Pool.php create mode 100644 src/Endpoints/Pools.php create mode 100644 tests/Configurations/PoolTest.php create mode 100644 tests/Endpoints/PoolsTest.php create mode 100644 tests/Fixtures/Endpoints/createPool.json create mode 100644 tests/Fixtures/Endpoints/deletePool.json create mode 100644 tests/Fixtures/Endpoints/getPoolDetails.json rename tests/Fixtures/Endpoints/{listLoadbalancers.json => listLoadBalancers.json} (100%) create mode 100644 tests/Fixtures/Endpoints/listPools.json create mode 100644 tests/Fixtures/Endpoints/updatePool.json diff --git a/src/Configurations/LoadBalancer.php b/src/Configurations/LoadBalancer.php index 150a88d..70b2da1 100644 --- a/src/Configurations/LoadBalancer.php +++ b/src/Configurations/LoadBalancer.php @@ -28,9 +28,9 @@ class LoadBalancer implements Configurations return $this->configs['name'] ?? ''; } - public function setDefaultPools(array $default_pools) + public function setDefaultPools(array $defaultPools) { - $this->configs['default_pools'] = $default_pools; + $this->configs['default_pools'] = $defaultPools; } public function getDefaultPools():array @@ -83,12 +83,7 @@ class LoadBalancer implements Configurations return !$this->configs['enabled'] ?? false; } - public function setEnabled(bool $enabled = true) - { - $this->configs['enabled'] = $enabled; - } - - public function getEnabled(bool $enabled = true):bool + public function getEnabled():bool { return $this->configs['enabled'] ?? true; } @@ -147,9 +142,14 @@ class LoadBalancer implements Configurations return $this->configs['description'] ?? ''; } - public function setProxied(bool $proxied = true) + public function enableProxied() { - $this->configs['proxied'] = $proxied; + $this->configs['proxied'] = true; + } + + public function disableProxied() + { + $this->configs['proxied'] = false; } public function isProxied():bool diff --git a/src/Configurations/Pool.php b/src/Configurations/Pool.php new file mode 100644 index 0000000..f28347b --- /dev/null +++ b/src/Configurations/Pool.php @@ -0,0 +1,111 @@ + + * User: HemeraOne + * Date: 13/05/2019 + */ + +namespace Cloudflare\API\Configurations; + +class Pool implements Configurations +{ + private $configs = []; + + public function __construct(string $name, array $origins) + { + $this->setName($name); + $this->setOrigins($origins); + } + + public function setName(string $name) + { + $this->configs['name'] = $name; + } + + public function getName():string + { + return $this->configs['name'] ?? ''; + } + + public function setOrigins(array $origins) + { + foreach ($origins as $origin) { + if (!isset($origin['name'])) { + throw new ConfigurationsException('name is required for origin'); + } + if (!isset($origin['address'])) { + throw new ConfigurationsException('address is required for origin'); + } + } + $this->configs['origins'] = $origins; + } + + public function getOrigins():array + { + return $this->configs['origins'] ?? []; + } + + public function setDescription(string $description = '') + { + $this->configs['description'] = $description; + } + + public function getDescription():string + { + return $this->configs['description'] ?? ''; + } + + 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 getEnabled():bool + { + return $this->configs['enabled'] ?? true; + } + + public function setMonitor(string $monitor) + { + $this->configs['monitor'] = $monitor; + } + + public function getMonitor():string + { + return $this->configs['monitor'] ?? ''; + } + + public function setNotificationEmail(string $email) + { + if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { + throw new ConfigurationsException('Invalid notification email given'); + } + + $this->configs['notification_email'] = $email; + } + + public function getNotificationEmail():string + { + return $this->configs['notification_email'] ?? ''; + } + + public function getArray(): array + { + return $this->configs; + } +} diff --git a/src/Endpoints/LoadBalancers.php b/src/Endpoints/LoadBalancers.php index 0ed43ab..7813d31 100644 --- a/src/Endpoints/LoadBalancers.php +++ b/src/Endpoints/LoadBalancers.php @@ -57,46 +57,54 @@ class LoadBalancers implements API { $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); + $lbConfiguration = new LoadBalancer($loadBalancer->name, $loadBalancer->default_pools, $loadBalancer->fallback_pool); + $lbConfiguration->setSteeringPolicy($loadBalancer->steering_policy); + if ($loadBalancer->enabled === true) { + $lbConfiguration->enable(); + } elseif ($loadBalancer->enabled === false) { + $lbConfiguration->disable(); + } if (is_array($loadBalancer->pop_pools)) { - $loadBalancerConfiguration->setPopPools($loadBalancer->pop_pools); + $lbConfiguration->setPopPools($loadBalancer->pop_pools); } if (isset($loadBalancer->ttl)) { - $loadBalancerConfiguration->setTtl($loadBalancer->ttl); + $lbConfiguration->setTtl($loadBalancer->ttl); } if (is_array($loadBalancer->region_pools)) { - $loadBalancerConfiguration->setRegionPools($loadBalancer->region_pools); + $lbConfiguration->setRegionPools($loadBalancer->region_pools); + } + $lbConfiguration->setSessionAffinity($loadBalancer->session_affinity); + $lbConfiguration->setDescription($loadBalancer->description); + if ($loadBalancer->proxied === true) { + $lbConfiguration->enableProxied(); + } elseif ($loadBalancer->proxied === false) { + $lbConfiguration->disableProxied(); } - $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); + $lbConfiguration->setSessionAffinityTtl($loadBalancer->session_affinity_ttl); } - return $loadBalancerConfiguration; + return $lbConfiguration; } /** * @param string $zoneID * @param string $loadBalancerID - * @param LoadBalancer $loadBalancerConfiguration + * @param LoadBalancer $lbConfiguration * @return bool */ public function updateLoadBalancer( string $zoneID, string $loadBalancerID, - LoadBalancer $loadBalancerConfiguration + LoadBalancer $lbConfiguration ): bool { - $options = $loadBalancerConfiguration->getArray(); + $options = $lbConfiguration->getArray(); - $query = $this->adapter->patch('zones/' . $zoneID . '/load_balancers/' . $loadBalancerID, $options); + $query = $this->adapter->put('zones/' . $zoneID . '/load_balancers/' . $loadBalancerID, $options); $this->body = json_decode($query->getBody()); @@ -109,14 +117,14 @@ class LoadBalancers implements API /** * @param string $zoneID - * @param LoadBalancer $loadBalancerConfiguration + * @param LoadBalancer $lbConfiguration * @return bool */ public function createLoadBalancer( string $zoneID, - LoadBalancer $loadBalancerConfiguration + LoadBalancer $lbConfiguration ): bool { - $options = $loadBalancerConfiguration->getArray(); + $options = $lbConfiguration->getArray(); $query = $this->adapter->post('zones/' . $zoneID . '/load_balancers', $options); diff --git a/src/Endpoints/Pools.php b/src/Endpoints/Pools.php new file mode 100644 index 0000000..4a4f193 --- /dev/null +++ b/src/Endpoints/Pools.php @@ -0,0 +1,152 @@ + + * User: HemeraOne + * Date: 13/05/2019 + */ + +namespace Cloudflare\API\Endpoints; + +use Cloudflare\API\Adapter\Adapter; +use Cloudflare\API\Configurations\ConfigurationsException; +use Cloudflare\API\Configurations\Pool; +use Cloudflare\API\Traits\BodyAccessorTrait; + +class Pools implements API +{ + use BodyAccessorTrait; + + private $adapter; + + public function __construct(Adapter $adapter) + { + $this->adapter = $adapter; + } + + /** + * @param string $accountID + * @return mixed + */ + public function listPools(string $accountID) + { + $pools = $this->adapter->get('accounts/' . $accountID . '/load_balancers/pools'); + $this->body = json_decode($pools->getBody()); + + return $this->body->result; + } + + /** + * @param string $accountID + * @param string $poolID + * @return mixed + */ + public function getPoolDetails(string $accountID, string $poolID) + { + $pool = $this->adapter->get('accounts/' . $accountID . '/load_balancers/pools/' . $poolID); + $this->body = json_decode($pool->getBody()); + return $this->body->result; + } + + /** + * @param string $accountID + * @param string $poolID + * @return mixed + */ + public function getPoolHealthDetails(string $accountID, string $poolID) + { + $pool = $this->adapter->get('accounts/' . $accountID . '/load_balancers/pools/' . $poolID . '/health'); + $this->body = json_decode($pool->getBody()); + return $this->body->result; + } + + /** + * @param string $accountID + * @param string $poolID + * @return Pool + * @throws ConfigurationsException + */ + public function getPoolConfiguration(string $accountID, string $poolID) + { + $pool = $this->getPoolDetails($accountID, $poolID); + + $origins = []; + foreach ($pool->origins as $origin) { + $origins[] = (array)$origin; + } + $poolConfiguration = new Pool($pool->name, $origins); + $poolConfiguration->setDescription($pool->description); + if ($pool->enabled === true) { + $poolConfiguration->enable(); + } elseif ($pool->enabled === false) { + $poolConfiguration->disable(); + } + $poolConfiguration->setMonitor($pool->monitor); + $poolConfiguration->setNotificationEmail($pool->notification_email); + + return $poolConfiguration; + } + + /** + * @param string $accountID + * @param string $poolID + * @param Pool $poolConfiguration + * @return bool + */ + public function updatePool( + string $accountID, + string $poolID, + Pool $poolConfiguration + ): bool { + $options = $poolConfiguration->getArray(); + + $query = $this->adapter->put('accounts/' . $accountID . '/load_balancers/pools/' . $poolID, $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + /** + * @param string $accountID + * @param Pool $poolConfiguration + * @return bool + */ + public function createPool( + string $accountID, + Pool $poolConfiguration + ): bool { + $options = $poolConfiguration->getArray(); + + $query = $this->adapter->post('accounts/' . $accountID . '/load_balancers/pools', $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + + /** + * @param string $accountID + * @param string $poolID + * @return bool + */ + public function deletePool(string $accountID, string $poolID): bool + { + $pool = $this->adapter->delete('accounts/' . $accountID . '/load_balancers/pools/' . $poolID); + + $this->body = json_decode($pool->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } +} diff --git a/tests/Configurations/LoadBalancerTest.php b/tests/Configurations/LoadBalancerTest.php index e726cd8..96b3d1e 100644 --- a/tests/Configurations/LoadBalancerTest.php +++ b/tests/Configurations/LoadBalancerTest.php @@ -15,19 +15,18 @@ class LoadBalancerTest extends TestCase */ public function testArguments($setFunction, $arguments, $getFunction, $invalid) { - $lb = new LoadBalancer('bous', [], 'bogus'); + $loadBalancer = new LoadBalancer('bogus', [], 'bogus'); foreach ($arguments as $argument) { - if ($invalid) { + if ($invalid === true) { try { - $lb->{$setFunction}($argument); + $loadBalancer->{$setFunction}($argument); } catch (ConfigurationsException $e) { - $this->assertNotEquals($argument, $lb->{$getFunction}()); + $this->assertNotEquals($argument, $loadBalancer->{$getFunction}()); } - } else { - $lb->{$setFunction}($argument); - $this->assertEquals($argument, $lb->{$getFunction}()); + } elseif ($invalid === false) { + $loadBalancer->{$setFunction}($argument); + $this->assertEquals($argument, $loadBalancer->{$getFunction}()); } - } } diff --git a/tests/Configurations/PoolTest.php b/tests/Configurations/PoolTest.php new file mode 100644 index 0000000..204b392 --- /dev/null +++ b/tests/Configurations/PoolTest.php @@ -0,0 +1,53 @@ + + * User: HemeraOne + * Date: 13/05/2019 + */ + +use Cloudflare\API\Configurations\ConfigurationsException; +use Cloudflare\API\Configurations\Pool; + +class PoolTest extends TestCase +{ + /** + * @dataProvider testArgumentsDataProvider + */ + public function testArguments($setFunction, $arguments, $getFunction, $invalid) + { + $pool = new Pool('bogus', []); + foreach ($arguments as $argument) { + if ($invalid) { + try { + $pool->{$setFunction}($argument); + } catch (ConfigurationsException $e) { + $this->assertNotEquals($argument, $pool->{$getFunction}()); + } + } elseif ($invalid === false) { + $pool->{$setFunction}($argument); + $this->assertEquals($argument, $pool->{$getFunction}()); + } + } + } + + public function testArgumentsDataProvider() + { + return [ + 'origins arguments valid' => [ + 'setOrigins', [[['name' => 'test', 'address' => 'server1.example.com']]], 'getOrigins', false + ], + 'setNotificationEmail arguments valid' => [ + 'setNotificationEmail', ['user@example.com'], 'getNotificationEmail', false + ], + 'origins arguments invalid no address' => [ + 'setOrigins', [['name' => 'test']], 'getOrigins', true + ], + 'origins arguments invalid no name' => [ + 'setOrigins', [['address' => 'server1.example.com']], 'getOrigins', true + ], + 'setNotificationEmail arguments invalid' => [ + 'setNotificationEmail', ['userexample.com'], 'getNotificationEmail', true + ] + ]; + } +} diff --git a/tests/Endpoints/LoadBalancersTest.php b/tests/Endpoints/LoadBalancersTest.php index a0a87b2..93418d4 100644 --- a/tests/Endpoints/LoadBalancersTest.php +++ b/tests/Endpoints/LoadBalancersTest.php @@ -90,10 +90,10 @@ class LoadBalancersTest extends TestCase $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateLoadBalancer.json'); $mock = $this->getMockBuilder(Adapter::class)->getMock(); - $mock->method('patch')->willReturn($response); + $mock->method('put')->willReturn($response); $mock->expects($this->once()) - ->method('patch') + ->method('put') ->with( $this->equalTo('zones/699d98642c564d2e855e9661899b7252/load_balancers/699d98642c564d2e855e9661899b7252'), $this->equalTo($lbConfiguration->getArray()) diff --git a/tests/Endpoints/PoolsTest.php b/tests/Endpoints/PoolsTest.php new file mode 100644 index 0000000..9846f48 --- /dev/null +++ b/tests/Endpoints/PoolsTest.php @@ -0,0 +1,133 @@ + + * User: HemeraOne + * Date: 13/05/2019 + */ + +class PoolsTest extends TestCase +{ + public function testCreatePool() + { + $origins = [ + [ + 'name' => 'app-server-1', + 'address' => '0.0.0.0', + 'enabled' => true, + 'weight' => 0.56 + ] + ]; + + $poolConfiguration = new \Cloudflare\API\Configurations\Pool('primary-dc-1', $origins); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/createPool.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('post')->willReturn($response); + + $mock->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/load_balancers/pools'), + $poolConfiguration->getArray() + ); + + $pools = new Pools($mock); + $result = $pools->createPool('01a7362d577a6c3019a474fd6f485823', $poolConfiguration); + + $this->assertTrue($result); + $this->assertEquals('17b5962d775c646f3f9725cbc7a53df4', $pools->getBody()->result->id); + } + + public function testListPools() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/listPools.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/load_balancers/pools') + ); + + $pools = new Pools($mock); + $pools->listPools('01a7362d577a6c3019a474fd6f485823'); + $this->assertEquals('17b5962d775c646f3f9725cbc7a53df4', $pools->getBody()->result[0]->id); + } + + public function testGetPoolDetails() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getPoolDetails.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/load_balancers/pools/17b5962d775c646f3f9725cbc7a53df4') + ); + + $pools = new Pools($mock); + $pools->getPoolDetails('01a7362d577a6c3019a474fd6f485823', '17b5962d775c646f3f9725cbc7a53df4'); + $this->assertEquals('17b5962d775c646f3f9725cbc7a53df4', $pools->getBody()->result->id); + } + + public function testUpdatePool() + { + $origins = [ + [ + 'name' => 'app-server-1', + 'address' => '0.0.0.0', + 'enabled' => true, + 'weight' => 0.56 + ] + ]; + + $poolConfiguration = new \Cloudflare\API\Configurations\Pool('primary-dc-1', $origins); + + $response = $this->getPsr7JsonResponseForFixture('Endpoints/updatePool.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('put')->willReturn($response); + + $mock->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/load_balancers/pools/17b5962d775c646f3f9725cbc7a53df4'), + $this->equalTo($poolConfiguration->getArray()) + ); + + $pools = new Pools($mock); + $result = $pools->updatePool('01a7362d577a6c3019a474fd6f485823', '17b5962d775c646f3f9725cbc7a53df4', $poolConfiguration); + + $this->assertTrue($result); + $this->assertEquals('17b5962d775c646f3f9725cbc7a53df4', $pools->getBody()->result->id); + } + + public function testDeletePool() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/deletePool.json'); + + $mock = $this->getMockBuilder(Adapter::class)->getMock(); + $mock->method('delete')->willReturn($response); + + $mock->expects($this->once()) + ->method('delete') + ->with( + $this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/load_balancers/pools/17b5962d775c646f3f9725cbc7a53df4') + ); + + $pools = new Pools($mock); + $result = $pools->deletePool('01a7362d577a6c3019a474fd6f485823', '17b5962d775c646f3f9725cbc7a53df4'); + + $this->assertTrue($result); + $this->assertEquals('17b5962d775c646f3f9725cbc7a53df4', $pools->getBody()->result->id); + } +} diff --git a/tests/Fixtures/Endpoints/createPool.json b/tests/Fixtures/Endpoints/createPool.json new file mode 100644 index 0000000..e1397a1 --- /dev/null +++ b/tests/Fixtures/Endpoints/createPool.json @@ -0,0 +1,28 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "17b5962d775c646f3f9725cbc7a53df4", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "description": "Primary data center - Provider XYZ", + "name": "primary-dc-1", + "enabled": true, + "minimum_origins": 2, + "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "check_regions": [ + "WEU", + "ENAM" + ], + "origins": [ + { + "name": "app-server-1", + "address": "0.0.0.0", + "enabled": true, + "weight": 0.56 + } + ], + "notification_email": "someone@example.com" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/deletePool.json b/tests/Fixtures/Endpoints/deletePool.json new file mode 100644 index 0000000..96c4395 --- /dev/null +++ b/tests/Fixtures/Endpoints/deletePool.json @@ -0,0 +1,8 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "17b5962d775c646f3f9725cbc7a53df4" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/getPoolDetails.json b/tests/Fixtures/Endpoints/getPoolDetails.json new file mode 100644 index 0000000..e1397a1 --- /dev/null +++ b/tests/Fixtures/Endpoints/getPoolDetails.json @@ -0,0 +1,28 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "17b5962d775c646f3f9725cbc7a53df4", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "description": "Primary data center - Provider XYZ", + "name": "primary-dc-1", + "enabled": true, + "minimum_origins": 2, + "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "check_regions": [ + "WEU", + "ENAM" + ], + "origins": [ + { + "name": "app-server-1", + "address": "0.0.0.0", + "enabled": true, + "weight": 0.56 + } + ], + "notification_email": "someone@example.com" + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/listLoadbalancers.json b/tests/Fixtures/Endpoints/listLoadBalancers.json similarity index 100% rename from tests/Fixtures/Endpoints/listLoadbalancers.json rename to tests/Fixtures/Endpoints/listLoadBalancers.json diff --git a/tests/Fixtures/Endpoints/listPools.json b/tests/Fixtures/Endpoints/listPools.json new file mode 100644 index 0000000..2c7a471 --- /dev/null +++ b/tests/Fixtures/Endpoints/listPools.json @@ -0,0 +1,36 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": [ + { + "id": "17b5962d775c646f3f9725cbc7a53df4", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "description": "Primary data center - Provider XYZ", + "name": "primary-dc-1", + "enabled": true, + "minimum_origins": 2, + "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "check_regions": [ + "WEU", + "ENAM" + ], + "origins": [ + { + "name": "app-server-1", + "address": "0.0.0.0", + "enabled": true, + "weight": 0.56 + } + ], + "notification_email": "someone@example.com" + } + ], + "result_info": { + "page": 1, + "per_page": 20, + "count": 1, + "total_count": 2000 + } +} \ No newline at end of file diff --git a/tests/Fixtures/Endpoints/updatePool.json b/tests/Fixtures/Endpoints/updatePool.json new file mode 100644 index 0000000..e1397a1 --- /dev/null +++ b/tests/Fixtures/Endpoints/updatePool.json @@ -0,0 +1,28 @@ +{ + "success": true, + "errors": [], + "messages": [], + "result": { + "id": "17b5962d775c646f3f9725cbc7a53df4", + "created_on": "2014-01-01T05:20:00.12345Z", + "modified_on": "2014-01-01T05:20:00.12345Z", + "description": "Primary data center - Provider XYZ", + "name": "primary-dc-1", + "enabled": true, + "minimum_origins": 2, + "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc", + "check_regions": [ + "WEU", + "ENAM" + ], + "origins": [ + { + "name": "app-server-1", + "address": "0.0.0.0", + "enabled": true, + "weight": 0.56 + } + ], + "notification_email": "someone@example.com" + } +} \ No newline at end of file