Compare commits
20 Commits
hotfix/202
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f4b9092175 | |||
|
|
7e89626b59 | ||
|
|
b2187e7b52 | ||
|
|
04e2032e9f | ||
|
|
7a839dfc2a | ||
|
|
10e3e120e4 | ||
|
|
369160682d | ||
|
|
66e2ba45ca | ||
|
|
9a5995970b | ||
|
|
c289ef2ef7 | ||
|
|
1c97befdd8 | ||
|
|
0f602b563b | ||
|
|
aa10bcba3c | ||
|
|
6ea062af19 | ||
|
|
fdfc656aa8 | ||
|
|
5024c2ab53 | ||
|
|
12ac2bbd76 | ||
|
|
99d8cfb71c | ||
|
|
bf796b9ec8 | ||
|
|
7f72427fa1 |
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "shellrent/cloudflare-php",
|
||||
"name": "yuemi/cloudflare-php",
|
||||
"description": "PHP binding for v4 of the Cloudflare Client API.",
|
||||
"type": "library",
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "~6.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"php": ">=7.2.5",
|
||||
"psr/http-message": "~1.0",
|
||||
"psr/http-message": "^1.0 || ^2.0",
|
||||
"ext-json": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
50
src/Endpoints/AccountMembers.php
Normal file
50
src/Endpoints/AccountMembers.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Traits\BodyAccessorTrait;
|
||||
|
||||
class AccountMembers implements API
|
||||
{
|
||||
use BodyAccessorTrait;
|
||||
|
||||
/**
|
||||
* @var Adapter
|
||||
*/
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function addAccountMember(string $accountId, string $email, array $roles): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'email' => $email,
|
||||
'roles' => $roles,
|
||||
];
|
||||
|
||||
$account = $this->adapter->post('accounts/' . $accountId . '/members', $options);
|
||||
$this->body = json_decode($account->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function listAccountMembers(string $accountId, int $page = 1, int $perPage = 20): \stdClass
|
||||
{
|
||||
$query = [
|
||||
'page' => $page,
|
||||
'per_page' => $perPage,
|
||||
];
|
||||
|
||||
$zone = $this->adapter->get('accounts/' . $accountId . '/members', $query);
|
||||
$this->body = json_decode($zone->getBody());
|
||||
|
||||
return (object)[
|
||||
'result' => $this->body->result,
|
||||
'result_info' => $this->body->result_info,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
src/Endpoints/AccountRoles.php
Normal file
33
src/Endpoints/AccountRoles.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Traits\BodyAccessorTrait;
|
||||
use stdClass;
|
||||
|
||||
class AccountRoles implements API
|
||||
{
|
||||
use BodyAccessorTrait;
|
||||
|
||||
/**
|
||||
* @var Adapter
|
||||
*/
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function listAccountRoles(string $accountId): stdClass
|
||||
{
|
||||
$roles = $this->adapter->get('accounts/' . $accountId . '/roles');
|
||||
$this->body = json_decode($roles->getBody());
|
||||
|
||||
return (object)[
|
||||
'result' => $this->body->result,
|
||||
'result_info' => $this->body->result_info,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,19 @@ class Accounts implements API
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function addAccount(string $name, string $type = 'standard'): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'name' => $name,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
$account = $this->adapter->post('accounts', $options);
|
||||
$this->body = json_decode($account->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function listAccounts(
|
||||
int $page = 1,
|
||||
int $perPage = 20,
|
||||
|
||||
117
src/Endpoints/RulesLists.php
Executable file
117
src/Endpoints/RulesLists.php
Executable file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Traits\BodyAccessorTrait;
|
||||
|
||||
class RulesLists implements API
|
||||
{
|
||||
use BodyAccessorTrait;
|
||||
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function getLists(string $accountId)
|
||||
{
|
||||
$response = $this->adapter->get('accounts/' . $accountId . '/rules/lists');
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function getListDetails(string $accountId, string $listId)
|
||||
{
|
||||
$response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/' . $listId);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function getListItems(string $accountId, string $listId, string $search = '', int $itemsPerPage = 20, string $cursor = '')
|
||||
{
|
||||
|
||||
$options = [
|
||||
'per_page' => $itemsPerPage,
|
||||
];
|
||||
|
||||
if ($search) {
|
||||
$options['search'] = $search;
|
||||
}
|
||||
|
||||
if ($cursor) {
|
||||
$options['cursor'] = $cursor;
|
||||
}
|
||||
|
||||
$response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info ?? null];
|
||||
}
|
||||
|
||||
public function createList(string $accountId, string $kind, string $name, string $description = '')
|
||||
{
|
||||
$options = [
|
||||
'kind' => $kind,
|
||||
'name' => $name,
|
||||
];
|
||||
|
||||
if ($description) {
|
||||
$options['description'] = $description;
|
||||
}
|
||||
|
||||
$response = $this->adapter->post('accounts/' . $accountId . '/rules/lists', $options);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function deleteList(string $accountId, string $listId)
|
||||
{
|
||||
|
||||
$response = $this->adapter->delete('accounts/' . $accountId . '/rules/lists/' . $listId);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function createListItem(string $accountId, string $listId, array $ip)
|
||||
{
|
||||
$options = [];
|
||||
foreach ($ip as $ipAddress) {
|
||||
$options[] = ['ip' => $ipAddress];
|
||||
}
|
||||
|
||||
$response = $this->adapter->post('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function deleteListItem(string $accountId, string $listId, array $itemIds)
|
||||
{
|
||||
|
||||
$options = ['items' => []];
|
||||
foreach ($itemIds as $itemId) {
|
||||
$options['items'][] = ['id' => $itemId];
|
||||
}
|
||||
|
||||
$response = $this->adapter->delete('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
public function getOperationStatus(string $accountId, string $operationId)
|
||||
{
|
||||
$response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/bulk_operations/' . $operationId);
|
||||
$this->body = json_decode($response->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
|
||||
}
|
||||
51
src/Endpoints/ZoneSubscriptions.php
Normal file
51
src/Endpoints/ZoneSubscriptions.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Cloudflare\API\Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Traits\BodyAccessorTrait;
|
||||
use stdClass;
|
||||
|
||||
class ZoneSubscriptions implements API
|
||||
{
|
||||
use BodyAccessorTrait;
|
||||
|
||||
/**
|
||||
* @var Adapter
|
||||
*/
|
||||
private $adapter;
|
||||
|
||||
public function __construct(Adapter $adapter)
|
||||
{
|
||||
$this->adapter = $adapter;
|
||||
}
|
||||
|
||||
public function listZoneSubscriptions(string $zoneId): \stdClass
|
||||
{
|
||||
$user = $this->adapter->get('zones/' . $zoneId . '/subscriptions');
|
||||
$this->body = json_decode($user->getBody());
|
||||
|
||||
return (object)[
|
||||
'result' => $this->body->result,
|
||||
];
|
||||
}
|
||||
|
||||
public function addZoneSubscription(string $zoneId, string $ratePlanId = ''): stdClass
|
||||
{
|
||||
$options = [];
|
||||
|
||||
if (empty($ratePlanId) === false) {
|
||||
$options['rate_plan'] = [
|
||||
'id' => $ratePlanId,
|
||||
];
|
||||
}
|
||||
|
||||
$existingSubscription = $this->listZoneSubscriptions($zoneId);
|
||||
$method = empty($existingSubscription->result) ? 'post' : 'put';
|
||||
|
||||
$subscription = $this->adapter->{$method}('zones/' . $zoneId . '/subscription', $options);
|
||||
$this->body = json_decode($subscription->getBody());
|
||||
|
||||
return $this->body->result;
|
||||
}
|
||||
}
|
||||
@@ -27,18 +27,20 @@ class Zones implements API
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $jumpStart
|
||||
* @param string $organizationID
|
||||
* @param string $accountId
|
||||
* @return \stdClass
|
||||
*/
|
||||
public function addZone(string $name, bool $jumpStart = false, string $organizationID = ''): \stdClass
|
||||
public function addZone(string $name, bool $jumpStart = false, string $accountId = ''): \stdClass
|
||||
{
|
||||
$options = [
|
||||
'name' => $name,
|
||||
'jump_start' => $jumpStart
|
||||
];
|
||||
|
||||
if (!empty($organizationID)) {
|
||||
$options['organization'] = ['id' => $organizationID];
|
||||
if (!empty($accountId)) {
|
||||
$options['account'] = [
|
||||
'id' => $accountId,
|
||||
];
|
||||
}
|
||||
|
||||
$user = $this->adapter->post('zones', $options);
|
||||
|
||||
59
tests/Endpoints/AccountMembersTest.php
Normal file
59
tests/Endpoints/AccountMembersTest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Endpoints\AccountMembers;
|
||||
|
||||
class AccountMembersTest extends TestCase
|
||||
{
|
||||
public function testAddAccountMember()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createAccountMember.json');
|
||||
|
||||
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/members'),
|
||||
$this->equalTo([
|
||||
'email' => 'user@example.com',
|
||||
'roles' => [
|
||||
'3536bcfad5faccb999b47003c79917fb',
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$accountMembers = new AccountMembers($mock);
|
||||
$accountMembers->addAccountMember('01a7362d577a6c3019a474fd6f485823', 'user@example.com', ['3536bcfad5faccb999b47003c79917fb']);
|
||||
|
||||
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $accountMembers->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testListAccountMembers()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listAccountMembers.json');
|
||||
|
||||
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('accounts/023e105f4ecef8ad9ca31a8372d0c353/members'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20,
|
||||
])
|
||||
);
|
||||
|
||||
$accountMembers = new AccountMembers($mock);
|
||||
$result = $accountMembers->listAccountMembers('023e105f4ecef8ad9ca31a8372d0c353', 1, 20);
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
|
||||
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $result->result[0]->id);
|
||||
$this->assertEquals(1, $result->result_info->count);
|
||||
$this->assertEquals('4536bcfad5faccb111b47003c79917fa', $accountMembers->getBody()->result[0]->id);
|
||||
}
|
||||
}
|
||||
32
tests/Endpoints/AccountRolesTest.php
Normal file
32
tests/Endpoints/AccountRolesTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Endpoints;
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Endpoints\AccountRoles;
|
||||
use TestCase;
|
||||
|
||||
class AccountRolesTest extends TestCase
|
||||
{
|
||||
public function testListAccountRoles()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listAccountRoles.json');
|
||||
|
||||
$adapter = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$adapter->method('get')->willReturn($response);
|
||||
|
||||
$adapter->expects($this->once())
|
||||
->method('get')
|
||||
->with($this->equalTo('accounts/023e105f4ecef8ad9ca31a8372d0c353/roles'));
|
||||
|
||||
$roles = new AccountRoles($adapter);
|
||||
$result = $roles->listAccountRoles('023e105f4ecef8ad9ca31a8372d0c353');
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
$this->assertObjectHasAttribute('result_info', $result);
|
||||
|
||||
$this->assertEquals('3536bcfad5faccb999b47003c79917fb', $result->result[0]->id);
|
||||
$this->assertEquals(1, $result->result_info->page);
|
||||
$this->assertEquals('3536bcfad5faccb999b47003c79917fb', $roles->getBody()->result[0]->id);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Cloudflare\API\Endpoints\Accounts;
|
||||
|
||||
/**
|
||||
* User: kanasite
|
||||
* Date: 01/28/2019
|
||||
@@ -24,7 +27,7 @@ class AccountsTest extends TestCase
|
||||
])
|
||||
);
|
||||
|
||||
$accounts = new \Cloudflare\API\Endpoints\Accounts($mock);
|
||||
$accounts = new Accounts($mock);
|
||||
$result = $accounts->listAccounts(1, 20, 'desc');
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
@@ -34,4 +37,50 @@ class AccountsTest extends TestCase
|
||||
$this->assertEquals(1, $result->result_info->page);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $accounts->getBody()->result[0]->id);
|
||||
}
|
||||
|
||||
public function testAddAccountWithDefaultType()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createStandardAccount.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('accounts'),
|
||||
$this->equalTo([
|
||||
'name' => 'Foo Bar',
|
||||
'type' => 'standard',
|
||||
])
|
||||
);
|
||||
|
||||
$accounts = new Accounts($mock);
|
||||
|
||||
$accounts->addAccount('Foo Bar');
|
||||
$this->assertEquals('2bab6ace8c72ed3f09b9eca6db1396bb', $accounts->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testAddAccountWithCustomType()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createEnterpriseAccount.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('accounts'),
|
||||
$this->equalTo([
|
||||
'name' => 'Foo Bar',
|
||||
'type' => 'enterprise',
|
||||
])
|
||||
);
|
||||
|
||||
$accounts = new Accounts($mock);
|
||||
|
||||
$accounts->addAccount('Foo Bar', 'enterprise');
|
||||
$this->assertEquals('2bab6ace8c72ed3f09b9eca6db1396bb', $accounts->getBody()->result->id);
|
||||
}
|
||||
}
|
||||
|
||||
191
tests/Endpoints/RulesListsTest.php
Executable file
191
tests/Endpoints/RulesListsTest.php
Executable file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
namespace Endpoints;
|
||||
|
||||
use TestCase;
|
||||
|
||||
class RulesListsTest extends TestCase
|
||||
{
|
||||
|
||||
public function testCreateRulesList()
|
||||
{
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRulesList.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists'),
|
||||
$this->equalTo([
|
||||
'kind' => 'ip',
|
||||
'name' => 'ip-allowlist',
|
||||
])
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->createList('01a7362d577a6c3019a474fd6f485823', 'ip', 'ip-allowlist');
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $result->id);
|
||||
$this->assertEquals('ip', $result->kind);
|
||||
$this->assertEquals('ip-allowlist', $result->name);
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $rulesLists->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testDeleteRulesList()
|
||||
{
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRulesList.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('delete')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->deleteList('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e');
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $result->id);
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $rulesLists->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testGetRulesLists()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listRulesLists.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->getLists('01a7362d577a6c3019a474fd6f485823');
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $result[0]->id);
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $rulesLists->getBody()->result[0]->id);
|
||||
}
|
||||
|
||||
public function testGetRulesListDetails()
|
||||
{
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getRulesListDetails.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->getListDetails('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e');
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $result->id);
|
||||
$this->assertEquals('ip', $result->kind);
|
||||
|
||||
$this->assertEquals('2c0fc9fa937b11eaa1b71c4d701ab86e', $rulesLists->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testGetRulesListItems()
|
||||
{
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getRulesListItems.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e/items'),
|
||||
$this->equalTo([
|
||||
'per_page' => 20,
|
||||
])
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->getListItems('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e');
|
||||
|
||||
$this->assertObjectHasAttribute('result', $result);
|
||||
$this->assertObjectHasAttribute('result_info', $result);
|
||||
|
||||
$this->assertEquals('10.0.0.1', $result->result[0]);
|
||||
$this->assertEquals('10.0.0.1', $rulesLists->getBody()->result[0]);
|
||||
}
|
||||
|
||||
public function testCreateRulesListItem() {
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/createRulesListItem.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e/items')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->createListItem('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e', [
|
||||
'10.0.0.1'
|
||||
]);
|
||||
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $result->operation_id);
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $rulesLists->getBody()->result->operation_id);
|
||||
}
|
||||
|
||||
public function testDeleteRulesListItem() {
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/deleteRulesListItem.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('delete')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('delete')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/2c0fc9fa937b11eaa1b71c4d701ab86e/items')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->deleteListItem('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e', ['6as9450mma215q6so7p79dd981r4ee09']);
|
||||
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $result->operation_id);
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $rulesLists->getBody()->result->operation_id);
|
||||
}
|
||||
|
||||
public function testGetOperationStatus() {
|
||||
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getOperationStatus.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('accounts/01a7362d577a6c3019a474fd6f485823/rules/lists/bulk_operations/4da8780eeb215e6cb7f48dd981c4ea02')
|
||||
);
|
||||
|
||||
$rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock);
|
||||
$result = $rulesLists->getOperationStatus('01a7362d577a6c3019a474fd6f485823', '4da8780eeb215e6cb7f48dd981c4ea02');
|
||||
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $result->id);
|
||||
$this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $rulesLists->getBody()->result->id);
|
||||
}
|
||||
|
||||
}
|
||||
78
tests/Endpoints/ZoneCacheTest.php
Normal file
78
tests/Endpoints/ZoneCacheTest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
class ZoneCacheTest extends TestCase
|
||||
{
|
||||
public function testCachePurgeEverything()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(['purge_everything' => true])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testCachePurgeHost()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(
|
||||
[
|
||||
'files' => [],
|
||||
'tags' => [],
|
||||
'hosts' => ['dash.cloudflare.com']
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']);
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testCachePurge()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurge.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(['files' => [
|
||||
'https://example.com/file.jpg',
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [
|
||||
'https://example.com/file.jpg',
|
||||
]);
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
}
|
||||
81
tests/Endpoints/ZoneSubscriptionsTest.php
Normal file
81
tests/Endpoints/ZoneSubscriptionsTest.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
use Cloudflare\API\Adapter\Adapter;
|
||||
use Cloudflare\API\Endpoints\ZoneSubscriptions;
|
||||
|
||||
class ZoneSubscriptionsTest extends TestCase
|
||||
{
|
||||
public function testListZoneSubscriptions()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/listZoneSubscriptions.json');
|
||||
|
||||
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscriptions')
|
||||
);
|
||||
|
||||
$zoneSubscriptions = new ZoneSubscriptions($mock);
|
||||
$zoneSubscriptions->listZoneSubscriptions('023e105f4ecef8ad9ca31a8372d0c353');
|
||||
|
||||
$this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result[0]->id);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result[0]->zone->id);
|
||||
}
|
||||
|
||||
public function testAddZoneSubscriptionIfMissing()
|
||||
{
|
||||
$postResponse = $this->getPsr7JsonResponseForFixture('Endpoints/createZoneSubscription.json');
|
||||
$getResponse = $this->getPsr7JsonResponseForFixture('Endpoints/listEmptyZoneSubscriptions.json');
|
||||
|
||||
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($postResponse);
|
||||
$mock->method('get')->willReturn($getResponse);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscription'),
|
||||
$this->equalTo([
|
||||
'rate_plan' => [
|
||||
'id' => 'PARTNER_PRO',
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$zoneSubscriptions = new ZoneSubscriptions($mock);
|
||||
$zoneSubscriptions->addZoneSubscription('023e105f4ecef8ad9ca31a8372d0c353', 'PARTNER_PRO');
|
||||
|
||||
$this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result->id);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result->zone->id);
|
||||
}
|
||||
|
||||
public function testAddZoneSubscriptionIfExisting()
|
||||
{
|
||||
$postResponse = $this->getPsr7JsonResponseForFixture('Endpoints/createZoneSubscription.json');
|
||||
$getResponse = $this->getPsr7JsonResponseForFixture('Endpoints/listZoneSubscriptions.json');
|
||||
|
||||
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||
$mock->method('put')->willReturn($postResponse);
|
||||
$mock->method('get')->willReturn($getResponse);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('put')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/subscription'),
|
||||
$this->equalTo([
|
||||
'rate_plan' => [
|
||||
'id' => 'PARTNER_PRO',
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$zoneSubscriptions = new ZoneSubscriptions($mock);
|
||||
$zoneSubscriptions->addZoneSubscription('023e105f4ecef8ad9ca31a8372d0c353', 'PARTNER_PRO');
|
||||
|
||||
$this->assertEquals('506e3185e9c882d175a2d0cb0093d9f2', $zoneSubscriptions->getBody()->result->id);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zoneSubscriptions->getBody()->result->zone->id);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,9 @@ class ZonesTest extends TestCase
|
||||
$this->equalTo([
|
||||
'name' => 'example.com',
|
||||
'jump_start' => true,
|
||||
'organization' => ['id' => '01a7362d577a6c3019a474fd6f485823']
|
||||
'account' => [
|
||||
'id' => '01a7362d577a6c3019a474fd6f485823',
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
@@ -49,6 +51,33 @@ class ZonesTest extends TestCase
|
||||
$this->assertEquals('9a7806061c88ada191ed06f989cc3dac', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testAddZoneWithAccountId()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/addZone.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones'),
|
||||
$this->equalTo([
|
||||
'name' => 'example.com',
|
||||
'jump_start' => false,
|
||||
'account' => [
|
||||
'id' => '023e105f4ecef8ad9ca31a8372d0c353',
|
||||
],
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->addZone('example.com', false, '023e105f4ecef8ad9ca31a8372d0c353');
|
||||
|
||||
$this->assertObjectHasAttribute('id', $result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $result->account->id);
|
||||
}
|
||||
|
||||
public function testActivationTest()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/activationTest.json');
|
||||
@@ -188,78 +217,4 @@ class ZonesTest extends TestCase
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('development_mode', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testCachePurgeEverything()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeEverything.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(['purge_everything' => true])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurgeEverything('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testCachePurgeHost()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurgeHost.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(
|
||||
[
|
||||
'files' => [],
|
||||
'tags' => [],
|
||||
'hosts' => ['dash.cloudflare.com']
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [], [], ['dash.cloudflare.com']);
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
|
||||
public function testCachePurge()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/cachePurge.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('post')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('post')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/purge_cache'),
|
||||
$this->equalTo(['files' => [
|
||||
'https://example.com/file.jpg',
|
||||
]
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
|
||||
$result = $zones->cachePurge('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', [
|
||||
'https://example.com/file.jpg',
|
||||
]);
|
||||
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals('023e105f4ecef8ad9ca31a8372d0c353', $zones->getBody()->result->id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
"email": "user@example.com",
|
||||
"owner_type": "user"
|
||||
},
|
||||
"account": {
|
||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||
"name": "Demo Account"
|
||||
},
|
||||
"permissions": [
|
||||
"#zone:read",
|
||||
"#zone:edit"
|
||||
|
||||
74
tests/Fixtures/Endpoints/createAccountMember.json
Normal file
74
tests/Fixtures/Endpoints/createAccountMember.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "4536bcfad5faccb111b47003c79917fa",
|
||||
"code": "05dd05cce12bbed97c0d87cd78e89bc2fd41a6cee72f27f6fc84af2e45c0fac0",
|
||||
"user": {
|
||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||
"first_name": "John",
|
||||
"last_name": "Appleseed",
|
||||
"email": "user@example.com",
|
||||
"two_factor_authentication_enabled": false
|
||||
},
|
||||
"status": "accepted",
|
||||
"roles": [
|
||||
{
|
||||
"id": "3536bcfad5faccb999b47003c79917fb",
|
||||
"name": "Account Administrator",
|
||||
"description": "Administrative access to the entire Account",
|
||||
"permissions": {
|
||||
"analytics": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"billing": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"cache_purge": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns_records": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"lb": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"logs": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"organization": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"ssl": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"waf": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zones": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zone_settings": {
|
||||
"read": true,
|
||||
"write": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
13
tests/Fixtures/Endpoints/createEnterpriseAccount.json
Normal file
13
tests/Fixtures/Endpoints/createEnterpriseAccount.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"result": {
|
||||
"id": "2bab6ace8c72ed3f09b9eca6db1396bb",
|
||||
"name": "Foo Bar",
|
||||
"type": "enterprise",
|
||||
"settings": {
|
||||
"enforce_twofactor": false
|
||||
}
|
||||
},
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": []
|
||||
}
|
||||
25
tests/Fixtures/Endpoints/createRulesList.json
Executable file
25
tests/Fixtures/Endpoints/createRulesList.json
Executable file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"id": "2c0fc9fa937b11eaa1b71c4d701ab86e",
|
||||
"created_on": "2020-01-01T08:00:00Z",
|
||||
"description": "",
|
||||
"kind": "ip",
|
||||
"modified_on": "2020-01-10T14:00:00Z",
|
||||
"name": "ip-allowlist",
|
||||
"num_items": 10,
|
||||
"num_referencing_filters": 2
|
||||
}
|
||||
}
|
||||
18
tests/Fixtures/Endpoints/createRulesListItem.json
Executable file
18
tests/Fixtures/Endpoints/createRulesListItem.json
Executable file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"operation_id": "4da8780eeb215e6cb7f48dd981c4ea02"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
13
tests/Fixtures/Endpoints/createStandardAccount.json
Normal file
13
tests/Fixtures/Endpoints/createStandardAccount.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"result": {
|
||||
"id": "2bab6ace8c72ed3f09b9eca6db1396bb",
|
||||
"name": "Foo Bar",
|
||||
"type": "standard",
|
||||
"settings": {
|
||||
"enforce_twofactor": false
|
||||
}
|
||||
},
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": []
|
||||
}
|
||||
40
tests/Fixtures/Endpoints/createZoneSubscription.json
Normal file
40
tests/Fixtures/Endpoints/createZoneSubscription.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"app": {
|
||||
"install_id": null
|
||||
},
|
||||
"id": "506e3185e9c882d175a2d0cb0093d9f2",
|
||||
"state": "Paid",
|
||||
"price": 20,
|
||||
"currency": "USD",
|
||||
"component_values": [
|
||||
{
|
||||
"name": "page_rules",
|
||||
"value": 20,
|
||||
"default": 5,
|
||||
"price": 5
|
||||
}
|
||||
],
|
||||
"zone": {
|
||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||
"name": "example.com"
|
||||
},
|
||||
"frequency": "monthly",
|
||||
"rate_plan": {
|
||||
"id": "free",
|
||||
"public_name": "Business Plan",
|
||||
"currency": "USD",
|
||||
"scope": "zone",
|
||||
"sets": [
|
||||
{}
|
||||
],
|
||||
"is_contract": false,
|
||||
"externally_managed": false
|
||||
},
|
||||
"current_period_end": "2014-03-31T12:20:00Z",
|
||||
"current_period_start": "2014-05-11T12:20:00Z"
|
||||
}
|
||||
}
|
||||
18
tests/Fixtures/Endpoints/deleteRulesList.json
Executable file
18
tests/Fixtures/Endpoints/deleteRulesList.json
Executable file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"id": "2c0fc9fa937b11eaa1b71c4d701ab86e"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
18
tests/Fixtures/Endpoints/deleteRulesListItem.json
Executable file
18
tests/Fixtures/Endpoints/deleteRulesListItem.json
Executable file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"operation_id": "4da8780eeb215e6cb7f48dd981c4ea02"
|
||||
}
|
||||
}
|
||||
21
tests/Fixtures/Endpoints/getOperationStatus.json
Executable file
21
tests/Fixtures/Endpoints/getOperationStatus.json
Executable file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"id": "4da8780eeb215e6cb7f48dd981c4ea02",
|
||||
"status": "pending",
|
||||
"completed": "2020-01-01T08:00:00Z",
|
||||
"error": "This list is at the maximum number of items"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
25
tests/Fixtures/Endpoints/getRulesListDetails.json
Executable file
25
tests/Fixtures/Endpoints/getRulesListDetails.json
Executable file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"id": "2c0fc9fa937b11eaa1b71c4d701ab86e",
|
||||
"created_on": "2020-01-01T08:00:00Z",
|
||||
"description": "This is a note",
|
||||
"kind": "ip",
|
||||
"modified_on": "2020-01-10T14:00:00Z",
|
||||
"name": "list1",
|
||||
"num_items": 10,
|
||||
"num_referencing_filters": 2
|
||||
}
|
||||
}
|
||||
24
tests/Fixtures/Endpoints/getRulesListItems.json
Executable file
24
tests/Fixtures/Endpoints/getRulesListItems.json
Executable file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": [
|
||||
"10.0.0.1"
|
||||
],
|
||||
"result_info": {
|
||||
"cursors": {
|
||||
"after": "yyy",
|
||||
"before": "xxx"
|
||||
}
|
||||
}
|
||||
}
|
||||
82
tests/Fixtures/Endpoints/listAccountMembers.json
Normal file
82
tests/Fixtures/Endpoints/listAccountMembers.json
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": [
|
||||
{
|
||||
"id": "4536bcfad5faccb111b47003c79917fa",
|
||||
"code": "05dd05cce12bbed97c0d87cd78e89bc2fd41a6cee72f27f6fc84af2e45c0fac0",
|
||||
"user": {
|
||||
"id": "7c5dae5552338874e5053f2534d2767a",
|
||||
"first_name": "John",
|
||||
"last_name": "Appleseed",
|
||||
"email": "user@example.com",
|
||||
"two_factor_authentication_enabled": false
|
||||
},
|
||||
"status": "accepted",
|
||||
"roles": [
|
||||
{
|
||||
"id": "3536bcfad5faccb999b47003c79917fb",
|
||||
"name": "Account Administrator",
|
||||
"description": "Administrative access to the entire Account",
|
||||
"permissions": {
|
||||
"analytics": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"billing": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"cache_purge": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns_records": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"lb": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"logs": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"organization": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"ssl": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"waf": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zones": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zone_settings": {
|
||||
"read": true,
|
||||
"write": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"result_info": {
|
||||
"page": 1,
|
||||
"per_page": 20,
|
||||
"count": 1,
|
||||
"total_count": 200
|
||||
}
|
||||
}
|
||||
69
tests/Fixtures/Endpoints/listAccountRoles.json
Normal file
69
tests/Fixtures/Endpoints/listAccountRoles.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": [
|
||||
{
|
||||
"id": "3536bcfad5faccb999b47003c79917fb",
|
||||
"name": "Account Administrator",
|
||||
"description": "Administrative access to the entire Account",
|
||||
"permissions": {
|
||||
"analytics": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"billing": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"cache_purge": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"dns_records": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"lb": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"logs": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"organization": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"ssl": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"waf": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zones": {
|
||||
"read": true,
|
||||
"write": true
|
||||
},
|
||||
"zone_settings": {
|
||||
"read": true,
|
||||
"write": true
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"result_info": {
|
||||
"page": 1,
|
||||
"per_page": 1,
|
||||
"total_pages": 1,
|
||||
"count": 1,
|
||||
"total_count": 1
|
||||
}
|
||||
}
|
||||
6
tests/Fixtures/Endpoints/listEmptyZoneSubscriptions.json
Normal file
6
tests/Fixtures/Endpoints/listEmptyZoneSubscriptions.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": []
|
||||
}
|
||||
27
tests/Fixtures/Endpoints/listRulesLists.json
Executable file
27
tests/Fixtures/Endpoints/listRulesLists.json
Executable file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"code": 1000,
|
||||
"message": "message"
|
||||
}
|
||||
],
|
||||
"result": [
|
||||
{
|
||||
"id": "2c0fc9fa937b11eaa1b71c4d701ab86e",
|
||||
"created_on": "2020-01-01T08:00:00Z",
|
||||
"kind": "ip",
|
||||
"modified_on": "2020-01-10T14:00:00Z",
|
||||
"name": "list1",
|
||||
"num_items": 10,
|
||||
"description": "This is a note",
|
||||
"num_referencing_filters": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
42
tests/Fixtures/Endpoints/listZoneSubscriptions.json
Normal file
42
tests/Fixtures/Endpoints/listZoneSubscriptions.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": [
|
||||
{
|
||||
"app": {
|
||||
"install_id": null
|
||||
},
|
||||
"id": "506e3185e9c882d175a2d0cb0093d9f2",
|
||||
"state": "Paid",
|
||||
"price": 20,
|
||||
"currency": "USD",
|
||||
"component_values": [
|
||||
{
|
||||
"name": "page_rules",
|
||||
"value": 20,
|
||||
"default": 5,
|
||||
"price": 5
|
||||
}
|
||||
],
|
||||
"zone": {
|
||||
"id": "023e105f4ecef8ad9ca31a8372d0c353",
|
||||
"name": "example.com"
|
||||
},
|
||||
"frequency": "monthly",
|
||||
"rate_plan": {
|
||||
"id": "free",
|
||||
"public_name": "Business Plan",
|
||||
"currency": "USD",
|
||||
"scope": "zone",
|
||||
"sets": [
|
||||
{}
|
||||
],
|
||||
"is_contract": false,
|
||||
"externally_managed": false
|
||||
},
|
||||
"current_period_end": "2014-03-31T12:20:00Z",
|
||||
"current_period_start": "2014-05-11T12:20:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user