All Products
Search
Document Center

Simple Log Service:Retrieve an OSS data import job

Last Updated:Jan 24, 2025

Call the GetOSSIngestion API to retrieve details of an 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).

    • Simple Log Service SDK for Python of the new version supports Python 3.7 and later.

    • You can run the python-V command to check the version of Python that is installed.

    • You can run the pip3 -V command to check the version of pip that is installed.

  • Simple Log Service SDK for Python of the new version is installed.

    • Run the following command in CLI to install Simple Log Service SDK for Python of the new version:

      pip install alibabacloud_sls20201230
    • After the installation is complete, run the following command to verify the installation:

      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 in 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

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