Call the StopOSSIngestion API to stop 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).
Simple Log Service SDK for Python of the new version supports Python 3.7 and later.
You can run the
python-Vcommand to check the version of Python that is installed.You can run the
pip3 -Vcommand 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_sls20201230After 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 stop_ossingestion(
self,
project: str,
oss_ingestion_name: str,
) -> sls_20201230_models.StopOSSIngestionResponse: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.stop_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()