调用ListScheduledSQLs接口列出定时SQL任务。
前提条件
您已完成以下操作:
参数说明
def list_scheduled_sql(self, project_name, offset=0, size=100):
请求参数
名称 | 类型 | 是否必填 | 描述 | 示例值 |
名称 | 类型 | 是否必填 | 描述 | 示例值 |
project_name | String | 是 | Project名称。 | demo-test-project |
offset | int | 否 | 查询开始行,默认值为 0。 | 0 |
size | int | 否 | 查询结束行,默认值为 100。 | 100 |
返回参数
返回参数说明,请参见ListScheduledSQLs - 列出定时SQL任务。
示例代码
import os
from aliyun.log import LogClient
def main():
# 本示例从环境变量中获取AccessKey ID和AccessKey Secret
accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
# 日志服务的服务接入点
endpoint = "cn-hangzhou.log.aliyuncs.com"
project_name = "demo-test-project"
client = LogClient(endpoint, accessKeyId, accessKey, "")
res = client.list_scheduled_sql(project_name)
res.log_print()
if __name__ == '__main__':
main()
示例返回结果
ListScheduledSqlJobResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '1005', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Fri, 01 Nov 2024 07:13:47 GMT', 'x-log-time': '1730445227', 'x-log-requestid': '67247FABD2F425CB26C87523'}
count: 1
total: 1
jobs: [{'name': 'test-001', 'type': 'ScheduledSQL', 'apiType': 'ScheduledSQL', 'status': 'ENABLED', 'description': '创建一个定时SQL任务', 'displayName': 'test-001', 'state': 'Enabled', 'recyclable': False, 'schedule': {'type': 'FixedRate', 'delay': 0, 'interval': '60s', 'runImmediately': False, 'timeZone': '+0800'}, 'configuration': {'roleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'destRoleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'sourceLogstore': 'test-logstore', 'destEndpoint': 'cn-hangzhou.log.aliyuncs.com', 'destProject': 'demo-test-project', 'destLogstore': 'test-logstore2', 'fromTimeExpr': '@m - 5m', 'toTimeExpr': '@m', 'maxRunTimeInSeconds': 1800, 'maxRetries': 10, 'forceComplete': False, 'fromTime': 1730444541, 'toTime': 0, 'sqlType': 'searchQuery', 'resourcePool': 'enhanced', 'dataFormat': 'log2log', 'version': 0, 'script': '* | select *', 'parameters': {}}, 'scheduleId': 'f3bc8ba5ccb******c68f34ea8fdcf8d', 'createTime': 1730444990, 'lastModifiedTime': 1730444990}]
Process finished with exit code 0
相关文档
该文章对您有帮助吗?
- 本页导读 (1)
- 前提条件
- 参数说明
- 请求参数
- 返回参数
- 示例代码
- 示例返回结果
- 相关文档