From 1da5f6ad78261d4afba075280edce6de1cd66d05 Mon Sep 17 00:00:00 2001
From: "ol@xvc.com"
Date: Fri, 14 Sep 2018 10:32:30 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=81=8D=E5=8E=86?=
=?UTF-8?q?=E5=9F=9F=E5=90=8D=E7=9A=84=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
qiniu/services/cdn/manager.py | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/qiniu/services/cdn/manager.py b/qiniu/services/cdn/manager.py
index 313736ef..17c8fe92 100644
--- a/qiniu/services/cdn/manager.py
+++ b/qiniu/services/cdn/manager.py
@@ -260,6 +260,29 @@ def create_sslcert(self, name, common_name, pri, ca):
url = '{0}/sslcert'.format(self.server)
return self.__post(url, body)
+ def domain_iter(self):
+ """
+ 遍历所有域名
+ """
+ marker = None
+ while 1:
+ r = self.domain_list(200, marker)
+ li = r['domains']
+ if li:
+ for i in li:
+ yield i
+ marker = r['marker']
+ else:
+ break
+
+
+ def domain_list(self, limit=10, marker=None):
+ p = dict(limit=limit)
+ if marker:
+ p['marker']=marker
+ return self.__get(self.server+"/domain", p)[0]
+
+
def __post(self, url, data=None):
headers = {'Content-Type': 'application/json'}
return http._post_with_auth_and_headers(url, data, self.auth, headers)
@@ -268,6 +291,9 @@ def __put(self, url, data=None):
headers = {'Content-Type': 'application/json'}
return http._put_with_auth_and_headers(url, data, self.auth, headers)
+ def __get(self, url, params=None):
+ return http._get(url, params, self.auth)
+
def create_timestamp_anti_leech_url(host, file_name, query_string, encrypt_key, deadline):
"""
From 6b3b71b6cde63a72b084b8118640b1d19c98d8a4 Mon Sep 17 00:00:00 2001
From: "ol@xvc.com"
Date: Fri, 14 Sep 2018 10:36:51 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E8=B0=83=E6=95=B4dnsmanager=20get=E7=9A=84?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
qiniu/services/cdn/manager.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qiniu/services/cdn/manager.py b/qiniu/services/cdn/manager.py
index 17c8fe92..09fd2e2b 100644
--- a/qiniu/services/cdn/manager.py
+++ b/qiniu/services/cdn/manager.py
@@ -280,7 +280,7 @@ def domain_list(self, limit=10, marker=None):
p = dict(limit=limit)
if marker:
p['marker']=marker
- return self.__get(self.server+"/domain", p)[0]
+ return self.__get("domain", p)[0]
def __post(self, url, data=None):
@@ -292,7 +292,7 @@ def __put(self, url, data=None):
return http._put_with_auth_and_headers(url, data, self.auth, headers)
def __get(self, url, params=None):
- return http._get(url, params, self.auth)
+ return http._get(self.server+"/"+url, params, self.auth)
def create_timestamp_anti_leech_url(host, file_name, query_string, encrypt_key, deadline):
From 4a104f0ef6e81d840b908d8ced47b59c57e5cf7d Mon Sep 17 00:00:00 2001
From: "root@xvc.bid"
Date: Mon, 27 Jun 2022 19:20:03 +0800
Subject: [PATCH 3/4] fix
---
qiniu/http.py | 21 ++++++++++++++++++++-
qiniu/services/cdn/manager.py | 28 +++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/qiniu/http.py b/qiniu/http.py
index 80596700..4d182920 100644
--- a/qiniu/http.py
+++ b/qiniu/http.py
@@ -21,9 +21,10 @@
def __return_wrapper(resp):
if resp.status_code != 200 or resp.headers.get('X-Reqid') is None:
+ print(resp.text)
return None, ResponseInfo(resp)
resp.encoding = 'utf-8'
- ret = resp.json(encoding='utf-8') if resp.text != '' else {}
+ ret = resp.json() if resp.text != '' else {}
return ret, ResponseInfo(resp)
@@ -37,6 +38,21 @@ def _init():
global _session
_session = session
+def _delete(url, data, files, auth, headers=None):
+ if _session is None:
+ _init()
+ try:
+ post_headers = _headers.copy()
+ if headers is not None:
+ for k, v in headers.items():
+ post_headers.update({k: v})
+ r = _session.delete(
+ url, data=data, files=files, auth=auth, headers=post_headers,
+ timeout=config.get_default('connection_timeout'))
+ except Exception as e:
+ return None, ResponseInfo(None, e)
+ return __return_wrapper(r)
+
def _post(url, data, files, auth, headers=None):
if _session is None:
@@ -107,6 +123,9 @@ def _post_with_auth(url, data, auth):
def _post_with_auth_and_headers(url, data, auth, headers):
return _post(url, data, None, qiniu.auth.RequestsAuth(auth), headers)
+def _delete_with_auth_and_headers(url, data, auth, headers):
+ return _delete(url, data, None, qiniu.auth.RequestsAuth(auth), headers)
+
def _put_with_auth(url, data, auth):
return _put(url, data, None, qiniu.auth.RequestsAuth(auth))
diff --git a/qiniu/services/cdn/manager.py b/qiniu/services/cdn/manager.py
index 09fd2e2b..56c1ac21 100644
--- a/qiniu/services/cdn/manager.py
+++ b/qiniu/services/cdn/manager.py
@@ -260,6 +260,27 @@ def create_sslcert(self, name, common_name, pri, ca):
url = '{0}/sslcert'.format(self.server)
return self.__post(url, body)
+ def sslcert_iter(self):
+ marker = None
+ while 1:
+ r = self.sslcert_list(200, marker)
+ li = r['certs']
+ if li:
+ for i in li:
+ yield i
+ marker = r['marker']
+ else:
+ break
+
+ def sslcert_delete(self, certid):
+ return self.__delete("sslcert/"+certid)
+
+ def sslcert_list(self, limit=10, marker=None):
+ p = dict(limit=limit)
+ if marker:
+ p['marker']=marker
+ return self.__get("sslcert", p)[0]
+
def domain_iter(self):
"""
遍历所有域名
@@ -280,12 +301,17 @@ def domain_list(self, limit=10, marker=None):
p = dict(limit=limit)
if marker:
p['marker']=marker
- return self.__get("domain", p)[0]
+ url = 'domain'
+ return self.__get(url, p)[0]
def __post(self, url, data=None):
headers = {'Content-Type': 'application/json'}
return http._post_with_auth_and_headers(url, data, self.auth, headers)
+
+ def __delete(self, url, data=None):
+ headers = {'Content-Type': 'application/json'}
+ return http._delete_with_auth_and_headers(url, data, self.auth, headers)
def __put(self, url, data=None):
headers = {'Content-Type': 'application/json'}
From 871e051eff5b413472f553ca76ad779214fc4fe5 Mon Sep 17 00:00:00 2001
From: "root@xvc.bid"
Date: Mon, 27 Jun 2022 19:22:58 +0800
Subject: [PATCH 4/4] fix
---
qiniu/services/cdn/manager.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qiniu/services/cdn/manager.py b/qiniu/services/cdn/manager.py
index 56c1ac21..00b4cf45 100644
--- a/qiniu/services/cdn/manager.py
+++ b/qiniu/services/cdn/manager.py
@@ -273,7 +273,8 @@ def sslcert_iter(self):
break
def sslcert_delete(self, certid):
- return self.__delete("sslcert/"+certid)
+ url = '{0}/sslcert/{1}'.format(self.server, certid)
+ return self.__delete(url)
def sslcert_list(self, limit=10, marker=None):
p = dict(limit=limit)