View a markdown version of this page

Gunakan CreateConfigurationSet dengan AWS SDK - Layanan Email Sederhana Amazon

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Gunakan CreateConfigurationSet dengan AWS SDK

Contoh kode berikut menunjukkan cara menggunakan CreateConfigurationSet.

Contoh tindakan adalah kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Anda dapat melihat tindakan ini dalam konteks dalam contoh kode berikut:

Python
SDK untuk Python (Boto3)
catatan

Ada lebih banyak tentang GitHub. Temukan contoh lengkapnya dan pelajari cara mengatur dan menjalankannya di Repositori Contoh Kode AWS.

Buat set konfigurasi untuk digunakan dalam skenario pencarian dan filter Amazon 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 create_configuration_set(self, configuration_set_name: str) -> bool: """ Creates a configuration set with the specified name. :param configuration_set_name: The name for the new configuration set. :return: True if the configuration set was created, or False if a configuration set with that name already existed. """ try: self.sesv2_client.create_configuration_set( ConfigurationSetName=configuration_set_name ) logger.info("Created configuration set '%s'.", configuration_set_name) return True except ClientError as err: if err.response["Error"]["Code"] == "AlreadyExistsException": logger.warning( "Configuration set '%s' already exists. Skipping creation.", configuration_set_name, ) return False else: logger.error( "Error creating configuration set '%s': %s", configuration_set_name, err.response["Error"]["Message"], ) raise

Untuk daftar lengkap AWS Panduan pengembang SDK dan contoh kode, lihat Menggunakan Amazon SES dengan AWS SDK. Topik ini juga mencakup informasi tentang memulai dan detail tentang versi SDK sebelumnya.