Skip to content

Commit

Permalink
sync from qcloudapi sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
zqfan committed Jul 2, 2018
1 parent 0919533 commit 97a404b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 44 deletions.
2 changes: 1 addition & 1 deletion QcloudApi/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.14'
__version__ = '2.0.15'
1 change: 1 addition & 0 deletions QcloudApi/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, config):
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', '')

Expand Down
19 changes: 0 additions & 19 deletions QcloudApi/modules/cdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,3 @@ def UploadCdnEntity(self, params):
}

return self.call(action, params, files)


def main():
config = {
'Region': 'gz',
'secretId': '你的secretId',
'secretKey': '你的secretKey',
'method': 'post'
}
params = {
'entityFileName': '/test.txt',
'entityFile': '/tmp/test.txt'
}
service = Cdn(config)
print(service.UploadCdnEntity(params))


if (__name__ == '__main__'):
main()
29 changes: 5 additions & 24 deletions QcloudApi/qcloudapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-

from QcloudApi.modules import base


class QcloudApi(object):
def __init__(self, module, config):
Expand Down Expand Up @@ -141,7 +143,8 @@ def _factory(self, module, config):
from .modules.dc import Dc
service = Dc(config)
else:
raise ValueError('module not exists')
config.setdefault("endpoint", module + '.api.qcloud.com')
service = base.Base(config)

return service

Expand All @@ -155,7 +158,7 @@ def setRequestMethod(self, method):
self.config['method'] = method

def setRegion(self, region):
self.config['region'] = region
self.config['Region'] = region

def setSignatureMethod(self, SignatureMethod):
self.config['SignatureMethod'] = SignatureMethod
Expand Down Expand Up @@ -191,25 +194,3 @@ def call(self, action, params, req_timeout=None, debug=False):
return func(params)

return service.call(action, params)


def main():
module = 'cdn'
action = 'UploadCdnEntity'
config = {
'Region': 'gz',
'secretId': '你的secretId',
'secretKey': '你的secretKey',
'method': 'post'
}
params = {
'entityFileName': '/test_____don.html',
'entityFile': 'c:/xampp/htdocs/index.html'
}
service = QcloudApi(module, config)
print(('URL:\n' + service.generateUrl(action, params)))
print((service.call(action, params)))


if (__name__ == '__main__'):
main()

0 comments on commit 97a404b

Please sign in to comment.