与 AWS SDK或DeleteIdentity一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

与 AWS SDK或DeleteIdentity一起使用 CLI

以下代码示例演示如何使用 DeleteIdentity

操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:

.NET
AWS SDK for .NET
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

/// <summary> /// Delete an email identity. /// </summary> /// <param name="identityEmail">The identity email to delete.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteIdentityAsync(string identityEmail) { var success = false; try { var response = await _amazonSimpleEmailService.DeleteIdentityAsync( new DeleteIdentityRequest { Identity = identityEmail }); success = response.HttpStatusCode == HttpStatusCode.OK; } catch (Exception ex) { Console.WriteLine("DeleteIdentityAsync failed with exception: " + ex.Message); } return success; }
  • 有关API详细信息,请参阅 “AWS SDK for .NET API参考 DeleteIdentity” 中的。

C++
SDK对于 C++
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

//! Delete the specified identity (an email address or a domain). /*! \param identity: The identity to delete. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteIdentity(const Aws::String &identity, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteIdentityRequest deleteIdentityRequest; deleteIdentityRequest.SetIdentity(identity); Aws::SES::Model::DeleteIdentityOutcome outcome = sesClient.DeleteIdentity( deleteIdentityRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted identity." << std::endl; } else { std::cerr << "Error deleting identity. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
  • 有关API详细信息,请参阅 “AWS SDK for C++ API参考 DeleteIdentity” 中的。

CLI
AWS CLI

删除身份

以下示例使用delete-identity命令从通过 Amazon 验证的身份列表中删除身份SES:

aws ses delete-identity --identity user@example.com

有关经过验证的身份的更多信息,请参阅《亚马逊简单电子邮件服务开发者指南》中的 “SES在亚马逊中验证电子邮件地址和域名”。

JavaScript
SDK对于 JavaScript (v3)
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

import { DeleteIdentityCommand } from "@aws-sdk/client-ses"; import { sesClient } from "./libs/sesClient.js"; const IDENTITY_EMAIL = "fake@example.com"; const createDeleteIdentityCommand = (identityName) => { return new DeleteIdentityCommand({ Identity: identityName, }); }; const run = async () => { const deleteIdentityCommand = createDeleteIdentityCommand(IDENTITY_EMAIL); try { return await sesClient.send(deleteIdentityCommand); } catch (err) { console.log("Failed to delete identity.", err); return err; } };
  • 有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 DeleteIdentity” 中的。

Python
SDK适用于 Python (Boto3)
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

class SesIdentity: """Encapsulates Amazon SES identity functions.""" def __init__(self, ses_client): """ :param ses_client: A Boto3 Amazon SES client. """ self.ses_client = ses_client def delete_identity(self, identity): """ Deletes an identity. :param identity: The identity to remove. """ try: self.ses_client.delete_identity(Identity=identity) logger.info("Deleted identity %s.", identity) except ClientError: logger.exception("Couldn't delete identity %s.", identity) raise
  • 有关API详细信息,请参阅DeleteIdentity中的 AWS SDKPython (Boto3) API 参考。