Alibaba Cloud Threat Detection SDK (20181203)
raw JSON → 9.2.0 verified Fri May 01 auth: no python
Official Alibaba Cloud SDK for Threat Detection (SAS) API version 2018-12-03. Current version 9.2.0, requires Python >=3.7. Released often alongside Alibaba Cloud API updates.
pip install alibabacloud-sas20181203 Common errors
error ModuleNotFoundError: No module named 'alibabacloud_sas20181203.client' ↓
cause Using an older SDK version (e.g., <7.0) where Client was directly under the package or installing an incompatible version.
fix
Upgrade to latest:
pip install --upgrade alibabacloud-sas20181203 and use from alibabacloud_sas20181203.client import Client. error AttributeError: module 'alibabacloud_sas20181203' has no attribute 'Client' ↓
cause Trying to import Client from the package root, which is not present in current versions.
fix
Change to
from alibabacloud_sas20181203.client import Client. Warnings
breaking Version 9.x changed the client import path. Before ~v7, Client was importable as `from alibabacloud_sas20181203 import Client`. In v9 you must use `from alibabacloud_sas20181203.client import Client`. ↓
fix Update imports: `from alibabacloud_sas20181203.client import Client`.
deprecated The SDK is based on the deprecated Tea DSL. Alibaba Cloud recommends migrating to the newer SDK style (V2 SDK) in the future. No immediate breaking changes, but new APIs may not be backported. ↓
fix Consider using the newer V2 SDK if the service supports it.
gotcha Models are not directly importable from the package root; you must import from `alibabacloud_sas20181203.models`. ↓
fix Use `from alibabacloud_sas20181203 import models` then `models.SomeRequest`.
Imports
- Client wrong
from alibabacloud_sas20181203 import Clientcorrectfrom alibabacloud_sas20181203.client import Client - DescribeSecurityEventOperationsRequest wrong
alibabacloud_sas20181203.models.DescribeSecurityEventOperationsRequest (for some earlier Alibaba SDKs models were directly importable; this SDK uses a dotted path from the models module)correctfrom alibabacloud_sas20181203.models import DescribeSecurityEventOperationsRequest
Quickstart
import os
from alibabacloud_sas20181203.client import Client as SasClient
from alibabacloud_sas20181203 import models
from alibabacloud_tea_openapi import models as open_api_models
config = open_api_models.Config(
access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''),
access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', ''),
region_id='cn-hangzhou'
)
client = SasClient(config)
req = models.DescribeSecurityEventOperationsRequest(
source_ip='127.0.0.1',
lang='zh',
security_event_id='<event_id>'
)
try:
resp = client.describe_security_event_operations(req)
print(resp.body.to_map())
except Exception as e:
print(e)