diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f4f77ab5..24ba1ab0 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,6 +6,9 @@ on: pull_request: branches: [ master ] +permissions: + contents: read + jobs: test: runs-on: ubuntu-latest @@ -37,4 +40,32 @@ jobs: - name: Run build tests run: | python -m pip install pytest - python -m pytest tests/ci/build-test/ \ No newline at end of file + python -m pytest tests/ci/build-test/ + + typing: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install dependencies + run: | + python -V + python -m pip install --upgrade pip setuptools + python -m pip install mypy types-requests types-six + python -m pip install protobuf lz4 + python -m pip install . + + - name: Run stubtest + run: | + python tests/ci/run_stubtest.py + + - name: Check stub signatures match source + run: | + python tests/ci/check_stub_signatures.py diff --git a/.gitignore b/.gitignore index f901e618..6b8bfbb5 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ cscope.in.out cscope.out cscope.po.out tags +.venv-stubtest/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..68b536b4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include aliyun *.pyi py.typed +recursive-include aliyun/log *.pyi py.typed diff --git a/aliyun/__init__.pyi b/aliyun/__init__.pyi new file mode 100644 index 00000000..e69de29b diff --git a/aliyun/log/__init__.pyi b/aliyun/log/__init__.pyi new file mode 100644 index 00000000..d519bd5e --- /dev/null +++ b/aliyun/log/__init__.pyi @@ -0,0 +1,56 @@ +from .logclient import LogClient as LogClient +from .logexception import LogException as LogException +from .gethistogramsrequest import GetHistogramsRequest as GetHistogramsRequest +from .getlogsrequest import GetLogsRequest as GetLogsRequest, GetProjectLogsRequest as GetProjectLogsRequest +from .index_config import IndexConfig as IndexConfig, IndexKeyConfig as IndexKeyConfig, IndexLineConfig as IndexLineConfig +from .listtopicsrequest import ListTopicsRequest as ListTopicsRequest +from .listlogstoresrequest import ListLogstoresRequest as ListLogstoresRequest +from .logtail_config_detail import PluginConfigDetail as PluginConfigDetail, SeperatorFileConfigDetail as SeperatorFileConfigDetail, SimpleFileConfigDetail as SimpleFileConfigDetail, FullRegFileConfigDetail as FullRegFileConfigDetail, JsonFileConfigDetail as JsonFileConfigDetail, ApsaraFileConfigDetail as ApsaraFileConfigDetail, SyslogConfigDetail as SyslogConfigDetail, LogtailConfigGenerator as LogtailConfigGenerator, CommonRegLogConfigDetail as CommonRegLogConfigDetail +from .logtail_pipeline_config_detail import LogtailPipelineConfigDetail as LogtailPipelineConfigDetail +from .logtail_pipeline_config_response import CreateLogtailPipelineConfigResponse as CreateLogtailPipelineConfigResponse, DeleteLogtailPipelineConfigResponse as DeleteLogtailPipelineConfigResponse, GetLogtailPipelineConfigResponse as GetLogtailPipelineConfigResponse, UpdateLogtailPipelineConfigResponse as UpdateLogtailPipelineConfigResponse, ListLogtailPipelineConfigResponse as ListLogtailPipelineConfigResponse +from .machine_group_detail import MachineGroupDetail as MachineGroupDetail +from .putlogsrequest import PutLogsRequest as PutLogsRequest +from .shipper_config import ShipperTask as ShipperTask, OssShipperConfig as OssShipperConfig, OdpsShipperConfig as OdpsShipperConfig +from .version import __version__ as __version__ +from .logitem import LogItem as LogItem +from .consumer_group_request import CreateConsumerGroupRequest as CreateConsumerGroupRequest, ConsumerGroupGetCheckPointRequest as ConsumerGroupGetCheckPointRequest, ConsumerGroupHeartBeatRequest as ConsumerGroupHeartBeatRequest, ConsumerGroupUpdateCheckPointRequest as ConsumerGroupUpdateCheckPointRequest +from .external_store_config import ExternalStoreConfig as ExternalStoreConfig, ExternalStoreConfigBase as ExternalStoreConfigBase, ExternalStoreCsvConfig as ExternalStoreCsvConfig, ExternalStoreOssConfig as ExternalStoreOssConfig + +from .consumer_group_response import ConsumerGroupEntity as ConsumerGroupEntity, ConsumerGroupCheckPointResponse as ConsumerGroupCheckPointResponse, ConsumerGroupHeartBeatResponse as ConsumerGroupHeartBeatResponse, ConsumerGroupUpdateCheckPointResponse as ConsumerGroupUpdateCheckPointResponse, CreateConsumerGroupResponse as CreateConsumerGroupResponse, DeleteConsumerGroupResponse as DeleteConsumerGroupResponse, ListConsumerGroupResponse as ListConsumerGroupResponse, UpdateConsumerGroupResponse as UpdateConsumerGroupResponse +from .cursor_response import GetCursorResponse as GetCursorResponse +from .cursor_time_response import GetCursorTimeResponse as GetCursorTimeResponse +from .gethistogramsresponse import GetHistogramsResponse as GetHistogramsResponse +from .getlogsresponse import GetLogsResponse as GetLogsResponse +from .histogram import Histogram as Histogram +from .queriedlog import QueriedLog as QueriedLog +from .index_config_response import CreateIndexResponse as CreateIndexResponse, UpdateIndexResponse as UpdateIndexResponse, DeleteIndexResponse as DeleteIndexResponse, GetIndexResponse as GetIndexResponse +from .listlogstoresresponse import ListLogstoresResponse as ListLogstoresResponse +from .listtopicsresponse import ListTopicsResponse as ListTopicsResponse +from .logresponse import LogResponse as LogResponse +from .logtail_config_response import CreateLogtailConfigResponse as CreateLogtailConfigResponse, DeleteLogtailConfigResponse as DeleteLogtailConfigResponse, GetLogtailConfigResponse as GetLogtailConfigResponse, UpdateLogtailConfigResponse as UpdateLogtailConfigResponse, ListLogtailConfigResponse as ListLogtailConfigResponse +from .machinegroup_response import CreateMachineGroupResponse as CreateMachineGroupResponse, DeleteMachineGroupResponse as DeleteMachineGroupResponse, GetMachineGroupResponse as GetMachineGroupResponse, UpdateMachineGroupResponse as UpdateMachineGroupResponse, ListMachineGroupResponse as ListMachineGroupResponse, ListMachinesResponse as ListMachinesResponse, ApplyConfigToMachineGroupResponse as ApplyConfigToMachineGroupResponse, RemoveConfigToMachineGroupResponse as RemoveConfigToMachineGroupResponse, GetMachineGroupAppliedConfigResponse as GetMachineGroupAppliedConfigResponse, GetConfigAppliedMachineGroupsResponse as GetConfigAppliedMachineGroupsResponse +from .project_response import CreateProjectResponse as CreateProjectResponse, UpdateProjectResponse as UpdateProjectResponse, DeleteProjectResponse as DeleteProjectResponse, GetProjectResponse as GetProjectResponse, ListProjectResponse as ListProjectResponse, GetProjectTagsResponse as GetProjectTagsResponse +from .pulllog_response import PullLogResponse as PullLogResponse +from .shard_response import ListShardResponse as ListShardResponse, DeleteShardResponse as DeleteShardResponse +from .shipper_response import CreateShipperResponse as CreateShipperResponse, UpdateShipperResponse as UpdateShipperResponse, DeleteShipperResponse as DeleteShipperResponse, GetShipperConfigResponse as GetShipperConfigResponse, ListShipperResponse as ListShipperResponse, GetShipperTasksResponse as GetShipperTasksResponse, RetryShipperTasksResponse as RetryShipperTasksResponse +from .common_response import CreateEntityResponse as CreateEntityResponse, UpdateEntityResponse as UpdateEntityResponse, DeleteEntityResponse as DeleteEntityResponse, GetEntityResponse as GetEntityResponse, ListEntityResponse as ListEntityResponse +from .external_store_config_response import CreateExternalStoreResponse as CreateExternalStoreResponse, DeleteExternalStoreResponse as DeleteExternalStoreResponse, GetExternalStoreResponse as GetExternalStoreResponse, UpdateExternalStoreResponse as UpdateExternalStoreResponse, ListExternalStoreResponse as ListExternalStoreResponse +from .proto import LogGroupRaw as LogGroup +from .rebuild_index_response import CreateRebuildIndexResponse as CreateRebuildIndexResponse, GetRebuildIndexResponse as GetRebuildIndexResponse +from .deletelogsrequest import DeleteLogsRequest as DeleteLogsRequest +from .deletelogssresponse import DeleteLogsResponse as DeleteLogsResponse +from .getdeletelogsstatusrequest import GetDeleteLogsStatusRequest as GetDeleteLogsStatusRequest +from .getdeletelogsstatusresponse import GetDeleteLogsStatusResponse as GetDeleteLogsStatusResponse +from .listdeletelogsstasksrequest import ListDeleteLogsTasksRequest as ListDeleteLogsTasksRequest +from .listdeletelogsstasksresponse import ListDeleteLogsTasksResponse as ListDeleteLogsTasksResponse +from .logger_hanlder import SimpleLogHandler as SimpleLogHandler, QueuedLogHandler as QueuedLogHandler, LogFields as LogFields, UwsgiQueuedLogHandler as UwsgiQueuedLogHandler +from .metering_mode_response import GetLogStoreMeteringModeResponse as GetLogStoreMeteringModeResponse, \ + GetMetricStoreMeteringModeResponse as GetMetricStoreMeteringModeResponse, \ + UpdateLogStoreMeteringModeResponse as UpdateLogStoreMeteringModeResponse, UpdateMetricStoreMeteringModeResponse as UpdateMetricStoreMeteringModeResponse +from .multimodal_config_response import GetLogStoreMultimodalConfigurationResponse as GetLogStoreMultimodalConfigurationResponse, \ + PutLogStoreMultimodalConfigurationResponse as PutLogStoreMultimodalConfigurationResponse +from .object_response import PutObjectResponse as PutObjectResponse, GetObjectResponse as GetObjectResponse + +from .store_view import StoreView as StoreView, StoreViewStore as StoreViewStore +from .store_view_response import CreateStoreViewResponse as CreateStoreViewResponse, UpdateStoreViewResponse as UpdateStoreViewResponse, DeleteStoreViewResponse as DeleteStoreViewResponse, ListStoreViewsResponse as ListStoreViewsResponse, GetStoreViewResponse as GetStoreViewResponse +from .submit_async_sql_request import SubmitAsyncSqlRequest as SubmitAsyncSqlRequest diff --git a/aliyun/log/consumer/__init__.pyi b/aliyun/log/consumer/__init__.pyi new file mode 100644 index 00000000..c9bb24a8 --- /dev/null +++ b/aliyun/log/consumer/__init__.pyi @@ -0,0 +1,3 @@ +from .config import CursorPosition as CursorPosition, LogHubConfig as LogHubConfig +from .tasks import ConsumerJsonProcessorBase as ConsumerJsonProcessorBase, ConsumerProcessorAdaptor as ConsumerProcessorAdaptor, ConsumerProcessorBase as ConsumerProcessorBase +from .worker import ConsumerWorker as ConsumerWorker diff --git a/aliyun/log/consumer/config.pyi b/aliyun/log/consumer/config.pyi new file mode 100644 index 00000000..eb206721 --- /dev/null +++ b/aliyun/log/consumer/config.pyi @@ -0,0 +1,40 @@ +from typing import Any, Callable, Optional +from enum import Enum + +class CursorPosition(Enum): + BEGIN_CURSOR = 'BEGIN_CURSOR' + END_CURSOR = 'END_CURSOR' + SPECIAL_TIMER_CURSOR = 'SPECIAL_TIMER_CURSOR' + +class ConsumerStatus(Enum): + INITIALIZING = 'INITIALIZING' + PROCESSING = 'PROCESSING' + SHUTTING_DOWN = 'SHUTTING_DOWN' + SHUTDOWN_COMPLETE = 'SHUTDOWN_COMPLETE' + +class LogHubConfig: + endpoint: str + accessKeyId: str + accessKey: str + project: str + logstore: str + consumer_group_name: str + consumer_name: str + cursor_position: CursorPosition + heartbeat_interval: int + data_fetch_interval: int + in_order: bool + cursor_start_time: Any + securityToken: Optional[str] + max_fetch_log_group_size: int + worker_pool_size: int + shared_executor: Any + consumer_group_time_out: int + cursor_end_time: Any + credentials_refresher: Optional[Callable[..., Any]] + auth_version: str + region: str + query: Optional[str] + accept_compress_type: Optional[str] + processor: Optional[str] + def __init__(self, endpoint: str, access_key_id: str, access_key: str, project: str, logstore: str, consumer_group_name: str, consumer_name: str, cursor_position: Optional[CursorPosition] = ..., heartbeat_interval: Optional[int] = ..., data_fetch_interval: Optional[int] = ..., in_order: bool = False, cursor_start_time: Any = ..., security_token: Optional[str] = ..., max_fetch_log_group_size: Optional[int] = ..., worker_pool_size: Optional[int] = ..., shared_executor: Any = ..., cursor_end_time: Any = ..., credentials_refresher: Optional[Callable[..., Any]] = ..., auth_version: str = ..., region: str = '', query: Optional[str] = ..., accept_compress_type: Optional[str] = ..., processor: Optional[str] = ...) -> None: ... diff --git a/aliyun/log/consumer/py.typed b/aliyun/log/consumer/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/aliyun/log/consumer/tasks.py b/aliyun/log/consumer/tasks.py index 57fed995..8cd04700 100755 --- a/aliyun/log/consumer/tasks.py +++ b/aliyun/log/consumer/tasks.py @@ -214,8 +214,7 @@ def consumer_fetch_task(loghub_client_adapter, preprocessor, shard_id, cursor, m for retry_times in range(3): try: - # type: PullLogResponse - response = loghub_client_adapter.pull_logs(shard_id, cursor, count=max_fetch_log_group_size, end_cursor=end_cursor, query=query, processor=consume_processor) + response = loghub_client_adapter.pull_logs(shard_id, cursor, count=max_fetch_log_group_size, end_cursor=end_cursor, query=query, processor=consume_processor) # type: PullLogResponse data = preprocessor(response) next_cursor = response.get_next_cursor() raw_size = response.get_raw_size() diff --git a/aliyun/log/consumer/tasks.pyi b/aliyun/log/consumer/tasks.pyi new file mode 100644 index 00000000..192eb280 --- /dev/null +++ b/aliyun/log/consumer/tasks.pyi @@ -0,0 +1,23 @@ +import abc +from typing import Any + +class ConsumerProcessorBase(object, metaclass=abc.ABCMeta): + shard_id: int + last_check_time: float + checkpoint_timeout: int + def __init__(self) -> None: ... + def save_checkpoint(self, tracker: Any, force: bool = False) -> None: ... + def initialize(self, shard: int) -> None: ... + @abc.abstractmethod + def process(self, log_groups: Any, check_point_tracker: Any) -> Any: ... + def shutdown(self, check_point_tracker: Any) -> None: ... + +class ConsumerJsonProcessorBase(ConsumerProcessorBase, metaclass=abc.ABCMeta): + def __init__(self) -> None: ... + @abc.abstractmethod + def process(self, flattern_json_list: Any, check_point_tracker: Any) -> Any: ... + +class ConsumerProcessorAdaptor(ConsumerProcessorBase): + func: Any + def __init__(self, func: Any) -> None: ... + def process(self, log_groups: Any, check_point_tracker: Any) -> None: ... diff --git a/aliyun/log/consumer/worker.pyi b/aliyun/log/consumer/worker.pyi new file mode 100644 index 00000000..5cb47c7f --- /dev/null +++ b/aliyun/log/consumer/worker.pyi @@ -0,0 +1,28 @@ +import logging +from typing import Any, Dict, MutableMapping, Optional, Sequence, Tuple +from threading import Thread +from .config import LogHubConfig as LogHubConfig + +class ConsumerWorkerLoggerAdapter(logging.LoggerAdapter): + def process(self, msg: Any, kwargs: MutableMapping[str, Any]) -> Tuple[Any, MutableMapping[str, Any]]: ... + +class ConsumerWorker(Thread): + make_processor: Any + process_args: Sequence[Any] + process_kwargs: Dict[str, Any] + option: LogHubConfig + consumer_client: Any + shut_down_flag: bool + logger: logging.LoggerAdapter + shard_consumers: Dict[Any, Any] + last_owned_consumer_finish_time: float + heart_beat: Any + own_executor: bool + def __init__(self, make_processor: Any, consumer_option: LogHubConfig, args: Optional[Sequence[Any]] = ..., kwargs: Optional[Dict[str, Any]] = ...) -> None: ... + @property + def executor(self) -> Any: ... + def run(self) -> None: ... + def start(self, join: bool = False) -> None: ... + def shutdown_and_wait(self) -> None: ... + def clean_shard_consumer(self, owned_shards: Sequence[Any]) -> None: ... + def shutdown(self) -> None: ... diff --git a/aliyun/log/credentials.pyi b/aliyun/log/credentials.pyi new file mode 100644 index 00000000..06c74bed --- /dev/null +++ b/aliyun/log/credentials.pyi @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from typing import Optional + +class Credentials: + access_key_id: str + access_key_secret: str + security_token: Optional[str] + def __init__(self, access_key_id: str, access_key_secret: str, security_token: Optional[str] = ...) -> None: ... + def get_access_key_id(self) -> str: ... + def get_access_key_secret(self) -> str: ... + def get_security_token(self) -> Optional[str]: ... + +class CredentialsProvider: + def get_credentials(self) -> Optional[Credentials]: ... + +class StaticCredentialsProvider(CredentialsProvider): + def __init__(self, access_key_id: str = ..., access_key_secret: str = ..., security_token: str = ...) -> None: ... + def get_credentials(self) -> Credentials: ... diff --git a/aliyun/log/cursor_response.pyi b/aliyun/log/cursor_response.pyi new file mode 100644 index 00000000..ae82830a --- /dev/null +++ b/aliyun/log/cursor_response.pyi @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from typing import Any, Dict + +from .logresponse import LogResponse + +class GetCursorResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_cursor(self) -> str: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/cursor_time_response.pyi b/aliyun/log/cursor_time_response.pyi new file mode 100644 index 00000000..9dcfbbc3 --- /dev/null +++ b/aliyun/log/cursor_time_response.pyi @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from typing import Any, Dict + +from .logresponse import LogResponse + +class GetCursorTimeResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_cursor_time(self) -> int: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/gethistogramsrequest.pyi b/aliyun/log/gethistogramsrequest.pyi new file mode 100644 index 00000000..f4872e0f --- /dev/null +++ b/aliyun/log/gethistogramsrequest.pyi @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from typing import Optional, Union + +from .logrequest import LogRequest +from .util import parse_timestamp + +class GetHistogramsRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., logstore: Optional[str] = ..., fromTime: Optional[Union[int, str]] = ..., toTime: Optional[Union[int, str]] = ..., topic: Optional[str] = ..., query: Optional[str] = ..., accurate_query: bool = ..., from_time_nano_part: int = ..., to_time_nano_part: int = ..., shard_id: int = ...) -> None: ... + def get_logstore(self) -> str: ... + def set_logstore(self, logstore: str) -> None: ... + def get_topic(self) -> str: ... + def set_topic(self, topic: str) -> None: ... + def get_from(self) -> int: ... + def set_from(self, fromTime: int) -> None: ... + def get_to(self) -> int: ... + def set_to(self, toTime: int) -> None: ... + def get_query(self) -> str: ... + def set_query(self, query: str) -> None: ... + def get_accurate_query(self) -> bool: ... + def set_accurate_query(self, accurate_query: bool) -> None: ... + def get_from_time_nano_part(self) -> int: ... + def set_from_time_nano_part(self, from_time_nano_part: int) -> None: ... + def get_to_time_nano_part(self) -> int: ... + def set_to_time_nano_part(self, to_time_nano_part: int) -> None: ... + def set_shard_id(self, shard_id: int) -> None: ... + def get_shard_id(self) -> int: ... diff --git a/aliyun/log/gethistogramsresponse.pyi b/aliyun/log/gethistogramsresponse.pyi new file mode 100644 index 00000000..6a0e7efa --- /dev/null +++ b/aliyun/log/gethistogramsresponse.pyi @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logresponse import LogResponse +from .histogram import Histogram +from .util import Util + +class GetHistogramsResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def is_completed(self) -> bool: ... + def get_total_count(self) -> int: ... + def get_histograms(self) -> List[Histogram]: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/getlogsrequest.pyi b/aliyun/log/getlogsrequest.pyi new file mode 100644 index 00000000..eca2c097 --- /dev/null +++ b/aliyun/log/getlogsrequest.pyi @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logrequest import LogRequest + +class GetLogsRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., logstore: Optional[str] = ..., fromTime: Optional[Union[int, str]] = ..., toTime: Optional[Union[int, str]] = ..., topic: Optional[str] = ..., query: Optional[str] = ..., line: int = ..., offset: int = ..., reverse: bool = ..., power_sql: bool = ..., scan: bool = ..., forward: bool = ..., accurate_query: bool = ..., from_time_nano_part: int = ..., to_time_nano_part: int = ...) -> None: ... + def get_logstore(self) -> str: ... + def set_logstore(self, logstore: str) -> None: ... + def get_topic(self) -> str: ... + def set_topic(self, topic: str) -> None: ... + def get_from(self) -> int: ... + def set_from(self, fromTime: int) -> None: ... + def get_to(self) -> int: ... + def set_to(self, toTime: int) -> None: ... + def get_query(self) -> str: ... + def set_query(self, query: str) -> None: ... + def get_line(self) -> int: ... + def set_line(self, line: int) -> None: ... + def get_offset(self) -> int: ... + def set_offset(self, offset: int) -> None: ... + def get_reverse(self) -> bool: ... + def set_reverse(self, reverse: bool) -> None: ... + def get_power_sql(self) -> bool: ... + def set_power_sql(self, power_sql: bool) -> None: ... + def get_scan(self) -> bool: ... + def set_scan(self, scan: bool) -> None: ... + def get_forward(self) -> bool: ... + def set_forward(self, forward: bool) -> None: ... + def get_accurate_query(self) -> bool: ... + def set_accurate_query(self, accurate_query: bool) -> None: ... + def get_from_time_nano_part(self) -> int: ... + def set_from_time_nano_part(self, from_time_nano_part: int) -> None: ... + def get_to_time_nano_part(self) -> int: ... + def set_to_time_nano_part(self, to_time_nano_part: int) -> None: ... + +class GetProjectLogsRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., query: Optional[str] = ..., power_sql: bool = ...) -> None: ... + def get_query(self) -> str: ... + def set_query(self, query: str) -> None: ... + def get_power_sql(self) -> bool: ... + def set_power_sql(self, power_sql: bool) -> None: ... diff --git a/aliyun/log/getlogsresponse.pyi b/aliyun/log/getlogsresponse.pyi new file mode 100644 index 00000000..41864d2d --- /dev/null +++ b/aliyun/log/getlogsresponse.pyi @@ -0,0 +1,72 @@ +from typing import Any, Dict, List, Optional +from enum import Enum + +from .logresponse import LogResponse +from .queriedlog import QueriedLog + +class GetLogsResponse(LogResponse): + class QueryMode(Enum): + NORMAL = 0 + PHRASE = 1 + SCAN = 2 + SCAN_SQL = 3 + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_count(self) -> int: ... + def is_completed(self) -> bool: ... + def get_logs(self) -> List[QueriedLog]: ... + def get_processed_rows(self) -> int: ... + def get_elapsed_mills(self) -> int: ... + def get_has_sql(self) -> bool: ... + def get_where_query(self) -> str: ... + def get_agg_query(self) -> str: ... + def get_cpu_sec(self) -> float: ... + def get_cpu_cores(self) -> float: ... + def get_query_mode(self) -> GetLogsResponse.QueryMode: ... + def get_scan_bytes(self) -> int: ... + def get_begin_offset(self) -> Optional[int]: ... + def get_end_offset(self) -> Optional[int]: ... + def get_scan_all(self) -> Optional[bool]: ... + def log_print(self) -> None: ... + def get_log_list(self) -> List[QueriedLog]: ... + def get_meta(self) -> GetLogsResponse.GetLogsResponseMeta: ... + def merge(self, other: GetLogsResponse) -> GetLogsResponse: ... + class GetLogsResponseMeta: + def __init__(self, meta: Any) -> None: ... + def is_completed(self) -> bool: ... + def merge(self, other: GetLogsResponse.GetLogsResponseMeta) -> GetLogsResponse.GetLogsResponseMeta: ... + def get_count(self) -> int: ... + def log_print(self) -> None: ... + def get_progress(self) -> Optional[str]: ... + def get_processed_rows(self) -> int: ... + def get_elapsed_millisecond(self) -> int: ... + def get_has_sql(self) -> bool: ... + def get_where_query(self) -> str: ... + def get_agg_query(self) -> Optional[str]: ... + def get_cpu_sec(self) -> float: ... + def get_cpu_cores(self) -> float: ... + def get_mode(self) -> int: ... + def get_scan_bytes(self) -> int: ... + def get_phrase_query_info(self) -> Optional[GetLogsResponse.PhraseQueryInfo]: ... + def get_limited(self) -> Optional[int]: ... + def get_processed_bytes(self) -> Optional[int]: ... + def get_telemetry_type(self) -> Optional[str]: ... + def get_power_sql(self) -> bool: ... + def get_inserted_sql(self) -> Optional[str]: ... + def get_keys(self) -> Optional[List[str]]: ... + def get_marker(self) -> Optional[str]: ... + def get_is_accurate(self) -> Optional[bool]: ... + def get_column_types(self) -> Optional[List[str]]: ... + def get_highlights(self) -> Any: ... + def get_terms(self) -> List[GetLogsResponse.Term]: ... + class PhraseQueryInfo: + def __init__(self, pharse_query_info: Any) -> None: ... + def get_begin_offset(self) -> Optional[int]: ... + def get_end_offset(self) -> Optional[int]: ... + def get_scan_all(self) -> Optional[bool]: ... + def get_end_time(self) -> Optional[int]: ... + def log_print(self) -> None: ... + class Term: + def __init__(self, key: str, term: str) -> None: ... + def get_key(self) -> Optional[str]: ... + def get_term(self) -> Optional[str]: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/index_config.pyi b/aliyun/log/index_config.pyi new file mode 100644 index 00000000..01a57eb5 --- /dev/null +++ b/aliyun/log/index_config.pyi @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +import time + +class IndexJsonKeyConfig(object): + def __init__(self, index_all: bool = ..., max_depth: int = ..., alias: Optional[str] = ...) -> None: ... + def add_key(self, key_name: Any, key_type: Any, doc_value: Any = ..., alias: Optional[str] = ...) -> None: ... + def to_json(self, json_value: Any) -> None: ... + def from_json(self, json_value: Any) -> None: ... + +class IndexKeyConfig(object): + def __init__(self, token_list: Optional[List[str]] = ..., case_sensitive: bool = ..., index_type: str = ..., doc_value: bool = ..., alias: Optional[str] = ..., json_key_config: Optional[IndexJsonKeyConfig] = ..., chinese: Optional[bool] = ..., embedding: Any = ..., vector_index: Any = ...) -> None: ... + def set_json_key_config(self, json_key_config: IndexJsonKeyConfig) -> None: ... + def get_json_key_config(self) -> Any: ... + def to_json(self) -> Any: ... + def from_json(self, json_value: Any) -> None: ... + +class IndexLineConfig(object): + def __init__(self, token_list: Optional[List[str]] = ..., case_sensitive: bool = ..., include_keys: Optional[List[str]] = ..., exclude_keys: Optional[List[str]] = ..., chinese: Optional[bool] = ..., auto_key_detect: Optional[bool] = ..., auto_key_count_limit: Optional[int] = ...) -> None: ... + def to_json(self) -> Any: ... + def from_json(self, json_value: Any) -> None: ... + +class IndexConfig(object): + def __init__(self, ttl: int = ..., line_config: Optional[IndexLineConfig] = ..., key_config_list: Optional[Dict[str, Any]] = ..., all_keys_config: Optional[IndexKeyConfig] = ..., log_reduce: Optional[bool] = ..., scan_index: Optional[bool] = ...) -> None: ... + def set_docvalue_max_text_len(self, max_len: Any) -> None: ... + def set_log_reduce_black_list(self, black_list: Any) -> None: ... + def set_log_reduce_white_list(self, white_list: Any) -> None: ... + def set_scan_index(self, scan_index: bool) -> None: ... + def to_json(self) -> Any: ... + def from_json(self, json_value: Any) -> None: ... diff --git a/aliyun/log/listlogstoresrequest.pyi b/aliyun/log/listlogstoresrequest.pyi new file mode 100644 index 00000000..bb740365 --- /dev/null +++ b/aliyun/log/listlogstoresrequest.pyi @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logrequest import LogRequest + +class ListLogstoresRequest(LogRequest): + def __init__(self, project: Optional[str] = ...) -> None: ... diff --git a/aliyun/log/listlogstoresresponse.pyi b/aliyun/log/listlogstoresresponse.pyi new file mode 100644 index 00000000..4de8ca66 --- /dev/null +++ b/aliyun/log/listlogstoresresponse.pyi @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logresponse import LogResponse + +class ListLogstoresResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_count(self) -> int: ... + def get_total(self) -> int: ... + def get_logstores(self) -> List[str]: ... + def log_print(self) -> None: ... + def merge(self, response: ListLogstoresResponse) -> ListLogstoresResponse: ... diff --git a/aliyun/log/listtopicsrequest.pyi b/aliyun/log/listtopicsrequest.pyi new file mode 100644 index 00000000..a16726e5 --- /dev/null +++ b/aliyun/log/listtopicsrequest.pyi @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logrequest import LogRequest + +class ListTopicsRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., logstore: Optional[str] = ..., token: Optional[str] = ..., line: Optional[int] = ...) -> None: ... + def get_logstore(self) -> str: ... + def set_logstore(self, logstore: str) -> None: ... + def get_token(self) -> str: ... + def set_token(self, token: str) -> None: ... + def get_line(self) -> int: ... + def set_line(self, line: int) -> None: ... diff --git a/aliyun/log/listtopicsresponse.pyi b/aliyun/log/listtopicsresponse.pyi new file mode 100644 index 00000000..096025a3 --- /dev/null +++ b/aliyun/log/listtopicsresponse.pyi @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logresponse import LogResponse +from .util import Util + +class ListTopicsResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_count(self) -> int: ... + def get_topics(self) -> List[Any]: ... + def get_next_token(self) -> Optional[str]: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/logclient.pyi b/aliyun/log/logclient.pyi new file mode 100644 index 00000000..5abea380 --- /dev/null +++ b/aliyun/log/logclient.pyi @@ -0,0 +1,283 @@ +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union +from .async_sql_response import AsyncSqlResponse +from .common_response import CreateEntityResponse, DeleteEntityResponse, GetEntityResponse, ListEntityResponse, UpdateEntityResponse +from .compress import CompressType, Compressor +from .consumer_group_response import ConsumerGroupCheckPointResponse, ConsumerGroupHeartBeatResponse, ConsumerGroupUpdateCheckPointResponse, CreateConsumerGroupResponse, DeleteConsumerGroupResponse, ListConsumerGroupResponse, UpdateConsumerGroupResponse +from .credentials import CredentialsProvider, StaticCredentialsProvider +from .cursor_response import GetCursorResponse +from .cursor_time_response import GetCursorTimeResponse +from .delete_async_sql_request import DeleteAsyncSqlRequest +from .deletelogsrequest import DeleteLogsRequest +from .deletelogssresponse import DeleteLogsResponse +from .etl_config_response import CreateEtlResponse, DeleteEtlResponse, GetEtlResponse, ListEtlsResponse, StartEtlResponse, StopEtlResponse, UpdateEtlResponse +from .export_response import CreateExportResponse, DeleteExportResponse, GetExportResponse, ListExportResponse, UpdateExportResponse +from .external_store_config import ExternalStoreConfigBase +from .external_store_config_response import CreateExternalStoreResponse, DeleteExternalStoreResponse, GetExternalStoreResponse, ListExternalStoreResponse, UpdateExternalStoreResponse +from .get_async_sql_request import GetAsyncSqlRequest +from .getcontextlogsresponse import GetContextLogsResponse +from .getdeletelogsstatusrequest import GetDeleteLogsStatusRequest +from .getdeletelogsstatusresponse import GetDeleteLogsStatusResponse +from .gethistogramsrequest import GetHistogramsRequest +from .gethistogramsresponse import GetHistogramsResponse +from .getlogsrequest import GetLogsRequest, GetProjectLogsRequest +from .getlogsresponse import GetLogsResponse +from .index_config import IndexConfig +from .index_config_response import CreateIndexResponse, DeleteIndexResponse, GetIndexResponse, UpdateIndexResponse +from .ingestion_response import CreateIngestionResponse, DeleteIngestionResponse, GetIngestionResponse, ListIngestionResponse, RestartIngestionResponse, StartIngestionResponse, StopIngestionResponse, UpdateIngestionResponse +from .job import Export +from .listdeletelogsstasksrequest import ListDeleteLogsTasksRequest +from .listdeletelogsstasksresponse import ListDeleteLogsTasksResponse +from .listlogstoresrequest import ListLogstoresRequest +from .listlogstoresresponse import ListLogstoresResponse +from .listtopicsrequest import ListTopicsRequest +from .listtopicsresponse import ListTopicsResponse +from .logclient_operator import ResourceUsageResponse, copy_project, list_more, query_more, pull_log_dump, copy_logstore, copy_data, get_resource_usage, arrange_shard, transform_data, copy_dashboard, copy_alert +from .logexception import LogException +from .logresponse import LogResponse +from .logstore_config_response import CreateLogStoreResponse, DeleteLogStoreResponse, GetLogStoreResponse, ListLogStoreResponse, UpdateLogStoreResponse +from .logtail_config_detail import ApsaraFileConfigDetail, CommonRegLogConfigDetail, FullRegFileConfigDetail, JsonFileConfigDetail, LogtailConfigGenerator, SeperatorFileConfigDetail, SimpleFileConfigDetail, SyslogConfigDetail +from .logtail_config_response import CreateLogtailConfigResponse, DeleteLogtailConfigResponse, GetLogtailConfigResponse, ListLogtailConfigResponse, UpdateLogtailConfigResponse +from .logtail_pipeline_config_detail import LogtailPipelineConfigDetail +from .logtail_pipeline_config_response import CreateLogtailPipelineConfigResponse, DeleteLogtailPipelineConfigResponse, GetLogtailPipelineConfigResponse, ListLogtailPipelineConfigResponse, UpdateLogtailPipelineConfigResponse +from .machine_group_detail import MachineGroupDetail +from .machinegroup_response import ApplyConfigToMachineGroupResponse, CreateMachineGroupResponse, DeleteMachineGroupResponse, GetConfigAppliedMachineGroupsResponse, GetMachineGroupAppliedConfigResponse, GetMachineGroupResponse, ListMachineGroupResponse, ListMachinesResponse, RemoveConfigToMachineGroupResponse, UpdateMachineGroupResponse +from .metering_mode_response import GetLogStoreMeteringModeResponse, GetMetricStoreMeteringModeResponse, UpdateLogStoreMeteringModeResponse, UpdateMetricStoreMeteringModeResponse +from .multimodal_config_response import GetLogStoreMultimodalConfigurationResponse, PutLogStoreMultimodalConfigurationResponse +from .object_response import PutObjectResponse, GetObjectResponse +from .project_response import CreateProjectResponse, DeleteProjectResponse, GetProjectResponse, GetProjectTagsResponse, ListProjectResponse, UpdateProjectResponse +from .proto import LogGroupRaw as LogGroup +from .pulllog_response import PullLogResponse +from .putlogsrequest import PutLogsRequest +from .putlogsresponse import PutLogsResponse +from .rebuild_index_response import CreateRebuildIndexResponse, GetRebuildIndexResponse +from .resource_params import Resource, ResourceRecord +from .resource_response import CreateRecordResponse, CreateResourceResponse, DeleteRecordResponse, DeleteResourceResponse, GetRecordResponse, GetResourceResponse, ListRecordResponse, ListResourcesResponse, UpdateRecordResponse, UpdateResourceResponse, UpsertRecordResponse +from .scheduled_sql import ScheduledSQL, ScheduledSQLConfiguration +from .scheduled_sql_response import CreateScheduledSQLResponse, DeleteScheduledSQLResponse, GetScheduledSQLResponse, GetScheduledSqlJobInstanceResponse, ListScheduledSQLResponse, ListScheduledSqlJobInstancesResponse, ModifyScheduledSqlJobStateResponse, UpdateScheduledSQLResponse +from .shard_response import DeleteShardResponse, ListShardResponse +from .shipper_response import CreateShipperResponse, DeleteShipperResponse, GetShipperConfigResponse, GetShipperTasksResponse, ListShipperResponse, RetryShipperTasksResponse, UpdateShipperResponse +from .sql_instance_response import CreateSqlInstanceResponse, ListSqlInstanceResponse, UpdateSqlInstanceResponse +from .store_view import StoreView +from .store_view_response import CreateStoreViewResponse, DeleteStoreViewResponse, GetStoreViewResponse, ListStoreViewsResponse, UpdateStoreViewResponse +from .substore_config_response import CreateMetricsStoreResponse, CreateSubStoreResponse, DeleteSubStoreResponse, GetSubStoreResponse, GetSubStoreTTLResponse, ListSubStoreResponse, UpdateSubStoreResponse, UpdateSubStoreTTLResponse +from .submit_async_sql_request import SubmitAsyncSqlRequest +from .tag_response import GetResourceTagsResponse +from .topostore_params import Topostore, TopostoreNode, TopostoreRelation +from .topostore_response import CreateTopostoreNodeResponse, CreateTopostoreRelationResponse, CreateTopostoreResponse, DeleteTopostoreNodeResponse, DeleteTopostoreRelationResponse, DeleteTopostoreResponse, GetTopostoreNodeResponse, GetTopostoreRelationResponse, GetTopostoreResponse, ListTopostoreNodesResponse, ListTopostoreRelationsResponse, ListTopostoresResponse, UpdateTopostoreNodeResponse, UpdateTopostoreRelationResponse, UpdateTopostoreResponse, UpsertTopostoreNodeResponse, UpsertTopostoreRelationResponse + +class LogClient(object): + __version__: str + Version: str + def __init__(self, endpoint: str, accessKeyId: Optional[str] = ..., accessKey: Optional[str] = ..., securityToken: Optional[str] = ..., source: Optional[str] = ..., auth_version: str = ..., region: str = ..., credentials_provider: Optional[CredentialsProvider] = ...) -> None: ... + def set_credentials_auto_refresher(self, refresher: Callable[[], Tuple[str, str, Optional[str]]]) -> None: ... + @property + def timeout(self) -> int: ... + @timeout.setter + def timeout(self, value: int) -> None: ... + def set_user_agent(self, user_agent: str) -> None: ... + def set_source(self, source: str) -> None: ... + def put_log_raw(self, project: str, logstore: str, log_group: LogGroup, compress: Optional[bool] = ...) -> PutLogsResponse: ... + def put_logs(self, request: PutLogsRequest) -> PutLogsResponse: ... + def list_logstores(self, request: ListLogstoresRequest) -> ListLogstoresResponse: ... + def list_topics(self, request: ListTopicsRequest) -> ListTopicsResponse: ... + def get_histograms(self, request: GetHistogramsRequest) -> GetHistogramsResponse: ... + def delete_logs(self, request: DeleteLogsRequest) -> DeleteLogsResponse: ... + def get_delete_logs_status(self, request: GetDeleteLogsStatusRequest) -> GetDeleteLogsStatusResponse: ... + def list_delete_logs_tasks(self, request: ListDeleteLogsTasksRequest) -> ListDeleteLogsTasksResponse: ... + def get_log(self, project: str, logstore: str, from_time: Union[int, str], to_time: Union[int, str], topic: Optional[str] = ..., query: Optional[str] = ..., reverse: bool = ..., offset: int = ..., size: int = ..., power_sql: bool = ..., scan: bool = ..., forward: bool = ..., accurate_query: bool = ..., from_time_nano_part: int = ..., to_time_nano_part: int = ...) -> GetLogsResponse: ... + def get_logs(self, request: GetLogsRequest) -> GetLogsResponse: ... + def get_log_all(self, project: str, logstore: str, from_time: Union[int, str], to_time: Union[int, str], topic: Optional[str] = ..., query: Optional[str] = ..., reverse: bool = ..., offset: int = ..., power_sql: bool = ..., accurate_query: bool = ...) -> Iterator[GetLogsResponse]: ... + def get_log_all_v2(self, project: str, logstore: str, from_time: Union[int, str], to_time: Union[int, str], topic: Optional[str] = ..., query: Optional[str] = ..., reverse: bool = ..., offset: int = ..., power_sql: bool = ..., scan: bool = ..., forward: bool = ...) -> Iterator[GetLogsResponse]: ... + def execute_logstore_sql(self, project: str, logstore: str, from_time: Union[int, str], to_time: Union[int, str], sql: str, power_sql: bool) -> GetLogsResponse: ... + def execute_project_sql(self, project: str, sql: str, power_sql: bool) -> GetLogsResponse: ... + def submit_async_sql(self, request: SubmitAsyncSqlRequest) -> AsyncSqlResponse: ... + def get_async_sql(self, request: GetAsyncSqlRequest) -> AsyncSqlResponse: ... + def delete_async_sql(self, request: DeleteAsyncSqlRequest) -> AsyncSqlResponse: ... + def get_context_logs(self, project: str, logstore: str, pack_id: str, pack_meta: str, back_lines: int, forward_lines: int) -> GetContextLogsResponse: ... + def get_project_logs(self, request: GetProjectLogsRequest) -> GetLogsResponse: ... + def get_cursor(self, project_name: str, logstore_name: str, shard_id: int, start_time: Union[str, int]) -> GetCursorResponse: ... + def get_cursor_time(self, project_name: str, logstore_name: str, shard_id: int, cursor: str) -> GetCursorTimeResponse: ... + def get_previous_cursor_time(self, project_name: str, logstore_name: str, shard_id: int, cursor: str, normalize: bool = ...) -> GetCursorTimeResponse: ... + def get_begin_cursor(self, project_name: str, logstore_name: str, shard_id: int) -> GetCursorResponse: ... + def get_end_cursor(self, project_name: str, logstore_name: str, shard_id: int) -> GetCursorResponse: ... + def pull_logs(self, project_name: str, logstore_name: str, shard_id: int, cursor: str, count: Optional[int] = ..., end_cursor: Optional[str] = ..., compress: Optional[bool] = ..., query: Optional[str] = ..., accept_compress_type: Optional[str] = ..., processor: Optional[str] = ...) -> PullLogResponse: ... + def pull_log(self, project_name: str, logstore_name: str, shard_id: int, from_time: Union[int, str], to_time: Union[int, str], batch_size: Optional[int] = ..., compress: Optional[bool] = ..., query: Optional[str] = ..., accept_compress_type: Optional[str] = ..., processor: Optional[str] = ...) -> Iterator[PullLogResponse]: ... + def pull_log_dump(self, project_name: str, logstore_name: str, from_time: Union[int, str], to_time: Union[int, str], file_path: str, batch_size: Optional[int] = ..., compress: Optional[bool] = ..., encodings: Optional[List[str]] = ..., shard_list: Optional[Union[str, List[str]]] = ..., no_escape: Optional[bool] = ..., query: Optional[str] = ..., processor: Optional[str] = ...) -> LogResponse: ... + def create_logstore(self, project_name: str, logstore_name: str, ttl: int = ..., shard_count: int = ..., enable_tracking: bool = ..., append_meta: bool = ..., auto_split: bool = ..., max_split_shard: int = ..., preserve_storage: bool = ..., encrypt_conf: Optional[Dict[str, Any]] = ..., telemetry_type: str = ..., hot_ttl: int = ..., mode: Optional[str] = ..., infrequent_access_ttl: int = ...) -> CreateLogStoreResponse: ... + def delete_logstore(self, project_name: str, logstore_name: str) -> DeleteLogStoreResponse: ... + def get_logstore(self, project_name: str, logstore_name: str) -> GetLogStoreResponse: ... + def update_logstore(self, project_name: str, logstore_name: str, ttl: Optional[int] = ..., enable_tracking: Optional[bool] = ..., shard_count: Optional[int] = ..., append_meta: Optional[bool] = ..., auto_split: Optional[bool] = ..., max_split_shard: Optional[int] = ..., preserve_storage: Optional[bool] = ..., encrypt_conf: Optional[Dict[str, Any]] = ..., hot_ttl: int = ..., mode: Optional[str] = ..., telemetry_type: Optional[str] = ..., infrequent_access_ttl: int = ...) -> UpdateLogStoreResponse: ... + def list_logstore(self, project_name: str, logstore_name_pattern: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListLogStoreResponse: ... + def get_logstore_metering_mode(self, project_name: str, logstore_name: str) -> GetLogStoreMeteringModeResponse: ... + def update_logstore_metering_mode(self, project_name: str, logstore_name: str, metering_mode: str) -> UpdateLogStoreMeteringModeResponse: ... + def get_logstore_multimodal_configuration(self, project_name: str, logstore_name: str) -> GetLogStoreMultimodalConfigurationResponse: ... + def put_logstore_multimodal_configuration(self, project_name: str, logstore_name: str, status: str, anonymous_write: Optional[str] = ...) -> PutLogStoreMultimodalConfigurationResponse: ... + def get_metric_store_metering_mode(self, project_name: str, metric_store_name: str) -> GetMetricStoreMeteringModeResponse: ... + def update_metric_store_metering_mode(self, project_name: str, metric_store_name: str, metering_mode: str) -> UpdateMetricStoreMeteringModeResponse: ... + def create_external_store(self, project_name: str, config: ExternalStoreConfigBase) -> CreateExternalStoreResponse: ... + def delete_external_store(self, project_name: str, store_name: str) -> DeleteExternalStoreResponse: ... + def get_external_store(self, project_name: str, store_name: str) -> GetExternalStoreResponse: ... + def update_external_store(self, project_name: Any, config: ExternalStoreConfigBase) -> UpdateExternalStoreResponse: ... + def list_external_store(self, project_name: str, external_store_name_pattern: Any = ..., offset: int = ..., size: int = ...) -> ListExternalStoreResponse: ... + def list_shards(self, project_name: str, logstore_name: str) -> ListShardResponse: ... + def split_shard(self, project_name: str, logstore_name: str, shardId: int, split_hash: str) -> ListShardResponse: ... + def merge_shard(self, project_name: str, logstore_name: str, shardId: int) -> ListShardResponse: ... + def delete_shard(self, project_name: str, logstore_name: str, shardId: int) -> DeleteShardResponse: ... + def create_index(self, project_name: str, logstore_name: str, index_detail: IndexConfig) -> CreateIndexResponse: ... + def update_index(self, project_name: str, logstore_name: str, index_detail: IndexConfig) -> UpdateIndexResponse: ... + def delete_index(self, project_name: str, logstore_name: str) -> DeleteIndexResponse: ... + def get_index_config(self, project_name: str, logstore_name: str) -> GetIndexResponse: ... + def create_logtail_config(self, project_name: str, config_detail: Union[LogtailConfigGenerator, SeperatorFileConfigDetail, SimpleFileConfigDetail, FullRegFileConfigDetail, JsonFileConfigDetail, ApsaraFileConfigDetail, SyslogConfigDetail, CommonRegLogConfigDetail]) -> CreateLogtailConfigResponse: ... + def update_logtail_config(self, project_name: str, config_detail: Union[LogtailConfigGenerator, SeperatorFileConfigDetail, SimpleFileConfigDetail, FullRegFileConfigDetail, JsonFileConfigDetail, ApsaraFileConfigDetail, SyslogConfigDetail, CommonRegLogConfigDetail]) -> UpdateLogtailConfigResponse: ... + def delete_logtail_config(self, project_name: str, config_name: str) -> DeleteLogtailConfigResponse: ... + def get_logtail_config(self, project_name: str, config_name: str) -> GetLogtailConfigResponse: ... + def list_logtail_config(self, project_name: str, logstore: Optional[str] = ..., config: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListLogtailConfigResponse: ... + def create_logtail_pipeline_config(self, project_name: str, config_detail: LogtailPipelineConfigDetail) -> CreateLogtailPipelineConfigResponse: ... + def update_logtail_pipeline_config(self, project_name: str, config_detail: LogtailPipelineConfigDetail) -> UpdateLogtailPipelineConfigResponse: ... + def delete_logtail_pipeline_config(self, project_name: str, config_name: str) -> DeleteLogtailPipelineConfigResponse: ... + def get_logtail_pipeline_config(self, project_name: str, config_name: str) -> GetLogtailPipelineConfigResponse: ... + def list_logtail_pipeline_config(self, project_name: str, config_name: Optional[str] = ..., logstore_name: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListLogtailPipelineConfigResponse: ... + def create_machine_group(self, project_name: str, group_detail: MachineGroupDetail) -> CreateMachineGroupResponse: ... + def delete_machine_group(self, project_name: str, group_name: str) -> DeleteMachineGroupResponse: ... + def update_machine_group(self, project_name: str, group_detail: MachineGroupDetail) -> UpdateMachineGroupResponse: ... + def get_machine_group(self, project_name: str, group_name: str) -> GetMachineGroupResponse: ... + def list_machine_group(self, project_name: str, offset: int = ..., size: int = ...) -> ListMachineGroupResponse: ... + def list_machines(self, project_name: str, group_name: str, offset: int = ..., size: int = ...) -> ListMachinesResponse: ... + def apply_config_to_machine_group(self, project_name: str, config_name: str, group_name: str) -> ApplyConfigToMachineGroupResponse: ... + def remove_config_to_machine_group(self, project_name: str, config_name: str, group_name: str) -> RemoveConfigToMachineGroupResponse: ... + def get_machine_group_applied_configs(self, project_name: str, group_name: str) -> GetMachineGroupAppliedConfigResponse: ... + def get_config_applied_machine_groups(self, project_name: str, config_name: str) -> GetConfigAppliedMachineGroupsResponse: ... + def get_shipper_tasks(self, project_name: str, logstore_name: str, shipper_name: str, start_time: int, end_time: int, status_type: str = ..., offset: int = ..., size: int = ...) -> GetShipperTasksResponse: ... + def retry_shipper_tasks(self, project_name: str, logstore_name: str, shipper_name: str, task_list: List[str]) -> RetryShipperTasksResponse: ... + def check_upsert_scheduled_sql(self, project_name: str, scheduled_sql: Any, method: str, resource: str) -> Tuple[Dict[str, Any], Dict[str, Any]]: ... + def create_scheduled_sql(self, project_name: str, scheduled_sql: ScheduledSQL) -> CreateScheduledSQLResponse: ... + def update_scheduled_sql(self, project_name: str, scheduled_sql: ScheduledSQL) -> UpdateScheduledSQLResponse: ... + def delete_scheduled_sql(self, project_name: str, job_name: str) -> DeleteScheduledSQLResponse: ... + def get_scheduled_sql(self, project_name: str, job_name: str) -> GetScheduledSQLResponse: ... + def list_scheduled_sql(self, project_name: str, offset: int = ..., size: int = ...) -> ListScheduledSQLResponse: ... + def list_scheduled_sql_job_instance(self, project: str, job_name: str, from_time: int, to_time: int, state: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListScheduledSqlJobInstancesResponse: ... + def get_scheduled_sql_job_instance(self, project: str, job_name: str, instance_id: str, result: Optional[str] = ...) -> GetScheduledSqlJobInstanceResponse: ... + def modify_scheduled_sql_job_instance_state(self, project: str, job_name: str, instance_id: str, state: str) -> ModifyScheduledSqlJobStateResponse: ... + def create_project(self, project_name: str, project_des: str, resource_group_id: str = ..., data_redundancy_type: Optional[str] = ...) -> CreateProjectResponse: ... + def update_project(self, project_name: str, project_des: str) -> UpdateProjectResponse: ... + def get_project(self, project_name: str) -> GetProjectResponse: ... + def delete_project(self, project_name: str) -> DeleteProjectResponse: ... + def change_resource_group(self, resource_id: str, resource_group_id: str, resource_type: str = ...) -> LogResponse: ... + def tag_project(self, project_name: str, **tags: Any) -> LogResponse: ... + def untag_project(self, project_name: str, *tag_keys: Any) -> LogResponse: ... + def get_project_tags(self, project_name: str, **filer_tags: Any) -> Iterator[GetProjectTagsResponse]: ... + def tag_resources(self, resource_type: str, resource_id: str, **tags: Any) -> LogResponse: ... + def untag_resources(self, resource_type: str, resource_id: str, *tag_keys: Any) -> LogResponse: ... + def list_tag_resources(self, resource_type: str, resource_id: Optional[str], **filer_tags: Any) -> Iterator[GetResourceTagsResponse]: ... + def create_consumer_group(self, project: str, logstore: str, consumer_group: str, timeout: int, in_order: bool = ...) -> CreateConsumerGroupResponse: ... + def update_consumer_group(self, project: str, logstore: str, consumer_group: str, timeout: Optional[int] = ..., in_order: Optional[bool] = ...) -> UpdateConsumerGroupResponse: ... + def delete_consumer_group(self, project: str, logstore: str, consumer_group: str) -> DeleteConsumerGroupResponse: ... + def list_consumer_group(self, project: str, logstore: str) -> ListConsumerGroupResponse: ... + def update_check_point(self, project: str, logstore: str, consumer_group: str, shard: int, check_point: str, consumer: str = ..., force_success: bool = ...) -> ConsumerGroupUpdateCheckPointResponse: ... + def get_check_point(self, project: str, logstore: str, consumer_group: str, shard: int = ...) -> ConsumerGroupCheckPointResponse: ... + def get_check_point_fixed(self, project: str, logstore: str, consumer_group: str, shard: int = ...) -> ConsumerGroupCheckPointResponse: ... + def heart_beat(self, project: str, logstore: str, consumer_group: str, consumer: str, shards: Optional[List[int]] = ...) -> ConsumerGroupHeartBeatResponse: ... + def copy_project(self, from_project: str, to_project: str, to_client: Optional[LogClient] = ..., copy_machine_group: bool = ..., copy_dashboards: bool = ..., copy_alerts: bool = ...) -> None: ... + def copy_logstore(self, from_project: str, from_logstore: str, to_logstore: str, to_project: Optional[str] = ..., to_client: Optional[LogClient] = ..., to_region_endpoint: Optional[str] = ..., keep_config_name: Any = ...) -> None: ... + def copy_dashboard(self, from_project: str, from_dashboard_name: str, to_project: Optional[str] = ..., to_dashboard_name: Optional[str] = ..., to_client: Optional[LogClient] = ..., to_region_endpoint: Optional[str] = ...) -> None: ... + def copy_alert(self, from_project: str, from_alert_name: str, to_project: Optional[str] = ..., to_alert_name: Optional[str] = ..., to_client: Optional[LogClient] = ..., to_region_endpoint: Optional[str] = ...) -> None: ... + def list_project(self, offset: int = ..., size: int = ..., project_name_pattern: Optional[str] = ..., resource_group_id: str = ..., description: Optional[str] = ...) -> ListProjectResponse: ... + def es_migration(self, cache_path: str, hosts: str, project_name: str, indexes: Optional[str] = ..., query: Optional[str] = ..., logstore_index_mappings: Optional[str] = ..., pool_size: Optional[int] = ..., time_reference: Optional[str] = ..., source: Optional[str] = ..., topic: Optional[str] = ..., batch_size: Optional[int] = ..., wait_time_in_secs: Optional[int] = ..., auto_creation: bool = ..., retries_failed: Optional[int] = ..., cache_duration: str = ...) -> LogResponse: ... + def copy_data(self, project: str, logstore: str, from_time: Union[str, int], to_time: Optional[Union[str, int]] = ..., to_client: Optional[LogClient] = ..., to_project: Optional[str] = ..., to_logstore: Optional[str] = ..., shard_list: Optional[str] = ..., batch_size: Optional[int] = ..., compress: Optional[bool] = ..., new_topic: Optional[str] = ..., new_source: Optional[str] = ...) -> LogResponse: ... + def transform_data(self, project: str, logstore: str, config: str, from_time: Union[str, int], to_time: Optional[Union[str, int]] = ..., to_client: Optional[LogClient] = ..., to_project: Optional[str] = ..., to_logstore: Optional[str] = ..., shard_list: Optional[str] = ..., batch_size: Optional[int] = ..., compress: Optional[bool] = ..., cg_name: Optional[str] = ..., c_name: Optional[str] = ..., cg_heartbeat_interval: Optional[int] = ..., cg_data_fetch_interval: Optional[int] = ..., cg_in_order: Optional[bool] = ..., cg_worker_pool_size: Optional[int] = ...) -> LogResponse: ... + def get_resource_usage(self, project: Any) -> ResourceUsageResponse: ... + def arrange_shard(self, project: str, logstore: str, count: int) -> None: ... + def enable_alert(self, project_name: str, job_name: str) -> LogResponse: ... + def disable_alert(self, project_name: str, job_name: str) -> LogResponse: ... + def list_ingestion(self, project_name: str, logstore_name: Any = ..., offset: Any = ..., size: Any = ...) -> ListIngestionResponse: ... + def create_ingestion(self, project_name: str, ingestion_config: str) -> CreateIngestionResponse: ... + def update_ingestion(self, project_name: str, ingestion_name: str, ingestion_config: str) -> UpdateIngestionResponse: ... + def delete_ingestion(self, project_name: str, ingestion_name: str) -> DeleteIngestionResponse: ... + def get_ingestion(self, project_name: str, ingestion_name: str) -> GetIngestionResponse: ... + def start_ingestion(self, project_name: str, ingestion_name: str) -> StartIngestionResponse: ... + def restart_ingestion(self, project_name: str, ingestion_name: str, ingestion_config: Any) -> RestartIngestionResponse: ... + def stop_ingestion(self, project_name: str, ingestion_name: str) -> StopIngestionResponse: ... + def create_etl(self, project_name: str, name: str, configuration: Dict[str, Any], schedule: Dict[str, Any], display_name: str, description: Optional[str] = ...) -> CreateEtlResponse: ... + def get_etl(self, project_name: str, name: str) -> GetEtlResponse: ... + def update_etl(self, project_name: str, name: str, configuration: Dict[str, Any], schedule: Dict[str, Any], display_name: str, description: Optional[str] = ...) -> UpdateEtlResponse: ... + def start_etl(self, project_name: str, name: str) -> StartEtlResponse: ... + def stop_etl(self, project_name: str, name: str) -> StopEtlResponse: ... + def list_etls(self, project_name: str, offset: int = ..., size: int = ...) -> ListEtlsResponse: ... + def delete_etl(self, project_name: str, name: str) -> DeleteEtlResponse: ... + def create_substore(self, project_name: str, logstore_name: str, substore_name: str, keys: List[Any], ttl: int, sorted_key_count: int, time_index: Any) -> CreateSubStoreResponse: ... + def delete_substore(self, project_name: str, logstore_name: str, substore_name: str) -> DeleteSubStoreResponse: ... + def get_substore(self, project_name: str, logstore_name: str, substore_name: str) -> GetSubStoreResponse: ... + def update_substore(self, project_name: str, logstore_name: str, substore_name: str, keys: List[Any], ttl: int, sorted_key_count: int, time_index: Any) -> UpdateSubStoreResponse: ... + def list_substore(self, project_name: str, logstore_name: str) -> ListSubStoreResponse: ... + def get_substore_ttl(self, project_name: str, logstore_name: str) -> GetSubStoreTTLResponse: ... + def update_substore_ttl(self, project_name: str, logstore_name: str, ttl: int) -> UpdateSubStoreTTLResponse: ... + def create_metric_store(self, project_name: str, logstore_name: str, ttl: int = ..., shard_count: int = ..., enable_tracking: bool = ..., append_meta: bool = ..., auto_split: bool = ..., max_split_shard: int = ..., preserve_storage: bool = ..., encrypt_conf: Optional[Dict[str, Any]] = ..., hot_ttl: int = ..., mode: Optional[str] = ...) -> CreateMetricsStoreResponse: ... + def delete_metric_store(self, project_name: str, logstore_name: str) -> DeleteLogStoreResponse: ... + def get_metric_store(self, project_name: str, logstore_name: str) -> GetLogStoreResponse: ... + def update_metric_store(self, project_name: str, logstore_name: str, ttl: Optional[int] = ..., enable_tracking: Optional[bool] = ..., shard_count: Optional[int] = ..., append_meta: Optional[bool] = ..., auto_split: Optional[bool] = ..., max_split_shard: Optional[int] = ..., preserve_storage: Optional[bool] = ..., encrypt_conf: Optional[Dict[str, Any]] = ..., hot_ttl: int = ..., mode: Optional[str] = ...) -> UpdateLogStoreResponse: ... + def create_sql_instance(self, project_name: str, sql_instance: int, useAsDefault: Any) -> CreateSqlInstanceResponse: ... + def update_sql_instance(self, project_name: str, sql_instance: int, useAsDefault: Any) -> UpdateSqlInstanceResponse: ... + def list_sql_instance(self, project_name: str) -> ListSqlInstanceResponse: ... + def create_resource(self, resource: Resource) -> CreateResourceResponse: ... + def delete_resource(self, resource_name: str) -> DeleteResourceResponse: ... + def update_resource(self, resource: Resource) -> UpdateResourceResponse: ... + def get_resource(self, resource_name: str) -> GetResourceResponse: ... + def list_resources(self, offset: int = ..., size: int = ..., resource_type: Optional[str] = ..., resource_names: Optional[List[Any]] = ...) -> ListResourcesResponse: ... + def create_resource_record(self, resource_name: str, record: ResourceRecord) -> CreateRecordResponse: ... + def delete_resource_record(self, resource_name: str, record_ids: List[Any]) -> DeleteRecordResponse: ... + def update_resource_record(self, resource_name: str, record: ResourceRecord) -> UpdateRecordResponse: ... + def upsert_resource_record(self, resource_name: str, records: List[ResourceRecord]) -> UpsertRecordResponse: ... + def get_resource_record(self, resource_name: str, record_id: str) -> GetRecordResponse: ... + def list_resource_records(self, resource_name: str, tag: Optional[str] = ..., record_ids: Optional[List[str]] = ..., offset: int = ..., size: int = ...) -> ListRecordResponse: ... + def create_topostore(self, topostore: Topostore) -> CreateTopostoreResponse: ... + def update_topostore(self, topostore: Topostore) -> UpdateTopostoreResponse: ... + def delete_topostore(self, topostore_name: str) -> DeleteTopostoreResponse: ... + def get_topostore(self, topostore_name: str) -> GetTopostoreResponse: ... + def list_topostores(self, names: Optional[List[str]] = ..., tag_key: Optional[str] = ..., tag_value: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListTopostoresResponse: ... + def create_topostore_node(self, topostore_name: str, node: TopostoreNode) -> CreateTopostoreNodeResponse: ... + def upsert_topostore_node(self, topostore_name: str, nodes: List[TopostoreNode]) -> UpsertTopostoreNodeResponse: ... + def update_topostore_node(self, topostore_name: str, node: TopostoreNode) -> UpdateTopostoreNodeResponse: ... + def delete_topostore_node(self, topostore_name: str, node_ids: List[Any]) -> DeleteTopostoreNodeResponse: ... + def get_topostore_node(self, topostore_name: str, node_id: str) -> GetTopostoreNodeResponse: ... + def list_topostore_node(self, topostore_name: str, node_ids: Optional[List[str]] = ..., node_types: Optional[List[str]] = ..., property_key: Optional[str] = ..., property_value: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListTopostoreNodesResponse: ... + def create_topostore_relation(self, topostore_name: str, relation: TopostoreRelation) -> CreateTopostoreRelationResponse: ... + def upsert_topostore_relation(self, topostore_name: str, relations: List[TopostoreRelation]) -> UpsertTopostoreRelationResponse: ... + def update_topostore_relation(self, topostore_name: str, relation: TopostoreRelation) -> UpdateTopostoreRelationResponse: ... + def delete_topostore_relation(self, topostore_name: str, relation_ids: List[str]) -> DeleteTopostoreRelationResponse: ... + def get_topostore_relation(self, topostore_name: str, relation_id: str) -> GetTopostoreRelationResponse: ... + def list_topostore_relation(self, topostore_name: str, relation_ids: Optional[List[str]] = ..., relation_types: Optional[List[str]] = ..., src_node_ids: Optional[List[str]] = ..., dst_node_ids: Optional[List[str]] = ..., property_key: Optional[str] = ..., property_value: Optional[str] = ..., offset: int = ..., size: int = ...) -> ListTopostoreRelationsResponse: ... + def create_export(self, project_name: str, export: Export) -> CreateExportResponse: ... + def delete_export(self, project_name: str, job_name: str) -> DeleteExportResponse: ... + def update_export(self, project_name: str, job_name: str, export: str) -> UpdateExportResponse: ... + def get_export(self, project_name: str, job_name: Any) -> GetExportResponse: ... + def list_export(self, project_name: str, offset: int = ..., size: int = ...) -> ListExportResponse: ... + def list_logstore_export(self, project_name: str, logstore_name: str, offset: int = ..., size: int = ...) -> ListExportResponse: ... + def list_alert(self, project: str, offset: int = ..., size: int = ...) -> ListEntityResponse: ... + def get_alert(self, project: str, entity: str) -> GetEntityResponse: ... + def delete_alert(self, project: str, entity: str) -> DeleteEntityResponse: ... + def update_alert(self, project: str, detail: Union[Dict[str, Any], str]) -> UpdateEntityResponse: ... + def create_alert(self, project: str, detail: Union[Dict[str, Any], str]) -> CreateEntityResponse: ... + def list_dashboard(self, project: str, offset: int = ..., size: int = ...) -> ListEntityResponse: ... + def get_dashboard(self, project: str, entity: str) -> GetEntityResponse: ... + def delete_dashboard(self, project: str, entity: str) -> DeleteEntityResponse: ... + def update_dashboard(self, project: str, detail: Union[Dict[str, Any], str]) -> UpdateEntityResponse: ... + def create_dashboard(self, project: str, detail: Union[Dict[str, Any], str]) -> CreateEntityResponse: ... + def list_savedsearch(self, project: str, offset: int = ..., size: int = ...) -> ListEntityResponse: ... + def get_savedsearch(self, project: str, entity: str) -> GetEntityResponse: ... + def delete_savedsearch(self, project: str, entity: str) -> DeleteEntityResponse: ... + def update_savedsearch(self, project: str, detail: Union[Dict[str, Any], str]) -> UpdateEntityResponse: ... + def create_savedsearch(self, project: str, detail: Union[Dict[str, Any], str]) -> CreateEntityResponse: ... + def list_shipper(self, project: str, logstore: str, offset: int = ..., size: int = ...) -> ListEntityResponse: ... + def get_shipper(self, project: str, logstore: str, entity: str) -> GetEntityResponse: ... + def delete_shipper(self, project: str, logstore: str, entity: str) -> DeleteEntityResponse: ... + def update_shipper(self, project: str, logstore: str, detail: Union[Dict[str, Any], str]) -> UpdateEntityResponse: ... + def create_shipper(self, project: str, logstore: str, detail: Union[Dict[str, Any], str]) -> CreateEntityResponse: ... + def create_rebuild_index(self, project: str, logstore: str, job_name: str, display_name: str, from_time: int, to_time: int) -> CreateRebuildIndexResponse: ... + def get_rebuild_index(self, project: str, job_name: str) -> GetRebuildIndexResponse: ... + def list_store_views(self, project_name: str, offset: int = ..., size: int = ..., store_type: Optional[str] = ...) -> ListStoreViewsResponse: ... + def get_store_view(self, project_name: str, store_view_name: str) -> GetStoreViewResponse: ... + def update_store_view(self, project_name: str, store_view_name: str, store_view: StoreView) -> UpdateStoreViewResponse: ... + def create_store_view(self, project_name: str, store_view: StoreView) -> CreateStoreViewResponse: ... + def delete_store_view(self, project_name: str, store_view_name: str) -> DeleteStoreViewResponse: ... + def put_object(self, project_name: str, logstore_name: str, object_name: str, content: Union[bytes, str], headers: Optional[Dict[str, Any]] = ...) -> PutObjectResponse: ... + def get_object(self, project_name: str, logstore_name: str, object_name: str) -> GetObjectResponse: ... diff --git a/aliyun/log/logclient_operator.py b/aliyun/log/logclient_operator.py index ba1341d0..8d424bbf 100644 --- a/aliyun/log/logclient_operator.py +++ b/aliyun/log/logclient_operator.py @@ -25,8 +25,8 @@ logger = logging.getLogger(__name__) -# type: (LogClient, LogClient, str, str, bool, bool, bool) -> None def copy_project(from_client, to_client, from_project, to_project, copy_machine_group=False, copy_dashboards=False, copy_alerts=False): + # type: (LogClient, LogClient, str, str, bool, bool, bool) -> None """ copy project, logstore, machine group and logtail config to target project, will create the target project if it doesn't exist @@ -1142,4 +1142,3 @@ def copy_alert(from_client, from_project, from_alert_name, to_project=None, to_a else: raise - diff --git a/aliyun/log/logexception.pyi b/aliyun/log/logexception.pyi new file mode 100644 index 00000000..f50bd828 --- /dev/null +++ b/aliyun/log/logexception.pyi @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +import json + +class LogException(Exception): + def __init__(self, errorCode: str, errorMessage: str, requestId: str = ..., resp_status: Any = ..., resp_header: Any = ..., resp_body: Any = ...) -> None: ... + def __str__(self): ... + def get_error_code(self) -> str: ... + def get_error_message(self) -> str: ... + def get_request_id(self) -> str: ... + def get_resp_body(self) -> str: ... + def get_resp_status(self) -> int: ... diff --git a/aliyun/log/logitem.pyi b/aliyun/log/logitem.pyi new file mode 100644 index 00000000..b9de8364 --- /dev/null +++ b/aliyun/log/logitem.pyi @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +import time +import copy + +class LogItem(object): + def __init__(self, timestamp: Optional[int] = ..., contents: Optional[List[Tuple[str, str]]] = ..., time_nano_part: Optional[int] = ...) -> None: ... + def push_back(self, key: str, value: str) -> None: ... + def get_contents(self) -> List[Tuple[str, str]]: ... + def set_contents(self, contents: List[Tuple[str, str]]) -> None: ... + def get_time(self) -> int: ... + def get_time_nano_part(self) -> int: ... + def set_time(self, timestamp: int) -> None: ... + def set_time_nano_part(self, time_nano_part: int) -> None: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/logresponse.pyi b/aliyun/log/logresponse.pyi new file mode 100644 index 00000000..c0e48720 --- /dev/null +++ b/aliyun/log/logresponse.pyi @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .util import Util + +class LogResponse(object): + def __init__(self, headers: Dict[str, Any], body: Any = ...) -> None: ... + def get_request_id(self) -> str: ... + def get_body(self) -> Any: ... + def get_all_headers(self) -> Dict[str, Any]: ... + def get_header(self, key: str) -> str: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/machine_group_detail.pyi b/aliyun/log/machine_group_detail.pyi new file mode 100644 index 00000000..0eda7b43 --- /dev/null +++ b/aliyun/log/machine_group_detail.pyi @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +import time +from .util import Util + +class MachineGroupDetail(object): + def __init__(self, group_name: Optional[str] = ..., machine_type: Optional[str] = ..., machine_list: Optional[str] = ..., group_type: str = ..., group_attribute: Optional[Dict[str, Any]] = ...) -> None: ... + def to_json(self) -> Any: ... + def from_json(self, json_value: Any) -> None: ... + +class MachineStatus(object): + def __init__(self, ip: str, machine_unique_id: str, user_defined_id: str, heartbeat_time: int, binary: Any = ...) -> None: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/metering_mode_response.pyi b/aliyun/log/metering_mode_response.pyi new file mode 100644 index 00000000..e236b2ff --- /dev/null +++ b/aliyun/log/metering_mode_response.pyi @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .util import Util +from .logresponse import LogResponse + +class GetLogStoreMeteringModeResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_metering_mode(self) -> str: ... + def log_print(self) -> None: ... + +class GetMetricStoreMeteringModeResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_metering_mode(self) -> str: ... + def log_print(self) -> None: ... + +class UpdateLogStoreMeteringModeResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... + +class UpdateMetricStoreMeteringModeResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/multimodal_config_response.pyi b/aliyun/log/multimodal_config_response.pyi new file mode 100644 index 00000000..9fb2ab19 --- /dev/null +++ b/aliyun/log/multimodal_config_response.pyi @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .util import Util +from .logresponse import LogResponse + +class GetLogStoreMultimodalConfigurationResponse(LogResponse): + def __init__(self, resp: Dict[str, Any], header: Dict[str, Any]) -> None: ... + def get_status(self) -> str: ... + def get_anonymous_write(self) -> Optional[str]: ... + def log_print(self) -> None: ... + +class PutLogStoreMultimodalConfigurationResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/object_response.pyi b/aliyun/log/object_response.pyi new file mode 100644 index 00000000..cf701986 --- /dev/null +++ b/aliyun/log/object_response.pyi @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from typing import Any, Dict, Optional + +from .logresponse import LogResponse + +__all__ = ['PutObjectResponse', 'GetObjectResponse'] + +class PutObjectResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: str = ...) -> None: ... + def get_etag(self) -> Optional[str]: ... + def log_print(self) -> None: ... + +class GetObjectResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: bytes) -> None: ... + def get_etag(self) -> Optional[str]: ... + def get_content_type(self) -> str: ... + def get_headers(self) -> Dict[str, Any]: ... + def get_body(self) -> bytes: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/pulllog_response.pyi b/aliyun/log/pulllog_response.pyi new file mode 100644 index 00000000..46814096 --- /dev/null +++ b/aliyun/log/pulllog_response.pyi @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +from typing import Any, Dict, List, Optional + +from .logresponse import LogResponse + +DEFAULT_DECODE_LIST: tuple + +class PullLogResponse(LogResponse): + def __init__(self, resp: str, header: Dict[str, Any]) -> None: ... + @property + def loggroup_list(self) -> Any: ... + def get_body(self) -> Dict[str, Any]: ... + @property + def body(self) -> Dict[str, Any]: ... + @body.setter + def body(self, value: Any) -> None: ... + def get_next_cursor(self) -> str: ... + @property + def log_count(self) -> int: ... + def get_log_count(self) -> int: ... + def get_loggroup_count(self) -> int: ... + def get_loggroup_json_list(self) -> List[Any]: ... + def get_loggroup_list(self) -> Any: ... + def get_loggroup(self, index: int) -> Optional[Any]: ... + def get_raw_size(self) -> int: ... + def get_raw_log_group_count_before_query(self) -> int: ... + def get_raw_size_before_query(self) -> int: ... + def log_print(self) -> None: ... + @staticmethod + def get_log_count_from_group(loggroup_list: Any) -> int: ... + @staticmethod + def loggroups_to_flattern_list(loggroup_list: Any, time_as_str: Optional[bool] = ..., decode_bytes: Any = ...) -> List[Dict[str, Any]]: ... + def get_flatten_logs_json(self, time_as_str: Optional[bool] = ..., decode_bytes: Any = ...) -> List[Dict[str, Any]]: ... + def get_flatten_logs_json_auto(self) -> List[Dict[str, Any]]: ... diff --git a/aliyun/log/putlogsrequest.pyi b/aliyun/log/putlogsrequest.pyi new file mode 100644 index 00000000..315a8cd1 --- /dev/null +++ b/aliyun/log/putlogsrequest.pyi @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union +from .logitem import LogItem + + +from .logrequest import LogRequest + +class PutLogsRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., logstore: Optional[str] = ..., topic: Optional[str] = ..., source: Optional[str] = ..., logitems: Optional[List[LogItem]] = ..., hashKey: Optional[str] = ..., compress: bool = ..., logtags: Optional[List[Tuple[str, str]]] = ..., compress_type: Optional[str] = ...) -> None: ... + def get_compress_type(self) -> Optional[str]: ... + def set_compress_type(self, compress_type: str) -> None: ... + def get_compress(self) -> bool: ... + def set_compress(self, compress: bool) -> None: ... + def get_logstore(self) -> str: ... + def set_logstore(self, logstore: str) -> None: ... + def get_topic(self) -> str: ... + def set_topic(self, topic: str) -> None: ... + def get_source(self) -> str: ... + def set_source(self, source: str) -> None: ... + def get_log_items(self) -> List[LogItem]: ... + def set_log_items(self, logitems: List[LogItem]) -> None: ... + def get_log_tags(self) -> List[Tuple[str, str]]: ... + def set_log_tags(self, logtags: List[Tuple[str, str]]) -> None: ... + def set_hash_key(self, hashKey: str) -> None: ... + def get_hash_key(self) -> Optional[str]: ... diff --git a/aliyun/log/putlogsresponse.pyi b/aliyun/log/putlogsresponse.pyi new file mode 100644 index 00000000..64b9f360 --- /dev/null +++ b/aliyun/log/putlogsresponse.pyi @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from typing import Any, Dict + +from .logresponse import LogResponse + +class PutLogsResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: str = ...) -> None: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/py.typed b/aliyun/log/py.typed new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/aliyun/log/py.typed @@ -0,0 +1 @@ + diff --git a/aliyun/log/queriedlog.pyi b/aliyun/log/queriedlog.pyi new file mode 100644 index 00000000..ae408ea3 --- /dev/null +++ b/aliyun/log/queriedlog.pyi @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +from typing import Dict, Optional + +class QueriedLog: + timestamp: int + source: str + contents: Dict[str, str] + def __init__(self, timestamp: int, source: str, contents: Dict[str, str]) -> None: ... + def get_time(self) -> int: ... + def get_source(self) -> str: ... + def get_contents(self) -> Dict[str, str]: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/shipper_config.pyi b/aliyun/log/shipper_config.pyi new file mode 100644 index 00000000..3fb91ad3 --- /dev/null +++ b/aliyun/log/shipper_config.pyi @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + + +class OdpsShipperConfig(object): + def __init__(self, odps_endpoint: str, odps_project: str, odps_table: str, log_fields_list: List[str], partition_column: List[str], partition_time_format: str, bufferInterval: Any = ...) -> None: ... + def to_json(self) -> Any: ... + +class OssShipperConfig(object): + def __init__(self, oss_bucket: str, oss_prefix: str, oss_role_arn: str, buffer_interval: int = ..., buffer_mb: int = ..., compress_type: str = ...) -> None: ... + def to_json(self) -> Any: ... + +class ShipperTask(object): + def __init__(self, task_id: str, task_status: str, task_message: str, task_create_time: int, task_last_data_receive_time: int, task_finish_time: int) -> None: ... + def to_json(self) -> Any: ... diff --git a/aliyun/log/store_view.pyi b/aliyun/log/store_view.pyi new file mode 100644 index 00000000..c4ea73a1 --- /dev/null +++ b/aliyun/log/store_view.pyi @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + + +class StoreViewStore: + def __init__(self, project_name: str, store_name: str, query: Optional[str] = ...) -> None: ... + @property + def project_name(self) -> str: ... + @project_name.setter + def project_name(self, project_name: str) -> None: ... + @property + def store_name(self) -> str: ... + @store_name.setter + def store_name(self, store_name: str) -> None: ... + @property + def query(self) -> Optional[str]: ... + @query.setter + def query(self, query: Optional[str]) -> None: ... + def _to_json_dict(self): ... + @classmethod + def _from_json_dict(cls, json_data): ... + +class StoreView: + def __init__(self, name: str, store_type: str, stores: Optional[List[StoreViewStore]] = ...) -> None: ... + @property + def name(self) -> str: ... + @name.setter + def name(self, name: str) -> None: ... + @property + def store_type(self) -> str: ... + @store_type.setter + def store_type(self, store_type: str) -> None: ... + @property + def stores(self) -> List[StoreViewStore]: ... + @stores.setter + def stores(self, stores: List[StoreViewStore]) -> None: ... + def _to_json_dict(self): ... + @classmethod + def _from_json_dict(cls, json_data): ... diff --git a/aliyun/log/store_view_response.pyi b/aliyun/log/store_view_response.pyi new file mode 100644 index 00000000..2658f751 --- /dev/null +++ b/aliyun/log/store_view_response.pyi @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +__all__ = ['CreateStoreViewResponse', 'UpdateStoreViewResponse', 'DeleteStoreViewResponse', 'ListStoreViewsResponse', 'GetStoreViewResponse'] +from .store_view import StoreView +from .logresponse import LogResponse + +class CreateStoreViewResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... + +class UpdateStoreViewResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... + +class DeleteStoreViewResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any = ...) -> None: ... + def log_print(self) -> None: ... + +class ListStoreViewsResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any) -> None: ... + def get_count(self) -> int: ... + def get_total(self) -> int: ... + def get_store_views(self) -> List[Any]: ... + def log_print(self) -> None: ... + +class GetStoreViewResponse(LogResponse): + def __init__(self, header: Dict[str, Any], resp: Any) -> None: ... + def get_store_view(self) -> StoreView: ... + def log_print(self) -> None: ... diff --git a/aliyun/log/submit_async_sql_request.pyi b/aliyun/log/submit_async_sql_request.pyi new file mode 100644 index 00000000..887beb85 --- /dev/null +++ b/aliyun/log/submit_async_sql_request.pyi @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union + +from .logrequest import LogRequest +from .util import parse_timestamp + +class SubmitAsyncSqlRequest(LogRequest): + def __init__(self, project: Optional[str] = ..., logstore: Optional[str] = ..., query: Optional[str] = ..., fromTime: Optional[Union[int, str]] = ..., toTime: Optional[Union[int, str]] = ..., power_sql: bool = ..., allow_incomplete: bool = ..., max_run_time: Optional[int] = ...) -> None: ... + def get_logstore(self) -> str: ... + def set_logstore(self, logstore: str) -> None: ... + def get_query(self) -> str: ... + def set_query(self, query: str) -> None: ... + def get_from(self) -> int: ... + def set_from(self, fromTime: int) -> None: ... + def get_to(self) -> int: ... + def set_to(self, toTime: int) -> None: ... + def get_power_sql(self) -> bool: ... + def set_power_sql(self, power_sql: bool) -> None: ... + def get_allow_incomplete(self) -> bool: ... + def set_allow_incomplete(self, allow_incomplete: bool) -> None: ... + def get_max_run_time(self) -> int: ... + def set_max_run_time(self, max_run_time: int) -> None: ... diff --git a/aliyun/py.typed b/aliyun/py.typed new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/aliyun/py.typed @@ -0,0 +1 @@ + diff --git a/setup.py b/setup.py index 1ee6be7d..4b6923f5 100755 --- a/setup.py +++ b/setup.py @@ -79,6 +79,12 @@ 'aliyun.log._proto_py2', ] +package_data = { + 'aliyun': ['*.pyi', 'py.typed'], + 'aliyun.log': ['*.pyi', 'py.typed'], + 'aliyun.log.consumer': ['*.pyi', 'py.typed'], +} + version = '' with open('aliyun/log/version.py', 'r') as fd: version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', @@ -112,6 +118,7 @@ url='https://github.com/aliyun/aliyun-log-python-sdk', install_requires=requirements, packages=packages, + package_data=package_data, classifiers=classifiers, long_description=long_description, extras_require = { diff --git a/tests/ci/check_stub_signatures.py b/tests/ci/check_stub_signatures.py new file mode 100644 index 00000000..e8137a3c --- /dev/null +++ b/tests/ci/check_stub_signatures.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# encoding: utf-8 +""" +Verify that every method stubbed in a .pyi file has parameter names that match +the corresponding .py source. Only checks names present in BOTH files. +Exit 1 if any mismatches are found. +""" + +import ast +import os +import sys + + +def _func_params(func_node): + names = [a.arg for a in func_node.args.args] + return names + + +def _collect_funcs(tree): + """Return { qualified_name -> param_names } for all module-level and class-level functions.""" + result = {} + for node in tree.body: + if isinstance(node, ast.ClassDef): + for item in node.body: + if isinstance(item, ast.FunctionDef): + result[f"{node.name}.{item.name}"] = _func_params(item) + elif isinstance(node, ast.FunctionDef): + result[node.name] = _func_params(node) + return result + + +def _parse(path): + with open(path, 'r', encoding='utf-8') as fh: + return ast.parse(fh.read(), filename=path) + + +def check_pair(py_path, pyi_path): + py_funcs = _collect_funcs(_parse(py_path)) + pyi_funcs = _collect_funcs(_parse(pyi_path)) + + mismatches = [] + for name, stub_params in pyi_funcs.items(): + if name not in py_funcs: + continue + stub_pos = [p for p in stub_params if p not in ('self', 'cls')] + src_pos = [p for p in py_funcs[name] if p not in ('self', 'cls')] + if stub_pos != src_pos: + mismatches.append(f" {name}: stub {stub_pos} != source {src_pos}") + return mismatches + + +def main(): + repo_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + log_dir = os.path.join(repo_root, 'aliyun', 'log') + + all_mismatches = {} + checked = 0 + + for pyi_name in sorted(f for f in os.listdir(log_dir) if f.endswith('.pyi')): + py_path = os.path.join(log_dir, pyi_name[:-1]) + if not os.path.exists(py_path): + continue + mismatches = check_pair(py_path, os.path.join(log_dir, pyi_name)) + checked += 1 + if mismatches: + all_mismatches[pyi_name] = mismatches + + if all_mismatches: + print('STUB SIGNATURE MISMATCHES FOUND:') + for fname, issues in all_mismatches.items(): + print(f'\n{fname}:') + for issue in issues: + print(issue) + total = sum(len(v) for v in all_mismatches.values()) + print(f'\n{total} mismatch(es) across {len(all_mismatches)} file(s).') + sys.exit(1) + else: + print(f'OK — {checked} stub/source pair(s) checked, all signatures match.') + + +if __name__ == '__main__': + main() diff --git a/tests/ci/run_stubtest.py b/tests/ci/run_stubtest.py new file mode 100644 index 00000000..67c5bf18 --- /dev/null +++ b/tests/ci/run_stubtest.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import os +import subprocess +import sys +import tempfile + + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +MODULES_FILE = os.path.join(BASE_DIR, 'stubtest_modules.txt') +ALLOWLIST_FILE = os.path.join(BASE_DIR, 'stubtest_allowlist.txt') + + +def _read_non_empty_lines(path): + with open(path, 'r') as fh: + return [line.strip() for line in fh if line.strip() and not line.lstrip().startswith('#')] + + +def main(): + modules = _read_non_empty_lines(MODULES_FILE) + # Run outside the checkout so stubtest validates the installed package payload. + os.chdir(tempfile.gettempdir()) + cmd = ( + [sys.executable, '-m', 'mypy.stubtest', '--ignore-missing-stub', + '--ignore-unused-allowlist', '--allowlist', ALLOWLIST_FILE] + + modules + ) + subprocess.check_call(cmd) + + +if __name__ == '__main__': + main() diff --git a/tests/ci/stubtest_allowlist.txt b/tests/ci/stubtest_allowlist.txt new file mode 100644 index 00000000..372098d7 --- /dev/null +++ b/tests/ci/stubtest_allowlist.txt @@ -0,0 +1,20 @@ +# stubtest allowlist +# Private methods that are intentionally omitted from stubs +aliyun\.log\.logclient\.LogClient\._replace_credentials +aliyun\.log\.logclient\.LogClient\._setendpoint +aliyun\.log\.logclient\.LogClient\._loadJson +aliyun\.log\.logclient\.LogClient\._get_http_sender +aliyun\.log\.logclient\.LogClient\._getHttpResponse +aliyun\.log\.logclient\.LogClient\._sendRequest +aliyun\.log\.logclient\.LogClient\._send +aliyun\.log\.logclient\.LogClient\._get_unicode +aliyun\.log\.logclient\.LogClient\._get_binary +aliyun\.log\.logclient\.LogClient\._get_cursor_as_int +aliyun\.log\.logclient\._is_auth_err +aliyun\.log\.logclient\._apply_cn_keys_patch +# Internal helpers in pulllog_response +aliyun\.log\.pulllog_response\.PullLogResponse\._parse_loggroup_list +aliyun\.log\.pulllog_response\.PullLogResponse\._transfer_to_json +aliyun\.log\.pulllog_response\.PullLogResponse\._b2u +# Internal method in getlogsresponse +aliyun\.log\.getlogsresponse\.GetLogsResponse\._from_v1_resp diff --git a/tests/ci/stubtest_modules.txt b/tests/ci/stubtest_modules.txt new file mode 100644 index 00000000..03d939be --- /dev/null +++ b/tests/ci/stubtest_modules.txt @@ -0,0 +1,28 @@ +aliyun.log.credentials +aliyun.log.cursor_response +aliyun.log.cursor_time_response +aliyun.log.gethistogramsrequest +aliyun.log.gethistogramsresponse +aliyun.log.getlogsrequest +aliyun.log.getlogsresponse +aliyun.log.index_config +aliyun.log.listlogstoresrequest +aliyun.log.listlogstoresresponse +aliyun.log.listtopicsrequest +aliyun.log.listtopicsresponse +aliyun.log.logclient +aliyun.log.logexception +aliyun.log.logitem +aliyun.log.logresponse +aliyun.log.machine_group_detail +aliyun.log.metering_mode_response +aliyun.log.multimodal_config_response +aliyun.log.object_response +aliyun.log.pulllog_response +aliyun.log.putlogsrequest +aliyun.log.putlogsresponse +aliyun.log.queriedlog +aliyun.log.shipper_config +aliyun.log.store_view +aliyun.log.store_view_response +aliyun.log.submit_async_sql_request