# OpenResty Edge SDK

Method Parameters Parameters type Description Return type
Edge2Client host, username, password, api_token string init SDK client object
login login to edge system bool
use_app app_id number set the application you want to operate bool
new_app domains, label string add a new application number
put_app domains, label string update application bool
get_app app_id number get application info array
put_app_config limiter dict update application config bool
get_app_config app_id number get application config dict
del_app app_id number delete application bool
search_app **kwargs dict search application array
search_http_app_by_keyword **kwargs dict search application by domain or name array
search_upstream_by_ip **kwargs dict search upstream by ip array
search_upstream_by_name **kwargs dict search upstream by name array
search_k8s_upstream_by_name **kwargs dict search upstream by name array
get_all_apps get all applications array
new_upstream **kwargs dict add a new upstream number
put_upstream **kwargs dict update upstream bool
get_upstream up_id number get upstream by up_id array
del_upstream up_id number delete upstream bool
get_all_upstreams detail bool get all upstreams array
new_k8s_upstream **kwargs dict add a new k8s upstream number
copy_upstream_to_k8s_upstream up_id, k8s_services number copy an upstream to an k8s_upstream number
put_k8s_upstream **kwargs dict update k8s upstream bool
get_k8s_upstream up_id number get k8s upstream by up_id array
del_k8s_upstream up_id number delete k8s upstream bool
get_all_k8s_upstreams detail bool get all k8s upstreams array
new_rule **kwargs dict add a new request rewrite rule number
put_rule **kwargs dict update request rewrite rule bool
get_rule rule_id number get request rewrite rule array
del_rule rule_id number delete request rewrite rule bool
get_all_rules app_id number get all request rewrite rules array
get_global_actions_used_in_app app_id number get all request rewrite global action rules array
get_all_rules_by_app_domain domain string get request rewrite rules of all matched apps by domain array
get_all_rules_by_upstream_ip ip string get request rewrite rules of all matched apps by upstream ip array
get_all_waf_rules app_id number get all waf rules array
set_le_cert **kwargs dict set LE SSL number
put_le_cert **kwargs dict put LE SSL number
set_cert_key **kwargs dict set SSL key and cert number
put_cert_key **kwargs dict update SSL key and cert bool
get_cert_key cert_id number get SSL key and cert array
get_all_cert_keys get all SSL key and certs array
del_cert_key cert_id list delete SSL key and cert bool
new_el phase, code, **kwargs string, string, array add EL code number
new_release new release bool
pending_changes pending changes number
sync_status the sync status of release number, number
use_dns_app app_id number set the DNS application you want to operate bool
new_dns_app **kwargs dict add a new dns number
put_dns_app **kwargs dict update dns bool
get_dns_app dns_id number get dns array
del_dns_app dns_id number delete dns bool
new_dns_record **kwargs dict add record of dns number
put_dns_record **kwargs dict update record of dns bool
get_dns_record record_id number get record of dns array
del_dns_record record_id number delete record of dns bool
set_global_cert_key **kwargs dict set global cert and key number
put_global_cert_key **kwargs dict update global cert and key bool
get_global_cert_key cert_id number get global cert and key array
del_global_cert_key cert_id number delete global cert and key bool
add_global_user **kwargs dict add global user bool
search_global_user name string search global user array
get_all_global_users detail boolean get all global user array
add_app_user **kwargs dict add user of application number
put_app_user **kwargs dict update user of application bool
get_app_user **kwargs dict get user of application array
del_app_user **kwargs dict delete user of application array
get_all_app_users get all users of application array
add_user_for_all_apps **kwargs dict add user for all applications bool
add_all_users_for_app **kwargs dict add all users for application bool
new_global_rule **kwargs dict add a new global rewrite rule number
put_global_rule **kwargs dict update global rewrite rule bool
get_global_rule rule_id number get global rewrite rule array
get_global_action_by_name name string get global action id by name number
get_all_global_rules get all global rewrite rules array
del_global_rule rule_id number delete global rewrite rule bool
new_global_var **kwargs dict add a new global var number
put_global_var **kwargs dict update global var bool
get_global_var var_id number get global var array
get_all_global_vars get all global vars array
del_global_var var_id number delete global var bool
get_global_ngx_config get global nginx configures array
set_global_ngx_config opts dict set global nginx configures bool
get_global_misc_config get global misc configures array
set_global_misc_config opts dict set global misc configures bool
get_request_id_status get status of global request id bool
enable_request_id enable global request id bool
disable_request_id disable global request id bool
new_global_waf_rule **kwargs dict add a new global waf rule number
put_global_waf_rule **kwargs dict update global waf rule bool
get_global_waf_rule rule_id number get global waf rule by id array
del_global_waf_rule rule_id number delete global waf rule by id bool
get_all_global_waf_rules detail bool return all global waf rule sets with name and id, and including built-in rule sets array
new_global_action **kwargs dict add a new global custom action number
put_global_action **kwargs dict update global custom action bool
get_global_action action_id number get global custom action array
del_global_action action_id number delete global custom action bool
count_global_actions Get the number of Global Actions bool
get_all_global_actions get all global actions bool
new_user_var **kwargs dict add a new user var number
put_user_var **kwargs dict update user var bool
get_user_var var_id number get user var array
del_user_var var_id number delete user var bool
node_sync_status sync status of all nodes dict
upload_static_file **kwargs dict upload global static file number
get_static_file file_id number get global static file array
del_static_file file_id number delete global static file bool
new_waf_whitelist **kwargs dict add a new whitelist rule number
put_waf_whitelist **kwargs dict update waf whitelist rule bool
get_waf_whitelist whitelist_id number get waf whitelist by id array
del_waf_whitelist whitelist_id number delete waf whitelist rule by id bool
get_all_waf_whitelists detail bool return all whitelist rules array
get_healthcheck_status node_id number return health check status array
new_cluster_group name dict add a new cluster group number
put_cluster_group **kwargs dict update cluster group bool
get_cluster_group group_id number get cluster group dict
get_all_cluster_groups get all cluster groups array
del_cluster_group group_id number delete cluster group bool
put_proxy_rule **kwargs dict update proxy rule bool
decode_request_id request_id string get info from request_id dict
search_waf_log request_id string search waf log by request id dict or None
add_api_token name, expire string, number add api token dict
get_api_token id, limit number, number get api token dict
del_api_token id number delete api token bool
get_all_gateway_tag get all gateway tag array
get_all_gateway get all gateway array
get_app_metrics id number get HTTP request status metrics and network metrics array
new_global_dymetrics add global dynamic metrics bool
put_global_dymetrics id number change the specified global dynamic metrics bool or number
del_global_dymetrics id number get the specified global dynamic metrics bool
get_global_dymetrics id number get the specified global dynamic metrics dict
get_all_global_dymetrics get all global dynamic metrics array
get_global_dymetrics_data get all global dynamic metrics data array
node_monitor get CPU and memory load metrics for gateway nodes array
get_version Obtain the versions of Admin, Admin DB, Log Server, Log Server DB, and WAF. dict
new_global_k8s add a new global k8s cluster configuration number
put_global_k8s update global k8s cluster configuration bool
get_global_k8s get global k8s cluster configuration dict
get_k8s_services_detail get k8s service detail info dict
get_all_global_k8s get all global k8s array
del_global_k8s del global k8s bool
new_global_upstream **kwargs dict add a new global upstream number
put_global_upstream **kwargs dict update global upstream bool
get_global_upstream up_id number get global upstream by up_id array
del_global_upstream up_id number delete global upstream bool
get_all_global_upstreams detail bool get all global upstreams array
new_global_k8s_upstream **kwargs dict add a new global k8s upstream number
put_global_k8s_upstream **kwargs dict update global k8s upstream bool
get_global_k8s_upstream up_id number get global k8s upstream by up_id array
del_global_k8s_upstream up_id number delete global k8s upstream bool
get_all_global_k8s_upstreams detail bool get all global k8s upstreams array

# Edge2Client

client = Edge2Client(host, username, password, api_token=None)

Description of parameters:

Key name Type Required Description
host string yes address of edge admin, including host and port
username string yes username of edge-admin
password string yes password of edge-admin
api_token string no api access token of edge-admin

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

# or

client = Edge2Client('http://127.0.0.1:8080', None, None, 'api_token')

# login

ok = login()

Returns True if login success else False.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
ok = client.login()

# use_app

ok = use_app(app_id)

Returns True if success else False.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

client.use_app(10)

# new_app

app_id = new_app(domains, label)

Description of parameters:

Key name Type Required Description
domains list yes domains of application
label string yes name of application
cluster_groups list no cluster group ids of application

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com', cluster_groups = [1])

# put_app

ok = put_app(domains, label)

Description of parameters:

Key name Type Required Description
app_id number yes id of application
domains list yes domains of application
label string yes name of application
cluster_groups list no cluster group ids of application

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

ok = client.put_app(app_id, domains = ['*.foo.com'], label = 'foo.com')

# get_app

data = get_app()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

data = client.get_app()

# put_app_config

ok = put_app_config(limiter)

Description of parameters:

Key name Type Required Description
app_id number yes id of application
limiter dict yes config of application

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

ok = client.put_app_config(app_id, {'max_uri_args': 120, 'check_post_args_type': False})

# get_app_config

data = get_app_config(app_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

data = client.get_app_config(app_id)

# del_app

ok = del_app(app_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

ok = client.del_app(app_id)

# search_app

data = search_app(app_domain)

Key name Type Required Description
app_domain string yes search app by the domain
page number no page number of results, default value is '1'
pagesize number no page size of results, default value is '20'

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

data = client.search_app(app_domain = 'orig.foo.com')

# search_http_app_by_keyword

data = search_http_app_by_keyword(keyword, page, pagesize)

Key name Type Required Description
keyword string yes search app by the domain or name
page number no page number of results, default value is '1'
pagesize number no page size of results, default value is '20'

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

data = client.search_http_app_by_keyword('orig.foo.com')
data = client.search_http_app_by_keyword('orig.foo.com', 1, 50)
data = client.search_http_app_by_keyword('origin')

# search_upstream_by_ip

data = search_upstream_by_ip(ip, page, pagesize)

Key name Type Required Description
ip string yes search upstream by ip
page number no page number of results, default value is '1'
pagesize number no page size of results, default value is '20'

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

data = client.search_upstream_by_ip('1.1.1.1')

# search_upstream_by_name

data = search_upstream_by_name(name, page, pagesize)

Key name Type Required Description
name string yes search upstream by name
page number no page number of results, default value is '1'
pagesize number no page size of results, default value is '20'

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

data = client.search_upstream_by_name('test')

# search_k8s_upstream_by_name

data = search_k8s_upstream_by_name(name, page, pagesize)

Key name Type Required Description
name string yes search upstream by name
page number no page number of results, default value is '1'
pagesize number no page size of results, default value is '20'

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

data = client.search_k8s_upstream_by_name('test')

# get_all_apps

data = get_all_apps(detail)

Key name Type Required Description
detail bool no default is False, only return app ids; returns app's detail if True

the return data will be list if detail is False, and will be dict if detail is True.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

apps = client.get_all_apps()

apps = client.get_all_apps(detail = True)

# new_upstream

app_id = new_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
servers list yes upstreams
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

# put_upstream

ok = put_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
servers list yes upstreams
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'domain': 'a.com', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

ok = client.put_upstream(up_id, name = 'origin-upstream',
                    servers = [
                        {'domain': 'test.com', 'port': 8080},
                        {'ip': '172.22.31.2', 'port': 8080, 'weight': 1}
                    ],
                    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'
                    })

# get_upstream

data = get_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

data = client.get_upstream(up_id)

# del-upstream

ok = del_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

ok = client.del_upstream(up_id)

# get_all_upstreams

upstreams = client.get_all_upstreams()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

upstreams = client.get_all_upstreams(up_id)

# new_k8s_upstream

k8s_up_id = new_k8s_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
k8s_services list yes upstreams is k8s services
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# k8s_services

Description of array k8s_services in **kwargs:

Key name Type Required Description
k8s number yes k8s cluster id
k8s_namespace string yes k8s namespace
k8s_service string yes k8s service
k8s_service_port number yes k8s service port

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

k8s_up_id = client.new_k8s_upstream(name = 'k8s-upstream',
                            k8s_services = [
                                {   
                                    'k8s' : 1,
                                    'k8s_namespace' : 'default',
                                    'k8s_service' : 'foo',
                                    'k8s_service_port' : 80, 
                                }   
                            ])

# copy_upstream_to_k8s_upstream

k8s_up_id = copy_upstream_to_k8s_upstream(up_id, k8s_services, delete_origin, transfer_rule, rules)

Key name Type Required Description
up_id number yes origin upstream id
k8s_services list yes k8s services
delete_origin bool no whether delete origin upstream, default is false
transfer_rule bool no whether change the origin upstream used in rule transfer to new k8s upstream, default is false
rules array no If transfer_rule is set to true, the rules will be traversed and the original upstream is used in rules will be migrated to k8s upstream.

# k8s_services

Description of array k8s_services in **kwargs:

Key name Type Required Description
k8s number yes k8s cluster id
k8s_namespace string yes k8s namespace
k8s_service string yes k8s service
k8s_service_port number yes k8s service port

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

up_id = client.new_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])


k8s_up_id = client.copy_upstream_to_k8s_upstream(up_id,
                            k8s_services = [
                                {   
                                    'k8s' : 1,
                                    'k8s_namespace' : 'default',
                                    'k8s_service' : 'foo',
                                    'k8s_service_port' : 80, 
                                }   
                            ])

# Example2


client.use_app(app_id)

rules = client.get_all_rules()

k8s_up_id = client.copy_upstream_to_k8s_upstream(up_id = up_id,
                            k8s_services = [
                                {   
                                    'k8s' : 1,
                                    'k8s_namespace' : 'default',
                                    'k8s_service' : 'foo',
                                    'k8s_service_port' : 80, 
                                }
                            ],
                            delete_origin = true,
                            transfer_rule = true,
                            rules = rules)

# put_k8s_upstream

ok = put_k8s_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
k8s_services list yes upstreams is k8s services
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

ok = client.put_k8s_upstream(up_id, name = 'origin-upstream',
                    k8s_services = [
                        {   
                            'k8s' : 1,
                            'k8s_namespace' : 'default',
                            'k8s_service' : 'foo',
                            'k8s_service_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'
                    })

# get_k8s_upstream

data = get_k8s_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

data = client.get_k8s_upstream(up_id)

# del-k8s-upstream

ok = del_k8s_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')


ok = client.del_k8s_upstream(up_id)

# get_all_k8s_upstreams

upstreams = client.get_all_k8s_upstreams()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

upstreams = client.get_all_k8s_upstreams(app_id)

# new_rule

rule_id = new_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
condition list no conditions of rule
conseq dict or list no actions of rule
waf list no rules of waf
proxy list no rules of proxy
cache list no rules of cache
content list no rules of content

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals string or array
vals list either val or vals array of val

# conseq

Description of conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

conseq can be a dict or a list, below is an example of dict.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
    {
        'var': 'host',
        'val': 'con.' + APEX
    },
    {
        'var': ['req-header', 'Referer'],
        'vals': [
            'foo.com',
            ['foo\d+', 'rx'],
            ['foo*', 'wc']
        ]
    }
]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302},
    'user-code': {'el': 'true => say(\"hello\");'}
}

rule_id = client.new_rule(condition = condition, conseq = conseq)


The dict is not guaranteed to be in order, and cannot set the same action repeatedly. So it is recommended to use the usage of the following list instead of dict:

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = [
            {'set-proxy-header': {
                'header': 'Foo',
                'value': 'default',
            }},
            {'set-proxy-header': {
                'header': 'Host',
                'value': "orig",
            }},
            {'print': {
                'msg': 'hello'
            }}
        ]

rule_id = client.new_rule(condition = condition, conseq = conseq)


# waf

Description of array waf in **kwargs:

Key name Type Required Description
rule_sets list no the set of user defined rules in global waf, default is empty array
robots bool no whether to enable this type of detection, default is False
generic bool no whether to enable this type of detection, default is False
inject bool no whether to enable this type of detection, default is False
trojans bool no whether to enable this type of detection, default is False
xss bool no whether to enable this type of detection, default is False
action string yes one of log, 403 Forbidden, edge-captcha, redirect
threshold string yes one of high, medium or low
clearance number no clearance time of edge captcha challenge, default is 60 secs
redirect_url string no redirect url when action is redirect

# Example of waf rule


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

user_defined_waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [{'var': 'uri', 'op': 'prefix', 'val': '/foo'}]

waf_rule = {'rule_sets': [user_defined_waf_rule_id], 'robots': True, 'generic': True, 'inject': True, 'action': '403 Forbidden', 'threshold': 'low'}

rule_id = client.new_rule(condition = condition, waf = waf_rule)

# proxy

Description of array proxy in **kwargs:

Key name Type Required Description
upstreams list yes upstreams
backup_upstreams list yes backup upstreams
upstream_el_code str yes using EdgeLang to set upstream
timeout number no timeout of proxy, default is 3 seconds
connect_timeout number no connect timeout of proxy, default is the same as timeout
read_timeout number no read timeout of proxy, default is the same as timeout
send_timeout number no send timeout of proxy, default is the same as timeout
retries number no retries time, default is 1
retry_condition list no conditions 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_algorithm string no algorithm of balancing policy, default is roundrobin, and you can set to hash and chash.
balancer_vars list no variables of balancing policy. If you set to balancer_algorithm to hash or chash, then you must set balancer_vars too.
multi_tier number no multi-tier policy ID.

# upstreams

Description of array upstreams and backup_upstreams in **kwargs:

Key name Type Required Description
upstream number yes id of upstream
global_upstream number yes id of global upstream
k8s_upstream number yes id of k8s upstream
global_k8s_upstream number yes id of global k8s upstream
weight number no weight of upstream, default is 1

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

up_id = client.new_upstream(name = 'origin-upstream',
                    servers = [
                        {'ip': '172.22.31.1', 'port': 80},
                        {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                    ])

k8s_up_id = client.new_k8s_upstream(
    name='k8s-upstream',
    k8s_services = [
        {
            'k8s' : k8s_id,
            'k8s_namespace' : 'default',
            'k8s_service' : 'test-hello',
            'k8s_service_port' : 80,
        }       
    ])

ok = client.put_upstream(up_id, name = 'origin-upstream',
                              servers = [
                                {'ip': '172.22.31.1', 'port': 8080},
                                {'ip': '172.22.31.2', 'port': 8080, 'weight': 1}
                              ])

backup_up_id = client.new_upstream(name = 'backup-upstream',
                                        servers = [
                                            {'ip': '172.22.31.3', 'port': 80},
                                            {'ip': '172.22.31.4', 'port': 80, 'weight': 3}
                                        ])

proxy_rule = {
            'upstreams': [{'upstream': up_id, 'weight': 2}],
            'backup_upstreams': [{'upstream': backup_up_id}],
            'upstream_el_code': '',
            'retries': 2,
            "retry_condition": ["invalid_header", "http_500"],
            "balancer_algorithm": "hash",
            "balancer_vars": [
                {"name":"uri"},
                {
                    "name":"uri-arg",
                    "args":"foo"
                }
            ]
        }

rule_id = client.new_rule(proxy = proxy_rule)

k8s_proxy_rule = {
            'upstreams': [{'k8s_upstream': up_id, 'weight': 2}],
            'upstream_el_code': '',
            'retries': 2,
            "retry_condition": ["invalid_header", "http_500"],
            "balancer_algorithm": "hash",
            "balancer_vars": [
                {"name":"uri"},
                {
                    "name":"uri-arg",
                    "args":"foo"
                }
            ]
        }

k8s_rule_id = client.new_rule(proxy = k8s_proxy_rule)

# cache

Description of array cache in **kwargs:

Key name Type Required Description
cache_key list yes cache keys

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(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}

rule_id = client.new_rule(condition = condition, cache = cache_rule)

# content

Description of array content in **kwargs:

Key name Type Required Description
favicon number yes file id
gid number no array of user group id

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [{'var': 'uri', 'op': 'eq', 'val': '/favicon.ico'}]
file_id = client.upload_favicon(name = 'test', favicon_content = 'content', gid=[1])

rule_id = client.new_rule(condition = condition, content = {'favicon': file_id})


# put_rule

ok = put_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
condition list no conditions of rule
conseq dict or list no actions of rule
waf list no rules of waf
proxy list no rules of proxy
cache list no rules of cache
content list no rules of content

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# conseq

Description of array conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_rule(condition = condition, conseq = conseq)

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

ok = client.put_rule(rule_id = rule_id, condition = condition, conseq = conseq)

# get_rule

ok = get_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_rule(condition = condition, conseq = conseq)

data = client.get_rule(rule_id)

# del_rule

ok = del_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_rule(condition = condition, conseq = conseq)

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

ok = client.del_rule(rule_id)

# get_all_rules

rules = get_all_rules(app_id)

Key name Type Required Description
app_id number no id of app, default is the current id of app

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(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}
rule_id = client.new_rule(condition = condition, cache = cache_rule, top = 1)

condition = [
    {'var': 'host', 'val': 'con.foo.com'},
    {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
]
conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}
rule_id = client.new_rule(condition = condition, conseq = conseq, last = True)

data = client.get_all_rules()

# get_global_actions_used_in_app

rules = get_global_actions_used_in_app(app_id)

Key name Type Required Description
app_id number no id of app, default is the current id of app

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

name = "test-actions"

client.new_global_rule(condition=condition, conseq=conseq, name=name)

rule_ids = client.get_global_actions_used_in_app(app_id)

# get_all_rules_by_app_domain

rules = get_all_rules_by_app_domain(domain)

Key name Type Required Description
domain string yes domain name of app

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(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}
rule_id = client.new_rule(condition = condition, cache = cache_rule, top = 1)

condition = [
    {'var': 'host', 'val': 'foo.com'},
    {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
]
conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}
rule_id = client.new_rule(condition = condition, conseq = conseq, last = True)

data = client.get_all_rules_by_app_domain('orig.foo.com')

# get_all_rules_by_upstream_ip

rules = get_all_rules_by_upstream_ip(domain)

Key name Type Required Description
ip string yes ip of upstream

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

upstream_ip = '172.22.31.2'
up_id = client.new_upstream(name = 'origin-upstream',
                                         servers = [
                                             {'domain': 'test.com', 'port': 80},
                                             {'ip': upstream_ip, 'port': 80, 'weight': 2}
                                         ])

proxy_rule = {
            'upstreams': [{'upstream': up_id, 'weight': 2}],
            'retries': 2,
            "retry_condition": ["invalid_header", "http_500"],
            "balancer_algorithm": "hash",
            "balancer_vars": [
                {"name": "uri"},
                {
                    "name": "uri-arg",
                    "args": "foo"
                }
            ]
        }

rule_id = client.new_rule(proxy = proxy_rule, top = 1)

data = client.get_all_rules_by_upstream_ip(upstream_ip)

for app_id, rules in data.items():
    print(app_id)

# get_all_waf_rules

rules = get_all_waf_rules(app_id)

Key name Type Required Description
app_id number no id of app, default is the current id of app

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [{'var': 'client-country', 'op': 'eq', 'val': 'JP'}]
waf_rule = {'robots': False, 'generic': True, 'inject': True, 'action': '403 Forbidden', 'threshold': 'high'}
rule_id = client.new_rule(condition = condition, waf = waf_rule, last = True)

data = client.get_all_waf_rules()

# set_le_cert

cert_id = set_le_cert(**kwargs)

Description of array **kwargs:

Key name Type Required Description
domains string array yes domains
gid list no array of user group id

# put_le_cert

cert_id = put_le_cert(**kwargs)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert
domains string array yes domains
gid list no array of user group id

# set_cert_key

cert_id = set_cert_key(**kwargs)

Description of array **kwargs:

Key name Type Required Description
key string yes content of private key
cert string no content of server cert
ca_chain string no content of CA chain
global_cert_id int no id of global cert
gid list no array of user group id

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_cert_key(key = key, cert = cert)

# put_cert_key

cert_id = put_cert_key(**kwargs)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert
key string yes content of private key
cert string no content of server cert
ca_chain string no content of CA chain
global_cert_id int no id of global cert
gid list no array of user group id

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_cert_key(key = key, cert = cert)

new_key_file = os.path.join('tests', 'new_key.pem')
new_cert_file = os.path.join('tests', 'new_cert.pem')
with open(new_key_file) as f:
    new_key = f.read()
with open(new_cert_file) as f:
    new_cert = f.read()

ok = client.put_cert_key(cert_id = cert_id, key = new_key, cert = new_cert)

# get_cert_key

cert_id = get_cert_key(cert_id)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_cert_key(key = key, cert = cert)

data = client.get_cert_key(cert_id)

# get_all_cert_keys

cert_id = get_all_cert_keys()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_cert_key(key = key, cert = cert)

data = client.get_all_cert_keys()

# del_cert_key

ok = del_cert_key(cert_id)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_cert_key(key = key, cert = cert)

ok = client.del_cert_key(cert_id)

# new_el

ok = new_el(**kwargs)

Description of array **kwargs:

Key name Type Required Description
phase string yes phase
code string yes edgelang code
post bool yes put EL code to then end of phase if set to True, else put to the front of phase

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

code = "true => print('hello, world');"

ok = client.new_el(phase = 'req-rewrite', code = code, pre = True)

# new_release

ok = new_release()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

code = "true => print('hello, world');"

ok = client.new_el(phase = 'req-rewrite', code = code, pre = True)

ok = client.new_release()

# pending_changes

changes = pending_changes()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

code = "true => print('hello, world');"

ok = client.new_el(phase = 'req-rewrite', code = code, pre = True)

changes = client.pending_changes()

# sync_status

total, synced = sync_status()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

code = "true => print('hello, world');"

ok = client.new_el(phase = 'req-rewrite', code = code, pre = True)

ok = client.new_release()

total, synced = client.sync_status()
if total == synced:
    print('the new release has been synced to all nodes')

# use_dns_app

ok = use_dns_app(dns_id)

Returns True if success else False.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

client.use_dns_app(10)

# new_dns_app

dns_id = new_dns_app(**kwargs)

Description of array **kwargs:

Key name Type Required Description
zone string yes domain of DNS
authority list yes server names of DNS
soa_email string no soa email of DNS

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

# put_dns_app

ok = put_dns_app(**kwargs)

Description of array **kwargs:

Key name Type Required Description
dns_id number yes id of DNS
zone string yes domain of DNS
authority list yes server names of DNS
soa_email string no soa email of DNS

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '4 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
ok = client.put_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

# get_dns_app

data = get_dns_app(dns_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

dat = client.get_dns_app(dns_id)

# del_dns_app

ok = del_dns_app(dns_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

dat = client.del_dns_app(dns_id)

# new_dns_record

record_id = new_dns_record(**kwargs)

Description of array **kwargs:

Key name Type Required Description
sub_domain string yes sub domain
line int no default is 0, see Client Geo Location for detail
cidr string no cidr
record_type string yes type of record, one of [A, TXT, MX, CNAME, CAA]
text string no required if record_type is TXT or CAA
ip string no required if response is ip
domain string no required if response is domain
priority int no required if record_type is MX

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

record_id = client.new_dns_record(
    sub_domain = 'bar', record_type = 'TXT', text = 'text string')
client.new_dns_record(
    sub_domain='bar', record_type='A', ip='127.0.0.1')
client.new_dns_record(
    sub_domain='bar', record_type='CNAME', domain='test.com')
client.new_dns_record(
    sub_domain='bar', record_type='MX', domain='test.com', priority=3)

# put_dns_record

ok = put_dns_record(**kwargs)

Description of array **kwargs:

Key name Type Required Description
record_id number yes record id of DNS
sub_domain string yes sub domain
line int no default is 0, see Client Geo Location for detail
cidr string no cidr
record_type string yes type of record, one of [A, TXT, MX, CNAME, CAA]
text string no required if record_type is TXT or CAA
ip string no required if response is ip
domain string no required if response is domain
priority int no required if record_type is MX

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

record_id = client.new_dns_record(sub_domain = 'bar', record_type = 'TXT', text = 'text string')

ok = client.put_dns_record(record_id = record_id, sub_domain = 'a.bar', record_type = 'TXT', text = 'text string')

# del_dns_record

data = get_dns_record(record_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

record_id = client.new_dns_record(sub_domain = 'bar', record_type = 'TXT', text = 'text string')

data = client.get_dns_record(record_id)

# del_dns_record

ok = del_dns_record(record_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

authority = [
            {'domain': 'ns1.foo.com', 'ttl': '2 hour'},
            {'domain': 'ns2.foo.com', 'ttl': '1 day'}
        ]
soa_email = 'admin@foo.com'

dns_id = client.new_dns_app(authority = authority, soa_email = soa_email, zone = 'foo.com')

record_id = client.new_dns_record(sub_domain = 'bar', record_type = 'TXT', text = 'text string')

ok = client.del_dns_record(record_id)

# set_global_cert_key

cert_id = set_global_cert_key(**kwargs)

Description of array **kwargs:

Key name Type Required Description
key string yes content of private key
cert string no content of server cert
ca_chain string no content of CA chain

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_global_cert_key(key = key, cert = cert)

# put_global_cert_key

cert_id = put_global_cert_key(**kwargs)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert
key string yes content of private key
cert string no content of server cert
ca_chain string no content of CA chain

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_global_cert_key(key = key, cert = cert)

new_key_file = os.path.join('tests', 'new_key.pem')
new_cert_file = os.path.join('tests', 'new_cert.pem')
with open(new_key_file) as f:
    new_key = f.read()
with open(new_cert_file) as f:
    new_cert = f.read()

ok = client.put_global_cert_key(cert_id = cert_id, key = new_key, cert = new_cert)

# get_global_cert_key

cert_id = get_global_cert_key(cert_id)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_global_cert_key(key = key, cert = cert)

data = client.get_global_cert_key(cert_id)

# del_global_cert_key

ok = del_global_cert_key(cert_id)

Description of array **kwargs:

Key name Type Required Description
cert_id number yes id of cert

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

key_file = os.path.join('tests', 'key.pem')
cert_file = os.path.join('tests', 'cert.pem')
with open(key_file) as f:
    key = f.read()
with open(cert_file) as f:
    cert = f.read()

cert_id = client.set_global_cert_key(key = key, cert = cert)

ok = client.del_global_cert_key(cert_id)

# add_global_user

app_id = add_global_user(name, pwd, gid)

Description of parameters:

Key name Type Required Description
name string yes name of global user
pwd string yes password of global user
gid array yes group id array, like [1]

# Example


import random
from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

write = ''.join([random.choice(string.ascii_letters) for n in range(10)])
pwd = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(12)])

ok = client.add_global_user(name = write, pwd = pwd, gid = [1])

# search_global_user

ok = search_global_user(name)

Description of parameters:

Key name Type Required Description
name string yes name of global user

# Example


import random
from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

write = ''.join([random.choice(string.ascii_letters) for n in range(10)])
pwd = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(12)])

ok = client.add_global_user(name = write, pwd = pwd, can_create_app = True, role = 'user')

data = client.search_global_user(write)
user_id = data.get('id')

# get_all_global_users

data = get_all_global_users(detail)

# Example


import random
from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

write = ''.join([random.choice(string.ascii_letters) for n in range(10)])
pwd = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(12)])

ok = client.add_global_user(name = write, pwd = pwd, can_create_app = True, role = 'user')

data = client.get_all_global_users()
data = client.get_all_global_users(True)

# add_app_user

app_id = add_app_user(name, read, write, release)

Description of parameters:

Key name Type Required Description
name string yes name of user
read bool no whether has read permission, default is True
write bool no whether has write permission, default is True
release bool no whether has release permission, default is False
dns_read bool no whether has read dns permission, default is False
dns_write bool no whether has write dns permission, default is False

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')
id = client.add_app_user(name = 'only_reader', write = False, release = False)

# put_app_user

app_id = put_app_user(id, name, read, write, release)

Description of parameters:

Key name Type Required Description
id list yes id of user
name string yes name of user
read bool no whether has read permission, default is True
write bool no whether has write permission, default is True
release bool no whether has release permission, default is False
dns_read bool no whether has read dns permission, default is False
dns_write bool no whether has write dns permission, default is False

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')
id = client.add_app_user(name = 'only_reader', write = False, release = False)

ok = client.put_app_user(id = id, name = 'master', write = True, release = True)

# get_app_user

data = get_app_user(id, name, app_id, user_id)

Description of parameters:

Key name Type Required Description
id list no id of user
name string no name of app
app_id number no id of app, default is the current id of app
user_id number no id of global user

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')
id = client.add_app_user(name = 'only_reader', write = False, release = False)

data = client.get_app_user(name = 'only_reader')

# del_app_user

data = del_app_user(id, name, app_id, user_id)

Description of parameters:

Key name Type Required Description
id list no id of user
name string no name of app
app_id number no id of app, default is the current id of app
user_id number no id of global user

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')
id = client.add_app_user(name = 'only_reader', write = False, release = False)

ok = client.del_app_user(name = 'only_reader')

# get_all_app_users

data = get_all_app_users(app_id)

Description of parameters:

Key name Type Required Description
app_id number no id of app, default is the current id of app

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')
id = client.add_app_user(name = 'only_reader', write = False, release = False)

data = client.get_all_app_users()

# add_user_for_all_apps

ok = add_user_for_all_apps(name, read, write, release)

Description of parameters:

Key name Type Required Description
name string no name of global user
read bool no whether has read permission, default is True
write bool no whether has write permission, default is True
release bool no whether has release permission, default is False
dns_read bool no whether has read dns permission, default is False
dns_write bool no whether has write dns permission, default is False

# Example


import random
from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

write = ''.join([random.choice(string.ascii_letters) for n in range(10)])
pwd = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(12)])
ok = client.add_global_user(name = write, pwd = pwd, can_create_app = True, role = 'user')

data = client.add_user_for_all_apps(name = write)

# add-all-users-for-app

ok = add_all_users_for_app(app_id, read, write, release)

Description of parameters:

Key name Type Required Description
app_id number no id of app, default is the current app
read bool no whether has read permission, default is True
write bool no whether has write permission, default is True
release bool no whether has release permission, default is False
dns_read bool no whether has read dns permission, default is False
dns_write bool no whether has write dns permission, default is False

# Example


import random
from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

write = ''.join([random.choice(string.ascii_letters) for n in range(10)])
pwd = ''.join([random.choice(string.ascii_letters + string.digits) for n in range(12)])

ok = client.add_global_user(name = write, pwd = pwd, can_create_app = True, role = 'user')
data = client.add_all_users_for_app(release = True)

# new_global_rule

rule_id = new_global_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
condition list no conditions of rule
conseq dict or list no actions of rule
gid list no array of user group id

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# conseq

Description of array conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_global_rule(condition = condition, conseq = conseq, gid=[1])

# put_global_rule

ok = put_global_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
rule_id number yes id of rule
condition list no conditions of rule
conseq dict or list no actions of rule
gid list no array of user group id

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# conseq

Description of array conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_global_rule(condition = condition, conseq = conseq)

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

ok = client.put_global_rule(rule_id = rule_id, condition = condition, conseq = conseq)

# get_global_rule

ok = get_global_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_global_rule(condition = condition, conseq = conseq)

data = client.get_global_rule(rule_id)

# get_global_action_by_name

rule_id = get_global_action_by_name(name)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

name = "test-actions"

client.new_global_rule(condition=condition, conseq=conseq, name=name)

rule_id = client.get_global_action_by_name('test-actions')

# get_all_global_rules

ok = get_all_global_rules()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_global_rule(condition = condition, conseq = conseq)

data = client.get_all_global_rules()

# del_global_rule

ok = del_global_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_global_rule(condition = condition, conseq = conseq)

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

ok = client.del_global_rule(rule_id)

# new_global_var

var_id = new_global_var(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of var
var_type string yes type of var
default string yes default value

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

var_id = client.new_global_var(name = 'is-whitelist', var_type = 'string', default = 'no')


# put_global_var

ok = put_global_var(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
var_id number yes id of var
name string yes name of var
var_type string yes type of var
default string yes default value

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

var_id = client.new_global_var(name = 'is-whitelist', var_type = 'string', default = 'no')

ok = client.put_global_var(var_id = var_id, name = 'is-whitelist', var_type = 'string', default = 'yes')

# get_global_var

data = get_global_var(var_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

var_id = client.new_global_var(name = 'is-whitelist', var_type = 'string', default = 'no')

data = client.get_global_var(var_id)

# get_all_global_vars

data = get_all_global_vars()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

var_id = client.new_global_var(name = 'is-whitelist', var_type = 'string', default = 'no')

data = client.get_all_global_vars()

# del_global_var

ok = del_global_var(var_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

var_id = client.new_global_var(name = 'is-whitelist', var_type = 'string', default = 'no')

ok = client.del_global_var(var_id)

# get_global_ngx_config

data = get_global_ngx_config()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_global_ngx_config()

# set_global_ngx_config

data = set_global_ngx_config(opts)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

opts = {'keepalive_timeout': 10, 'enable_open_file_cache': False}
ok = client.set_global_ngx_config(opts)

# get_global_misc_config

data = get_global_misc_config()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_global_misc_config()

# set_global_misc_config

data = set_global_misc_config(opts)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

opts = {'enabled_req_id': True}
ok = client.set_global_misc_config(opts)

# get_request_id_status

status = get_request_id_status()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

status = client.get_request_id_status()

# enable_request_id

ok = enable_request_id()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.enable_request_id()

# disable_request_id

ok = disable_request_id()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.disable_request_id()

# new_global_waf_rule

rule_id = new_global_waf_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of rule
code string yes EL code of rule

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")


# put_global_waf_rule

ok = put_global_waf_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
rule_id number yes id of rule
name string yes name of rule
code string yes EL code of rule

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")

ok = client.put_global_waf_rule(rule_id = waf_rule_id, name = 'bar', code = "uri-arg('bar') => waf-mark-risk(level: 'definite', msg: 'found bar');")

# get_global_waf_rule

data = get_global_waf_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")

data = client.get_global_waf_rule(waf_rule_id)

# del_global_waf_rule

ok = del_global_waf_rule(rule_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")

ok = client.del_global_waf_rule(waf_rule_id)

# get_all_global_waf_rules

data = get_all_global_waf_rules(detail = False)

Key name Type Required Description
detail bool no default is False, not returns the code of rules.

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

waf_rule_id = client.new_global_waf_rule(name = 'foo', code = "uri-arg('foo') => waf-mark-risk(level: 'definite', msg: 'found foo');")

data = client.get_all_global_waf_rules()

# new_global_action

rule_id = new_global_action(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of action
condition list no conditions of global custom action
conseq dict or list no actions of global custom action
[gid] list no array of user group id

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# conseq

Description of array conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

name = 'test'
condition = [
    {'var': 'req-method', 'vals': ['GET', 'POST', 'HEAD']}
]
conseq = [
    {
        'exit': {'code': 403}
    }
]
action_id = client.new_global_action(name = name, condition = condition, conseq = conseq, gid=[1])

# put_global_action

ok = put_global_action(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
action_id number yes id of action
name string no name of action
condition list no conditions of global custom action
conseq dict or list no actions of global custom action
[gid] list no array of user group id

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# conseq

Description of array conseq in **kwargs:

Key name Type Required Description
edgelang builtin action function string yes one of edgelang builtin action functions
args of edgelang builtin action function list yes args of edgelang builtin action function

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

name = 'test'
condition = [
    {'var': 'req-method', 'vals': ['GET', 'POST', 'HEAD']}
]
conseq = [
    {
        'exit': {'code': 403}
    }
]
action_id = client.new_global_action(name = name, condition = condition, conseq = conseq)

conseq = [
            {
                'exit': {'code': 404}
            }
        ]
ok = client.put_global_action(name = name, action_id = action_id, condition = condition, conseq = conseq, gid=[1])

# get_global_action

ok = get_global_action(action_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

name = 'test'
condition = [
    {'var': 'req-method', 'vals': ['GET', 'POST', 'HEAD']}
]
conseq = [
    {
        'exit': {'code': 403}
    }
]
action_id = client.new_global_action(name = name, condition = condition, conseq = conseq)

data = client.get_global_action(action_id)

# del_global_action

ok = del_global_action(action_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

name = 'test'
condition = [
    {'var': 'req-method', 'vals': ['GET', 'POST', 'HEAD']}
]
conseq = [
    {
        'exit': {'code': 403}
    }
]
action_id = client.new_global_action(name = name, condition = condition, conseq = conseq)

ok = client.del_global_action(action_id)

# count_global_actions

count = count_global_actions()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.count_global_actions()

# get_all_global_actions

data = get_all_global_actions()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_all_global_actions()

# new_user_var

var_id = new_user_var(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of var
var_type string yes type of var
default string yes default value

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

var_id = client.new_user_var(name = 'is-whitelist', var_type = 'string', default = 'no')

# put_user_var

ok = put_user_var(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
var_id number yes id of var
name string yes name of var
var_type string yes type of var
default string yes default value

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

var_id = client.new_user_var(name = 'is-whitelist', var_type = 'string', default = 'no')

ok = client.put_user_var(var_id = var_id, name = 'is-whitelist', var_type = 'string', default = 'yes')

# get_user_var

data = get_user_var(var_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

var_id = client.new_user_var(name = 'is-whitelist', var_type = 'string', default = 'no')

data = client.get_user_var(var_id)

# del_user_var

ok = del_user_var(var_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

var_id = client.new_user_var(name = 'is-whitelist', var_type = 'string', default = 'no')

ok = client.del_user_var(var_id)

# **node_sync_status

**

data = node_sync_status()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.node_sync_status()
for node_id, delay in data.items():
    if delay > 0:
        print('WARNING: node id {}: releases behind {}'.format(str(node_id), str(delay)))

# upload_static_file

file_id = upload_static_file(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
content string yes content of static file
label string yes label of static file
file_type string no default is 'html'
gid list no array of user group id

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

file_id = client.upload_static_file(content = 'test_content', label = '500.html', gid=[1])

# get_static_file

data = get_static_file(file_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

file_id = client.upload_static_file(content = 'test_content', label = '500.html')

data = client.get_static_file(file_id)

# del_static_file

ok = del_static_file(file_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

file_id = client.upload_static_file(content = 'test_content', label = '500.html')

ok = client.del_static_file(file_id)

# new_waf_whitelist

rule_id = new_waf_whitelist(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
condition list no conditions of rule
rule_sets list yes list of waf rule id

# condition

Description of array condition in **kwargs:

Key name Type Required Description
var string or array yes name of edgelang builtin predicate function if type is string, name and args of function if type is array
op string no operator, default is eq
val string either val or vals value
vals list either val or vals array of val

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.foo.com'},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

id = client.new_waf_whitelist(condition = condition, rule_sets = [1, 2])

# put_waf_whitelist

ok = put_waf_whitelist(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
whitelist_id number yes id of whitelist
condition list no conditions of rule
rule_sets list yes list of waf rule id

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.foo.com'},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

id = client.new_waf_whitelist(condition = condition, rule_sets = [1, 2])

ok = client.put_waf_whitelist(whitelist_id = id, condition = condition, rule_sets = [1])

# get_waf_whitelist

data = get_waf_whitelist(whitelist_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.foo.com'},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

id = client.new_waf_whitelist(condition = condition, rule_sets = [1, 2])
data = client.get_waf_whitelist(id)

# del_waf_whitelist

ok = del_waf_whitelist(whitelist_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.foo.com'},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

id = client.new_waf_whitelist(condition = condition, rule_sets = [1, 2])
ok = client.del_waf_whitelist(id)

# get_all_waf_whitelists

data = get_all_waf_whitelists()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.foo.com'},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

id = client.new_waf_whitelist(condition = condition, rule_sets = [1, 2])
data = client.get_all_waf_whitelists()

# get_healthcheck_status

data = get_healthcheck_status()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.node_sync_status()
for node_id, node_info in data.items():
    node_id = int(node_id)
    data = client.get_healthcheck_status(node_id)

# new_cluster_group

group_id = new_cluster_group(group_name)

Key name Type Required Description
group_name string yes name of cluster group

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

group_id = client.new_cluster_group('foo')


# put_cluster_group

ok = put_cluster_group(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
group_id number yes id of group
group_name string yes name of group

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

group_id = client.new_cluster_group(group_name = 'foo')

ok = client.put_cluster_group(group_id = group_id, group_name = 'bar')

# get_cluster_group

data = get_cluster_group(group_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

group_id = client.new_cluster_group(group_name = 'foo')

data = client.get_cluster_group(group_id)

# get_all_cluster_groups

data = get_all_cluster_groups()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

group_id = client.new_cluster_group(group_name = 'foo')

data = client.get_all_cluster_groups()

# del_cluster_group

ok = del_cluster_group(group_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

group_id = client.new_cluster_group(group_name = 'foo')

ok = client.del_cluster_group(group_id)

# put_proxy_rule

ok = put_proxy_rule(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
rule_id number yes id of rule
proxy list yes rules of proxy

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

app_id = client.new_app(domains = ['orig.foo.com'], label = 'origin site for foo.com')

condition = [
            {'var': 'host', 'val': 'con.' + APEX},
            {'var': ['req-header', 'Referer'], 'vals': [['foo\d+', 'rx'], 'foo.com']}
        ]

conseq = {
    'enable-websocket': {},
    'redirect': {'url': '/cn/2017/', 'code': 302}
}

rule_id = client.new_rule(condition = condition, conseq = conseq)

proxy_rule = {
            'upstreams': [{'upstream': up_id, 'weight': 2}],
            'backup_upstreams': [{'upstream': backup_up_id}],
            'retries': -1,
            "retry_condition": ["invalid_header", "http_500"],
            "balancer_algorithm": "hash",
            "balancer_vars": [
                {"name":"uri"},
                {
                    "name":"uri-arg",
                    "args":"foo"
                }
            ]
        }

ok = client.put_proxy_rule(rule_id = rule_id, proxy = proxy_rule)

# decode_request_id

data = decode_request_id(request_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.decode_request_id('00000a00000c0826c9803222')

# {u'timestamp': 1531859760, u'node_id': 20, u'app_id': 3, u'is_stream': False, u'sequence': 12834}
print(data)

# search_waf_log

data = search_waf_log(request_id)

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

request_id = "0000008000042c421ea80011"

data = client.search_waf_log(request_id)

# add_api_token

data = add_api_token(name=None, expire=0)

Key name Type Required Description
name string no api token name
expire number no api token expiration time

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.add_api_token("name", 0)

# get_api_token

data = get_api_token(id=None, limit=20)

Key name Type Required Description
id number no api token id
limit number no limit on the number of returns

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_api_token(id)

# or

data = client.get_api_token(None, 100)

# del_api_token

data = del_api_token(id)

Key name Type Required Description
id number no api token id

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.del_api_token(id)

# get_all_gateway_tag

tags = get_all_gateway_tag()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

tags = client.get_all_gateway_tag()

for i, tag in enumerate(tags):
    print(i, tag)

# get_all_gateway

gateways = get_all_gateway()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

gateways = client.get_all_gateway()

for i, gateway in enumerate(gateways):
    print(i, gateway)

# get_app_metrics

metrics = get_app_metrics(id, start_time=None, end_time=None)

Description of parameters:

Key name Type Required Description
id number yes id of application
start_time number no start of unix timestamp
end_time number no end of unix timestamp

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

metrics = client.get_app_metrics()

for i, mt in enumerate(metrics):
    print(i, mt)

# new_global_dymetrics

id = new_global_dymetrics(name=None, note=None, interval=60, sql=None)

Description of parameters:

Key name Type Required Description
name string yes name of dymetrics
note string no note for dymetrics
interval number no statistical interval
sql string yes sql statements for generating metrics

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

sql = 'select status, count(*) from reqs group by status'
dymetrics_id = client.new_global_dymetrics(name='test', sql=sql)

# put_global_dymetrics

ok = put_global_dymetrics(id=None, name=None, note=None, interval=60, sql=None, http_verb="PUT")

Description of parameters:

Key name Type Required Description
id number yes id of dymetrics
name string yes name of dymetrics
note string no note for dymetrics
interval number no statistical interval
sql string yes sql statements for generating metrics
http_verb string no http request method

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

sql = 'select status, count(*) from reqs group by status'
ok = client.put_global_dymetrics(id=dymetrics_id, name='test', sql=sql)

# del_global_dymetrics

ok = del_global_dymetrics(id)

Description of parameters:

Key name Type Required Description
id number yes id of dymetrics

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.del_global_dymetrics(dymetrics_id)

# get_global_dymetrics

data = get_global_dymetrics(id)

Description of parameters:

Key name Type Required Description
id number yes id of dymetrics

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_global_dymetrics(dymetrics_id)

# get_all_global_dymetrics

data = get_all_global_dymetrics()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_all_global_dymetrics()

# get_global_dymetrics_data

data = get_global_dymetrics_data(id, chart_type='line', start_time=None, end_time=None, node_id=None)

Description of parameters:

Key name Type Required Description
id number yes id of application
chart_type string no id of application, defaul 'line'
start_time number no start of unix timestamp
end_time number no end of unix timestamp
node_id number no id of gateway node

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_global_dymetrics_data(dymetrics_id)

# node_monitor

data = node_monitor(start_time=None, end_time=None, step=60)

Description of parameters:

Key name Type Required Description
start_time number no start of unix timestamp
end_time number no end of unix timestamp
step number no statistical interval

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.node_monitor()

# get_version

data = get_version()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_version()

# new_global_k8s

k8s_id = new_global_k8s(name=None, host=None, port=None, ssl_verify=True, token=None)

Description of parameters:

Key name Type Required Description
name string yes name of k8s cluster
host string yes host of k8s cluster
port number yes port of k8s cluster
ssl_verify bool no ssl verify enable
token string yes api token of k8s cluster

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

k8s_id = client.new_global_k8s(name = "k8s", host = "192.168.1.1", port = 443, token = "xxxxx")

# put_global_k8s

ok = put_global_k8s(k8s_id=None, name=None, host=None, port=None, ssl_verify=True, token=None)

Description of parameters:

Key name Type Required Description
k8s_id string yes k8s id
name string no name of k8s cluster
host string no host of k8s cluster
port number no port of k8s cluster
ssl_verify bool no ssl verify enable
token string no api token of k8s cluster

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.put_global_k8s(k8s_id = 1, name = "k8s", host = "192.168.1.1", port = 443, token = "xxxxx")

# get_global_k8s

data = get_global_k8s(k8s_id=None)

Description of parameters:

Key name Type Required Description
k8s_id string yes k8s id

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_global_k8s(k8s_id = 1)

# get_k8s_service_detail

data = get_k8s_service_detail(k8s_id=None)

Description of parameters:

Key name Type Required Description
k8s_id string yes k8s id

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_k8s_service_detail(k8s_id = 1)

# get_all_global_k8s

data = get_all_global_k8s()

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

data = client.get_all_global_k8s()

# del_global_k8s

ok = del_global_k8s(k8s_id = None)

# Example

from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')

client.login()

ok = client.del_global_k8s(k8s_id = 1)

# new_global_upstream

up_id = new_global_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of global upstream
servers list yes upstreams
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

up_id = client.new_global_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

# put_global_upstream

ok = put_global_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
servers list yes upstreams
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

up_id = client.new_global_upstream(name = 'origin-upstream',
                            servers = [
                                {'domain': 'a.com', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

ok = client.put_global_upstream(up_id, name = 'origin-upstream',
                    servers = [
                        {'domain': 'test.com', 'port': 8080},
                        {'ip': '172.22.31.2', 'port': 8080, 'weight': 1}
                    ],
                    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'
                    })

# get_global_upstream

data = get_global_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

up_id = client.new_global_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

data = client.get_global_upstream(up_id)

# del-global-upstream

ok = del_global_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

up_id = client.new_global_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

ok = client.del_global_upstream(up_id)

# get_all_global_upstreams

upstreams = client.get_all_global_upstreams()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

up_id = client.new_global_upstream(name = 'origin-upstream',
                            servers = [
                                {'ip': '172.22.31.1', 'port': 80},
                                {'ip': '172.22.31.2', 'port': 80, 'weight': 2}
                            ])

upstreams = client.get_all_global_upstreams(up_id)

# new_global_k8s_upstream

k8s_up_id = new_global_k8s_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
k8s_services list yes upstreams is k8s services
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# k8s_services

Description of array k8s_services in **kwargs:

Key name Type Required Description
k8s number yes k8s cluster id
k8s_namespace string yes k8s namespace
k8s_service string yes k8s service
k8s_service_port number yes k8s service port

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

k8s_up_id = client.new_global_k8s_upstream(name = 'k8s-upstream',
                            k8s_services = [
                                {   
                                    'k8s' : 1,
                                    'k8s_namespace' : 'default',
                                    'k8s_service' : 'foo',
                                    'k8s_service_port' : 80, 
                                }   
                            ])

# put_global_k8s_upstream

ok = put_global_k8s_upstream(**kwargs)

Description of dict **kwargs:

Key name Type Required Description
name string yes name of upstream
k8s_services list yes upstreams is k8s services
ssl bool no set protocol to HTTPS, default is false(HTTP)
health_checker dict no detail configure of health checker, default is none

# servers

Description of array servers in **kwargs:

Key name Type Required Description
domain string no domain of upstream
ip string no ip of upstream. Choose one from domain and ip
port string yes port of upstream
weight number no weight of upstream, default is 1

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()


ok = client.put_global_k8s_upstream(up_id, name = 'origin-upstream',
                    k8s_services = [
                        {   
                            'k8s' : 1,
                            'k8s_namespace' : 'default',
                            'k8s_service' : 'foo',
                            'k8s_service_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'
                    })

# get_global_k8s_upstream

data = get_global_k8s_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

data = client.get_global_k8s_upstream(up_id)

# del-global-k8s-upstream

ok = del_global_k8s_upstream(up_id)

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

ok = client.del_global_k8s_upstream(up_id)

# get_all_global_k8s_upstreams

upstreams = client.get_all_global_k8s_upstreams()

# Example


from edge2client import Edge2Client

client = Edge2Client('http://127.0.0.1:8080', 'username', 'password')
client.login()

upstreams = client.get_all_global_k8s_upstreams(app_id)