すべてのプロダクト
Search
ドキュメントセンター

Simple Log Service:OSSデータインポートジョブの停止

最終更新日:Jan 26, 2025

StopOSSIngestion APIを呼び出して、Object Storage Service (OSS) データインポートジョブを停止します。

前提条件

  • Simple Log Serviceが有効化されています。

  • Pythonがインストールされ (Pythonのインストールを参照) 、Python開発環境が設定され (PyCharmを参照) 、Pythonパッケージ管理ツールがインストールされます (pipを参照) 。

    • 新バージョンのSimple Log Service SDK for Pythonは、Python 3.7以降をサポートしています。

    • python-Vコマンドを実行して、インストールされているPythonのバージョンを確認できます。

    • pip3 -Vコマンドを実行して、インストールされているpipのバージョンを確認できます。

  • 新バージョンのSimple Log Service SDK for Pythonがインストールされています。

    • CLIで次のコマンドを実行して、新しいバージョンのSimple Log Service SDK for Pythonをインストールします。

      pip install alibabacloud_sls20201230
    • インストールが完了したら、次のコマンドを実行してインストールを確認します。

      pip show alibabacloud_sls20201230
  • 環境変数が設定されます。 詳細については、「Linux、macOS、およびWindowsでの環境変数の設定」をご参照ください。

パラメータ説明

def stop_ossingestion(
        self,
        project: str,
        oss_ingestion_name: str,
) -> sls_20201230_models.StopOSSIngestionResponse:

リクエストパラメーター

パラメーター

必須 / 任意

説明

project

String

対象

プロジェクトの名前。

ali-test-project

oss_ingest_name

String

対象

OSSデータインポートジョブの名前。

ingest-oss-123456

サンプルコード

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()