本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用 DeleteConfigurationSet 用 AWS SDK
以下代码示例演示了如何使用 DeleteConfigurationSet。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- Python
-
- 适用于 Python 的 SDK(Boto3)
-
删除由亚马逊 SES API v2 搜索和筛选场景创建的配置集。
class SearchFilterWrapper:
"""Encapsulates Amazon SES v2 search-and-filter operations."""
def __init__(self, sesv2_client: boto3.client):
"""
Initializes the SearchFilterWrapper with an Amazon SES v2 client.
:param sesv2_client: A Boto3 Amazon SES v2 client.
"""
self.sesv2_client = sesv2_client
@classmethod
def from_client(cls) -> "SearchFilterWrapper":
"""
Creates a SearchFilterWrapper instance with a default Boto3 SES v2 client.
:return: An initialized SearchFilterWrapper instance.
"""
sesv2_client = boto3.client("sesv2")
return cls(sesv2_client)
def delete_configuration_set(self, configuration_set_name: str) -> None:
"""
Deletes a configuration set.
:param configuration_set_name: The name of the configuration set to
delete.
"""
try:
self.sesv2_client.delete_configuration_set(
ConfigurationSetName=configuration_set_name
)
logger.info("Deleted configuration set '%s'.", configuration_set_name)
except ClientError as err:
if err.response["Error"]["Code"] == "NotFoundException":
logger.warning(
"Configuration set '%s' not found. Skipping deletion.",
configuration_set_name,
)
else:
logger.error(
"Error deleting configuration set '%s': %s",
configuration_set_name,
err.response["Error"]["Message"],
)
raise
如需查看完整清单 AWS SDK 开发者指南和代码示例,请参阅 将 Amazon SES 与 AWS SDK。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。