aliyun-log-python-sdk 0.9.1__tar.gz → 0.9.3__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.1/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.3}/PKG-INFO +1 -1
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/auth.py +24 -15
- aliyun-log-python-sdk-0.9.3/aliyun/log/credentials.py +33 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/gethistogramsrequest.py +21 -2
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/getlogsresponse.py +35 -35
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/index_config.py +1 -1
- aliyun-log-python-sdk-0.9.3/aliyun/log/log_logs_pb2.py +33 -0
- aliyun-log-python-sdk-0.9.3/aliyun/log/log_logs_raw_pb2.py +33 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logclient.py +13 -6
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/version.py +1 -1
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3/aliyun_log_python_sdk.egg-info}/PKG-INFO +1 -1
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun_log_python_sdk.egg-info/SOURCES.txt +1 -0
- aliyun-log-python-sdk-0.9.1/aliyun/log/log_logs_pb2.py +0 -297
- aliyun-log-python-sdk-0.9.1/aliyun/log/log_logs_raw_pb2.py +0 -297
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/LICENSE +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/README.md +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/acl_config.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/acl_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/common_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/config.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/consumer_client.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/fetched_log_group.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/heart_beat.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/shard_worker.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/tasks.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer/worker.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer_group_request.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/consumer_group_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/cursor_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/cursor_time_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/migration_log.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/migration_manager.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/migration_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/migration_task.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/es_migration/util.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/etl_util.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/runner.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/settings.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/condition_list.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/condition_util.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/transform_base.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/transform_list.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/export_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/ext/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/ext/jupyter_magic.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/ext/syslogclient.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/external_store_config.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/external_store_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/getcontextlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/gethistogramsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/getlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/histogram.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/index_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/ingestion_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/job.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/listlogstoresrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/listlogstoresresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/listtopicsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/listtopicsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logclient_core.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logclient_operator.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logexception.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logger_hanlder.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logitem.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logstore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logtail_config_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/logtail_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/machine_group_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/machinegroup_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/odps_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/oss_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/pluralize.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/project_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/pulllog_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/putlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/putlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/queriedlog.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/resource_params.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/resource_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/scheduled_sql.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/scheduled_sql_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/shard_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/shipper_config.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/shipper_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/sink.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/sql_instance_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/substore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/tag_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/topostore_params.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/topostore_response.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/util.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun_log_python_sdk.egg-info/requires.txt +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/setup.cfg +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/setup.py +0 -0
- {aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/tests/test_alert.py +0 -0
|
@@ -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
|
{aliyun-log-python-sdk-0.9.1 → aliyun-log-python-sdk-0.9.3}/aliyun/log/gethistogramsrequest.py
RENAMED
|
@@ -33,9 +33,12 @@ class GetHistogramsRequest(LogRequest):
|
|
|
33
33
|
|
|
34
34
|
:type to_time_nano_part: int
|
|
35
35
|
:param to_time_nano_part: nano part of query end time
|
|
36
|
+
|
|
37
|
+
:type shard_id: int
|
|
38
|
+
:param shard_id: specific shard id,-1 means all shard
|
|
36
39
|
"""
|
|
37
40
|
|
|
38
|
-
def __init__(self, project=None, logstore=None, fromTime=None, toTime=None, topic=None, query=None, accurate_query=True, from_time_nano_part=0
|
|
41
|
+
def __init__(self, project=None, logstore=None, fromTime=None, toTime=None, topic=None, query=None, accurate_query=True, from_time_nano_part=0, to_time_nano_part=0, shard_id=-1):
|
|
39
42
|
LogRequest.__init__(self, project)
|
|
40
43
|
self.logstore = logstore
|
|
41
44
|
self.fromTime = parse_timestamp(fromTime)
|
|
@@ -45,6 +48,7 @@ class GetHistogramsRequest(LogRequest):
|
|
|
45
48
|
self.accurate_query = accurate_query
|
|
46
49
|
self.from_time_nano_part = from_time_nano_part
|
|
47
50
|
self.to_time_nano_part = to_time_nano_part
|
|
51
|
+
self.shard_id = shard_id
|
|
48
52
|
|
|
49
53
|
def get_logstore(self):
|
|
50
54
|
""" Get logstore name
|
|
@@ -162,4 +166,19 @@ class GetHistogramsRequest(LogRequest):
|
|
|
162
166
|
:type to_time_nano_part: int
|
|
163
167
|
:param to_time_nano_part: to_time_nano_part part of query end time
|
|
164
168
|
"""
|
|
165
|
-
self.to_time_nano_part = to_time_nano_part
|
|
169
|
+
self.to_time_nano_part = to_time_nano_part
|
|
170
|
+
|
|
171
|
+
def set_shard_id(self, shard_id):
|
|
172
|
+
""" Set request shard_id
|
|
173
|
+
|
|
174
|
+
:type shard_id: int
|
|
175
|
+
:param shard_id: user defined shard_id
|
|
176
|
+
"""
|
|
177
|
+
self.shard_id = shard_id
|
|
178
|
+
|
|
179
|
+
def get_shard_id(self):
|
|
180
|
+
""" Get request shard_id
|
|
181
|
+
|
|
182
|
+
:return: int, shard_id
|
|
183
|
+
"""
|
|
184
|
+
return self.shard_id
|
|
@@ -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,
|
|
@@ -267,15 +268,15 @@ class GetLogsResponse(LogResponse):
|
|
|
267
268
|
|
|
268
269
|
:return: bool, true if this logs query is completed
|
|
269
270
|
"""
|
|
270
|
-
return self.
|
|
271
|
+
return self.get_progress() == 'Complete'
|
|
271
272
|
|
|
272
273
|
def merge(self, other):
|
|
273
274
|
""" merge with other GetLogsResponseMeta
|
|
274
275
|
|
|
275
276
|
"""
|
|
276
|
-
self._progress = other.
|
|
277
|
-
self._count += other.
|
|
278
|
-
self._processed_rows += other.
|
|
277
|
+
self._progress = other.get_progress()
|
|
278
|
+
self._count += other.get_count()
|
|
279
|
+
self._processed_rows += other.get_processed_rows()
|
|
279
280
|
return self
|
|
280
281
|
|
|
281
282
|
def get_count(self):
|
|
@@ -288,23 +289,22 @@ class GetLogsResponse(LogResponse):
|
|
|
288
289
|
def _to_dict(self):
|
|
289
290
|
""" to Dict
|
|
290
291
|
"""
|
|
291
|
-
phrase_query_info =
|
|
292
|
-
|
|
293
|
-
phrase_query_info = self._phrase_query_info._to_dict()
|
|
292
|
+
phrase_query_info = self.get_phrase_query_info()
|
|
293
|
+
phrase_query_info_dict = phrase_query_info._to_dict() if phrase_query_info is not None else None
|
|
294
294
|
|
|
295
295
|
return {
|
|
296
|
-
'count': self.
|
|
297
|
-
'progress': self.
|
|
298
|
-
'processedRows': self.
|
|
299
|
-
'elapsedMillisecond': self.
|
|
300
|
-
'hasSQL': self.
|
|
301
|
-
'whereQuery': self.
|
|
302
|
-
'aggQuery': self.
|
|
303
|
-
'cpuSec': self.
|
|
304
|
-
'cpuCores': self.
|
|
305
|
-
'mode': self.
|
|
306
|
-
'scanBytes': self.
|
|
307
|
-
'phraseQueryInfo':
|
|
296
|
+
'count': self.get_count(),
|
|
297
|
+
'progress': self.get_progress(),
|
|
298
|
+
'processedRows': self.get_processed_rows(),
|
|
299
|
+
'elapsedMillisecond': self.get_elapsed_millisecond(),
|
|
300
|
+
'hasSQL': self.get_has_sql(),
|
|
301
|
+
'whereQuery': self.get_where_query(),
|
|
302
|
+
'aggQuery': self.get_agg_query(),
|
|
303
|
+
'cpuSec': self.get_cpu_sec(),
|
|
304
|
+
'cpuCores': self.get_cpu_cores(),
|
|
305
|
+
'mode': self.get_mode(),
|
|
306
|
+
'scanBytes': self.get_scan_bytes(),
|
|
307
|
+
'phraseQueryInfo': phrase_query_info_dict,
|
|
308
308
|
# 'limited': self._limited,
|
|
309
309
|
# 'processedBytes': self._processed_bytes,
|
|
310
310
|
# 'telementryType': self._telemetry_type, # not typo
|
|
@@ -515,10 +515,10 @@ class GetLogsResponse(LogResponse):
|
|
|
515
515
|
""" to Dict
|
|
516
516
|
"""
|
|
517
517
|
return {
|
|
518
|
-
"beginOffset": self.
|
|
519
|
-
"endOffset": self.
|
|
520
|
-
"scanAll": self.
|
|
521
|
-
"endTime": self.
|
|
518
|
+
"beginOffset": self.get_begin_offset(),
|
|
519
|
+
"endOffset": self.get_end_offset(),
|
|
520
|
+
"scanAll": self.get_scan_all(),
|
|
521
|
+
"endTime": self.get_end_time()
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
def log_print(self):
|
|
@@ -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
|
|
@@ -154,8 +155,8 @@ class LogClient(object):
|
|
|
154
155
|
__version__ = API_VERSION
|
|
155
156
|
Version = __version__
|
|
156
157
|
|
|
157
|
-
def __init__(self, endpoint, accessKeyId, accessKey, securityToken=None, source=None,
|
|
158
|
-
auth_version=AUTH_VERSION_1, region=''):
|
|
158
|
+
def __init__(self, endpoint, accessKeyId=None, accessKey=None, securityToken=None, source=None,
|
|
159
|
+
auth_version=AUTH_VERSION_1, region='', credentials_provider=None):
|
|
159
160
|
self._isRowIp = Util.is_row_ip(endpoint)
|
|
160
161
|
self._setendpoint(endpoint)
|
|
161
162
|
self._accessKeyId = accessKeyId
|
|
@@ -172,7 +173,11 @@ class LogClient(object):
|
|
|
172
173
|
self._last_refresh = 0
|
|
173
174
|
self._auth_version = auth_version
|
|
174
175
|
self._region = region
|
|
175
|
-
|
|
176
|
+
if credentials_provider is not None:
|
|
177
|
+
self._auth = make_auth(credentials_provider, auth_version, region)
|
|
178
|
+
else:
|
|
179
|
+
self._auth = make_auth(StaticCredentialsProvider(accessKeyId, accessKey, securityToken),
|
|
180
|
+
auth_version, region)
|
|
176
181
|
self._get_logs_v2_enabled = True
|
|
177
182
|
|
|
178
183
|
def _replace_credentials(self):
|
|
@@ -185,8 +190,8 @@ class LogClient(object):
|
|
|
185
190
|
self._last_refresh = time.time()
|
|
186
191
|
for tries in range(DEFAULT_REFRESH_RETRY_COUNT + 1):
|
|
187
192
|
try:
|
|
188
|
-
self.
|
|
189
|
-
|
|
193
|
+
self._auth = make_auth(StaticCredentialsProvider(self._credentials_auto_refresher()),
|
|
194
|
+
self._auth_version, self._region)
|
|
190
195
|
except Exception as ex:
|
|
191
196
|
logger.error(
|
|
192
197
|
"failed to call _credentials_auto_refresher to refresh credentials, details: {0}".format(str(ex)))
|
|
@@ -545,6 +550,8 @@ class LogClient(object):
|
|
|
545
550
|
params['accurate'] = request.get_accurate_query()
|
|
546
551
|
params['fromNs'] = request.get_from_time_nano_part()
|
|
547
552
|
params['toNs'] = request.get_to_time_nano_part()
|
|
553
|
+
if request.get_shard_id() != -1:
|
|
554
|
+
params['shard'] = request.get_shard_id()
|
|
548
555
|
params['type'] = 'histogram'
|
|
549
556
|
logstore = request.get_logstore()
|
|
550
557
|
project = request.get_project()
|
|
@@ -947,7 +954,7 @@ class LogClient(object):
|
|
|
947
954
|
project = request.get_project()
|
|
948
955
|
resource = "/logs"
|
|
949
956
|
(resp, header) = self._send("GET", project, None, resource, params, headers)
|
|
950
|
-
return GetLogsResponse(resp, header)
|
|
957
|
+
return GetLogsResponse._from_v1_resp(resp, header)
|
|
951
958
|
|
|
952
959
|
def get_cursor(self, project_name, logstore_name, shard_id, start_time):
|
|
953
960
|
""" Get cursor from log service for batch pull logs
|
|
@@ -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
|