cfmgrv4 init...1
This commit is contained in:
parent
958da4e1ee
commit
5c7aeb0625
@ -10,15 +10,11 @@ use App\Entities\Cloudflare\AccountEntity;
|
|||||||
class Account extends MyCloudflare
|
class Account extends MyCloudflare
|
||||||
{
|
{
|
||||||
private $_myStorage = null;
|
private $_myStorage = null;
|
||||||
private $_authkey = "";
|
public function __construct(string $auth_key)
|
||||||
public function __construct()
|
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct($auth_key);
|
||||||
}
|
|
||||||
private function getRequest(): Guzzle
|
|
||||||
{
|
|
||||||
return $this->getMySocket()->request($this->_authkey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getMyStorage(): AccountModel
|
final protected function getMyStorage(): AccountModel
|
||||||
{
|
{
|
||||||
if ($this->_myStorage === null) {
|
if ($this->_myStorage === null) {
|
||||||
@ -72,7 +68,7 @@ class Account extends MyCloudflare
|
|||||||
{
|
{
|
||||||
//Account의 경우 인증키를 가지고있고 생성할수 없으므로 get으로 읽은후 첫번째것을 사용하기로 함
|
//Account의 경우 인증키를 가지고있고 생성할수 없으므로 get으로 읽은후 첫번째것을 사용하기로 함
|
||||||
$entitys = [];
|
$entitys = [];
|
||||||
foreach ($this->reload_cfs($this->getRequest(), 'accounts') as $cf) {
|
foreach ($this->reload_cfs($this->getMySocket(), 'accounts') as $cf) {
|
||||||
$formDatas = $this->getArrayByResult($cf->result);
|
$formDatas = $this->getArrayByResult($cf->result);
|
||||||
$entity = $this->$this->getMyStorage()->create($formDatas);
|
$entity = $this->$this->getMyStorage()->create($formDatas);
|
||||||
log_message("notice", "Account:" . __FUNCTION__ . "=> {$entity->getTitle()} 작업을 완료하였습니다.");
|
log_message("notice", "Account:" . __FUNCTION__ . "=> {$entity->getTitle()} 작업을 완료하였습니다.");
|
||||||
|
|||||||
@ -8,10 +8,12 @@ use App\Libraries\CommonLibrary;
|
|||||||
|
|
||||||
abstract class MyCloudflare extends CommonLibrary
|
abstract class MyCloudflare extends CommonLibrary
|
||||||
{
|
{
|
||||||
|
private $_account_uid = "";
|
||||||
private $_mySocket = null;
|
private $_mySocket = null;
|
||||||
protected function __construct()
|
protected function __construct(string $account_uid)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->_account_uid = $account_uid;
|
||||||
}
|
}
|
||||||
abstract protected function getArrayByResult($result, array $formDatas = []): array;
|
abstract protected function getArrayByResult($result, array $formDatas = []): array;
|
||||||
abstract protected function reload_entity($cf): mixed;
|
abstract protected function reload_entity($cf): mixed;
|
||||||
|
|||||||
@ -16,14 +16,10 @@ class Record extends MyCloudflare
|
|||||||
private $_zone_entity = null;
|
private $_zone_entity = null;
|
||||||
public function __construct(AccountEntity $account_entity, ZoneEntity $zone_entity)
|
public function __construct(AccountEntity $account_entity, ZoneEntity $zone_entity)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct($this->_account_entity->getPK());
|
||||||
$this->_account_entity = $account_entity;
|
$this->_account_entity = $account_entity;
|
||||||
$this->_zone_entity = $zone_entity;
|
$this->_zone_entity = $zone_entity;
|
||||||
}
|
}
|
||||||
protected function getRequest(): Guzzle
|
|
||||||
{
|
|
||||||
return $this->getMySocket()->request($this->_account_entity->getAuthKey());
|
|
||||||
}
|
|
||||||
final protected function getMyStorage(): RecordModel
|
final protected function getMyStorage(): RecordModel
|
||||||
{
|
{
|
||||||
if ($this->_myStorage === null) {
|
if ($this->_myStorage === null) {
|
||||||
|
|||||||
@ -15,13 +15,9 @@ class Zone extends MyCloudflare
|
|||||||
private $_account_entity = null;
|
private $_account_entity = null;
|
||||||
public function __construct(AccountEntity $account_entity)
|
public function __construct(AccountEntity $account_entity)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct($this->_account_entity->getPK());
|
||||||
$this->_account_entity = $account_entity;
|
$this->_account_entity = $account_entity;
|
||||||
}
|
}
|
||||||
private function getRequest(): Guzzle
|
|
||||||
{
|
|
||||||
return $this->getMySocket()->request($this->_account_entity->getAuthKey());
|
|
||||||
}
|
|
||||||
final protected function getMyStorage(): ZoneModel
|
final protected function getMyStorage(): ZoneModel
|
||||||
{
|
{
|
||||||
if ($this->_myStorage === null) {
|
if ($this->_myStorage === null) {
|
||||||
@ -29,6 +25,10 @@ class Zone extends MyCloudflare
|
|||||||
}
|
}
|
||||||
return $this->_myStorage;
|
return $this->_myStorage;
|
||||||
}
|
}
|
||||||
|
final protected function getRequest(): Guzzle
|
||||||
|
{
|
||||||
|
return $this->getMySocket()->request($this->_account_uid);
|
||||||
|
}
|
||||||
protected function getArrayByResult($result, array $formDatas = []): array
|
protected function getArrayByResult($result, array $formDatas = []): array
|
||||||
{
|
{
|
||||||
$formDatas[$this->getMyStorage()->getPKField()] = $result->id;
|
$formDatas[$this->getMyStorage()->getPKField()] = $result->id;
|
||||||
|
|||||||
@ -7,10 +7,6 @@ use Cloudflare\API\Auth\APIKey;
|
|||||||
use Cloudflare\API\Adapter\Guzzle;
|
use Cloudflare\API\Adapter\Guzzle;
|
||||||
use App\Models\Cloudflare\AccountModel;
|
use App\Models\Cloudflare\AccountModel;
|
||||||
use App\Libraries\CommonLibrary;
|
use App\Libraries\CommonLibrary;
|
||||||
// use App\Entities\Cloudflare\AccountEntity;
|
|
||||||
// use Cloudflare\API\Endpoints\Zones;
|
|
||||||
// use Cloudflare\API\Endpoints\DNS;
|
|
||||||
// use Cloudflare\API\Endpoints\Accounts;
|
|
||||||
|
|
||||||
class CloudflareSocket extends CommonLibrary
|
class CloudflareSocket extends CommonLibrary
|
||||||
{
|
{
|
||||||
@ -35,15 +31,15 @@ class CloudflareSocket extends CommonLibrary
|
|||||||
private function initAdapters(): void
|
private function initAdapters(): void
|
||||||
{
|
{
|
||||||
foreach ($this->getAccountModel()->getEntitys() as $entity) {
|
foreach ($this->getAccountModel()->getEntitys() as $entity) {
|
||||||
$this->_clients[$entity->getAuthKey()] = new Guzzle(
|
$this->_clients[$entity->getPK()] = new Guzzle(
|
||||||
new APIKey($entity->getTitle(), $entity->getAuthKey())
|
new APIKey($entity->getTitle(), $entity->getAuthKey())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final public function request(string $authkey): Guzzle
|
final public function request(string $key): Guzzle
|
||||||
{
|
{
|
||||||
if (!array_key_exists($authkey, $this->_clients)) {
|
if (!array_key_exists($key, $this->_clients)) {
|
||||||
throw new \Exception(+__FUNCTION__ . " => {$authkey}에 해당하는 Adapter를 찾을수 없습니다.");
|
throw new \Exception(+__FUNCTION__ . " => {$key}에 해당하는 Adapter를 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
if (self::$_request >= self::$_request_max) {
|
if (self::$_request >= self::$_request_max) {
|
||||||
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait));
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 시작--", self::$_request_timewait));
|
||||||
@ -52,18 +48,6 @@ class CloudflareSocket extends CommonLibrary
|
|||||||
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
|
log_message('warning', sprintf("--Cloudflare API Call %s초 대기 종료--", self::$_request_timewait));
|
||||||
}
|
}
|
||||||
self::$_request++;
|
self::$_request++;
|
||||||
return $this->_clients[$authkey];
|
return $this->_clients[$key];
|
||||||
}
|
}
|
||||||
// public function getAccount(string $authkey): Accounts
|
|
||||||
// {
|
|
||||||
// return new Accounts($this->request($authkey));
|
|
||||||
// }
|
|
||||||
// public function getZone(string $authkey): Zones
|
|
||||||
// {
|
|
||||||
// return new Zones($this->request($authkey));
|
|
||||||
// }
|
|
||||||
// public function getRecord(string $authkey): DNS
|
|
||||||
// {
|
|
||||||
// return new DNS($this->request($authkey));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user