OpenResty Edge™ PHP SDK Manual

All of these methods will throw an exception if the client encounters errors, for example, network error, 400 and 500 level errors.

MethodParametersParameters typeDescriptionReturn type
Edge2Client$optsarrayinit SDK clientobject
loginlogin to edge systembool
useApp$appIDnumberset the application you want to operatebool
newApp$optsarrayadd a new applicationnumber
updateApp$optsarrayupdate applicationbool
getAppget info of applicationarray
getAllApps$detailboolget info of all applicationsarray
appendAppDomain$optsarrayappend one more domain of applicationbool
deleteApp$appIDnumberdelete applicationbool
searchApp$optsarraysearch applicationarray
newUpstream$optsarrayadd a new upstreamnumber
updateUpstream$optsarrayupdate upstreambool
deleteUpstream$UpstreamIDnumberdelete upstreambool
newRewriteRule$optsarrayadd a new rewrite rulenumber
updateRewriteRule$optsarrayupdate rewrite rulebool
getRewriteRulerule_idnumberget request rewrite rulearray
getAllRewriteRulesapp_idnumberget all rewrite rulesarray
deleteRewriteRule$RewriteRuleIDnumberdelete rewrite rulebool
newAppDymetrics$optsarraynew application dynamic metricsarray
deleteAppDymetrics$metricIDnumberdelete application dynamic metricsbool
getAppDymetricsget application dynamic metricsbool
getAppDymetricsData$optsarrayget dynamic metrics dataarray
newAppIPList$optsarraycreate a new application IP listnumber
deleteAppIPList$appIPListIDnumberdelete application IP list by idbool
updateAppIPList$optsarrayupdate application IP list by idbool
appendToAppIPList$optsarrayappend IP to application IP list by idbool
removeFromAppIPList$optsarrayremove IP from application IP list by idbool
getAppIPList$appIPListIDnumberget application IP list by idarray
getAllAppIPListget all AppIP listarray
setCertKey$optsarrayset SSL key and certnumber
updateCertKey$optsarrayupdate SSL key and certbool
getCertKey$optsarrayget SSL key and cert by cert idarray
getAllCertKeys$optsarrayget all SSL keys and certsarray
deleteCertKey$certIDnumberdelete certbool
setGlobalCertKey$optsarrayset global SSL key and certnumber
updateGlobalCertKey$optsarrayupdate global SSL key and certbool
getGlobalCertKey$certIDnumberget global SSL key and cert by cert idarray
getAllGlobalCertKeysget all SSL keys and certsarray
deleteGlobalCertKey$certIDnumberdelete global certbool
newCachePurgeTask$optsarrayadd cache purge tasknumber
getCachePurgeTask$taskIDnumberget cache purge taskarray
getAllCachePurgeTasksget all cache purge tasksarray
deleteCachePurgeTask$taskIDnumberdelete cache purge taskbool
newEL$optsarrayadd EL codebool
newReleasenew releasebool
pendingChangespending changesnumber
getGlobalConfig$optsarrayget global configjson format string
setWorker$optsarrayset global config of workerbool
setSSL$optsarrayset global config of SSLbool
setProxy$optsarrayset global config of proxybool
setClientReq$optsarrayset global config of client requestbool
setFileBuffer$optsarrayset global config of client bufferbool
setLog$optsarrayset global config of logbool
setDNS$optsarrayset global config of DNSbool
setGzip$optsarrayset global config of Gzipbool
newDNS$optsarrayadd a new DNSnumber
updateDNS$optsarrayupdate DNSbool
deleteDNS$dnsIDnumberdelete DNSbool
newDnsRecord$optsarrayadd record of DNSbool
updateDnsRecord$optsarrayupdate record of DNSbool
deleteDnsRecord$optsarraydelete record of DNSbool
disabledDnsRecord$optsarraydisabled record of DNSbool
newGlobalDymetrics$optsarraynew global dynamic metricsarray
deleteGlobalDymetrics$metricIDnumberdelete global dynamic metricsbool
getGlobalDymetricsget global dynamic metricsbool
getGlobalDymetricsData$optsarrayget dynamic metrics dataarray
getMetricData$appIDnumberget last one minute metric data of apparray
newLayerPolicy$optsarrayadd a layer policynumber
deleteLayerPolicy$policyIDnumberdelete a layer policybool
updateLayerPolicy$optsarrayupdate a layer policybool
getLayerPoliciesget all layer policiesarray
newGlobalIPList$optsarraycreate a new global IP listnumber
deleteGlobalIPList$globalIPListIDnumberdelete global IP list by idbool
updateGlobalIPList$optsarrayupdate global IP list by idbool
appendToGlobalIPList$optsarrayappend IP to global IP list by idbool
removeFromGlobalIPList$optsarrayremove IP from global IP list by idbool
getGlobalIPList$globalIPListIDnumberget global IP list by idarray
getAllGlobalIPListget all global IP listarray
convCrlToLuaModule$crl_filesarrayconvert CRL files into Lua Modulestring

Edge2Client

$client = Edge2Client($opts)

Description of array $opts:

Key nameTypeRequiredDescription
edge_admin_addrstringyesaddress of edge admin, including host and port
usernamestringnousername of edge-admin, required when api_token is empty
passwordstringnopassword of edge-admin, required when api_token is empty
api_tokenstringnoapi_token, required when username and password are empty

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

// use api token
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'api_token' => 'xxx-xxx-xxx-xxx'
]);

?>

login

$ok = login()

Returns true if login success else false.

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();
?>

useApp

$ok = useApp($appID)

Returns true if success else false.

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->useApp(10);
?>

newApp

$appID = newApp($opts)

Description of array $opts:

Key nameTypeRequiredDescription
domainsarrayyesdomains of application
labelstringyesname of application

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);
?>

appendAppDomain

$ok = appendAppDomain($opts);

Description of array $opts:

Key nameTypeRequiredDescription
appIDintnoid of application, default is current application’s id
domainarrayyesdomain of application
isWildcardboolnodefault is false

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$client->appendAppDomain(['domain' => 'foo.test.com']);

?>

updateApp

$ok = updateApp($opts);

Description of array $opts:

Key nameTypeRequiredDescription
domainsarrayyesdomains of application
labelstringyesname of application

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$appID = $client->updateApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com'
]);

?>

getApp

$ok = getApp($appID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$app_info = $client->getApp();

?>

getAllApps

$ok = getAllApps($detail);

Key nameTypeRequiredDescription
detailboolnodefault is false, only return id of apps.

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$apps_info = $client->getAllApps();

?>

deleteApp

$ok = deleteApp($appID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ok = $client->deleteApp($appID);

?>

searchApp

$ok = searchApp($opts);

Description of array $opts:

Key nameTypeRequiredDescription
appDomainstringnothe search keyword of app domain, support the regular expressions
upstreamIpstringnoip address of app’s upstream

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$app_info = $client->client->searchApp(['appDomain' => 'test']);
$app_id = $app_info[0]['id'];
?>

newUpstream

$appID = newUpstream($opts)

Description of array $opts:

Key nameTypeRequiredDescription
namestringyesname of upstream
serversarrayyesupstreams
sslboolnoset protocol to HTTPS, default is false(HTTP)
health_checkboolnoenable active health check, default is false

servers

Description of array servers in $opts:

Key nameTypeRequiredDescription
ipstringyesip of upstream
portstringyesport of upstream
weightnumbernoweight of upstream, default is 1
statusnumbernoenabled or disabled upstream, default is 1 (enabled)
health_checkerdictnodetail configure of health checker, default is none

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$upstreamID = $client->newUpstream([
   'name' => 'origin-upstream',
   'servers' => [
        ['ip' => '172.22.31.1','port' => 80],
        ['ip' => '172.22.31.2','port' => 80,'weight' => 2]
    ]
]);

updateUpstream

$ok = updateUpstream($opts)

Description of array $opts:

Key nameTypeRequiredDescription
up_idnumberyesid of rule
namestringyesname of upstream
serversarrayyesupstreams
sslboolnoset protocol to HTTPS, default is false(HTTP)
health_checkboolnoenable active health check, default is false

servers

Description of array servers in $opts:

Key nameTypeRequiredDescription
ipstringyesip of upstream
portstringyesport of upstream
weightnumbernoweight of upstream, default is 1
disablednumbernodisabled upstream, default is 0

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$upstreamID = $client->newUpstream([
   'name' => 'origin-upstream',
   'servers' => [
            ['ip' => '172.22.31.1', 'port' => 80],
            ['ip' => '172.22.31.2', 'port' => 80, 'weight' => 2]
        ]
]);

$ok = $client->updateUpstream([
        'up_id' => $upstreamID,
        'name' => 'backup-upstream',
        'servers' => [
                ['domain' => 'test.com', 'port' => 8080, 'weight' => 3],
                ['ip' => '172.22.31.6', 'port' => 80]
        ],
        'health_checker' => [
            'type' => 'http',
            'http_req_uri' => '/status',
            'http_req_host' => 'test.com',
            'interval' => 3,
            'interval_unit' => 'sec',
            'timeout' => 1,
            'fall' => 3,
            'rise' => 2,
            'valid_statuses' => [200, 302],
            'report_interval' => 3,
            'report_interval_unit' => 'min'
        ]
    ]);

deleteUpstream

$ok = deleteUpstream($up_id);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$upstreamID = $client->newUpstream([
   'name' => 'origin-upstream',
   'servers' => [
            ['ip' => '172.22.31.1','port' => 80],
            ['ip' => '172.22.31.2','port' => 80, 'weight' => 2]
        ]
]);

$ok = $client->deleteUpstream($upstreamID);
?>

newProxyRule

$ruleID = newProxyRule($opts)

Description of array $opts:

Key nameTypeRequiredDescription
upstreamsarrayyesupstreams
backupUpstreamsarrayyesbackup upstreams
timeoutnumbernotimeout of proxy, default is 3 seconds
connectTimeoutnumbernoconnect timeout of proxy, default is the same as timeout
readTimeoutnumbernoread timeout of proxy, default is the same as timeout
sendTimeoutnumbernosend timeout of proxy, default is the same as timeout

upstreams

Description of array upstreams in $opts:

Key nameTypeRequiredDescription
upstreamnumberyesid of upstream
weightnumbernoweight of upstream, default is 1

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$upstreamID = $client->newUpstream([
   'name' => 'origin-upstream',
   'servers' => [
            ['ip' => '172.22.31.1', 'port' => 80],
            ['ip' => '172.22.31.2', 'port' => 80, 'weight' => 2]
        ]
]);

$backupUpstreamID = $client->newUpstream([
   'name' => 'backup-upstream',
   'servers' => [
        ['ip' => '172.22.31.3', 'port' => 8000],
        ['ip' => '172.22.31.4', 'port' => 80, 'weight' => 3]
        ]
]);

$proxyRuleID = $client->newProxyRule([
   'upstreams' => [['upstream' => $upstreamID, 'weight' => 2]],
   'backup_upstreams' => [['upstream' => $backupUpstreamID]]
]);
?>

newRewriteRule

$rewriteRuleID = newRewriteRule($opts)

Description of array $opts:

Key nameTypeRequiredDescription
conditionlistnoconditions of rule
conseqdict or listnoactions of rule
waflistnorules of waf
proxylistnorules of proxy
cachelistnorules of cache
contentlistnorules of content

condition

Description of array condition in $opts:

Key nameTypeRequiredDescription
varstring or arrayyesname of edgelang builtin predicate function if type is string, name and args of function if type is array
opstringnooperator, default is eq
valstringeither val or valsvalue
valsarrayeither val or valsarray of val

conseq

Description of array conseq in $opts:

Key nameTypeRequiredDescription
edgelang builtin action functionstringyesone of edgelang builtin action functions
args of edgelang builtin action functionarrayyesargs of edgelang builtin action function

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [
    ['var' => 'host', 'op' => 'eq', 'val' => "con.foo.com"],
    ['var' => ['req-header', 'Referer'], 'vals' => [['foo\d+','rx'], 'foo.com']]
];

$conseq = [
    'print' => ['msg' => 'hello'],
    enable-'websocket' => [],
   'redirect' => ['url' => '/cn/2017/', 'code' => 302]
];

$rewriteRuleID = $client->newRewriteRule([
   'condition' => $condition,
   'conseq' => $conseq
]);
?>

waf

Description of array waf:

Key nameTypeRequiredDescription
rule_setslistnothe set of user defined rules in global waf, default is empty array
scanner_detectionboolnowhether to enable this type of detection, default is False
protocol_enforcementboolnowhether to enable this type of detection, default is False
protocol_attackboolnowhether to enable this type of detection, default is False
application_attack_lfiboolnowhether to enable this type of detection, default is False
application_attack_rfiboolnowhether to enable this type of detection, default is False
application_attack_rceboolnowhether to enable this type of detection, default is False
application_attack_phpboolnowhether to enable this type of detection, default is False
application_attack_nodejsboolnowhether to enable this type of detection, default is False
application_attack_xssboolnowhether to enable this type of detection, default is False
application_attack_sqliboolnowhether to enable this type of detection, default is False
application_attack_session_fixationboolnowhether to enable this type of detection, default is False
application_attack_javaboolnowhether to enable this type of detection, default is False
actionstringyesone of log, 403 Forbidden, edge-captcha, redirect
thresholdstringyesone of high, medium or low
clearancenumbernoclearance time of edge captcha challenge, default is 60 secs
redirect_urlstringnoredirect url when action is redirect

Example: of waf rule

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [['var' => 'uri', 'op' => 'prefix', 'val' => "/foo"]];

$waf = ['robots' => true, 'generic' => true, 'inject' => true,
        'action' => '403 Forbidden', 'threshold' => 'high'];

$rewrite_waf_rule_id = $client->newRewriteRule(['waf' => $waf, 'condition' => $condition]);
?>

proxy

Description of array proxy:

Key nameTypeRequiredDescription
upstreamslistyesupstreams
backup_upstreamslistyesbackup upstreams
timeoutnumbernotimeout of proxy, default is 3 seconds
connect_timeoutnumbernoconnect timeout of proxy, default is the same as timeout
read_timeoutnumbernoread timeout of proxy, default is the same as timeout
send_timeoutnumbernosend timeout of proxy, default is the same as timeout
retriesnumbernoretries time, default is 1
retry_conditionlistnoconditions of retry, default is [“error”, “timeout”, “invalid_header”, “http_500”, “http_502”, “http_504”]. And “http_503”, “http_403”, “http_404”, “http_429” and “non_valueempotent”(means even when method is POST, LOCK, PATCH) are also optional.
balancer_algorithmstringnoalgorithm of balancing policy, default is roundrobin, and you can set to hash and chash.
balancer_varslistnovariables of balancing policy. If you set to balancer_algorithm to hash or chash, then you must set balancer_vars too.

upstreams

Description of array upstreams and backup_upstreams:

Key nameTypeRequiredDescription
upstreamnumberyesid of upstream
weightnumbernoweight of upstream, default is 1

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$upstream_id = $client->newUpstream([
                        'name' => 'origin-upstream',
                        'servers' => [
                                ['ip' => '172.22.31.1', 'port' => 80],
                                ['ip' => '172.22.31.2', 'port' => 80, 'weight' => 2]
                            ]
                        ]);

$backup_upstream_id = $client->newUpstream([
                              'name' => 'backup-upstream',
                              'servers' => [
                                    ['ip' => '172.22.31.3', 'port' => 8000],
                                    ['ip' => '172.22.31.4', 'port' => 80, 'weight' => 3]
                                 ]
                            ]);

$ok = $client->updateUpstream([
                        'up_id' => $backup_upstream_id,
                        'name' => 'backup-upstream',
                        'servers' => [
                                ['ip' => '172.22.31.5', 'port' => 80, 'weight' => 3],
                                ['ip' => '172.22.31.6', 'port' => 80]
                            ]
                        ]);

$proxy = [
            'upstreams' => [['upstream' => $upstream_id, 'weight' => 2]],
            'backup_upstreams' => [['upstream' => $backup_upstream_id]]
        ];

$proxy_rule_id = $client->newRewriteRule(['proxy' => $proxy]);
?>

cache

Description of array cache:

Key nameTypeRequiredDescription
cache_keylistyescache keys

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [['var' => 'client-country', 'op' => 'eq', 'val' => 'CN']];
$cache_key = ['uri', 'query-string', 'client-city'];
$cache_rule = ['cache_key' => $cache_key, 'cluster_hash' => true ];

$cache_rule_id = $client->newRewriteRule(['cache' => $cache_rule, 'condition' => $condition]);
?>

content

Description of array content:

Key nameTypeRequiredDescription
faviconnumberyesfile id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [
            ['var' => 'uri', 'op' => 'prefix', 'val' => '/foo']
        ];
$file_id = $client->uploadFavicon($name = 'test', $faviconContent = content);

$rule_id = $client->newRewriteRule(['condition' => $condition, 'content' => ['favicon' => $file_id]]);

?>

updateRewriteRule

$ok = updateRewriteRule($opts)

Description of array $opts:

Key nameTypeRequiredDescription
ruleIDnumberyesconditions of rule
conditionarraynoconditions of rule
conseqarrayyesactions of rule

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [
    ['var' => 'host', 'op' => 'eq', 'val' => "con.foo.com"],
    ['var' => ['req-header', 'Referer'], 'vals' => [['foo\d+','rx'], 'foo.com']]
];

$conseq = [
    'print' => ['msg' => 'hello'],
    enable-'websocket' => [],
    'redirect' => ['url' => '/cn/2017/', 'code' => 302]
];

$rewriteRuleID = $client->newRewriteRule([
   'condition' => $condition,
   'conseq' => $conseq
]);

$conseq['redirect']['url'] = '/cn/2018/';

$ok = $client->updateRewriteRule([
   'rule_id' => $rewriteRuleID,
   'conseq' => $conseq
]);

?>

deleteRewriteRule

$ok = deleteRewriteRule($ruleID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$condition = [
    ['var' => 'host', 'op' => 'eq', 'val' => "con.foo.com"],
    ['var' => ['req-header', 'Referer'], 'vals' => [['foo\d+','rx'], 'foo.com']]
];

$conseq = [
    'print' => ['msg' => 'hello'],
    enable-'websocket' => [],
    'redirect' => ['url' => '/cn/2017/', 'code' => 302]
];

$rewriteRuleID = $client->newRewriteRule([
   'condition' => $condition,
   'conseq' => $conseq
]);

$ok = $client->deleteRewriteRule($rewriteRuleID);

?>

newAppDymetrics

$metric = newAppDymetrics($opts);

Description of array $opts:

Key nameTypeRequiredDescription
namestringyesdynamic metric name
intervalintyesdynamic metric aggregate interval
sqlstringyesdynamic metric SQL

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$dymetric = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newAppDymetrics($dymetric);

?>

deleteAppDymetrics

$ok = deleteAppDymetrics($metricID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newAppDymetrics($opts);

$ok = $client->deleteAppDymetrics($metric)
?>

getAppDymetrics

$metrics = getAppDymetrics();

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newAppDymetrics($opts);

$metrics = $client->getAppDymetrics();

?>

getAppDymetricsData

$data = getAppDymetricsData($opts);

Description of array $opts:

Key nameTypeRequiredDescription
idstringyesdynamic metric id
chart_typestringyeschart type: line, pie, bar
start_timeintyesquery start time
end_timeintyesquery end time
node_idstringnogateway node id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newAppDymetrics($opts);

$opts = [
   'id' => $metric['id'],
   'chart_type' => 'line',
   'start_time' => 1619014008,
   'end_time' => 1619015008
];
data = $client->getAppDymetricsData($opts);

?>

newAppIPList

$appIPListID = newAppIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
namestringyesthe name of the IP list
typestringnoipv4 or ipv6 here (ipv6 is not supported yet)
itemsarrayno$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringyesone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$appIPListID = $client->newAppIPList([
    'name' => 'app-iplist-1',
    'type' => 'ipv4',
    'items' => [
        [ 'ip' => '127.0.0.1' ],
        [ 'ip' => '192.168.1.0/24' ]
    ]
]);

?>

deleteAppIPList

$ok = deleteAppIPList($appIPListID)

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$appIPListID = $client->newGlobalIPList([
    'name' => 'iplist-1',
    'type' => 'ipv4',
    'items' => [
        [ 'ip' => '127.0.0.2' ],
        [ 'ip' => '192.168.1.0/24' ]
    ]
]);

$ok = $client->deleteAppIPList($appIPListID);

?>

updateAppIPList

Update the application-level IP list, which will overwrite the original data.

$ok = updateAppIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
appIPListIDnumberyesID of the IP list
namestringnothe name of the IP list
typestringnoipv4 or ipv6 here (ipv6 is not supported yet)
itemsarrayno$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ok = $client->updateAppIPList([
    'appIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.2' ],
        [ 'ip' => '192.168.1.0/24' ]
    ]
]);

?>

appendToAppIPList

Update the application-level IP list, which will not overwrite the original data.

$ok = appendToAppIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
appIPListIDnumberyesID of the IP list
itemsarrayyes$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ok = $client->appendToAppIPList([
    'appIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.3' ]
    ]
]);

?>

removeFromAppIPList

Remove IPs from application-level IP list, which will not overwrite the original data.

$ok = removeFromAppIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
appIPListIDnumberyesID of the IP list
itemsarrayyes$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ok = $client->removeFromAppIPList([
    'appIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.3' ]
    ]
]);

?>

getAppIPList

$data = getAppIPList($appIPListID)

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ipList = $client->getAppIPList($appIPListID);

?>

getAllAppIPList

$data = getAllAppIPList()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$ipList = $client->getAllAppIPList();

?>

setCertKey

$certID = setCertKey($opts)

Description of array $opts:

Key nameTypeRequiredDescription
keystringyescontent of private key
certstringyescontent of server cert
caChainstringnocontent of CA chain
global_cert_idintnoid of global cert

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setCertKey([
   'key' => $key,
   'cert' => $cert
]);

?>

updateCertKey

$certID = updateCertKey($opts)

Description of array $opts:

Key nameTypeRequiredDescription
cert_idintyesid of cert
keystringyescontent of private key
certstringyescontent of server cert
caChainstringnocontent of CA chain
global_cert_idintnoid of global cert

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setCertKey([
   'key' => $key,
   'cert' => $cert
]);

$ok = $client->updateCertKey(['cert_id' => $certID, 'key' => $key, 'cert' => $cert]);

?>

getCertKey

$data = getCertKey($certID)

Description of array $opts:

Key nameTypeRequiredDescription
cert_idintyesid of cert

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setCertKey([
   'key' => $key,
   'cert' => $cert
]);

$data = $client->getCertKey($certID);

?>

getAllCertKeys

$data = getAllCertKeys($appID)

Description of array $opts:

Key nameTypeRequiredDescription
AppIDintnoid of app, default is current app’s id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setCertKey([
   'key' => $key,
   'cert' => $cert
]);

$data = $client->getAllCertKeys();

?>

deleteCertKey

$ok = deleteCertKey($certID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');
$certID = $client->setCertKey([
   'key' => $key,
   'cert' => $cert
]);

$ok = $client->deleteCertKey($certID);

?>

setGlobalCertKey

$certID = setGlobalCertKey($opts)

Description of array $opts:

Key nameTypeRequiredDescription
keystringyescontent of private key
certstringyescontent of server cert
caChainstringnocontent of CA chain

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setGlobalCertKey([
   'key' => $key,
   'cert' => $cert
]);

?>

updateGlobalCertKey

$ok = updateGlobalCertKey($opts)

Description of array $opts:

Key nameTypeRequiredDescription
cert_idintyesid of cert
keystringyescontent of private key
certstringyescontent of server cert
caChainstringnocontent of CA chain

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setGlobalCertKey([
   'key' => $key,
   'cert' => $cert
]);

$ok = $client->updateGlobalCertKey(['cert_id' => $certID, 'key' => $key, 'cert' => $cert]);

?>

getGlobalCertKey

$data = getGlobalCertKey($certID)

Description of array $opts:

Key nameTypeRequiredDescription
certIDintyesid of cert

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setGlobalCertKey([
   'key' => $key,
   'cert' => $cert
]);

$data = $client->getGlobalCertKey($certID);

?>

getAllGlobalCertKeys

$data = getAllGlobalCertKeys()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setGlobalCertKey([
   'key' => $key,
   'cert' => $cert
]);

$data = $client->getAllGlobalCertKeys();

?>

deleteGlobalCertKey

$ok = deleteGlobalCertKey($certID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$key = file_get_contents('tests/key.pem');
$cert = file_get_contents('tests/cert.pem');

$certID = $client->setGlobalCertKey([
   'key' => $key,
   'cert' => $cert
]);

$ok = $client->deleteGlobalCertKey($certID);

?>

newCachePurgeTask

$taskID = newCachePurgeTask($opts)

Description of array $opts:

Key nameTypeRequiredDescription
typestringnoone of urls or conditional, default is conditional
notestringnonote of purge task
conditionlistnoconditions of task when type is conditional
urlsarraynourls needs to be refreshed when type is urls. url must belong to this application and starts with http or https.

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['test.com'],
   'label' => 'origin site for test.com',
]);

$condition = [
            ['var' => 'uri', 'op' => 'prefix', 'val' => '/foo']
        ];

$task_id = $client->newCachePurgeTask(['condition' => $condition]);

$task_id = $client->newCachePurgeTask(['type' => 'urls', 'urls' => array('http://test.com/foo', 'http://test.com/bar', 'http://test.com/abc/ddd')]);

?>

getCachePurgeTask

$data = getCachePurgeTask($taskID)

Description of array $opts:

Key nameTypeRequiredDescription
taskIDintyesid of cache purge task

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$condition = [
            ['var' => 'uri', 'op' => 'prefix', 'val' => '/foo']
        ];

$task_id = $client->newCachePurgeTask(['condition' => $condition]);

$data = $client->getCachePurgeTask($task_id);
?>

getAllCachePurgeTasks

$data = getAllCachePurgeTasks()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$condition = [
            ['var' => 'uri', 'op' => 'prefix', 'val' => '/foo']
        ];

$task_id = $client->newCachePurgeTask(['condition' => $condition]);
$data = $client->getAllCachePurgeTasks();
?>

deleteCachePurgeTask

$ok = deleteCachePurgeTask($taskID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$condition = [
            ['var' => 'uri', 'op' => 'prefix', 'val' => '/foo']
        ];

$task_id = $client->newCachePurgeTask(['condition' => $condition]);

$ok = $client->deleteCachePurgeTask($task_id);
?>

newEL

$certID = newEL($opts)

Description of array $opts:

Key nameTypeRequiredDescription
phasestringyesphase
codestringyesedgelang code
postboolyesput EL code to then end of phase if set to true, else put to the front of phase

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$code = "'true' => print('hello, foo.com');";
$ok = $client->newEL([
   'phase' => 'req-rewrite',
   'code' => $code,
   'post' => false
]);

?>

newRelease

$ok = newRelease()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$code = "'true' => print('hello, foo.com');";
$ok = $client->newEL([
   'phase' => 'req-rewrite',
   'code' => $code,
   'post' => false
]);

$ok = $client->newRelease();
?>

pendingChanges

$changes = pendingChanges()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$code = "'true' => print('hello, foo.com');";
$ok = $client->newEL([
   'phase' => 'req-rewrite',
   'code' => $code,
   'post' => false
]);

$beforeChanges = $client->pendingChanges();

$ok = $client->newRelease();

$afterChanges = $client->pendingChanges();

?>

setWorker

$ok = setWorker($opts)

Description of array $opts:

Key nameTypeRequiredDescription
connectionsnumbernoworker connections; default is 10240
processesstringnoworker processes; default is auto; should set to string "8" instead of 8
maxOpenFilesnumbernothe maximum number of open files (RLIMIT_NOFILE); default is 20480
backlognumbernolistening socket’s backlog queue size; default is 511
enable_http2boolnodefault is false

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setWorker([
   'connections' => 20480,
   'processes' => '8',
   'enable_http2' => true
]);

?>

setSSL

$ok = setSSL($opts)

Description of array $opts:

Key nameTypeRequiredDescription
session_ttlnumbernosession timeout; unit is minute; default is 1 day
session_cachenumbernothe size of share memory to cache the SSL session; unit is MB; default is 32 MB
protocolsarraynodefault is [“TLSv1”,“TLSv1.1”,“TLSv1.2”]
ciphersstringnoSSL ciphers
prefer_server_ciphersboolnoSpecifies that server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols; default is true

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setSSL([
   'session_ttl' => 60,
   'session_cache' => 100,
   'protocols' => ["TLSv1","TLSv1.1","TLSv1.2"],
   'prefer_server_ciphers' => false
]);

?>

setProxy

$ok = setProxy($opts)

Description of array $opts:

Key nameTypeRequiredDescription
intercept_errorsboolnointercept proxy error response; default is false
ignoreClientAbortboolnodetermines whether the connection with a proxied server should be closed when a client closes the connection without waiting for a response; default is false
buffer_sizenumbernoproxy buffer size; unit is KB; default is 8 KB
buffers_countnumbernothe number of the buffers; default is 8
buffers_sizenumbernothe size of the buffers; unit is KB; default is 16
busy_buffers_sizenumbernothe size of the busy buffers; unit is KB; default is 16
temp_file_write_sizenumbernoproxy temporary file write size; unit is KB; default is 16

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setProxy([
   'intercept_errors' => true,
   'buffer_size' => 100
]);

?>

setClientReq

$ok = setClientReq($opts)

Description of array $opts:

Key nameTypeRequiredDescription
body_timeoutnumbernoreading client request body timeout; unit is second; default is 60
header_timeoutnumbernoreading client request header timeout; unit is second; default is 60

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setClientReq([
   'body_timeout' => 30,
   'header_timeout' => 100
]);

?>

setFileBuffer

$ok = setFileBuffer($opts)

Description of array $opts:

Key nameTypeRequiredDescription
enable_cacheboolnoenable open file cache; default is true
max_cachenumbernomaximum cached number of elements; default is 1000
inactive_ttlnumbernoInactive TTL (second); default is 60

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setFileBuffer([
   'max_cache' => 2000,
   'inactive_ttl' => 30
]);

?>

setLog

$ok = setLog($opts)

Description of array $opts:

Key nameTypeRequiredDescription
no_errLogboolnoavoid generating error logs; default is false
log_levelstringnoerror log level; default is info
max_log_filesnumbernomaximum number of log files to keep; default is 168

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setLog([
   'no_errLog' => false,
   'log_level' => 'error',
   'max_log_files' => 100
]);

?>

setDNS

$ok = setDNS($opts)

global config of DNS.

Description of array $opts:

Key nameTypeRequiredDescription
enable_dnsboolnoenable DNS; default is true
resolversarraynoresolvers of DNS; default is ["114.114.114.114", "8.8.8.8"]
timeoutnumbernoDNS resolver timeout(second); default is 5 seconds

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setDNS([
   'timeout' => 10,
   'resolvers' => ['114.114.114.114']
]);

?>

setGzip

$ok = setGzip($opts)

global config of DNS.

Description of array $opts:

Key nameTypeRequiredDescription
enable_gzipboolnoenable Gzip; default is false
http_versionstringnoone of 1.0 and 1.1; default is 1.1
buffersnumbernothe number of buffers; default is 32
buffer_sizenumbernosize of each buffer; unit is KB; default is 4
compression_levelnumbernothe level of compression level; default is 1
min_lengthnumbernominimum response body size for Gzip compression; default is 20
disable_ie6boolnoDisable Gzip for IE6; default is true

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->setGzip([
   'enable_gzip' => true,
   'buffers' => 64,
   'compression_level' => 6
]);

?>

newDNS

$appID = newDNS($opts)

Description of array $opts:

Key nameTypeRequiredDescription
zonestringyesdomain of DNS
authorityarrayyesserver names of DNS
soa_emailstringnosoa email of DNS

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com",'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com",'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

?>

updateDNS

$ok = updateDNS($opts);

Description of array $opts:

Key nameTypeRequiredDescription
dnsIDnumberyesid of DNS
zonestringyesdomain of DNS
authorityarrayyesserver names of DNS
soa_emailstringnosoa email of DNS

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com", 'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com", 'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$data = self::$client->getDNS(self::$dns_id);

$authority = [
    ['domain' => "ns1.foo.com", 'ttl' => '1 hour', 'id' => $data['nameserver'][0]'id'],
    ['domain' => "ns2.foo.com", 'ttl' => '1 hour', 'id' =>  $data['nameserver'][1]['id']],
    ['domain' => "ns3.foo.com", 'ttl' => '1 hour']
];

$ok = $client->updateDNS(['dns_id' => $dnsID,
                       'authority' => $authority,'zone' => 'foo.com']);
?>

deleteDNS

$ok = deleteDNS($dnsID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com", 'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com", 'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$ok = $client->deleteDNS($dnsID);

?>

newDnsRecord

$appID = newDnsRecord($opts)

Description of array $opts:

Key nameTypeRequiredDescription
dnsIDnumberyesid of DNS
sub_domainstringyessub domain
linenumberfalseline, default 0
cidrstringfalsecidr
typestringyestype of record, one of [A, TXT, MX, CNAME]
textstringnorequired if type is TXT
ipstringnorequired if type is A
domainstringnorequired if type is CNAME
prioritynumbernorequired if type is MX

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com",'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com",'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$record_id = $client->newDnsRecord([
   'dns_id' => $dnsID,
   'sub_domain' => 'bar',
   'line' => 0,
   'type' => 'TXT',
   'text' => 'text string'
]);

?>

updateDnsRecord

$appID = updateDnsRecord($opts)

Description of array $opts:

Key nameTypeRequiredDescription
dnsIDnumberyesid of DNS
record_idnumberyesrecord id of DNS
sub_domainstringyessub domain
linenumberfalseline, default 0
cidrstringfalsecidr
typestringyestype of record, one of [A, TXT, MX, CNAME]
textstringnorequired if type is TXT
ipstringnorequired if type is A
domainstringnorequired if type is CNAME
prioritynumbernorequired if type is MX

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com",'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com",'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$record_id = $client->newDnsRecord([
   'dns_id' => $dnsID,
   'sub_domain' => 'bar',
   'line' => 0,
   'type' => 'TXT',
   'text' => 'text string'
]);

$ok = $client->updateDnsRecord([
   'dns_id' => $dnsID,
   'record_id' => $record_id,
   'sub_domain' => 'a.bar',
   'line' => 0,
   'type' => 'TXT',
   'text' => 'text string'
]);

?>

deleteDnsRecord

$appID = deleteDnsRecord($opts)

Description of array $opts:

Key nameTypeRequiredDescription
dnsIDnumberyesid of DNS
record_idnumberyesrecord id of DNS

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com",'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com",'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$record_id = $client->newDnsRecord([
   'dns_id' => $dnsID,
   'sub_domain' => 'bar',
   'line' => 0,
   'type' => 'TXT',
   'text' => 'text string'
]);

$ok = $client->deleteDnsRecord([
   'dns_id' => $dnsID,
   'record_id' => $record_id
]);

?>

disabledDnsRecord

$appID = disabledDnsRecord($opts)

Description of array $opts:

Key nameTypeRequiredDescription
dnsIDnumberyesid of DNS
record_idnumberyesrecord id of DNS

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$authority = [
    ['domain' => "ns1.foo.com",'ttl' => '2 hour'],
    ['domain' => "ns2.foo.com",'ttl' => '1 day'],
];

$dnsID = $client->newDNS([
   'authority' => $authority,
   'soa_email' => 'admin.foo.com',
   'zone' => 'foo.com'
]);

$record_id = $client->newDnsRecord([
   'dns_id' => $dnsID,
   'sub_domain' => 'bar',
   'line' => 0,
   'type' => 'TXT',
   'text' => 'text string'
]);

$ok = $client->disabledDnsRecord([
   'dns_id' => $dnsID,
   'record_id' => $record_id
]);

?>

newGlobalDymetrics

$metric = newGlobalDymetrics($opts);

Description of array $opts:

Key nameTypeRequiredDescription
namestringyesdynamic metric name
intervalintyesdynamic metric aggregate interval
sqlstringyesdynamic metric SQL

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newGlobalDymetrics($opts);

?>

deleteGlobalDymetrics

$ok = deleteGlobalDymetrics($metricID);

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newGlobalDymetrics($opts);

$ok = $client->deleteGlobalDymetrics($metric)
?>

getGlobalDymetrics

$metrics = getGlobalDymetrics();

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newGlobalDymetrics($opts);

$metrics = $client->getGlobalDymetrics();

?>

getGlobalDymetricsData

$data = getGlobalDymetricsData($opts);

Description of array $opts:

Key nameTypeRequiredDescription
idstringyesdynamic metric id
chart_typestringyeschart type: line, pie, bar
start_timeintyesquery start time
end_timeintyesquery end time
node_idstringnogateway node id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$opts = [
   'name' => 'test',
   'interval' => 60,
   'sql' => 'select status, count(*) from reqs group by status'
];

$metric = $client->newGlobalDymetrics($opts);

$opts = [
   'id' => $metric['id'],
   'chart_type' => 'line',
   'start_time' => 1619014008,
   'end_time' => 1619015008
];
data = $client->getGlobalDymetricsData($opts);

?>

getMetricData

$data = getMetricData($appID)

Key nameTypeRequiredDescription
appIDnumbernodefault is id of current app

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$appID = $client->newApp([
   'domains' => ['orig.foo.com'],
   'label' => 'origin site for foo.com',
]);

$data = $client->getMetricData();
?>

newLayerPolicy

$policyID = newLayerPolicy($opts)

Description of array $opts:

Key nameTypeRequiredDescription
namestringyesthe policy name
rulesarrayyesthe policy rules

Description of array $rule:

Key nameTypeRequiredDescription
gatewaynumberyescurrent gateway id
upstreamnumberyesupstream gateway id
backupnumbernobackup upstream gateway id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$policyID = $client->newLayerPolicy([
   'name' => 'policy_1',
   'rules' => [
      [
         "gateway" => 3,
         "upstream" => 2,
         "backup" => 1
      ]
   ]
]);
?>

deleteLayerPolicy

$ok = deleteLayerPolicy($policyID)

Description of $policyID:

Key nameTypeRequiredDescription
policyIDnumberyesthe policy id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->deleteLayerPolicy(1);
?>

updateLayerPolicy

$ok = updateLayerPolicy($opts)

Description of array $opts:

Key nameTypeRequiredDescription
policy_idnumberyesthe policy id
namestringyesthe policy name
rulesarrayyesthe policy rules

Description of array $rule:

Key nameTypeRequiredDescription
gatewaynumberyescurrent gateway id
upstreamnumberyesupstream gateway id
backupnumbernobackup upstream gateway id

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->updateLayerPolicy([
   'policy_id' => 1,
   'name' => 'policy_2',
   'rules' => [
      [
         "gateway" => 3,
         "upstream" => 2,
         "backup" => 1
      ]
   ]
]);
?>

getLayerPolicies

$data = getLayerPolicies()

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$policies = $client->getLayerPolicies();
?>

newGlobalIPList

$GlobalIPListID = newGlobalIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
namestringyesthe name of the IP list
typestringnoipv4 or ipv6 here (ipv6 is not supported yet)
itemsarrayno$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringyesone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$globalIPListID = $client->newGlobalIPList([
    'name' => 'iplist-1',
    'type' => 'ipv4',
    'items' => [
        [ 'ip' => '127.0.0.1' ],
        [ 'ip' => '192.168.0.0/16' ]
    ]
]);

?>

deleteGlobalIPList

$ok = deleteGlobalIPList($globalIPListID)

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$globalIPListID = $client->newGlobalIPList([
    'name' => 'iplist-1',
    'type' => 'ipv4',
    'items' => [
        [ 'ip' => '127.0.0.1' ],
        [ 'ip' => '192.168.0.0/16' ]
    ]
]);

$ok = $client->deleteGlobalIPList($globalIPListID);

?>

updateGlobalIPList

Update the global IP list, which will overwrite the original data.

$ok = updateGlobalIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
globalIPListIDnumberyesID of the IP list
namestringnothe name of the IP list
typestringnoipv4 or ipv6 here (ipv6 is not supported yet)
itemsarrayno$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->updateGlobalIPList([
    'globalIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.1' ],
        [ 'ip' => '192.168.0.0/16' ]
    ]
]);

?>

appendToGlobalIPList

Update the global IP list, which will not overwrite the original data.

$ok = appendToGlobalIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
globalIPListIDnumberyesID of the IP list
itemsarrayyes$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->appendToGlobalIPList([
    'globalIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.3' ],
    ]
]);

?>

removeFromGlobalIPList

Remove IPs from global IP list, which will not overwrite the original data.

$ok = removeFromGlobalIPList($opts)

Description of object $opts:

Key nameTypeRequiredDescription
globalIPListIDnumberyesID of the IP list
itemsarrayyes$item array list

Description of object $item:

Key nameTypeRequiredDescription
ipstringnoone IP Address or one CIDR IP

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

// use username and password
$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ok = $client->removeFromGlobalIPList([
    'globalIPListID' => 1,
    'items' => [
        [ 'ip' => '127.0.0.3' ],
    ]
]);

?>

getGlobalIPList

$data = getGlobalIPList($globalIPListID)

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ipList = $client->getGlobalIPList($globalIPListID);

?>

getAllGlobalIPList

$data = getAllGlobalIPList()

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$ok = $client->login();

$ipList = $client->getAllGlobalIPList();

?>

convCrlToLuaModule

$data = convCrlToLuaModule($crlFiles)

Example:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
use OpenResty\Edge2Client;

$client = new Edge2Client([
   'edge_admin_addr' => 'https://admin.openresty.com',
   'username' => 'admin',
   'password' => '123456'
]);

$crlFiles = array('test.crl');

$ok = $client->login();
$code = $client->convCrlToLuaModule($crlFiles)

?>