Retrieve an OSS data import job
Calls the GetOSSIngestion API operation to retrieve the details of a specified OSS data import job.
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.
Parameter description
def get_ossingestion(
self,
project: str,
oss_ingestion_name: str,
) -> sls_20201230_models.GetOSSIngestionResponse:
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
|
project |
String |
Yes |
The name of the project. |
ali-test-project |
|
oss_ingestion_name |
String |
Yes |
The name of the OSS data import job. |
ingest-oss-123456 |
Response parameters
For information about the response parameters, see GetOSSIngestion - Retrieve OSS Data Import Jobs.
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 specified in the code.
access_key_id=os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'],
# Required. Make sure that the ALIBABA_CLOUD_ACCESS_KEY_SECRET environment variable is specified in the code.
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"
oss_ingestion_name = "ingest-oss-123456"
client = Sls20201230Client(config)
try:
response = client.get_ossingestion(project_name, oss_ingestion_name)
print(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': '603', 'connection': 'keep-alive', 'access-control-allow-origin': '*', 'date': 'Thu, 31 Oct 2024 08:46:59 GMT', 'x-log-time': '1730364419', 'x-log-requestid': '672344030326D19FD1F73E56'}, 'statusCode': 200, 'body': {'configuration': {'logstore': 'test-logstore', '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 test', 'displayName': 'OSS import test', 'lastModifiedTime': 1730359624, 'name': 'ingest-oss-123456', 'schedule': {'type': 'Resident'}, 'scheduleId': 'e64359bc5328******bfb8e935ebca09', 'status': 'RUNNING'}}
Process finished with exit code 0
References
-
Related API operations for OSS data import: