第一次提交:阿龙电竞 Django 后端最新版本
This commit is contained in:
@@ -0,0 +1 @@
|
||||
__version__ = '2.0.15'
|
||||
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class ApiExceptionBase(Exception):
|
||||
"""
|
||||
@type message: string
|
||||
@param message: error describe
|
||||
"""
|
||||
def __init__(self, message):
|
||||
self.message = message
|
||||
|
||||
def get_info(self):
|
||||
return 'Error Message: %s\n' % (self.message)
|
||||
|
||||
def __str__(self):
|
||||
return "ApiExceptionBase %s" % (self.get_info())
|
||||
|
||||
|
||||
class ApiClientParamException(ApiExceptionBase):
|
||||
def __init__(self, message):
|
||||
ApiExceptionBase.__init__(self, message)
|
||||
|
||||
def __str__(self):
|
||||
return "ApiClientException %s" % (self.get_info())
|
||||
|
||||
|
||||
class ApiClientNetworkException(ApiExceptionBase):
|
||||
""" @note: client network exception
|
||||
"""
|
||||
def __init__(self, message):
|
||||
ApiExceptionBase.__init__(self, message)
|
||||
|
||||
def __str__(self):
|
||||
return "ApiClientNetworkException %s" % (self.get_info())
|
||||
|
||||
|
||||
class ApiServerNetworkException(ApiExceptionBase):
|
||||
""" @note: api server exception
|
||||
"""
|
||||
def __init__(self, status=200, header=None, data=""):
|
||||
if header is None:
|
||||
header = {}
|
||||
self.status = status
|
||||
self.header = header
|
||||
self.data = data
|
||||
|
||||
def __str__(self):
|
||||
headers = "\n".join("%s: %s" % (k, v) for k, v in self.header.items())
|
||||
return ("ApiServerNetworkException Status: %s\nHeader: %s\nData: %s\n"
|
||||
% (self.status, headers, self.data))
|
||||
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
import socket
|
||||
try:
|
||||
from http.client import HTTPConnection, BadStatusLine, HTTPSConnection
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from httplib import HTTPConnection, BadStatusLine, HTTPSConnection
|
||||
from urlparse import urlparse
|
||||
|
||||
from .api_exception import ApiClientNetworkException, ApiClientParamException
|
||||
|
||||
|
||||
class MyHTTPSConnection(HTTPSConnection):
|
||||
def __init__(self, host, port=None):
|
||||
self.has_proxy = False
|
||||
self.request_host = host
|
||||
https_proxy = (os.environ.get('https_proxy')
|
||||
or os.environ.get('HTTPS_PROXY'))
|
||||
if https_proxy:
|
||||
url = urlparse(https_proxy)
|
||||
if not url.hostname:
|
||||
url = urlparse('https://' + https_proxy)
|
||||
host = url.hostname
|
||||
port = url.port
|
||||
self.has_proxy = True
|
||||
HTTPSConnection.__init__(self, host, port)
|
||||
self.request_length = 0
|
||||
|
||||
def send(self, astr):
|
||||
HTTPSConnection.send(self, astr)
|
||||
self.request_length += len(astr)
|
||||
|
||||
def request(self, method, url, body=None, headers={}):
|
||||
self.request_length = 0
|
||||
if self.has_proxy:
|
||||
self.set_tunnel(self.request_host, 443)
|
||||
HTTPSConnection.request(self, method, url, body, headers)
|
||||
|
||||
|
||||
class ApiRequest(object):
|
||||
def __init__(self, host, req_timeout=90, debug=False):
|
||||
self.conn = MyHTTPSConnection(host)
|
||||
self.req_timeout = req_timeout
|
||||
self.keep_alive = False
|
||||
self.debug = debug
|
||||
self.request_size = 0
|
||||
self.response_size = 0
|
||||
|
||||
def set_req_timeout(self, req_timeout):
|
||||
self.req_timeout = req_timeout
|
||||
|
||||
def is_keep_alive(self):
|
||||
return self.keep_alive
|
||||
|
||||
def set_debug(self, debug):
|
||||
self.debug = debug
|
||||
|
||||
def send_request(self, req_inter):
|
||||
try:
|
||||
if self.debug:
|
||||
print("SendRequest %s" % req_inter)
|
||||
if req_inter.method == 'GET':
|
||||
req_inter_url = '%s?%s' % (req_inter.uri, req_inter.data)
|
||||
self.conn.request(req_inter.method, req_inter_url,
|
||||
None, req_inter.header)
|
||||
elif req_inter.method == 'POST':
|
||||
self.conn.request(req_inter.method, req_inter.uri,
|
||||
req_inter.data, req_inter.header)
|
||||
else:
|
||||
raise ApiClientParamException(
|
||||
'Method only support (GET, POST)')
|
||||
|
||||
self.conn.sock.settimeout(self.req_timeout)
|
||||
self.conn.sock.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_NODELAY, 1)
|
||||
try:
|
||||
http_resp = self.conn.getresponse()
|
||||
except BadStatusLine:
|
||||
# open another connection when keep-alive timeout
|
||||
# httplib will not handle keep-alive timeout,
|
||||
# so we must handle it ourself
|
||||
if self.debug:
|
||||
print("keep-alive timeout, reopen connection")
|
||||
self.conn.close()
|
||||
|
||||
self.conn.request(req_inter.method, req_inter.uri,
|
||||
req_inter.data, req_inter.header)
|
||||
self.conn.sock.settimeout(self.req_timeout)
|
||||
self.conn.sock.setsockopt(socket.IPPROTO_TCP,
|
||||
socket.TCP_NODELAY, 1)
|
||||
http_resp = self.conn.getresponse()
|
||||
headers = dict(http_resp.getheaders())
|
||||
resp_inter = ResponseInternal(status=http_resp.status,
|
||||
header=headers,
|
||||
data=http_resp.read())
|
||||
self.request_size = self.conn.request_length
|
||||
self.response_size = len(resp_inter.data)
|
||||
if not self.is_keep_alive():
|
||||
self.conn.close()
|
||||
if self.debug:
|
||||
print(("GetResponse %s" % resp_inter))
|
||||
return resp_inter
|
||||
except Exception as e:
|
||||
self.conn.close()
|
||||
raise ApiClientNetworkException(str(e))
|
||||
|
||||
|
||||
class RequestInternal(object):
|
||||
def __init__(self, host="", method="", uri="", header=None, data=""):
|
||||
if header is None:
|
||||
header = {}
|
||||
self.host = host
|
||||
self.method = method
|
||||
self.uri = uri
|
||||
self.header = header
|
||||
self.data = data
|
||||
|
||||
def __str__(self):
|
||||
headers = "\n".join("%s: %s" % (k, v) for k, v in self.header.items())
|
||||
return ("Host: %s\nMethod: %s\nUri: %s\nHeader: %s\nData: %s\n"
|
||||
% (self.host, self.method, self.uri, headers, self.data))
|
||||
|
||||
|
||||
class ResponseInternal(object):
|
||||
def __init__(self, status=0, header=None, data=""):
|
||||
if header is None:
|
||||
header = {}
|
||||
self.status = status
|
||||
self.header = header
|
||||
self.data = data
|
||||
|
||||
def __str__(self):
|
||||
headers = "\n".join("%s: %s" % (k, v) for k, v in self.header.items())
|
||||
return ("Status: %s\nHeader: %s\nData: %s\n"
|
||||
% (self.status, headers, self.data))
|
||||
@@ -0,0 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import binascii
|
||||
import hashlib
|
||||
import hmac
|
||||
import sys
|
||||
|
||||
|
||||
class Sign(object):
|
||||
def __init__(self, secretId, secretKey):
|
||||
self.secretId = secretId
|
||||
self.secretKey = secretKey
|
||||
if sys.version_info[0] > 2:
|
||||
self.Py2 = False
|
||||
self.secretKey = bytes(self.secretKey, 'utf-8')
|
||||
else:
|
||||
self.Py2 = True
|
||||
|
||||
def make(self, requestHost, requestUri, params,
|
||||
method='POST', sign_method='HmacSHA1'):
|
||||
p = {}
|
||||
for k in params:
|
||||
if method == 'POST' and str(params[k])[0:1] == '@':
|
||||
continue
|
||||
p[k.replace('_', '.')] = params[k]
|
||||
ps = '&'.join('%s=%s' % (k, p[k]) for k in sorted(p))
|
||||
|
||||
msg = '%s%s%s?%s' % (method.upper(), requestHost, requestUri, ps)
|
||||
if not self.Py2:
|
||||
msg = bytes(msg, 'utf-8')
|
||||
|
||||
if sign_method == 'HmacSHA256':
|
||||
digestmod = hashlib.sha256
|
||||
else:
|
||||
digestmod = hashlib.sha1
|
||||
|
||||
hashed = hmac.new(self.secretKey, msg, digestmod)
|
||||
base64 = binascii.b2a_base64(hashed.digest())[:-1]
|
||||
if not self.Py2:
|
||||
base64 = base64.decode()
|
||||
|
||||
return base64
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Account(base.Base):
|
||||
requestHost = 'account.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class APIGateway(base.Base):
|
||||
requestHost = 'apigateway.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 1999-2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Athena(base.Base):
|
||||
"""Financial Intelligent Customer Service.
|
||||
|
||||
document: https://cloud.tencent.com/document/product/671
|
||||
"""
|
||||
requestHost = 'athena.api.qcloud.com'
|
||||
162
venv_prod/lib/python3.12/site-packages/QcloudApi/modules/base.py
Normal file
162
venv_prod/lib/python3.12/site-packages/QcloudApi/modules/base.py
Normal file
@@ -0,0 +1,162 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import time
|
||||
import random
|
||||
import sys
|
||||
import os
|
||||
import warnings
|
||||
|
||||
try:
|
||||
from urllib.parse import urlencode
|
||||
except ImportError:
|
||||
from urllib import urlencode
|
||||
|
||||
import QcloudApi
|
||||
from QcloudApi.common.api_exception import ApiClientParamException
|
||||
from QcloudApi.common.api_exception import ApiServerNetworkException
|
||||
from QcloudApi.common.request import ApiRequest
|
||||
from QcloudApi.common.request import RequestInternal
|
||||
from QcloudApi.common.sign import Sign
|
||||
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
|
||||
class Base(object):
|
||||
requestHost = ''
|
||||
requestUri = '/v2/index.php'
|
||||
_params = {}
|
||||
version = 'SDK_PYTHON_%s' % QcloudApi.__version__
|
||||
|
||||
def __init__(self, config):
|
||||
self.secretId = config['secretId']
|
||||
self.secretKey = config['secretKey']
|
||||
self.defaultRegion = config.get('Region', '')
|
||||
self.Version = config.get('Version', '')
|
||||
self.method = config.get('method', 'GET').upper()
|
||||
self.sign_method = config.get('SignatureMethod', 'HmacSHA1')
|
||||
self.requestHost = self.requestHost or config.get("endpoint")
|
||||
self.apiRequest = ApiRequest(self.requestHost)
|
||||
self.Token = config.get('Token', '')
|
||||
|
||||
def set_req_timeout(self, req_timeout):
|
||||
self.apiRequest.set_req_timeout(req_timeout)
|
||||
|
||||
def open_debug(self):
|
||||
self.apiRequest.set_debug(True)
|
||||
|
||||
def close_debug(self):
|
||||
self.apiRequest.set_debug(False)
|
||||
|
||||
def _build_header(self, req):
|
||||
if self.apiRequest.is_keep_alive():
|
||||
req.header["Connection"] = "Keep-Alive"
|
||||
if req.method == 'POST':
|
||||
req.header["Content-Type"] = "application/x-www-form-urlencoded"
|
||||
|
||||
def _fix_params(self, params):
|
||||
if not isinstance(params, (dict,)):
|
||||
return params
|
||||
return self._format_params(None, params)
|
||||
|
||||
def _format_params(self, prefix, params):
|
||||
d = {}
|
||||
if params is None:
|
||||
return d
|
||||
|
||||
if not isinstance(params, (tuple, list, dict)):
|
||||
d[prefix] = params
|
||||
return d
|
||||
|
||||
if isinstance(params, (list, tuple)):
|
||||
for idx, item in enumerate(params):
|
||||
if prefix:
|
||||
key = "{0}.{1}".format(prefix, idx)
|
||||
else:
|
||||
key = "{0}".format(idx)
|
||||
d.update(self._format_params(key, item))
|
||||
return d
|
||||
|
||||
if isinstance(params, dict):
|
||||
for k, v in params.items():
|
||||
if prefix:
|
||||
key = '{0}.{1}'.format(prefix, k)
|
||||
else:
|
||||
key = '{0}'.format(k)
|
||||
d.update(self._format_params(key, v))
|
||||
return d
|
||||
|
||||
raise ApiClientParamException('some params type error')
|
||||
|
||||
def _build_req_inter(self, action, params, req_inter):
|
||||
_params = copy.deepcopy(self._fix_params(params))
|
||||
_params['Action'] = action[0].upper() + action[1:]
|
||||
_params['RequestClient'] = self.version
|
||||
|
||||
if ('Region' not in _params and self.defaultRegion != ''):
|
||||
_params['Region'] = self.defaultRegion
|
||||
|
||||
if ('Version' not in _params and self.Version != ''):
|
||||
_params['Version'] = self.Version
|
||||
|
||||
if ('Token' not in _params and self.Token != ''):
|
||||
_params['Token'] = self.Token
|
||||
|
||||
if ('SecretId' not in _params):
|
||||
_params['SecretId'] = self.secretId
|
||||
|
||||
if ('Nonce' not in _params):
|
||||
_params['Nonce'] = random.randint(1, sys.maxsize)
|
||||
|
||||
if ('Timestamp' not in _params):
|
||||
_params['Timestamp'] = int(time.time())
|
||||
|
||||
if ('SignatureMethod' in _params):
|
||||
self.sign_method = _params['SignatureMethod']
|
||||
else:
|
||||
_params['SignatureMethod'] = self.sign_method
|
||||
|
||||
sign = Sign(self.secretId, self.secretKey)
|
||||
_params['Signature'] = sign.make(
|
||||
req_inter.host, req_inter.uri, _params,
|
||||
req_inter.method, self.sign_method)
|
||||
|
||||
req_inter.data = urlencode(_params)
|
||||
|
||||
self._build_header(req_inter)
|
||||
|
||||
def _check_status(self, resp_inter):
|
||||
if resp_inter.status != 200:
|
||||
raise ApiServerNetworkException(
|
||||
resp_inter.status, resp_inter.header, resp_inter.data)
|
||||
|
||||
def generateUrl(self, action, params):
|
||||
req_inter = RequestInternal(
|
||||
self.requestHost, self.method, self.requestUri)
|
||||
self._build_req_inter(action, params, req_inter)
|
||||
url = 'https://%s%s' % (req_inter.host, req_inter.uri)
|
||||
if (req_inter.method == 'GET'):
|
||||
url += '?' + req_inter.data
|
||||
return url
|
||||
|
||||
def call(self, action, params, files={}):
|
||||
req_inter = RequestInternal(
|
||||
self.requestHost, self.method, self.requestUri)
|
||||
self._build_req_inter(action, params, req_inter)
|
||||
resp_inter = self.apiRequest.send_request(req_inter)
|
||||
self._check_status(resp_inter)
|
||||
return resp_inter.data
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Batch(base.Base):
|
||||
requestHost = 'batch.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bgpip(base.Base):
|
||||
requestHost = 'bgpip.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bill(base.Base):
|
||||
requestHost = 'bill.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bm(base.Base):
|
||||
requestHost = 'bm.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bmeip(base.Base):
|
||||
requestHost = 'bmeip.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bmlb(base.Base):
|
||||
requestHost = 'bmlb.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Bmvpc(base.Base):
|
||||
requestHost = 'bmvpc.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cbs(base.Base):
|
||||
requestHost = 'cbs.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Ccr(base.Base):
|
||||
"""Cloud Container Repository
|
||||
|
||||
document: https://cloud.tencent.com/document/product/457/9427
|
||||
"""
|
||||
requestHost = 'ccr.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Ccs(base.Base):
|
||||
requestHost = 'ccs.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cdb(base.Base):
|
||||
requestHost = 'cdb.api.qcloud.com'
|
||||
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cdn(base.Base):
|
||||
requestHost = 'cdn.api.qcloud.com'
|
||||
|
||||
def UploadCdnEntity(self, params):
|
||||
action = 'UploadCdnEntity'
|
||||
if params.get('entityFile') is None:
|
||||
raise ValueError('entityFile can not be empty.')
|
||||
if os.path.isfile(params['entityFile']) is False:
|
||||
raise ValueError('entityFile is not exist.')
|
||||
|
||||
file = params.pop('entityFile')
|
||||
if 'entityFileMd5' not in params:
|
||||
content = open(file, 'rb').read()
|
||||
params['entityFileMd5'] = hashlib.md5(content).hexdigest()
|
||||
|
||||
files = {
|
||||
'entityFile': open(file, 'rb')
|
||||
}
|
||||
|
||||
return self.call(action, params, files)
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class CloudAudit(base.Base):
|
||||
requestHost = 'cloudaudit.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cmem(base.Base):
|
||||
requestHost = 'cmem.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cns(base.Base):
|
||||
requestHost = 'cns.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Cvm(base.Base):
|
||||
requestHost = 'cvm.api.qcloud.com'
|
||||
@@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Dc(base.Base):
|
||||
"""Tencent Cloud Direct Connect
|
||||
|
||||
document: https://cloud.tencent.com/document/product/216/1711
|
||||
"""
|
||||
requestHost = 'dc.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Dfw(base.Base):
|
||||
requestHost = 'dfw.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Eip(base.Base):
|
||||
requestHost = 'eip.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 1999-2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Emr(base.Base):
|
||||
"""Elastic Map Reduce.
|
||||
|
||||
document: https://cloud.tencent.com/document/product/589
|
||||
"""
|
||||
requestHost = 'emr.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Feecenter(base.Base):
|
||||
requestHost = 'feecenter.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Image(base.Base):
|
||||
requestHost = 'image.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Lb(base.Base):
|
||||
requestHost = 'lb.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Live(base.Base):
|
||||
requestHost = 'live.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Market(base.Base):
|
||||
requestHost = 'market.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Monitor(base.Base):
|
||||
requestHost = 'monitor.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Partners(base.Base):
|
||||
requestHost = 'partners.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Redis(base.Base):
|
||||
requestHost = 'redis.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Scaling(base.Base):
|
||||
requestHost = 'scaling.api.qcloud.com'
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Scf(base.Base):
|
||||
"""Serverless Cloud Function."""
|
||||
|
||||
requestHost = 'scf.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Sec(base.Base):
|
||||
requestHost = 'csec.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Snapshot(base.Base):
|
||||
requestHost = 'snapshot.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 1999-2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Sts(base.Base):
|
||||
"""Security Token Service.
|
||||
|
||||
document: https://cloud.tencent.com/document/product/598
|
||||
"""
|
||||
requestHost = 'sts.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 1999-2018 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Tbaas(base.Base):
|
||||
"""Tencent Blockchain as a Service.
|
||||
|
||||
document: https://cloud.tencent.com/document/product/663
|
||||
"""
|
||||
requestHost = 'tbaas.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Tdsql(base.Base):
|
||||
requestHost = 'tdsql.api.qcloud.com'
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Tmt(base.Base):
|
||||
"""Tencent Machine Translation.
|
||||
|
||||
document: https://cloud.tencent.com/document/product/551
|
||||
"""
|
||||
requestHost = 'tmt.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Trade(base.Base):
|
||||
requestHost = 'trade.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Vod(base.Base):
|
||||
requestHost = 'vod.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Vpc(base.Base):
|
||||
requestHost = 'vpc.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Wenzhi(base.Base):
|
||||
requestHost = 'wenzhi.api.qcloud.com'
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright 1999-2017 Tencent Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class Yunsou(base.Base):
|
||||
requestHost = 'yunsou.api.qcloud.com'
|
||||
196
venv_prod/lib/python3.12/site-packages/QcloudApi/qcloudapi.py
Normal file
196
venv_prod/lib/python3.12/site-packages/QcloudApi/qcloudapi.py
Normal file
@@ -0,0 +1,196 @@
|
||||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from QcloudApi.modules import base
|
||||
|
||||
|
||||
class QcloudApi(object):
|
||||
def __init__(self, module, config):
|
||||
self.module = module
|
||||
self.config = config
|
||||
|
||||
def _factory(self, module, config):
|
||||
if (module == 'cdb'):
|
||||
from .modules.cdb import Cdb
|
||||
service = Cdb(config)
|
||||
elif (module == 'account'):
|
||||
from .modules.account import Account
|
||||
service = Account(config)
|
||||
elif (module == 'cvm'):
|
||||
from .modules.cvm import Cvm
|
||||
service = Cvm(config)
|
||||
elif (module == 'image'):
|
||||
from .modules.image import Image
|
||||
service = Image(config)
|
||||
elif (module == 'lb'):
|
||||
from .modules.lb import Lb
|
||||
service = Lb(config)
|
||||
elif (module == 'sec'):
|
||||
from .modules.sec import Sec
|
||||
service = Sec(config)
|
||||
elif (module == 'trade'):
|
||||
from .modules.trade import Trade
|
||||
service = Trade(config)
|
||||
elif (module == 'bill'):
|
||||
from .modules.bill import Bill
|
||||
service = Bill(config)
|
||||
elif (module == 'monitor'):
|
||||
from .modules.monitor import Monitor
|
||||
service = Monitor(config)
|
||||
elif (module == 'cdn'):
|
||||
from .modules.cdn import Cdn
|
||||
service = Cdn(config)
|
||||
elif (module == 'vpc'):
|
||||
from .modules.vpc import Vpc
|
||||
service = Vpc(config)
|
||||
elif (module == 'vod'):
|
||||
from .modules.vod import Vod
|
||||
service = Vod(config)
|
||||
elif (module == 'yunsou'):
|
||||
from .modules.yunsou import Yunsou
|
||||
service = Yunsou(config)
|
||||
elif (module == 'wenzhi'):
|
||||
from .modules.wenzhi import Wenzhi
|
||||
service = Wenzhi(config)
|
||||
elif (module == 'market'):
|
||||
from .modules.market import Market
|
||||
service = Market(config)
|
||||
elif (module == 'live'):
|
||||
from .modules.live import Live
|
||||
service = Live(config)
|
||||
elif (module == 'eip'):
|
||||
from .modules.eip import Eip
|
||||
service = Eip(config)
|
||||
elif (module == 'cbs'):
|
||||
from .modules.cbs import Cbs
|
||||
service = Cbs(config)
|
||||
elif (module == 'snapshot'):
|
||||
from .modules.snapshot import Snapshot
|
||||
service = Snapshot(config)
|
||||
elif (module == 'scaling'):
|
||||
from .modules.scaling import Scaling
|
||||
service = Scaling(config)
|
||||
elif (module == 'cmem'):
|
||||
from .modules.cmem import Cmem
|
||||
service = Cmem(config)
|
||||
elif (module == 'tdsql'):
|
||||
from .modules.tdsql import Tdsql
|
||||
service = Tdsql(config)
|
||||
elif (module == 'bm'):
|
||||
from .modules.bm import Bm
|
||||
service = Bm(config)
|
||||
elif (module == 'bmlb'):
|
||||
from .modules.bmlb import Bmlb
|
||||
service = Bmlb(config)
|
||||
elif (module == 'redis'):
|
||||
from .modules.redis import Redis
|
||||
service = Redis(config)
|
||||
elif (module == 'dfw'):
|
||||
from .modules.dfw import Dfw
|
||||
service = Dfw(config)
|
||||
elif (module == 'ccs'):
|
||||
from .modules.ccs import Ccs
|
||||
service = Ccs(config)
|
||||
elif (module == 'feecenter'):
|
||||
from .modules.feecenter import Feecenter
|
||||
service = Feecenter(config)
|
||||
elif (module == 'cns'):
|
||||
from .modules.cns import Cns
|
||||
service = Cns(config)
|
||||
elif (module == 'bmeip'):
|
||||
from .modules.bmeip import Bmeip
|
||||
service = Bmeip(config)
|
||||
elif (module == 'bmvpc'):
|
||||
from .modules.bmvpc import Bmvpc
|
||||
service = Bmvpc(config)
|
||||
elif module == 'bgpip':
|
||||
from .modules.bgpip import Bgpip
|
||||
service = Bgpip(config)
|
||||
elif module == 'scf':
|
||||
from .modules.scf import Scf
|
||||
service = Scf(config)
|
||||
elif module == 'apigateway':
|
||||
from .modules.apigateway import APIGateway
|
||||
service = APIGateway(config)
|
||||
elif module == 'batch':
|
||||
from .modules.batch import Batch
|
||||
service = Batch(config)
|
||||
elif module == 'cloudaudit':
|
||||
from .modules.cloudaudit import CloudAudit
|
||||
service = CloudAudit(config)
|
||||
elif module == 'tmt':
|
||||
from .modules.tmt import Tmt
|
||||
service = Tmt(config)
|
||||
elif module == 'partners':
|
||||
from .modules.partners import Partners
|
||||
service = Partners(config)
|
||||
elif module == 'tbaas':
|
||||
from .modules.tbaas import Tbaas
|
||||
service = Tbaas(config)
|
||||
elif module == 'athena':
|
||||
from .modules.athena import Athena
|
||||
service = Athena(config)
|
||||
elif module == 'emr':
|
||||
from .modules.emr import Emr
|
||||
service = Emr(config)
|
||||
elif module == 'sts':
|
||||
from .modules.sts import Sts
|
||||
service = Sts(config)
|
||||
elif module == 'ccr':
|
||||
from .modules.ccr import Ccr
|
||||
service = Ccr(config)
|
||||
elif module == 'dc':
|
||||
from .modules.dc import Dc
|
||||
service = Dc(config)
|
||||
else:
|
||||
config.setdefault("endpoint", module + '.api.qcloud.com')
|
||||
service = base.Base(config)
|
||||
|
||||
return service
|
||||
|
||||
def setSecretId(self, secretId):
|
||||
self.config['secretId'] = secretId
|
||||
|
||||
def setSecretKey(self, secretKey):
|
||||
self.config['secretKey'] = secretKey
|
||||
|
||||
def setRequestMethod(self, method):
|
||||
self.config['method'] = method
|
||||
|
||||
def setRegion(self, region):
|
||||
self.config['Region'] = region
|
||||
|
||||
def setSignatureMethod(self, SignatureMethod):
|
||||
self.config['SignatureMethod'] = SignatureMethod
|
||||
|
||||
def generateUrl(self, action, params):
|
||||
service = self._factory(self.module, self.config)
|
||||
return service.generateUrl(action, params)
|
||||
|
||||
def call(self, action, params, req_timeout=None, debug=False):
|
||||
"""
|
||||
@type action: string
|
||||
@param action: action interface
|
||||
|
||||
@type params: dict
|
||||
@param params: interface parameters
|
||||
|
||||
@type req_timeout: int
|
||||
@param req_timeout: request timeout(seconds)
|
||||
|
||||
@type debug: bool
|
||||
@param debug: debug switch
|
||||
"""
|
||||
service = self._factory(self.module, self.config)
|
||||
if req_timeout is not None:
|
||||
service.set_req_timeout(req_timeout)
|
||||
if debug:
|
||||
service.open_debug()
|
||||
|
||||
methods = dir(service)
|
||||
for method in methods:
|
||||
if (method == action):
|
||||
func = getattr(service, action)
|
||||
return func(params)
|
||||
|
||||
return service.call(action, params)
|
||||
Reference in New Issue
Block a user