aliyun-log-python-sdk 0.9.2__tar.gz → 0.9.6__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.
- {aliyun-log-python-sdk-0.9.2/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.6}/PKG-INFO +1 -8
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/auth.py +24 -15
- aliyun-log-python-sdk-0.9.6/aliyun/log/credentials.py +33 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/export_response.py +10 -1
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/getlogsresponse.py +13 -12
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/index_config.py +1 -1
- aliyun-log-python-sdk-0.9.6/aliyun/log/log_logs_pb2.py +33 -0
- aliyun-log-python-sdk-0.9.6/aliyun/log/log_logs_raw_pb2.py +33 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logclient.py +46 -31
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/pulllog_response.py +3 -2
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/util.py +5 -4
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/version.py +1 -1
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6/aliyun_log_python_sdk.egg-info}/PKG-INFO +1 -8
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun_log_python_sdk.egg-info/SOURCES.txt +2 -2
- aliyun-log-python-sdk-0.9.2/aliyun/log/log_logs_pb2.py +0 -297
- aliyun-log-python-sdk-0.9.2/aliyun/log/log_logs_raw_pb2.py +0 -297
- aliyun-log-python-sdk-0.9.2/tests/test_alert.py +0 -30
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/LICENSE +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/README.md +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/acl_config.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/acl_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/common_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/config.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/consumer_client.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/fetched_log_group.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/heart_beat.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/shard_worker.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/tasks.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer/worker.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer_group_request.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/consumer_group_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/cursor_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/cursor_time_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/migration_log.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/migration_manager.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/migration_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/migration_task.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/es_migration/util.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/etl_util.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/runner.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/settings.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/condition_list.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/condition_util.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/transform_base.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/transform_list.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/ext/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/ext/jupyter_magic.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/ext/syslogclient.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/external_store_config.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/external_store_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/getcontextlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/gethistogramsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/gethistogramsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/getlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/histogram.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/index_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/ingestion_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/job.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/listlogstoresrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/listlogstoresresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/listtopicsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/listtopicsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logclient_core.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logclient_operator.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logexception.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logger_hanlder.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logitem.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logstore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logtail_config_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/logtail_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/machine_group_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/machinegroup_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/odps_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/oss_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/pluralize.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/project_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/putlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/putlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/queriedlog.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/resource_params.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/resource_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/scheduled_sql.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/scheduled_sql_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/shard_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/shipper_config.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/shipper_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/sink.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/sql_instance_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/substore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/tag_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/topostore_params.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun/log/topostore_response.py +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun_log_python_sdk.egg-info/requires.txt +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/setup.cfg +0 -0
- {aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6}/setup.py +0 -0
{aliyun-log-python-sdk-0.9.2/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.6}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aliyun-log-python-sdk
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.6
|
|
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
|
|
@@ -16,13 +16,6 @@ Classifier: Programming Language :: Python :: 3.6
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.7
|
|
17
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: six
|
|
20
|
-
Requires-Dist: requests
|
|
21
|
-
Requires-Dist: python-dateutil
|
|
22
|
-
Requires-Dist: elasticsearch
|
|
23
|
-
Requires-Dist: jmespath
|
|
24
|
-
Requires-Dist: dateparser
|
|
25
|
-
Requires-Dist: protobuf<4.0.0,>3.4.0
|
|
26
19
|
|
|
27
20
|
|
|
28
21
|
Python SDK for Alicloud Log Service
|
|
@@ -32,17 +32,16 @@ AUTH_VERSION_1 = 'v1'
|
|
|
32
32
|
AUTH_VERSION_4 = 'v4'
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def make_auth(
|
|
35
|
+
def make_auth(credentials_provider, auth_version=AUTH_VERSION_1, region=''):
|
|
36
36
|
if auth_version == AUTH_VERSION_4:
|
|
37
|
-
return AuthV4(
|
|
37
|
+
return AuthV4(credentials_provider, region)
|
|
38
38
|
else:
|
|
39
|
-
return AuthV1(
|
|
39
|
+
return AuthV1(credentials_provider)
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class AuthBase(object):
|
|
43
|
-
def __init__(self,
|
|
44
|
-
self.
|
|
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,
|
|
54
|
-
AuthBase.__init__(self,
|
|
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
|
|
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,
|
|
83
|
-
headers['Authorization'] = 'LOG ' +
|
|
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,
|
|
89
|
-
AuthBase.__init__(self,
|
|
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(
|
|
123
|
-
|
|
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
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
from .logresponse import LogResponse
|
|
9
9
|
from .util import Util
|
|
10
10
|
|
|
11
|
-
__all__ = ['CreateExportResponse', 'DeleteExportResponse', 'GetExportResponse', 'ListExportResponse']
|
|
11
|
+
__all__ = ['CreateExportResponse', 'DeleteExportResponse', 'GetExportResponse', 'ListExportResponse', 'UpdateExportResponse']
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
class CreateExportResponse(LogResponse):
|
|
@@ -32,6 +32,15 @@ class DeleteExportResponse(LogResponse):
|
|
|
32
32
|
print('headers:', self.get_all_headers())
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
class UpdateExportResponse(LogResponse):
|
|
36
|
+
def __init__(self, header, resp=''):
|
|
37
|
+
LogResponse.__init__(self, header, resp)
|
|
38
|
+
|
|
39
|
+
def log_print(self):
|
|
40
|
+
print('UpdateExportResponse:')
|
|
41
|
+
print('headers:', self.get_all_headers())
|
|
42
|
+
|
|
43
|
+
|
|
35
44
|
class GetExportResponse(LogResponse):
|
|
36
45
|
""" The response of the get_export API from log.
|
|
37
46
|
|
|
@@ -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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
'
|
|
75
|
-
|
|
76
|
-
|
|
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["
|
|
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
|
-
|
|
70
|
-
import
|
|
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
|
-
|
|
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.
|
|
189
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1129
|
+
if lz4_available:
|
|
1138
1130
|
headers['Accept-Encoding'] = 'lz4'
|
|
1139
1131
|
else:
|
|
1140
1132
|
headers['Accept-Encoding'] = 'gzip'
|
|
@@ -1157,11 +1149,12 @@ 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
|
-
|
|
1152
|
+
raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
|
|
1153
|
+
if raw_size <= 0:
|
|
1154
|
+
return PullLogResponse(None, header)
|
|
1161
1155
|
compress_type = Util.h_v_td(header, 'x-log-compresstype', '').lower()
|
|
1162
1156
|
if compress_type == 'lz4':
|
|
1163
|
-
|
|
1164
|
-
if lz4:
|
|
1157
|
+
if lz4_available:
|
|
1165
1158
|
raw_data = lz_decompress(raw_size, resp)
|
|
1166
1159
|
return PullLogResponse(raw_data, header)
|
|
1167
1160
|
else:
|
|
@@ -5082,7 +5075,7 @@ class LogClient(object):
|
|
|
5082
5075
|
:type project_name: string
|
|
5083
5076
|
:param project_name: the Project name
|
|
5084
5077
|
|
|
5085
|
-
:type export:
|
|
5078
|
+
:type export: Export
|
|
5086
5079
|
:param export: the export job configuration
|
|
5087
5080
|
"""
|
|
5088
5081
|
params = {}
|
|
@@ -5117,6 +5110,28 @@ class LogClient(object):
|
|
|
5117
5110
|
(resp, header) = self._send("DELETE", project_name, None, resource, params, headers)
|
|
5118
5111
|
return DeleteExportResponse(header, resp)
|
|
5119
5112
|
|
|
5113
|
+
def update_export(self, project_name, job_name, export):
|
|
5114
|
+
""" Update and Restart an export job
|
|
5115
|
+
Unsuccessful opertaion will cause an LogException.
|
|
5116
|
+
|
|
5117
|
+
:type project_name: string
|
|
5118
|
+
:param project_name: the Project name
|
|
5119
|
+
|
|
5120
|
+
:type job_name: string
|
|
5121
|
+
:param job_name: the job name of export job
|
|
5122
|
+
|
|
5123
|
+
:type export: string
|
|
5124
|
+
:param export: the export job configuration
|
|
5125
|
+
"""
|
|
5126
|
+
if not isinstance(export, str):
|
|
5127
|
+
raise TypeError("export type must be string")
|
|
5128
|
+
params = {"action": "RESTART"}
|
|
5129
|
+
body = six.b(export)
|
|
5130
|
+
headers = {'Content-Type': 'application/json', 'x-log-bodyrawsize': str(len(body))}
|
|
5131
|
+
resource = "/jobs/" + job_name
|
|
5132
|
+
(resp, header) = self._send("PUT", project_name, body, resource, params, headers)
|
|
5133
|
+
return UpdateExportResponse(header, resp)
|
|
5134
|
+
|
|
5120
5135
|
def get_export(self, project_name, job_name):
|
|
5121
5136
|
""" get export
|
|
5122
5137
|
Unsuccessful operation will cause an LogException.
|
|
@@ -29,13 +29,14 @@ class PullLogResponse(LogResponse):
|
|
|
29
29
|
def __init__(self, resp, header):
|
|
30
30
|
LogResponse.__init__(self, header, resp)
|
|
31
31
|
self._is_bytes_type = None
|
|
32
|
-
self.next_cursor = Util.convert_unicode_to_str(Util.h_v_t(header, "x-log-cursor"))
|
|
33
32
|
self.log_count = int(Util.h_v_t(header, "x-log-count"))
|
|
34
33
|
self.raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
|
|
34
|
+
self.next_cursor = Util.convert_unicode_to_str(Util.h_v_t(header, "x-log-cursor"))
|
|
35
35
|
self.raw_log_group_count_before_query = int(Util.h_v_td(self.headers, 'x-log-rawdatacount', '-1'))
|
|
36
36
|
self.raw_size_before_query = int(Util.h_v_td(self.headers, 'x-log-rawdatasize', '-1'))
|
|
37
37
|
self.loggroup_list = LogGroupList()
|
|
38
|
-
|
|
38
|
+
if resp is not None:
|
|
39
|
+
self._parse_loggroup_list(resp)
|
|
39
40
|
self.loggroup_list_json = None
|
|
40
41
|
self.flatten_logs_json = None
|
|
41
42
|
self._body = None
|
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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)
|
{aliyun-log-python-sdk-0.9.2 → aliyun-log-python-sdk-0.9.6/aliyun_log_python_sdk.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: aliyun-log-python-sdk
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.6
|
|
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
|
|
@@ -16,13 +16,6 @@ Classifier: Programming Language :: Python :: 3.6
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.7
|
|
17
17
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: six
|
|
20
|
-
Requires-Dist: requests
|
|
21
|
-
Requires-Dist: python-dateutil
|
|
22
|
-
Requires-Dist: elasticsearch
|
|
23
|
-
Requires-Dist: jmespath
|
|
24
|
-
Requires-Dist: dateparser
|
|
25
|
-
Requires-Dist: protobuf<4.0.0,>3.4.0
|
|
26
19
|
|
|
27
20
|
|
|
28
21
|
Python SDK for Alicloud Log Service
|
|
@@ -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
|
|
@@ -116,5 +117,4 @@ aliyun_log_python_sdk.egg-info/PKG-INFO
|
|
|
116
117
|
aliyun_log_python_sdk.egg-info/SOURCES.txt
|
|
117
118
|
aliyun_log_python_sdk.egg-info/dependency_links.txt
|
|
118
119
|
aliyun_log_python_sdk.egg-info/requires.txt
|
|
119
|
-
aliyun_log_python_sdk.egg-info/top_level.txt
|
|
120
|
-
tests/test_alert.py
|
|
120
|
+
aliyun_log_python_sdk.egg-info/top_level.txt
|