List OSS data import jobs
Lists OSS data import jobs in a project using the ListOSSIngestions Python SDK method.
Prerequisites
-
Simple Log Service is activated.
-
Python is installed (see Install Python), a Python development environment is set up (see PyCharm), and a Python package management tool is installed (see pip).
-
The new version of Simple Log Service SDK for Python supports Python 3.7 and later.
-
Run the
python -Vcommand to check the installed Python version. -
Run the
pip3 -Vcommand to check the installed pip version.
-
-
The new version of Simple Log Service SDK for Python is installed.
-
Run the following command to install the new version of Simple Log Service SDK for Python:
pip install alibabacloud_sls20201230 -
After the installation is complete, run the following command to verify it:
pip show alibabacloud_sls20201230
-
-
The ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variables are configured. For more information, see Configure environment variables on Linux, macOS, and Windows.
Parameters
def list_ossingestions(
self,
project: str,
request: sls_20201230_models.ListOSSIngestionsRequest,
) -> sls_20201230_models.ListOSSIngestionsResponse:
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
|
project |
String |
Yes |
Project name. |
ali-test-project |
|
request |
object |
Yes |
Request body. |
Null |
Request fields:
class ListOSSIngestionsRequest(TeaModel):
def __init__(
self,
logstore: str = None,
offset: int = None,
size: int = None,
):
|
Parameter |
Type |
Required |
Description |
Example |
|
logstore |
String |
No |
Logstore name. |
test-logstore |
|
offset |
int |
No |
Query start offset. Default: 0. |
0 |
|
size |
int |
No |
Maximum number of jobs to return. |
10 |
Response parameters
For information about the response parameters, see ListOSSIngestions.
Sample code
import os
from alibabacloud_sls20201230.client import Client as Sls20201230Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_sls20201230 import models as sls_20201230_models
from alibabacloud_tea_util.client import Client as UtilClient
def main():
config = open_api_models.Config(
# Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_ID environment variable is configured.
access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
# Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is configured.
access_key_secret=os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET']
)
# The Simple Log Service endpoint.
config.endpoint = "cn-hangzhou.log.aliyuncs.com"
project_name = "ali-test-project"
client = Sls20201230Client(config)
request = sls_20201230_models.ListOSSIngestionsRequest()
try:
list_ossingestions_response = client.list_ossingestions(project_name, list_ossingestions_request)
print(list_ossingestions_response)
except Exception as error:
print(error.message)
print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message)
if __name__ == '__main__':
main()
Sample response
{'headers': {'server': 'AliyunSLS', 'content-type': 'application/json', 'content-length': '1358', 'connection': 'keep-alive', 'access-control-allow-origin': '*', 'date': 'Thu, 31 Oct 2024 08:35:51 GMT', 'x-log-time': '1730363751', 'x-log-requestid': '6723416702F16E98DF4641C2'}, 'statusCode': 200, 'body': {'count': 2, 'results': [{'configuration': {'logstore': 'test-logstore1', 'source': {'bucket': 'oss-test-shanghai001', 'compressionCodec': 'none', 'encoding': 'UTF-8', 'endpoint': 'cn-shanghai-internal.aliyuncs.com', 'format': {'type': 'Line'}, 'interval': '30s', 'useMetaIndex': False}}, 'createTime': 1730359624, 'description': 'This is a description', 'displayName': 'OSS ingestion test', 'lastModifiedTime': 1730359624, 'name': 'ingest-oss-123456', 'schedule': {'type': 'Resident'}, 'scheduleId': 'e64359bc****901d57bfb8e935ebca09', 'status': 'RUNNING'}, {'configuration': {'logstore': 'test-logstore2', 'source': {'bucket': 'oss-test-hangzhou001', 'compressionCodec': 'none', 'encoding': 'UTF-8', 'endpoint': 'oss-cn-hangzhou-internal.aliyuncs.com', 'format': {'type': 'Line'}, 'interval': '30m', 'pattern': '', 'prefix': '', 'restoreObjectEnabled': False, 'timeField': '', 'timeFormat': '', 'timePattern': '', 'timeZone': '', 'useMetaIndex': False}}, 'createTime': 1730357727, 'description': 'This is a description', 'displayName': 'test', 'lastModifiedTime': 1730357727, 'name': 'ingest-oss-17*****487-54**77', 'schedule': {'type': 'Resident'}, 'scheduleId': '8f9cbc2bc044****3750b65d1a8180c3', 'status': 'RUNNING'}], 'total': 2}}
Process finished with exit code 0