本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DeleteConfigurationSet 搭配 AWS SDK 使用
以下程式碼範例顯示如何使用 DeleteConfigurationSet。
動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:
- Python
-
- 適用於 Python 的 SDK (Boto3)
-
刪除由 Amazon SES API v2 search-and-filter案例建立的組態設定。
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 開發人員指南和程式碼範例的完整清單,請參閱 搭配 SDK 使用 Amazon SES AWS。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。