aliyun-log-python-sdk 0.9.15__tar.gz → 0.9.16__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 (129) hide show
  1. {aliyun_log_python_sdk-0.9.15/aliyun_log_python_sdk.egg-info → aliyun_log_python_sdk-0.9.16}/PKG-INFO +10 -2
  2. aliyun_log_python_sdk-0.9.16/aliyun/log/compress.py +77 -0
  3. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logclient.py +22 -44
  4. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/putlogsrequest.py +1 -1
  5. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/util.py +1 -45
  6. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/version.py +1 -1
  7. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16/aliyun_log_python_sdk.egg-info}/PKG-INFO +10 -2
  8. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun_log_python_sdk.egg-info/SOURCES.txt +1 -0
  9. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun_log_python_sdk.egg-info/requires.txt +1 -0
  10. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/setup.py +2 -1
  11. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/LICENSE +0 -0
  12. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/README.md +0 -0
  13. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/__init__.py +0 -0
  14. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/__init__.py +0 -0
  15. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/_proto_py2/__init__.py +0 -0
  16. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/_proto_py2/log_logs_pb2.py +0 -0
  17. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/_proto_py2/log_logs_raw_pb2.py +0 -0
  18. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/acl_config.py +0 -0
  19. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/acl_response.py +0 -0
  20. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/auth.py +0 -0
  21. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/common_response.py +0 -0
  22. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/__init__.py +0 -0
  23. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
  24. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/config.py +0 -0
  25. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/consumer_client.py +0 -0
  26. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/exceptions.py +0 -0
  27. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/fetched_log_group.py +0 -0
  28. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/heart_beat.py +0 -0
  29. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/shard_worker.py +0 -0
  30. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/tasks.py +0 -0
  31. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer/worker.py +0 -0
  32. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer_group_request.py +0 -0
  33. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/consumer_group_response.py +0 -0
  34. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/credentials.py +0 -0
  35. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/cursor_response.py +0 -0
  36. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/cursor_time_response.py +0 -0
  37. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/__init__.py +0 -0
  38. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
  39. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
  40. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
  41. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/migration_log.py +0 -0
  42. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/migration_manager.py +0 -0
  43. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/migration_response.py +0 -0
  44. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/migration_task.py +0 -0
  45. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/es_migration/util.py +0 -0
  46. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_config_response.py +0 -0
  47. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/__init__.py +0 -0
  48. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/config_parser.py +0 -0
  49. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/etl_util.py +0 -0
  50. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/exceptions.py +0 -0
  51. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
  52. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/runner.py +0 -0
  53. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/settings.py +0 -0
  54. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
  55. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
  56. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
  57. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
  58. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
  59. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
  60. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
  61. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
  62. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
  63. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/__init__.py +0 -0
  64. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/condition_list.py +0 -0
  65. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
  66. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/condition_util.py +0 -0
  67. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/transform_base.py +0 -0
  68. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/transform_list.py +0 -0
  69. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
  70. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/export_response.py +0 -0
  71. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/ext/__init__.py +0 -0
  72. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/ext/jupyter_magic.py +0 -0
  73. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/ext/syslogclient.py +0 -0
  74. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/external_store_config.py +0 -0
  75. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/external_store_config_response.py +0 -0
  76. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/getcontextlogsresponse.py +0 -0
  77. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/gethistogramsrequest.py +0 -0
  78. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/gethistogramsresponse.py +0 -0
  79. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/getlogsrequest.py +0 -0
  80. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/getlogsresponse.py +0 -0
  81. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/histogram.py +0 -0
  82. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/index_config.py +0 -0
  83. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/index_config_response.py +0 -0
  84. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/ingestion_response.py +0 -0
  85. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/job.py +0 -0
  86. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/listlogstoresrequest.py +0 -0
  87. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/listlogstoresresponse.py +0 -0
  88. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/listtopicsrequest.py +0 -0
  89. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/listtopicsresponse.py +0 -0
  90. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/log_logs_pb2.py +0 -0
  91. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/log_logs_raw_pb2.py +0 -0
  92. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logclient_core.py +0 -0
  93. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logclient_operator.py +0 -0
  94. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logexception.py +0 -0
  95. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logger_hanlder.py +0 -0
  96. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logitem.py +0 -0
  97. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logrequest.py +0 -0
  98. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logresponse.py +0 -0
  99. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logstore_config_response.py +0 -0
  100. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logtail_config_detail.py +0 -0
  101. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/logtail_config_response.py +0 -0
  102. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/machine_group_detail.py +0 -0
  103. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/machinegroup_response.py +0 -0
  104. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/odps_sink.py +0 -0
  105. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/oss_sink.py +0 -0
  106. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/pluralize.py +0 -0
  107. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/project_response.py +0 -0
  108. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/proto.py +0 -0
  109. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/pulllog_response.py +0 -0
  110. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/putlogsresponse.py +0 -0
  111. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/queriedlog.py +0 -0
  112. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/rebuild_index_response.py +0 -0
  113. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/resource_params.py +0 -0
  114. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/resource_response.py +0 -0
  115. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/scheduled_sql.py +0 -0
  116. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/scheduled_sql_response.py +0 -0
  117. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/shard_response.py +0 -0
  118. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/shipper_config.py +0 -0
  119. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/shipper_response.py +0 -0
  120. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/sink.py +0 -0
  121. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/sql_instance_response.py +0 -0
  122. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/substore_config_response.py +0 -0
  123. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/tag_response.py +0 -0
  124. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/topostore_params.py +0 -0
  125. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun/log/topostore_response.py +0 -0
  126. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
  127. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
  128. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/setup.cfg +0 -0
  129. {aliyun_log_python_sdk-0.9.15 → aliyun_log_python_sdk-0.9.16}/tests/test_alert.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: aliyun-log-python-sdk
3
- Version: 0.9.15
3
+ Version: 0.9.16
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
@@ -23,11 +23,19 @@ Requires-Dist: elasticsearch
23
23
  Requires-Dist: jmespath
24
24
  Requires-Dist: dateparser
25
25
  Requires-Dist: protobuf<6.0.0,>=3.20.3
26
+ Requires-Dist: lz4
26
27
  Provides-Extra: test
27
28
  Requires-Dist: pytest; extra == "test"
28
29
  Requires-Dist: lz4; extra == "test"
29
30
  Requires-Dist: virtualenv; extra == "test"
30
31
  Requires-Dist: zstandard; extra == "test"
32
+ Dynamic: author
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: home-page
36
+ Dynamic: provides-extra
37
+ Dynamic: requires-dist
38
+ Dynamic: summary
31
39
 
32
40
 
33
41
  Python SDK for Alicloud Log Service
@@ -0,0 +1,77 @@
1
+
2
+ import zlib
3
+ from enum import Enum
4
+ from .logexception import LogException
5
+ from .util import Util
6
+ import six
7
+ import lz4.block
8
+
9
+
10
+ def lz_decompress(raw_size, data):
11
+ return lz4.block.decompress(data, uncompressed_size=raw_size)
12
+
13
+
14
+ def lz_compresss(data):
15
+ return lz4.block.compress(data)[4:]
16
+
17
+
18
+ class CompressType(Enum):
19
+ UNCOMPRESSED = 1
20
+ LZ4 = 2
21
+
22
+ @staticmethod
23
+ def default_compress_type():
24
+ return CompressType.LZ4
25
+
26
+ def __str__(self):
27
+ if self == CompressType.LZ4:
28
+ return 'lz4'
29
+ return ''
30
+
31
+
32
+ class Compressor():
33
+ @staticmethod
34
+ def compress(data, compress_type):
35
+ # type: (bytes, CompressType) -> bytes
36
+ if compress_type == CompressType.LZ4:
37
+ return lz_compresss(data)
38
+
39
+ if compress_type == CompressType.UNCOMPRESSED:
40
+ return data
41
+
42
+ raise LogException('UnknownCompressType',
43
+ 'Unknown compress type: ' + compress_type)
44
+
45
+ @staticmethod
46
+ def decompress(data, raw_size, compress_type):
47
+ # type: (bytes, int, CompressType) -> bytes
48
+ if compress_type == CompressType.LZ4:
49
+ return lz_decompress(raw_size, data)
50
+
51
+ if compress_type == CompressType.UNCOMPRESSED:
52
+ return data
53
+
54
+ raise LogException('UnknownCompressType',
55
+ 'Unknown compress type: ' + compress_type)
56
+
57
+ @staticmethod
58
+ def decompress_response(header, response):
59
+ # type: (dict, bytes) -> bytes
60
+ compress_type_str = Util.h_v_td(
61
+ header, 'x-log-compresstype', '').lower()
62
+
63
+ if compress_type_str == '':
64
+ return response
65
+
66
+ raw_size = int(Util.h_v_td(header, 'x-log-bodyrawsize', 0))
67
+ if raw_size == 0:
68
+ return six.b('')
69
+
70
+ if compress_type_str == 'lz4':
71
+ return Compressor.decompress(response, raw_size, CompressType.LZ4)
72
+
73
+ if compress_type_str in ('gzip', 'deflate'):
74
+ return zlib.decompress(response)
75
+
76
+ raise LogException('UnknownCompressType', 'Unknown compress type: ' +
77
+ compress_type_str, resp_header=header, resp_body=response)
@@ -62,15 +62,13 @@ from .etl_config_response import *
62
62
  from .export_response import *
63
63
  from .common_response import *
64
64
  from .auth import *
65
+ from .compress import CompressType, Compressor
65
66
 
66
67
  logger = logging.getLogger(__name__)
67
68
 
68
69
  if six.PY3:
69
70
  xrange = range
70
71
 
71
- lz4_available = Util.is_lz4_available()
72
- if lz4_available:
73
- from .util import lz_decompress, lz_compresss
74
72
 
75
73
  CONNECTION_TIME_OUT = 120
76
74
  MAX_LIST_PAGING_SIZE = 500
@@ -384,13 +382,11 @@ class LogClient(object):
384
382
  raw_body_size = len(body)
385
383
  headers = {'x-log-bodyrawsize': str(raw_body_size), 'Content-Type': 'application/x-protobuf'}
386
384
 
387
- if compress is None or compress:
388
- if lz4_available:
389
- headers['x-log-compresstype'] = 'lz4'
390
- body = lz_compresss(body)
391
- else:
392
- headers['x-log-compresstype'] = 'deflate'
393
- body = zlib.compress(body)
385
+ need_compress = compress is None or compress
386
+ if need_compress:
387
+ compress_type = CompressType.default_compress_type()
388
+ headers['x-log-compresstype'] = str(compress_type)
389
+ body = Compressor.compress(body, compress_type)
394
390
 
395
391
  params = {}
396
392
  resource = '/logstores/' + logstore + "/shards/lb"
@@ -445,16 +441,12 @@ class LogClient(object):
445
441
  len(body) / 1024.0 / 1024))
446
442
 
447
443
  headers = {'x-log-bodyrawsize': str(len(body)), 'Content-Type': 'application/x-protobuf'}
448
- is_compress = request.get_compress()
449
-
450
- compress_data = None
451
- if is_compress:
452
- if lz4_available:
453
- headers['x-log-compresstype'] = 'lz4'
454
- compress_data = lz_compresss(body)
455
- else:
456
- headers['x-log-compresstype'] = 'deflate'
457
- compress_data = zlib.compress(body)
444
+
445
+ need_compress = request.get_compress() is None or request.get_compress()
446
+ if need_compress:
447
+ compress_type = CompressType.default_compress_type()
448
+ headers['x-log-compresstype'] = str(compress_type)
449
+ body = Compressor.compress(body, compress_type)
458
450
 
459
451
  params = {}
460
452
  logstore = request.get_logstore()
@@ -465,11 +457,7 @@ class LogClient(object):
465
457
  else:
466
458
  resource = '/logstores/' + logstore + "/shards/lb"
467
459
 
468
- if is_compress:
469
- (resp, header) = self._send('POST', project, compress_data, resource, params, headers)
470
- else:
471
- (resp, header) = self._send('POST', project, body, resource, params, headers)
472
-
460
+ (resp, header) = self._send('POST', project, body, resource, params, headers)
473
461
  return PutLogsResponse(header, resp)
474
462
 
475
463
  def list_logstores(self, request):
@@ -654,12 +642,12 @@ class LogClient(object):
654
642
  params['forward'] = forward
655
643
  body_str = six.b(json.dumps(params))
656
644
  headers["x-log-bodyrawsize"] = str(len(body_str))
657
- accept_encoding = "lz4" if lz4_available else "deflate"
645
+ accept_encoding = str(CompressType.default_compress_type())
658
646
  headers['Accept-Encoding'] = accept_encoding
659
647
 
660
648
  (resp, header) = self._send("POST", project, body_str, resource, None, headers, respons_body_type=accept_encoding)
661
649
 
662
- raw_data = Util.uncompress_response(header, resp)
650
+ raw_data = Compressor.decompress_response(header, resp)
663
651
  exJson = self._loadJson(200, header, raw_data, requestId=Util.h_v_td(header, 'x-log-requestid', ''))
664
652
  exJson = Util.convert_unicode_to_str(exJson)
665
653
  ret = GetLogsResponse(exJson, header)
@@ -1128,11 +1116,10 @@ class LogClient(object):
1128
1116
  """
1129
1117
 
1130
1118
  headers = {}
1131
- if compress is None or compress:
1132
- if lz4_available:
1133
- headers['Accept-Encoding'] = 'lz4'
1134
- else:
1135
- headers['Accept-Encoding'] = 'gzip'
1119
+
1120
+ need_compress = compress is None or compress
1121
+ if need_compress:
1122
+ headers['Accept-Encoding'] = str(CompressType.default_compress_type())
1136
1123
  else:
1137
1124
  headers['Accept-Encoding'] = ''
1138
1125
 
@@ -1155,18 +1142,9 @@ class LogClient(object):
1155
1142
  raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
1156
1143
  if raw_size <= 0:
1157
1144
  return PullLogResponse(None, header)
1158
- compress_type = Util.h_v_td(header, 'x-log-compresstype', '').lower()
1159
- if compress_type == 'lz4':
1160
- if lz4_available:
1161
- raw_data = lz_decompress(raw_size, resp)
1162
- return PullLogResponse(raw_data, header)
1163
- else:
1164
- raise LogException("ClientHasNoLz4", "There's no Lz4 lib available to decompress the response", resp_header=header, resp_body=resp)
1165
- elif compress_type in ('gzip', 'deflate'):
1166
- raw_data = zlib.decompress(resp)
1167
- return PullLogResponse(raw_data, header)
1168
- else:
1169
- return PullLogResponse(resp, header)
1145
+
1146
+ raw_data = Compressor.decompress_response(header, resp)
1147
+ return PullLogResponse(raw_data, header)
1170
1148
 
1171
1149
  def pull_log(self, project_name, logstore_name, shard_id, from_time, to_time, batch_size=None, compress=None, query=None):
1172
1150
  """ batch pull log data from log service using time-range
@@ -29,7 +29,7 @@ class PutLogsRequest(LogRequest):
29
29
  :param hashKey: put data with set hash, the data will be send to shard whose range contains the hashKey
30
30
 
31
31
  :type compress: bool
32
- :param compress: if need to compress the logs
32
+ :param compress: if need to compress the logs, default is True
33
33
 
34
34
  :type logtags: list
35
35
  :param logtags: list of key:value tag pair , [(tag_key_1,tag_value_1) , (tag_key_2,tag_value_2)]
@@ -17,27 +17,7 @@ from .logexception import LogException
17
17
  import re
18
18
  import logging
19
19
  import json
20
- import struct
21
- import zlib
22
20
 
23
- try:
24
- import lz4
25
- if hasattr(lz4, 'loads') and hasattr(lz4, 'dumps'):
26
- def lz_decompress(raw_size, data):
27
- return lz4.loads(struct.pack('<I', raw_size) + data)
28
-
29
- def lz_compresss(data):
30
- return lz4.dumps(data)[4:]
31
- else:
32
- import lz4.block
33
- def lz_decompress(raw_size, data):
34
- return lz4.block.decompress(data, uncompressed_size=raw_size)
35
-
36
- def lz_compresss(data):
37
- return lz4.block.compress(data)[4:]
38
- lz4_available = True
39
- except ImportError:
40
- lz4_available = False
41
21
 
42
22
  logger = logging.getLogger(__name__)
43
23
 
@@ -91,11 +71,6 @@ class Util(object):
91
71
  if s:
92
72
  s.close()
93
73
 
94
- @staticmethod
95
- def compress_data(data):
96
- import zlib
97
- return zlib.compress(data, 6)
98
-
99
74
  @staticmethod
100
75
  def cal_md5(content):
101
76
  return hashlib.md5(content).hexdigest().upper()
@@ -164,9 +139,6 @@ class Util(object):
164
139
 
165
140
  return data
166
141
 
167
- @staticmethod
168
- def is_lz4_available():
169
- return lz4_available
170
142
 
171
143
  @staticmethod
172
144
  def h_v_t(header, key):
@@ -208,23 +180,7 @@ class Util(object):
208
180
  else return v
209
181
  """
210
182
  return v if v is not None else default
211
-
212
- @staticmethod
213
- def uncompress_response(header, response):
214
- """
215
- Supported compress type [lz4, gzip, deflate]
216
- """
217
- compress_type = Util.h_v_td(header, 'x-log-compresstype', '').lower()
218
- if compress_type == 'lz4':
219
- raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
220
- if Util.is_lz4_available():
221
- return lz_decompress(raw_size, response)
222
- else:
223
- raise LogException("ClientHasNoLz4", "There's no Lz4 lib available to decompress the response", resp_header=header, resp_body=response)
224
- elif compress_type in ('gzip', 'deflate'):
225
- return zlib.decompress(response)
226
- else:
227
- raise LogException('UnknownCompressType', 'Unknown compress type: ' + compress_type, resp_header=header, resp_body=response)
183
+
228
184
 
229
185
  ZERO = timedelta(0)
230
186
 
@@ -1,4 +1,4 @@
1
- __version__ = '0.9.15'
1
+ __version__ = '0.9.16'
2
2
 
3
3
 
4
4
  import sys
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: aliyun-log-python-sdk
3
- Version: 0.9.15
3
+ Version: 0.9.16
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
@@ -23,11 +23,19 @@ Requires-Dist: elasticsearch
23
23
  Requires-Dist: jmespath
24
24
  Requires-Dist: dateparser
25
25
  Requires-Dist: protobuf<6.0.0,>=3.20.3
26
+ Requires-Dist: lz4
26
27
  Provides-Extra: test
27
28
  Requires-Dist: pytest; extra == "test"
28
29
  Requires-Dist: lz4; extra == "test"
29
30
  Requires-Dist: virtualenv; extra == "test"
30
31
  Requires-Dist: zstandard; extra == "test"
32
+ Dynamic: author
33
+ Dynamic: classifier
34
+ Dynamic: description
35
+ Dynamic: home-page
36
+ Dynamic: provides-extra
37
+ Dynamic: requires-dist
38
+ Dynamic: summary
31
39
 
32
40
 
33
41
  Python SDK for Alicloud Log Service
@@ -7,6 +7,7 @@ aliyun/log/acl_config.py
7
7
  aliyun/log/acl_response.py
8
8
  aliyun/log/auth.py
9
9
  aliyun/log/common_response.py
10
+ aliyun/log/compress.py
10
11
  aliyun/log/consumer_group_request.py
11
12
  aliyun/log/consumer_group_response.py
12
13
  aliyun/log/credentials.py
@@ -5,6 +5,7 @@ elasticsearch
5
5
  jmespath
6
6
  dateparser
7
7
  protobuf<6.0.0,>=3.20.3
8
+ lz4
8
9
 
9
10
  [test]
10
11
  pytest
@@ -33,6 +33,7 @@ requirements_py3 = [
33
33
  'jmespath',
34
34
  'dateparser',
35
35
  'protobuf>=3.20.3,<6.0.0',
36
+ 'lz4',
36
37
  ]
37
38
  requirements_py2 = [
38
39
  'six==1.14.0',
@@ -45,7 +46,7 @@ requirements_py2 = [
45
46
  'protobuf>3.4.0,<=3.17.3', # 3.18.0 is the last version support py2, but yanked
46
47
  'regex==2021.3.17',
47
48
  'tzlocal==2.0.0',
48
- 'lz4a==0.7.0',
49
+ 'lz4==2.2.1',
49
50
  ]
50
51
 
51
52
  test_requirements = [