View a markdown version of this page

Uso ListConfigurationSets com um AWS SDK - Amazon Simple Email Service

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Uso ListConfigurationSets com um AWS SDK

O código de exemplo a seguir mostra como usar ListConfigurationSets.

Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação em contexto no seguinte exemplo de código:

Python
SDK para Python (Boto3)
nota

Há mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

Filtre os conjuntos de configurações por nome usando o suporte de filtro da API v2 do Amazon SES.

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 list_configuration_sets( self, filter_params: Optional[Dict[str, str]] = None, page_size: Optional[int] = None, ) -> List[str]: """ Lists configuration sets associated with the account in the current region. Supports optional filter parameters and pagination. :param filter_params: Optional dictionary of filter key-value pairs (e.g., {"CONFIGURATION_SET_NAME_CONTAINS": "marketing"}). :param page_size: Optional number of results per page. :return: A list of configuration set name strings. """ try: # ListConfigurationSets has no registered Boto3 paginator, so # pagination is handled manually using the NextToken field. configuration_sets = list() next_token = None while True: kwargs = dict() if filter_params is not None: kwargs["Filter"] = filter_params if page_size is not None: kwargs["PageSize"] = page_size if next_token is not None: kwargs["NextToken"] = next_token response = self.sesv2_client.list_configuration_sets(**kwargs) configuration_sets.extend(response.get("ConfigurationSets", list())) next_token = response.get("NextToken") if not next_token: break logger.info("Listed %d configuration sets.", len(configuration_sets)) return configuration_sets except ClientError as err: if err.response["Error"]["Code"] == "BadRequestException": logger.error( "Bad request when listing configuration sets: %s", err.response["Error"]["Message"], ) else: logger.error( "Error listing configuration sets: %s", err.response["Error"]["Message"], ) raise
  • Para obter detalhes da API, consulte ListConfigurationSets em AWS Referência da API SDK para Python (Boto3).

Para obter uma lista completa de AWS Guias para desenvolvedores e exemplos de código do SDK, consulte Usando o Amazon SES com um AWS SDK. Este tópico também inclui informações sobre como começar e detalhes sobre versões anteriores do SDK.