Start an OSS data import job
Use the StartOSSIngestion operation to start an Object Storage Service (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 start_ossingestion(
self,
project: str,
oss_ingestion_name: str,
) -> sls_20201230_models.StartOSSIngestionResponse:
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 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"
oss_ingestion_name = "ingest-oss-123456"
client = Sls20201230Client(config)
try:
response = client.start_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()