搭DeleteIdentity配 AWS SDK或使用 CLI - AWS SDK 程式碼範例

AWS 文檔 AWS SDK示例 GitHub 回購中有更多SDK示例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DeleteIdentity配 AWS SDK或使用 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

如需有關已驗證身分的詳細資訊,請參閱 Amazon 簡易電子郵件服務開發人員指南SES中的在 Amazon 驗證電子郵件地址和網域。

  • 如需詳API細資訊,請參閱AWS CLI 指令參考DeleteIdentity中的。

JavaScript
SDK對於 JavaScript (3)
注意

還有更多關於 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(肉毒桿菌 3)
注意

還有更多關於 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 SDK的〈〉中的〈〉API