aliyun-log-python-sdk 0.9.0__tar.gz → 0.9.1__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.0/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.1}/PKG-INFO +8 -1
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/consumer_client.py +1 -1
- aliyun-log-python-sdk-0.9.1/aliyun/log/getlogsresponse.py +568 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient.py +25 -7
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/queriedlog.py +22 -1
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/util.py +48 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/version.py +1 -1
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1/aliyun_log_python_sdk.egg-info}/PKG-INFO +8 -1
- aliyun-log-python-sdk-0.9.0/aliyun/log/getlogsresponse.py +0 -203
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/LICENSE +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/README.md +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/acl_config.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/acl_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/auth.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/common_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/config.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/fetched_log_group.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/heart_beat.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/shard_worker.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/tasks.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/worker.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer_group_request.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer_group_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/cursor_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/cursor_time_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_log.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_manager.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_task.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/util.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/etl_util.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/exceptions.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/runner.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/settings.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_list.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_util.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_base.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_list.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/export_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/__init__.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/jupyter_magic.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/syslogclient.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/external_store_config.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/external_store_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/getcontextlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/gethistogramsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/gethistogramsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/getlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/histogram.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/index_config.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/index_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ingestion_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/job.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listlogstoresrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listlogstoresresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listtopicsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listtopicsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/log_logs_pb2.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/log_logs_raw_pb2.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient_core.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient_operator.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logexception.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logger_hanlder.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logitem.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logstore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logtail_config_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logtail_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/machine_group_detail.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/machinegroup_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/odps_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/oss_sink.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/pluralize.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/project_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/pulllog_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/putlogsrequest.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/putlogsresponse.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/resource_params.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/resource_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/scheduled_sql.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/scheduled_sql_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shard_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shipper_config.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shipper_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/sink.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/sql_instance_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/substore_config_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/tag_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/topostore_params.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/topostore_response.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/SOURCES.txt +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/requires.txt +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/setup.cfg +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/setup.py +0 -0
- {aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/tests/test_alert.py +0 -0
{aliyun-log-python-sdk-0.9.0/aliyun_log_python_sdk.egg-info → aliyun-log-python-sdk-0.9.1}/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.1
|
|
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,6 +16,13 @@ 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
|
|
19
26
|
|
|
20
27
|
|
|
21
28
|
Python SDK for Alicloud Log Service
|
{aliyun-log-python-sdk-0.9.0 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/consumer_client.py
RENAMED
|
@@ -27,7 +27,7 @@ class ConsumerClient(object):
|
|
|
27
27
|
from .. import LogClient
|
|
28
28
|
|
|
29
29
|
self.mclient = LogClient(endpoint, access_key_id, access_key, security_token, auth_version=auth_version, region=region)
|
|
30
|
-
self.mclient.set_user_agent('%s-consumergroup-%s' % (USER_AGENT, consumer_group))
|
|
30
|
+
self.mclient.set_user_agent('%s-consumergroup-%s-%s' % (USER_AGENT, consumer_group, consumer))
|
|
31
31
|
if credentials_refresher is not None:
|
|
32
32
|
self.mclient.set_credentials_auto_refresher(credentials_refresher)
|
|
33
33
|
self.mproject = project
|
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
# Copyright (C) Alibaba Cloud Computing
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
|
|
7
|
+
from .logresponse import LogResponse
|
|
8
|
+
from .queriedlog import QueriedLog
|
|
9
|
+
from .logexception import LogException
|
|
10
|
+
from .util import Util
|
|
11
|
+
from enum import Enum
|
|
12
|
+
import json
|
|
13
|
+
|
|
14
|
+
class GetLogsResponse(LogResponse):
|
|
15
|
+
""" The response of the GetLog API from log.
|
|
16
|
+
|
|
17
|
+
:type resp: dict
|
|
18
|
+
:param resp: GetLogsResponse HTTP response body
|
|
19
|
+
|
|
20
|
+
:type header: dict
|
|
21
|
+
:param header: GetLogsResponse HTTP response header
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
class QueryMode(Enum):
|
|
25
|
+
""" The enum of query type"""
|
|
26
|
+
NORMAL = 0
|
|
27
|
+
PHRASE = 1
|
|
28
|
+
SCAN = 2
|
|
29
|
+
SCAN_SQL = 3
|
|
30
|
+
|
|
31
|
+
def __init__(self, resp, header):
|
|
32
|
+
LogResponse.__init__(self, header, resp)
|
|
33
|
+
try:
|
|
34
|
+
self._meta = GetLogsResponse.GetLogsResponseMeta(
|
|
35
|
+
resp.get("meta"))
|
|
36
|
+
self._logs = []
|
|
37
|
+
for log in resp["data"]:
|
|
38
|
+
self._logs.append(QueriedLog._from_dict(log))
|
|
39
|
+
|
|
40
|
+
except Exception as ex:
|
|
41
|
+
raise LogException("InvalidResponse",
|
|
42
|
+
"Failed to parse GetLogResponse, \nheader: "
|
|
43
|
+
+ str(header) + " \nBody:"
|
|
44
|
+
+ str(resp) + " \nOther: " + str(ex),
|
|
45
|
+
resp_header=header,
|
|
46
|
+
resp_body=resp)
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def _from_v1_resp(resp, header):
|
|
50
|
+
"""
|
|
51
|
+
Support old api with best effort
|
|
52
|
+
"""
|
|
53
|
+
meta_dict = {
|
|
54
|
+
'count': len(resp),
|
|
55
|
+
'progress': Util.h_v_t(header, 'x-log-progress'),
|
|
56
|
+
'processedRows': int(Util.h_v_td(header, 'x-log-processed-rows', '0')),
|
|
57
|
+
'elapsedMillisecond': int(Util.h_v_td(header, 'x-log-elapsed-millisecond', '0')),
|
|
58
|
+
'hasSQL': (Util.h_v_td(header, 'x-log-has-sql', 'false') != 'false'),
|
|
59
|
+
'whereQuery': Util.h_v_td(header, 'x-log-where-query', ''),
|
|
60
|
+
'aggQuery': Util.h_v_td(header, 'x-log-agg-query', ''),
|
|
61
|
+
'cpuSec': float(Util.h_v_td(header, 'x-log-cpu-sec', '0')),
|
|
62
|
+
'cpuCores': int(Util.h_v_td(header, 'x-log-cpu-cores', '0')),
|
|
63
|
+
}
|
|
64
|
+
# parse query info
|
|
65
|
+
query_info_str = Util.h_v_td(header, 'x-log-query-info', '')
|
|
66
|
+
query_info = json.loads(query_info_str)
|
|
67
|
+
meta_dict['mode'] = Util.h_v_td(query_info, 'mode', 0)
|
|
68
|
+
query_mode = GetLogsResponse.QueryMode(meta_dict['mode'])
|
|
69
|
+
if query_mode in (GetLogsResponse.QueryMode.SCAN, GetLogsResponse.QueryMode.SCAN_SQL):
|
|
70
|
+
meta_dict['scanBytes'] = Util.h_v_td(query_info, 'scanBytes', 0)
|
|
71
|
+
if query_mode in (GetLogsResponse.QueryMode.PHRASE, GetLogsResponse.QueryMode.SCAN):
|
|
72
|
+
scan_query_info = Util.h_v_td(query_info, 'phraseQueryInfo', dict())
|
|
73
|
+
meta_dict['phraseQueryInfo'] = {
|
|
74
|
+
'scanAll': (Util.h_v_td(scan_query_info, 'scanAll', 'false') != 'false'),
|
|
75
|
+
'beginOffset': int(Util.h_v_td(scan_query_info, 'beginOffset', '0')),
|
|
76
|
+
'endOffset': int(Util.h_v_td(scan_query_info, 'endOffset', '0'))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return GetLogsResponse({
|
|
80
|
+
"meta": meta_dict,
|
|
81
|
+
"data": resp
|
|
82
|
+
}, header)
|
|
83
|
+
|
|
84
|
+
def get_count(self):
|
|
85
|
+
""" Get log number from the response
|
|
86
|
+
|
|
87
|
+
:return: int, log number
|
|
88
|
+
"""
|
|
89
|
+
return self.get_meta().get_count()
|
|
90
|
+
|
|
91
|
+
def is_completed(self):
|
|
92
|
+
""" Check if the get logs query is completed
|
|
93
|
+
|
|
94
|
+
:return: bool, true if this logs query is completed
|
|
95
|
+
"""
|
|
96
|
+
return self.get_meta().is_completed()
|
|
97
|
+
|
|
98
|
+
def get_logs(self):
|
|
99
|
+
""" Get all logs from the response
|
|
100
|
+
|
|
101
|
+
:return: QueriedLog list, all log data
|
|
102
|
+
"""
|
|
103
|
+
return self._logs
|
|
104
|
+
|
|
105
|
+
def get_processed_rows(self):
|
|
106
|
+
""" Get processed rows from the response
|
|
107
|
+
|
|
108
|
+
:return: int, processed_rows
|
|
109
|
+
"""
|
|
110
|
+
return self.get_meta().get_processed_rows()
|
|
111
|
+
|
|
112
|
+
def get_elapsed_mills(self):
|
|
113
|
+
""" Get elapsed mills from the response
|
|
114
|
+
|
|
115
|
+
:return: int, elapsed_mills
|
|
116
|
+
"""
|
|
117
|
+
return self.get_meta().get_elapsed_millisecond()
|
|
118
|
+
|
|
119
|
+
def get_has_sql(self):
|
|
120
|
+
""" Get whether has sql from the response
|
|
121
|
+
|
|
122
|
+
:return: boolean, has_sql
|
|
123
|
+
"""
|
|
124
|
+
return self.get_meta().get_has_sql()
|
|
125
|
+
|
|
126
|
+
def get_where_query(self):
|
|
127
|
+
""" Get the Search part of "Search|Analysis"
|
|
128
|
+
|
|
129
|
+
:return: str, where_query
|
|
130
|
+
"""
|
|
131
|
+
return self.get_meta().get_where_query()
|
|
132
|
+
|
|
133
|
+
def get_agg_query(self):
|
|
134
|
+
""" Get the Analysis part of "Search|Analysis"
|
|
135
|
+
|
|
136
|
+
:return: str, agg_query
|
|
137
|
+
"""
|
|
138
|
+
return self.get_meta().get_agg_query()
|
|
139
|
+
|
|
140
|
+
def get_cpu_sec(self):
|
|
141
|
+
""" Get cpu seconds used from the response
|
|
142
|
+
|
|
143
|
+
:return: float, cpu_sec
|
|
144
|
+
"""
|
|
145
|
+
return self.get_meta().get_cpu_sec()
|
|
146
|
+
|
|
147
|
+
def get_cpu_cores(self):
|
|
148
|
+
""" Get cpu cores used from the response
|
|
149
|
+
|
|
150
|
+
:return: int, cpu_cores
|
|
151
|
+
"""
|
|
152
|
+
return self.get_meta().get_cpu_cores()
|
|
153
|
+
|
|
154
|
+
def get_query_mode(self):
|
|
155
|
+
""" Get query_mode from the response
|
|
156
|
+
|
|
157
|
+
:return: GetLogsResponse.QueryMode, query_mode
|
|
158
|
+
"""
|
|
159
|
+
|
|
160
|
+
return GetLogsResponse.QueryMode(self.get_meta().get_mode())
|
|
161
|
+
|
|
162
|
+
def get_scan_bytes(self):
|
|
163
|
+
""" Get scan_bytes from the response
|
|
164
|
+
|
|
165
|
+
:return: int, scan_bytes
|
|
166
|
+
"""
|
|
167
|
+
return self.get_meta().get_scan_bytes()
|
|
168
|
+
|
|
169
|
+
def get_begin_offset(self):
|
|
170
|
+
""" Get begin_offset from the response
|
|
171
|
+
|
|
172
|
+
:return: int, begin_offset
|
|
173
|
+
"""
|
|
174
|
+
phrase_query_info = self.get_meta().get_phrase_query_info()
|
|
175
|
+
return phrase_query_info.get_begin_offset() if phrase_query_info else None
|
|
176
|
+
|
|
177
|
+
def get_end_offset(self):
|
|
178
|
+
""" Get end_offset from the response
|
|
179
|
+
|
|
180
|
+
:return: int, end_offset
|
|
181
|
+
"""
|
|
182
|
+
phrase_query_info = self.get_meta().get_phrase_query_info()
|
|
183
|
+
return phrase_query_info.get_end_offset() if phrase_query_info else None
|
|
184
|
+
|
|
185
|
+
def get_scan_all(self):
|
|
186
|
+
""" Get scan_all from the response
|
|
187
|
+
|
|
188
|
+
:return: bool, scan_all
|
|
189
|
+
"""
|
|
190
|
+
phrase_query_info = self.get_meta().get_phrase_query_info()
|
|
191
|
+
return phrase_query_info.get_scan_all() if phrase_query_info else None
|
|
192
|
+
|
|
193
|
+
def log_print(self):
|
|
194
|
+
print('GetLogsResponse:')
|
|
195
|
+
print('headers:', self.get_all_headers())
|
|
196
|
+
print('count:', self.get_count())
|
|
197
|
+
print('progress:', self.get_meta().get_progress())
|
|
198
|
+
print('meta:', self.get_meta()._to_dict())
|
|
199
|
+
print("\nQueriedLog class:\n")
|
|
200
|
+
for log in self.get_logs():
|
|
201
|
+
log.log_print()
|
|
202
|
+
print("\n")
|
|
203
|
+
|
|
204
|
+
def get_log_list(self):
|
|
205
|
+
print('count:', self.get_count())
|
|
206
|
+
print('progress:', self.get_meta().get_progress())
|
|
207
|
+
return self.get_logs()
|
|
208
|
+
|
|
209
|
+
def get_meta(self):
|
|
210
|
+
""" Get meta from the response
|
|
211
|
+
|
|
212
|
+
:return: meta, GetLogsResponseMeta
|
|
213
|
+
"""
|
|
214
|
+
return self._meta
|
|
215
|
+
|
|
216
|
+
def merge(self, other):
|
|
217
|
+
""" merge with other response
|
|
218
|
+
merge logs and meta
|
|
219
|
+
"""
|
|
220
|
+
if not isinstance(other, GetLogsResponse):
|
|
221
|
+
raise ValueError(
|
|
222
|
+
"passed response is not a GetLogsResponse: " + str(type(other)))
|
|
223
|
+
if other is None:
|
|
224
|
+
return self
|
|
225
|
+
self.get_meta().merge(other.get_meta())
|
|
226
|
+
self.get_logs().extend(other.get_logs())
|
|
227
|
+
return self
|
|
228
|
+
|
|
229
|
+
class GetLogsResponseMeta():
|
|
230
|
+
""" The meta info of get logs response
|
|
231
|
+
|
|
232
|
+
"""
|
|
233
|
+
|
|
234
|
+
def __init__(self, meta):
|
|
235
|
+
self._count = Util.v_or_d(meta.get("count"), 0)
|
|
236
|
+
self._progress = meta.get("progress")
|
|
237
|
+
self._processed_rows = Util.v_or_d(meta.get("processedRows"), 0)
|
|
238
|
+
self._elapsed_millisecond = Util.v_or_d(meta.get("elapsedMillisecond"), 0)
|
|
239
|
+
self._has_sql = Util.v_or_d(meta.get("hasSQL"), False)
|
|
240
|
+
self._where_query = Util.v_or_d(meta.get("whereQuery"), '')
|
|
241
|
+
self._agg_query = Util.v_or_d(meta.get("aggQuery"))
|
|
242
|
+
self._cpu_sec = Util.v_or_d(meta.get("cpuSec"), 0.0)
|
|
243
|
+
self._cpu_cores = Util.v_or_d(meta.get("cpuCores"), 0)
|
|
244
|
+
self._mode = Util.v_or_d(meta.get("mode"), 0)
|
|
245
|
+
self._scan_bytes = Util.v_or_d(meta.get("scanBytes"), 0)
|
|
246
|
+
phrase_query_info = meta.get("phraseQueryInfo")
|
|
247
|
+
self._phrase_query_info = GetLogsResponse.PhraseQueryInfo(
|
|
248
|
+
phrase_query_info) if phrase_query_info else None
|
|
249
|
+
|
|
250
|
+
# self._limited = meta.get("limited")
|
|
251
|
+
# self._processed_bytes = meta.get("processedBytes")
|
|
252
|
+
# self._telemetry_type = meta.get("telementryType") # not typo
|
|
253
|
+
# self._power_sql = Util.v_or_d(meta.get("powerSql"), False)
|
|
254
|
+
# self._inserted_sql = meta.get("insertedSQL")
|
|
255
|
+
# self._keys = meta.get("keys")
|
|
256
|
+
# self._marker = meta.get("marker")
|
|
257
|
+
# self._shard = meta.get("shard")
|
|
258
|
+
# self._is_accurate = meta.get("isAccurate")
|
|
259
|
+
# self._column_types = meta.get("columnTypes")
|
|
260
|
+
# self._highlights = meta.get("highlights")
|
|
261
|
+
# self._terms = []
|
|
262
|
+
# for term in meta.get("terms", []):
|
|
263
|
+
# self._terms.append(GetLogsResponse.Term._from_dict(term))
|
|
264
|
+
|
|
265
|
+
def is_completed(self):
|
|
266
|
+
""" Check if the get logs query is completed
|
|
267
|
+
|
|
268
|
+
:return: bool, true if this logs query is completed
|
|
269
|
+
"""
|
|
270
|
+
return self._progress == 'Complete'
|
|
271
|
+
|
|
272
|
+
def merge(self, other):
|
|
273
|
+
""" merge with other GetLogsResponseMeta
|
|
274
|
+
|
|
275
|
+
"""
|
|
276
|
+
self._progress = other.progress
|
|
277
|
+
self._count += other.count
|
|
278
|
+
self._processed_rows += other.processed_rows
|
|
279
|
+
return self
|
|
280
|
+
|
|
281
|
+
def get_count(self):
|
|
282
|
+
""" Get log number from the response
|
|
283
|
+
|
|
284
|
+
:return: int, log number
|
|
285
|
+
"""
|
|
286
|
+
return self._count
|
|
287
|
+
|
|
288
|
+
def _to_dict(self):
|
|
289
|
+
""" to Dict
|
|
290
|
+
"""
|
|
291
|
+
phrase_query_info = None
|
|
292
|
+
if self._phrase_query_info is not None:
|
|
293
|
+
phrase_query_info = self._phrase_query_info._to_dict()
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
'count': self._count,
|
|
297
|
+
'progress': self._progress,
|
|
298
|
+
'processedRows': self._processed_rows,
|
|
299
|
+
'elapsedMillisecond': self._elapsed_millisecond,
|
|
300
|
+
'hasSQL': self._has_sql,
|
|
301
|
+
'whereQuery': self._where_query,
|
|
302
|
+
'aggQuery': self._agg_query,
|
|
303
|
+
'cpuSec': self._cpu_sec,
|
|
304
|
+
'cpuCores': self._cpu_cores,
|
|
305
|
+
'mode': self._mode,
|
|
306
|
+
'scanBytes': self._scan_bytes,
|
|
307
|
+
'phraseQueryInfo': phrase_query_info,
|
|
308
|
+
# 'limited': self._limited,
|
|
309
|
+
# 'processedBytes': self._processed_bytes,
|
|
310
|
+
# 'telementryType': self._telemetry_type, # not typo
|
|
311
|
+
# 'powerSql': self._power_sql,
|
|
312
|
+
# 'insertedSQL': self._inserted_sql,
|
|
313
|
+
# 'keys': self._keys,
|
|
314
|
+
# 'marker': self._marker,
|
|
315
|
+
# 'shard': self._shard,
|
|
316
|
+
# 'isAccurate': self._is_accurate,
|
|
317
|
+
# 'columnTypes': self._column_types,
|
|
318
|
+
# 'highlights': self._highlights,
|
|
319
|
+
# 'terms': [term.to_dict() for term in self._terms],
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
def log_print(self):
|
|
323
|
+
""" print infos
|
|
324
|
+
"""
|
|
325
|
+
print(self._to_dict())
|
|
326
|
+
|
|
327
|
+
def get_progress(self):
|
|
328
|
+
""" Progress of get logs, returns 'Complete' if completed
|
|
329
|
+
|
|
330
|
+
:return: str
|
|
331
|
+
"""
|
|
332
|
+
return self._progress
|
|
333
|
+
|
|
334
|
+
def get_processed_rows(self):
|
|
335
|
+
""" Get processed rows from the response
|
|
336
|
+
|
|
337
|
+
:return: processed_rows, int
|
|
338
|
+
"""
|
|
339
|
+
return self._processed_rows
|
|
340
|
+
|
|
341
|
+
def get_elapsed_millisecond(self):
|
|
342
|
+
""" Get elapsed mills from the response
|
|
343
|
+
|
|
344
|
+
:return: elapsed_millisecond, int
|
|
345
|
+
"""
|
|
346
|
+
return self._elapsed_millisecond
|
|
347
|
+
|
|
348
|
+
def get_has_sql(self):
|
|
349
|
+
""" Get whether has sql from the response
|
|
350
|
+
|
|
351
|
+
:return: has_sql, boolean
|
|
352
|
+
"""
|
|
353
|
+
return self._has_sql
|
|
354
|
+
|
|
355
|
+
def get_where_query(self):
|
|
356
|
+
""" Get the Search part of "Search|Analysis"
|
|
357
|
+
|
|
358
|
+
:return: where_query, str
|
|
359
|
+
"""
|
|
360
|
+
return self._where_query
|
|
361
|
+
|
|
362
|
+
def get_agg_query(self):
|
|
363
|
+
""" Get the Analysis part of "Search|Analysis"
|
|
364
|
+
|
|
365
|
+
:return: agg_query, str
|
|
366
|
+
"""
|
|
367
|
+
return self._agg_query
|
|
368
|
+
|
|
369
|
+
def get_cpu_sec(self):
|
|
370
|
+
""" Get cpu seconds used from the response
|
|
371
|
+
|
|
372
|
+
:return: cpu_sec, float64
|
|
373
|
+
"""
|
|
374
|
+
return self._cpu_sec
|
|
375
|
+
|
|
376
|
+
def get_cpu_cores(self):
|
|
377
|
+
""" Get cpu cores used from the response
|
|
378
|
+
|
|
379
|
+
:return: cpu_cores, float64
|
|
380
|
+
"""
|
|
381
|
+
return self._cpu_cores
|
|
382
|
+
|
|
383
|
+
def get_mode(self):
|
|
384
|
+
""" Get query mode from the response
|
|
385
|
+
|
|
386
|
+
:return: mode
|
|
387
|
+
"""
|
|
388
|
+
return self._mode
|
|
389
|
+
|
|
390
|
+
def get_scan_bytes(self):
|
|
391
|
+
""" Get scan_bytes from the response
|
|
392
|
+
|
|
393
|
+
:return: scan_bytes, int
|
|
394
|
+
"""
|
|
395
|
+
return self._scan_bytes
|
|
396
|
+
|
|
397
|
+
def get_phrase_query_info(self):
|
|
398
|
+
"""
|
|
399
|
+
:return: phraseQueryInfo, PhraseQueryInfo
|
|
400
|
+
"""
|
|
401
|
+
return self._phrase_query_info
|
|
402
|
+
|
|
403
|
+
# def get_limited(self):
|
|
404
|
+
# """
|
|
405
|
+
# :return: limited, int
|
|
406
|
+
# """
|
|
407
|
+
# return self._limited
|
|
408
|
+
|
|
409
|
+
# def get_processed_bytes(self):
|
|
410
|
+
# """
|
|
411
|
+
# :return: processed_bytes, int
|
|
412
|
+
# """
|
|
413
|
+
# return self._processed_bytes
|
|
414
|
+
|
|
415
|
+
# def get_telemetry_type(self):
|
|
416
|
+
# """
|
|
417
|
+
# :return: telemetry_type, str
|
|
418
|
+
# """
|
|
419
|
+
# return self._telemetry_type
|
|
420
|
+
|
|
421
|
+
# def get_power_sql(self):
|
|
422
|
+
# """
|
|
423
|
+
# :return: power_sql, bool
|
|
424
|
+
# """
|
|
425
|
+
# return self._power_sql
|
|
426
|
+
|
|
427
|
+
# def get_inserted_sql(self):
|
|
428
|
+
# """
|
|
429
|
+
# :return: inserted_sql, str
|
|
430
|
+
# """
|
|
431
|
+
# return self._inserted_sql
|
|
432
|
+
|
|
433
|
+
# def get_keys(self):
|
|
434
|
+
# """
|
|
435
|
+
# :return: keys, List[str]
|
|
436
|
+
# """
|
|
437
|
+
# return self._keys
|
|
438
|
+
|
|
439
|
+
# def get_marker(self):
|
|
440
|
+
# """
|
|
441
|
+
# :return: marker, str
|
|
442
|
+
# """
|
|
443
|
+
# return self._marker
|
|
444
|
+
|
|
445
|
+
# def get_shard(self):
|
|
446
|
+
# """
|
|
447
|
+
# :return: shard, int
|
|
448
|
+
# """
|
|
449
|
+
# return self._shard
|
|
450
|
+
|
|
451
|
+
# def get_is_accurate(self):
|
|
452
|
+
# """
|
|
453
|
+
# :return: is_accurate, bool
|
|
454
|
+
# """
|
|
455
|
+
# return self._is_accurate
|
|
456
|
+
|
|
457
|
+
# def get_column_types(self):
|
|
458
|
+
# """
|
|
459
|
+
# :return: column_types, List[str]
|
|
460
|
+
# """
|
|
461
|
+
# return self._column_types
|
|
462
|
+
|
|
463
|
+
# def get_highlights(self):
|
|
464
|
+
# """
|
|
465
|
+
# :return: highlights, List[Dict]
|
|
466
|
+
# """
|
|
467
|
+
# return self._highlights
|
|
468
|
+
|
|
469
|
+
# def get_terms(self):
|
|
470
|
+
# """
|
|
471
|
+
# :return: terms, List[Term]
|
|
472
|
+
# """
|
|
473
|
+
# return self._terms
|
|
474
|
+
|
|
475
|
+
class PhraseQueryInfo():
|
|
476
|
+
""" query info of phrase, includes beginOffset/endOffset/scanAll/endTime
|
|
477
|
+
|
|
478
|
+
"""
|
|
479
|
+
|
|
480
|
+
def __init__(self, pharse_query_info):
|
|
481
|
+
self._begin_offset = pharse_query_info.get("beginOffset")
|
|
482
|
+
self._end_offset = pharse_query_info.get("endOffset")
|
|
483
|
+
self._scan_all = pharse_query_info.get("scanAll")
|
|
484
|
+
self._end_time = pharse_query_info.get("endTime")
|
|
485
|
+
|
|
486
|
+
def get_begin_offset(self):
|
|
487
|
+
""" Get begin_offset from the response
|
|
488
|
+
|
|
489
|
+
:return: begin_offset, int
|
|
490
|
+
"""
|
|
491
|
+
return self._begin_offset
|
|
492
|
+
|
|
493
|
+
def get_end_offset(self):
|
|
494
|
+
""" Get end_offset from the response
|
|
495
|
+
|
|
496
|
+
:return: end_offset, int
|
|
497
|
+
"""
|
|
498
|
+
return self._end_offset
|
|
499
|
+
|
|
500
|
+
def get_scan_all(self):
|
|
501
|
+
""" Get scan_all from the response
|
|
502
|
+
|
|
503
|
+
:return: scan_all, bool
|
|
504
|
+
"""
|
|
505
|
+
return self._scan_all
|
|
506
|
+
|
|
507
|
+
def get_end_time(self):
|
|
508
|
+
""" Get end_time from the response
|
|
509
|
+
|
|
510
|
+
:return: end_time, int
|
|
511
|
+
"""
|
|
512
|
+
return self._end_time
|
|
513
|
+
|
|
514
|
+
def _to_dict(self):
|
|
515
|
+
""" to Dict
|
|
516
|
+
"""
|
|
517
|
+
return {
|
|
518
|
+
"beginOffset": self._begin_offset,
|
|
519
|
+
"endOffset": self._end_offset,
|
|
520
|
+
"scanAll": self._scan_all,
|
|
521
|
+
"endTime": self._end_time
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
def log_print(self):
|
|
525
|
+
""" print info
|
|
526
|
+
|
|
527
|
+
"""
|
|
528
|
+
print(self._to_dict())
|
|
529
|
+
|
|
530
|
+
|
|
531
|
+
# class Term():
|
|
532
|
+
# """ terms of query, field key/term
|
|
533
|
+
# """
|
|
534
|
+
|
|
535
|
+
# def __init__(self, key, term):
|
|
536
|
+
# self._key = key
|
|
537
|
+
# self._term = term
|
|
538
|
+
|
|
539
|
+
# @classmethod
|
|
540
|
+
# def _from_dict(cls, data):
|
|
541
|
+
# """ Initialize from a dict
|
|
542
|
+
# """
|
|
543
|
+
# key = data.get("key")
|
|
544
|
+
# term = data.get("term")
|
|
545
|
+
# return cls(key, term)
|
|
546
|
+
|
|
547
|
+
# def get_key(self):
|
|
548
|
+
# """ field key of term
|
|
549
|
+
# """
|
|
550
|
+
# return self._key
|
|
551
|
+
|
|
552
|
+
# def get_term(self):
|
|
553
|
+
# """ field term of term
|
|
554
|
+
# """
|
|
555
|
+
# return self._term
|
|
556
|
+
|
|
557
|
+
# def _to_dict(self):
|
|
558
|
+
# """ to Dict
|
|
559
|
+
# """
|
|
560
|
+
# return {
|
|
561
|
+
# "key": self._key,
|
|
562
|
+
# "term": self._term
|
|
563
|
+
# }
|
|
564
|
+
|
|
565
|
+
# def log_print(self):
|
|
566
|
+
# """ print info
|
|
567
|
+
# """
|
|
568
|
+
# print(self._to_dict())
|
|
@@ -173,6 +173,7 @@ class LogClient(object):
|
|
|
173
173
|
self._auth_version = auth_version
|
|
174
174
|
self._region = region
|
|
175
175
|
self._auth = make_auth(accessKeyId, accessKey, auth_version, region)
|
|
176
|
+
self._get_logs_v2_enabled = True
|
|
176
177
|
|
|
177
178
|
def _replace_credentials(self):
|
|
178
179
|
delta = time.time() - self._last_refresh
|
|
@@ -633,10 +634,8 @@ class LogClient(object):
|
|
|
633
634
|
headers = {}
|
|
634
635
|
params = {'from': parse_timestamp(from_time),
|
|
635
636
|
'to': parse_timestamp(to_time),
|
|
636
|
-
'type': 'log',
|
|
637
637
|
'line': size,
|
|
638
638
|
'offset': offset,
|
|
639
|
-
'reverse': 'true' if reverse else 'false',
|
|
640
639
|
'powerSql': power_sql,
|
|
641
640
|
'accurate': accurate_query,
|
|
642
641
|
'fromNs': from_time_nano_part,
|
|
@@ -650,10 +649,29 @@ class LogClient(object):
|
|
|
650
649
|
if scan:
|
|
651
650
|
params['session'] = 'mode=scan'
|
|
652
651
|
params['forward'] = 'true' if forward else 'false'
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
652
|
+
|
|
653
|
+
if self._get_logs_v2_enabled:
|
|
654
|
+
resource = "/logstores/" + logstore + "/logs"
|
|
655
|
+
headers["Content-Type"] = "application/json"
|
|
656
|
+
params['reverse'] = reverse
|
|
657
|
+
params['forward'] = forward
|
|
658
|
+
body_str = six.b(json.dumps(params))
|
|
659
|
+
headers["x-log-bodyrawsize"] = str(len(body_str))
|
|
660
|
+
accept_encoding = "lz4" if Util.is_lz4_available() else "deflate"
|
|
661
|
+
headers['Accept-Encoding'] = accept_encoding
|
|
662
|
+
|
|
663
|
+
(resp, header) = self._send("POST", project, body_str, resource, None, headers, respons_body_type=accept_encoding)
|
|
664
|
+
|
|
665
|
+
raw_data = Util.uncompress_response(header, resp)
|
|
666
|
+
exJson = self._loadJson(200, header, raw_data, requestId=Util.h_v_td(header, 'x-log-requestid', ''))
|
|
667
|
+
exJson = Util.convert_unicode_to_str(exJson)
|
|
668
|
+
ret = GetLogsResponse(exJson, header)
|
|
669
|
+
else:
|
|
670
|
+
resource = "/logstores/" + logstore
|
|
671
|
+
params['type'] = 'log'
|
|
672
|
+
params['reverse'] = 'true' if reverse else 'false'
|
|
673
|
+
(resp, header) = self._send("GET", project, None, resource, params, headers)
|
|
674
|
+
ret = GetLogsResponse._from_v1_resp(resp, header)
|
|
657
675
|
if ret.is_completed():
|
|
658
676
|
break
|
|
659
677
|
|
|
@@ -804,7 +822,7 @@ class LogClient(object):
|
|
|
804
822
|
if query_mode is GetLogsResponse.QueryMode.NORMAL or query_mode is GetLogsResponse.QueryMode.SCAN_SQL:
|
|
805
823
|
offset += count
|
|
806
824
|
else:
|
|
807
|
-
scan_all =
|
|
825
|
+
scan_all = response.get_scan_all()
|
|
808
826
|
if forward:
|
|
809
827
|
offset = response.get_end_offset()
|
|
810
828
|
else:
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# Copyright (C) Alibaba Cloud Computing
|
|
5
5
|
# All rights reserved.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import six
|
|
8
8
|
class QueriedLog(object):
|
|
9
9
|
""" The QueriedLog is a log of the GetLogsResponse which obtained from the log.
|
|
10
10
|
|
|
@@ -23,6 +23,27 @@ class QueriedLog(object):
|
|
|
23
23
|
self.source = source
|
|
24
24
|
self.contents = contents
|
|
25
25
|
|
|
26
|
+
@staticmethod
|
|
27
|
+
def _from_dict(data):
|
|
28
|
+
""" Initalize from dict
|
|
29
|
+
"""
|
|
30
|
+
source = data.get("__source__", "")
|
|
31
|
+
time = data.get("__time__", '0')
|
|
32
|
+
contents = {}
|
|
33
|
+
for key in six.iterkeys(data):
|
|
34
|
+
if key not in ['__time__', '__source__']:
|
|
35
|
+
contents[key] = data[key]
|
|
36
|
+
|
|
37
|
+
return QueriedLog(time, source, contents)
|
|
38
|
+
|
|
39
|
+
def _to_dict(self):
|
|
40
|
+
res = {
|
|
41
|
+
'__time__': str(self.timestamp),
|
|
42
|
+
'__source__': self.source,
|
|
43
|
+
}
|
|
44
|
+
res.update(self.contents)
|
|
45
|
+
return res
|
|
46
|
+
|
|
26
47
|
def get_time(self):
|
|
27
48
|
""" Get log time
|
|
28
49
|
|