aliyun-log-python-sdk 0.9.2__tar.gz → 0.9.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. {aliyun-log-python-sdk-0.9.2/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.4}/PKG-INFO +1 -1
  2. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/auth.py +24 -15
  3. aliyun-log-python-sdk-0.9.4/aliyun/log/credentials.py +33 -0
  4. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/getlogsresponse.py +13 -12
  5. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/index_config.py +1 -1
  6. aliyun-log-python-sdk-0.9.4/aliyun/log/log_logs_pb2.py +33 -0
  7. aliyun-log-python-sdk-0.9.4/aliyun/log/log_logs_raw_pb2.py +33 -0
  8. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logclient.py +20 -29
  9. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/util.py +5 -4
  10. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/version.py +1 -1
  11. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4/aliyun_log_python_sdk.egg-info}/PKG-INFO +1 -1
  12. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun_log_python_sdk.egg-info/SOURCES.txt +1 -0
  13. aliyun-log-python-sdk-0.9.2/aliyun/log/log_logs_pb2.py +0 -297
  14. aliyun-log-python-sdk-0.9.2/aliyun/log/log_logs_raw_pb2.py +0 -297
  15. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/LICENSE +0 -0
  16. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/README.md +0 -0
  17. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/__init__.py +0 -0
  18. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/__init__.py +0 -0
  19. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/acl_config.py +0 -0
  20. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/acl_response.py +0 -0
  21. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/common_response.py +0 -0
  22. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/__init__.py +0 -0
  23. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
  24. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/config.py +0 -0
  25. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/consumer_client.py +0 -0
  26. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/exceptions.py +0 -0
  27. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/fetched_log_group.py +0 -0
  28. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/heart_beat.py +0 -0
  29. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/shard_worker.py +0 -0
  30. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/tasks.py +0 -0
  31. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer/worker.py +0 -0
  32. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer_group_request.py +0 -0
  33. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/consumer_group_response.py +0 -0
  34. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/cursor_response.py +0 -0
  35. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/cursor_time_response.py +0 -0
  36. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/__init__.py +0 -0
  37. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
  38. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
  39. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
  40. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/migration_log.py +0 -0
  41. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/migration_manager.py +0 -0
  42. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/migration_response.py +0 -0
  43. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/migration_task.py +0 -0
  44. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/es_migration/util.py +0 -0
  45. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_config_response.py +0 -0
  46. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/__init__.py +0 -0
  47. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/config_parser.py +0 -0
  48. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/etl_util.py +0 -0
  49. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/exceptions.py +0 -0
  50. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
  51. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/runner.py +0 -0
  52. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/settings.py +0 -0
  53. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
  54. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
  55. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
  56. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
  57. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
  58. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
  59. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
  60. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
  61. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
  62. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/__init__.py +0 -0
  63. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/condition_list.py +0 -0
  64. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
  65. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/condition_util.py +0 -0
  66. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/transform_base.py +0 -0
  67. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/transform_list.py +0 -0
  68. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
  69. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/export_response.py +0 -0
  70. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/ext/__init__.py +0 -0
  71. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/ext/jupyter_magic.py +0 -0
  72. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/ext/syslogclient.py +0 -0
  73. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/external_store_config.py +0 -0
  74. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/external_store_config_response.py +0 -0
  75. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/getcontextlogsresponse.py +0 -0
  76. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/gethistogramsrequest.py +0 -0
  77. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/gethistogramsresponse.py +0 -0
  78. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/getlogsrequest.py +0 -0
  79. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/histogram.py +0 -0
  80. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/index_config_response.py +0 -0
  81. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/ingestion_response.py +0 -0
  82. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/job.py +0 -0
  83. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/listlogstoresrequest.py +0 -0
  84. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/listlogstoresresponse.py +0 -0
  85. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/listtopicsrequest.py +0 -0
  86. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/listtopicsresponse.py +0 -0
  87. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logclient_core.py +0 -0
  88. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logclient_operator.py +0 -0
  89. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logexception.py +0 -0
  90. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logger_hanlder.py +0 -0
  91. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logitem.py +0 -0
  92. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logrequest.py +0 -0
  93. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logresponse.py +0 -0
  94. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logstore_config_response.py +0 -0
  95. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logtail_config_detail.py +0 -0
  96. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/logtail_config_response.py +0 -0
  97. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/machine_group_detail.py +0 -0
  98. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/machinegroup_response.py +0 -0
  99. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/odps_sink.py +0 -0
  100. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/oss_sink.py +0 -0
  101. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/pluralize.py +0 -0
  102. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/project_response.py +0 -0
  103. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/pulllog_response.py +0 -0
  104. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/putlogsrequest.py +0 -0
  105. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/putlogsresponse.py +0 -0
  106. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/queriedlog.py +0 -0
  107. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/resource_params.py +0 -0
  108. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/resource_response.py +0 -0
  109. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/scheduled_sql.py +0 -0
  110. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/scheduled_sql_response.py +0 -0
  111. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/shard_response.py +0 -0
  112. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/shipper_config.py +0 -0
  113. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/shipper_response.py +0 -0
  114. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/sink.py +0 -0
  115. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/sql_instance_response.py +0 -0
  116. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/substore_config_response.py +0 -0
  117. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/tag_response.py +0 -0
  118. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/topostore_params.py +0 -0
  119. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun/log/topostore_response.py +0 -0
  120. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
  121. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun_log_python_sdk.egg-info/requires.txt +0 -0
  122. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
  123. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/setup.cfg +0 -0
  124. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/setup.py +0 -0
  125. {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.4}/tests/test_alert.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aliyun-log-python-sdk
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Aliyun log service Python client SDK
5
5
  Home-page: https://github.com/aliyun/aliyun-log-python-sdk
6
6
  Author: Aliyun
@@ -32,17 +32,16 @@ AUTH_VERSION_1 = 'v1'
32
32
  AUTH_VERSION_4 = 'v4'
33
33
 
34
34
 
35
- def make_auth(access_key_id, access_key_secret, auth_version=AUTH_VERSION_1, region=''):
35
+ def make_auth(credentials_provider, auth_version=AUTH_VERSION_1, region=''):
36
36
  if auth_version == AUTH_VERSION_4:
37
- return AuthV4(access_key_id, access_key_secret, region)
37
+ return AuthV4(credentials_provider, region)
38
38
  else:
39
- return AuthV1(access_key_id, access_key_secret)
39
+ return AuthV1(credentials_provider)
40
40
 
41
41
 
42
42
  class AuthBase(object):
43
- def __init__(self, access_key_id, access_key_secret):
44
- self.access_key_id = access_key_id
45
- self.access_key_secret = access_key_secret
43
+ def __init__(self, credentials_provider):
44
+ self.credentials_provider = credentials_provider
46
45
 
47
46
  def sign_request(self, method, resource, params, headers, body):
48
47
  pass
@@ -50,8 +49,8 @@ class AuthBase(object):
50
49
 
51
50
  class AuthV1(AuthBase):
52
51
 
53
- def __init__(self, access_key_id, access_key_secret):
54
- AuthBase.__init__(self, access_key_id, access_key_secret)
52
+ def __init__(self, credentials_provider):
53
+ AuthBase.__init__(self, credentials_provider)
55
54
 
56
55
  @staticmethod
57
56
  def _getGMT():
@@ -62,12 +61,16 @@ class AuthV1(AuthBase):
62
61
  return datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
63
62
 
64
63
  def sign_request(self, method, resource, params, headers, body):
64
+ credentials = self.credentials_provider.get_credentials()
65
+ if credentials.get_security_token():
66
+ headers['x-acs-security-token'] = credentials.get_security_token()
67
+
65
68
  headers['x-log-signaturemethod'] = 'hmac-sha1'
66
69
  headers['Date'] = self._getGMT()
67
70
 
68
71
  if body:
69
72
  headers['Content-MD5'] = Util.cal_md5(body)
70
- if not self.access_key_secret:
73
+ if not credentials.get_access_key_secret():
71
74
  return six.b('')
72
75
  content = method + '\n'
73
76
  if 'Content-MD5' in headers:
@@ -79,14 +82,14 @@ class AuthV1(AuthBase):
79
82
  content += headers['Date'] + '\n'
80
83
  content += Util.canonicalized_log_headers(headers)
81
84
  content += Util.canonicalized_resource(resource, params)
82
- signature = Util.hmac_sha1(content, self.access_key_secret)
83
- headers['Authorization'] = 'LOG ' + self.access_key_id + ':' + signature
85
+ signature = Util.hmac_sha1(content, credentials.get_access_key_secret())
86
+ headers['Authorization'] = 'LOG ' + credentials.get_access_key_id() + ':' + signature
84
87
  headers['x-log-date'] = headers['Date'] # bypass some proxy doesn't allow "Date" in header issue.
85
88
 
86
89
 
87
90
  class AuthV4(AuthBase):
88
- def __init__(self, access_key_id, access_key_secret, region):
89
- AuthBase.__init__(self, access_key_id, access_key_secret)
91
+ def __init__(self, credentials_provider, region):
92
+ AuthBase.__init__(self, credentials_provider)
90
93
  self._region = region
91
94
 
92
95
  def sign_request(self, method, resource, params, headers, body):
@@ -94,6 +97,11 @@ class AuthV4(AuthBase):
94
97
  headers['Authorization'] = self._do_sign_request(method, resource, params, headers, body, current_time)
95
98
 
96
99
  def _do_sign_request(self, method, resource, params, headers, body, current_time):
100
+ credentials = self.credentials_provider.get_credentials()
101
+
102
+ if credentials.get_security_token():
103
+ headers['x-acs-security-token'] = credentials.get_security_token()
104
+
97
105
  content_sha256 = sha256(body).hexdigest() \
98
106
  if body else 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
99
107
  headers['x-log-content-sha256'] = content_sha256
@@ -119,8 +127,9 @@ class AuthV4(AuthBase):
119
127
  + current_time + '\n' \
120
128
  + scope + '\n' \
121
129
  + sha256(canonical_request.encode('utf-8')).hexdigest()
122
- signature = self.build_sign_key(self.access_key_secret, self._region, current_date, string_to_sign)
123
- return 'SLS4-HMAC-SHA256 Credential=%s/%s,Signature=%s' % (self.access_key_id, scope, signature)
130
+ signature = self.build_sign_key(credentials.get_access_key_secret(),
131
+ self._region, current_date, string_to_sign)
132
+ return 'SLS4-HMAC-SHA256 Credential=%s/%s,Signature=%s' % (credentials.get_access_key_id(), scope, signature)
124
133
 
125
134
  @staticmethod
126
135
  def build_canonical_request(method, resource, params, canonical_headers, signed_headers, hashed_payload):
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env python
2
+ # encoding: utf-8
3
+
4
+ # Copyright (C) Alibaba Cloud Computing
5
+ # All rights reserved.
6
+
7
+ class Credentials(object):
8
+ def __init__(self, access_key_id, access_key_secret, security_token=None):
9
+ self.access_key_id = access_key_id
10
+ self.access_key_secret = access_key_secret
11
+ self.security_token = security_token
12
+
13
+ def get_access_key_id(self):
14
+ return self.access_key_id
15
+
16
+ def get_access_key_secret(self):
17
+ return self.access_key_secret
18
+
19
+ def get_security_token(self):
20
+ return self.security_token
21
+
22
+
23
+ class CredentialsProvider(object):
24
+ def get_credentials(self):
25
+ return
26
+
27
+
28
+ class StaticCredentialsProvider(CredentialsProvider):
29
+ def __init__(self, access_key_id="", access_key_secret="", security_token=""):
30
+ self.credentials = Credentials(access_key_id, access_key_secret, security_token)
31
+
32
+ def get_credentials(self):
33
+ return self.credentials
@@ -63,18 +63,19 @@ class GetLogsResponse(LogResponse):
63
63
  }
64
64
  # parse query info
65
65
  query_info_str = Util.h_v_td(header, 'x-log-query-info', '')
66
- query_info = json.loads(query_info_str)
67
- meta_dict['mode'] = Util.h_v_td(query_info, 'mode', 0)
68
- query_mode = GetLogsResponse.QueryMode(meta_dict['mode'])
69
- if query_mode in (GetLogsResponse.QueryMode.SCAN, GetLogsResponse.QueryMode.SCAN_SQL):
70
- meta_dict['scanBytes'] = Util.h_v_td(query_info, 'scanBytes', 0)
71
- if query_mode in (GetLogsResponse.QueryMode.PHRASE, GetLogsResponse.QueryMode.SCAN):
72
- scan_query_info = Util.h_v_td(query_info, 'phraseQueryInfo', dict())
73
- meta_dict['phraseQueryInfo'] = {
74
- 'scanAll': (Util.h_v_td(scan_query_info, 'scanAll', 'false') != 'false'),
75
- 'beginOffset': int(Util.h_v_td(scan_query_info, 'beginOffset', '0')),
76
- 'endOffset': int(Util.h_v_td(scan_query_info, 'endOffset', '0'))
77
- }
66
+ if query_info_str != '':
67
+ query_info = json.loads(query_info_str)
68
+ meta_dict['mode'] = Util.h_v_td(query_info, 'mode', 0)
69
+ query_mode = GetLogsResponse.QueryMode(meta_dict['mode'])
70
+ if query_mode in (GetLogsResponse.QueryMode.SCAN, GetLogsResponse.QueryMode.SCAN_SQL):
71
+ meta_dict['scanBytes'] = Util.h_v_td(query_info, 'scanBytes', 0)
72
+ if query_mode in (GetLogsResponse.QueryMode.PHRASE, GetLogsResponse.QueryMode.SCAN):
73
+ scan_query_info = Util.h_v_td(query_info, 'phraseQueryInfo', dict())
74
+ meta_dict['phraseQueryInfo'] = {
75
+ 'scanAll': (Util.h_v_td(scan_query_info, 'scanAll', 'false') != 'false'),
76
+ 'beginOffset': int(Util.h_v_td(scan_query_info, 'beginOffset', '0')),
77
+ 'endOffset': int(Util.h_v_td(scan_query_info, 'endOffset', '0'))
78
+ }
78
79
 
79
80
  return GetLogsResponse({
80
81
  "meta": meta_dict,
@@ -193,7 +193,7 @@ class IndexLineConfig(object):
193
193
  def from_json(self, json_value):
194
194
  self.token_list = json_value["token"]
195
195
  self.case_sensitive = bool(json_value.get("caseSensitive", False))
196
- self.chn = bool(json_value["caseSensitive"]) if "caseSensitive" in json_value else None
196
+ self.chn = bool(json_value["chn"]) if "chn" in json_value else None
197
197
 
198
198
 
199
199
  class IndexConfig(object):
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: log_logs.proto
4
+ """Generated protocol buffer code."""
5
+ from google.protobuf.internal import builder as _builder
6
+ from google.protobuf import descriptor as _descriptor
7
+ from google.protobuf import descriptor_pool as _descriptor_pool
8
+ from google.protobuf import symbol_database as _symbol_database
9
+ # @@protoc_insertion_point(imports)
10
+
11
+ _sym_db = _symbol_database.Default()
12
+
13
+
14
+
15
+
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0elog_logs.proto\"k\n\x03Log\x12\x0c\n\x04Time\x18\x01 \x02(\r\x12\x1e\n\x08\x43ontents\x18\x02 \x03(\x0b\x32\x0c.Log.Content\x12\x0f\n\x07Time_ns\x18\x04 \x01(\x07\x1a%\n\x07\x43ontent\x12\x0b\n\x03Key\x18\x01 \x02(\t\x12\r\n\x05Value\x18\x02 \x02(\t\"$\n\x06LogTag\x12\x0b\n\x03Key\x18\x01 \x02(\t\x12\r\n\x05Value\x18\x02 \x02(\t\"~\n\x08LogGroup\x12\x12\n\x04Logs\x18\x01 \x03(\x0b\x32\x04.Log\x12\x10\n\x08Reserved\x18\x02 \x01(\t\x12\r\n\x05Topic\x18\x03 \x01(\t\x12\x0e\n\x06Source\x18\x04 \x01(\t\x12\x13\n\x0bMachineUUID\x18\x05 \x01(\t\x12\x18\n\x07LogTags\x18\x06 \x03(\x0b\x32\x07.LogTag\",\n\x0cLogGroupList\x12\x1c\n\tLogGroups\x18\x01 \x03(\x0b\x32\t.LogGroup')
17
+
18
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'log_logs_pb2', globals())
20
+ if _descriptor._USE_C_DESCRIPTORS == False:
21
+
22
+ DESCRIPTOR._options = None
23
+ _LOG._serialized_start=18
24
+ _LOG._serialized_end=125
25
+ _LOG_CONTENT._serialized_start=88
26
+ _LOG_CONTENT._serialized_end=125
27
+ _LOGTAG._serialized_start=127
28
+ _LOGTAG._serialized_end=163
29
+ _LOGGROUP._serialized_start=165
30
+ _LOGGROUP._serialized_end=291
31
+ _LOGGROUPLIST._serialized_start=293
32
+ _LOGGROUPLIST._serialized_end=337
33
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: log_logs_raw.proto
4
+ """Generated protocol buffer code."""
5
+ from google.protobuf.internal import builder as _builder
6
+ from google.protobuf import descriptor as _descriptor
7
+ from google.protobuf import descriptor_pool as _descriptor_pool
8
+ from google.protobuf import symbol_database as _symbol_database
9
+ # @@protoc_insertion_point(imports)
10
+
11
+ _sym_db = _symbol_database.Default()
12
+
13
+
14
+
15
+
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x12log_logs_raw.proto\"q\n\x06LogRaw\x12\x0c\n\x04Time\x18\x01 \x02(\r\x12!\n\x08\x43ontents\x18\x02 \x03(\x0b\x32\x0f.LogRaw.Content\x12\x0f\n\x07Time_ns\x18\x04 \x01(\x07\x1a%\n\x07\x43ontent\x12\x0b\n\x03Key\x18\x01 \x02(\t\x12\r\n\x05Value\x18\x02 \x02(\x0c\"\'\n\tLogTagRaw\x12\x0b\n\x03Key\x18\x01 \x02(\t\x12\r\n\x05Value\x18\x02 \x02(\t\"\x87\x01\n\x0bLogGroupRaw\x12\x15\n\x04Logs\x18\x01 \x03(\x0b\x32\x07.LogRaw\x12\x10\n\x08Reserved\x18\x02 \x01(\t\x12\r\n\x05Topic\x18\x03 \x01(\t\x12\x0e\n\x06Source\x18\x04 \x01(\t\x12\x13\n\x0bMachineUUID\x18\x05 \x01(\t\x12\x1b\n\x07LogTags\x18\x06 \x03(\x0b\x32\n.LogTagRaw\"2\n\x0fLogGroupListRaw\x12\x1f\n\tLogGroups\x18\x01 \x03(\x0b\x32\x0c.LogGroupRaw')
17
+
18
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'log_logs_raw_pb2', globals())
20
+ if _descriptor._USE_C_DESCRIPTORS == False:
21
+
22
+ DESCRIPTOR._options = None
23
+ _LOGRAW._serialized_start=22
24
+ _LOGRAW._serialized_end=135
25
+ _LOGRAW_CONTENT._serialized_start=98
26
+ _LOGRAW_CONTENT._serialized_end=135
27
+ _LOGTAGRAW._serialized_start=137
28
+ _LOGTAGRAW._serialized_end=176
29
+ _LOGGROUPRAW._serialized_start=179
30
+ _LOGGROUPRAW._serialized_end=314
31
+ _LOGGROUPLISTRAW._serialized_start=316
32
+ _LOGGROUPLISTRAW._serialized_end=366
33
+ # @@protoc_insertion_point(module_scope)
@@ -12,6 +12,7 @@ import time
12
12
  import zlib
13
13
  from datetime import datetime
14
14
  import logging
15
+ from .credentials import StaticCredentialsProvider
15
16
  from .scheduled_sql import ScheduledSQLConfiguration
16
17
  from .scheduled_sql_response import *
17
18
  from itertools import cycle
@@ -46,7 +47,7 @@ from .tag_response import GetResourceTagsResponse
46
47
  from .topostore_response import *
47
48
  from .topostore_params import *
48
49
  from .util import base64_encodestring as b64e
49
- from .util import base64_encodestring as e64, base64_decodestring as d64
50
+ from .util import base64_encodestring as e64, base64_decodestring as d64, Util
50
51
  from .version import API_VERSION, USER_AGENT
51
52
 
52
53
  from .log_logs_raw_pb2 import LogGroupRaw as LogGroup
@@ -65,22 +66,9 @@ logger = logging.getLogger(__name__)
65
66
  if six.PY3:
66
67
  xrange = range
67
68
 
68
-
69
- try:
70
- import lz4
71
-
72
- if not hasattr(lz4, 'loads') or not hasattr(lz4, 'dumps'):
73
- lz4 = None
74
- else:
75
- def lz_decompress(raw_size, data):
76
- return lz4.loads(struct.pack('<I', raw_size) + data)
77
-
78
- def lz_compresss(data):
79
- return lz4.dumps(data)[4:]
80
-
81
- except ImportError:
82
- lz4 = None
83
-
69
+ lz4_available = Util.is_lz4_available()
70
+ if lz4_available:
71
+ from .util import lz_decompress, lz_compresss
84
72
 
85
73
  CONNECTION_TIME_OUT = 120
86
74
  MAX_LIST_PAGING_SIZE = 500
@@ -154,8 +142,8 @@ class LogClient(object):
154
142
  __version__ = API_VERSION
155
143
  Version = __version__
156
144
 
157
- def __init__(self, endpoint, accessKeyId, accessKey, securityToken=None, source=None,
158
- auth_version=AUTH_VERSION_1, region=''):
145
+ def __init__(self, endpoint, accessKeyId=None, accessKey=None, securityToken=None, source=None,
146
+ auth_version=AUTH_VERSION_1, region='', credentials_provider=None):
159
147
  self._isRowIp = Util.is_row_ip(endpoint)
160
148
  self._setendpoint(endpoint)
161
149
  self._accessKeyId = accessKeyId
@@ -172,7 +160,11 @@ class LogClient(object):
172
160
  self._last_refresh = 0
173
161
  self._auth_version = auth_version
174
162
  self._region = region
175
- self._auth = make_auth(accessKeyId, accessKey, auth_version, region)
163
+ if credentials_provider is not None:
164
+ self._auth = make_auth(credentials_provider, auth_version, region)
165
+ else:
166
+ self._auth = make_auth(StaticCredentialsProvider(accessKeyId, accessKey, securityToken),
167
+ auth_version, region)
176
168
  self._get_logs_v2_enabled = True
177
169
 
178
170
  def _replace_credentials(self):
@@ -185,8 +177,8 @@ class LogClient(object):
185
177
  self._last_refresh = time.time()
186
178
  for tries in range(DEFAULT_REFRESH_RETRY_COUNT + 1):
187
179
  try:
188
- self._accessKeyId, self._accessKey, self._securityToken = self._credentials_auto_refresher()
189
- self._auth = make_auth(self._accessKeyId, self._accessKey, self._auth_version, self._region)
180
+ self._auth = make_auth(StaticCredentialsProvider(self._credentials_auto_refresher()),
181
+ self._auth_version, self._region)
190
182
  except Exception as ex:
191
183
  logger.error(
192
184
  "failed to call _credentials_auto_refresher to refresh credentials, details: {0}".format(str(ex)))
@@ -390,7 +382,7 @@ class LogClient(object):
390
382
  headers = {'x-log-bodyrawsize': str(raw_body_size), 'Content-Type': 'application/x-protobuf'}
391
383
 
392
384
  if compress is None or compress:
393
- if lz4:
385
+ if lz4_available:
394
386
  headers['x-log-compresstype'] = 'lz4'
395
387
  body = lz_compresss(body)
396
388
  else:
@@ -454,7 +446,7 @@ class LogClient(object):
454
446
 
455
447
  compress_data = None
456
448
  if is_compress:
457
- if lz4:
449
+ if lz4_available:
458
450
  headers['x-log-compresstype'] = 'lz4'
459
451
  compress_data = lz_compresss(body)
460
452
  else:
@@ -659,7 +651,7 @@ class LogClient(object):
659
651
  params['forward'] = forward
660
652
  body_str = six.b(json.dumps(params))
661
653
  headers["x-log-bodyrawsize"] = str(len(body_str))
662
- accept_encoding = "lz4" if Util.is_lz4_available() else "deflate"
654
+ accept_encoding = "lz4" if lz4_available else "deflate"
663
655
  headers['Accept-Encoding'] = accept_encoding
664
656
 
665
657
  (resp, header) = self._send("POST", project, body_str, resource, None, headers, respons_body_type=accept_encoding)
@@ -949,7 +941,7 @@ class LogClient(object):
949
941
  project = request.get_project()
950
942
  resource = "/logs"
951
943
  (resp, header) = self._send("GET", project, None, resource, params, headers)
952
- return GetLogsResponse(resp, header)
944
+ return GetLogsResponse._from_v1_resp(resp, header)
953
945
 
954
946
  def get_cursor(self, project_name, logstore_name, shard_id, start_time):
955
947
  """ Get cursor from log service for batch pull logs
@@ -1134,7 +1126,7 @@ class LogClient(object):
1134
1126
 
1135
1127
  headers = {}
1136
1128
  if compress is None or compress:
1137
- if lz4:
1129
+ if lz4_available:
1138
1130
  headers['Accept-Encoding'] = 'lz4'
1139
1131
  else:
1140
1132
  headers['Accept-Encoding'] = 'gzip'
@@ -1157,11 +1149,10 @@ class LogClient(object):
1157
1149
  if end_cursor:
1158
1150
  params['end_cursor'] = end_cursor
1159
1151
  (resp, header) = self._send("GET", project_name, None, resource, params, headers, "binary")
1160
-
1161
1152
  compress_type = Util.h_v_td(header, 'x-log-compresstype', '').lower()
1162
1153
  if compress_type == 'lz4':
1163
1154
  raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
1164
- if lz4:
1155
+ if lz4_available:
1165
1156
  raw_data = lz_decompress(raw_size, resp)
1166
1157
  return PullLogResponse(raw_data, header)
1167
1158
  else:
@@ -34,9 +34,10 @@ try:
34
34
  return lz4.block.decompress(data, uncompressed_size=raw_size)
35
35
 
36
36
  def lz_compresss(data):
37
- return lz4.block.compress(data)
37
+ return lz4.block.compress(data)[4:]
38
+ lz4_available = True
38
39
  except ImportError:
39
- lz4 = None
40
+ lz4_available = False
40
41
 
41
42
  logger = logging.getLogger(__name__)
42
43
 
@@ -165,7 +166,7 @@ class Util(object):
165
166
 
166
167
  @staticmethod
167
168
  def is_lz4_available():
168
- return lz4 is not None
169
+ return lz4_available
169
170
 
170
171
  @staticmethod
171
172
  def h_v_t(header, key):
@@ -216,7 +217,7 @@ class Util(object):
216
217
  compress_type = Util.h_v_td(header, 'x-log-compresstype', '').lower()
217
218
  if compress_type == 'lz4':
218
219
  raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
219
- if lz4:
220
+ if Util.is_lz4_available():
220
221
  return lz_decompress(raw_size, response)
221
222
  else:
222
223
  raise LogException("ClientHasNoLz4", "There's no Lz4 lib available to decompress the response", resp_header=header, resp_body=response)
@@ -1,4 +1,4 @@
1
- __version__ = '0.9.2'
1
+ __version__ = '0.9.4'
2
2
 
3
3
  import sys
4
4
  OS_VERSION = str(sys.platform)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aliyun-log-python-sdk
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Aliyun log service Python client SDK
5
5
  Home-page: https://github.com/aliyun/aliyun-log-python-sdk
6
6
  Author: Aliyun
@@ -9,6 +9,7 @@ aliyun/log/auth.py
9
9
  aliyun/log/common_response.py
10
10
  aliyun/log/consumer_group_request.py
11
11
  aliyun/log/consumer_group_response.py
12
+ aliyun/log/credentials.py
12
13
  aliyun/log/cursor_response.py
13
14
  aliyun/log/cursor_time_response.py
14
15
  aliyun/log/etl_config_response.py