AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
DeleteReceiptRule
搭配使用 AWS SDK
以下代码示例演示如何使用 DeleteReceiptRule
。
- C++
-
- SDK对于 C++
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 //! Delete an Amazon Simple Email Service (Amazon SES) receipt rule. /*! \param receiptRuleName: The name for the receipt rule. \param receiptRuleSetName: The name for the receipt rule set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptRule(const Aws::String &receiptRuleName, const Aws::String &receiptRuleSetName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptRuleRequest deleteReceiptRuleRequest; deleteReceiptRuleRequest.SetRuleName(receiptRuleName); deleteReceiptRuleRequest.SetRuleSetName(receiptRuleSetName); Aws::SES::Model::DeleteReceiptRuleOutcome outcome = sesClient.DeleteReceiptRule( deleteReceiptRuleRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt rule." << std::endl; } else { std::cout << "Error deleting receipt rule. " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
有关API详细信息,请参阅 “AWS SDK for C++ API参考 DeleteReceiptRule” 中的。
-
- JavaScript
-
- SDK对于 JavaScript (v3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 import { DeleteReceiptRuleCommand } from "@aws-sdk/client-ses"; import { getUniqueName } from "@aws-doc-sdk-examples/lib/utils/util-string.js"; import { sesClient } from "./libs/sesClient.js"; const RULE_NAME = getUniqueName("RuleName"); const RULE_SET_NAME = getUniqueName("RuleSetName"); const createDeleteReceiptRuleCommand = () => { return new DeleteReceiptRuleCommand({ RuleName: RULE_NAME, RuleSetName: RULE_SET_NAME, }); }; const run = async () => { const deleteReceiptRuleCommand = createDeleteReceiptRuleCommand(); try { return await sesClient.send(deleteReceiptRuleCommand); } catch (err) { console.log("Failed to delete receipt rule.", err); return err; } };
-
有关API详细信息,请参阅 “AWS SDK for JavaScript API参考 DeleteReceiptRule” 中的。
-
- Python
-
- SDK适用于 Python (Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 class SesReceiptHandler: """Encapsulates Amazon SES receipt handling functions.""" def __init__(self, ses_client, s3_resource): """ :param ses_client: A Boto3 Amazon SES client. :param s3_resource: A Boto3 Amazon S3 resource. """ self.ses_client = ses_client self.s3_resource = s3_resource def delete_receipt_rule(self, rule_set_name, rule_name): """ Deletes a rule. :param rule_set_name: The rule set that contains the rule to delete. :param rule_name: The rule to delete. """ try: self.ses_client.delete_receipt_rule( RuleSetName=rule_set_name, RuleName=rule_name ) logger.info("Removed rule %s from rule set %s.", rule_name, rule_set_name) except ClientError: logger.exception( "Couldn't remove rule %s from rule set %s.", rule_name, rule_set_name ) raise
-
有关API详细信息,请参阅DeleteReceiptRule中的 AWS SDKPython (Boto3) API 参考。
-
DeleteReceiptFilter
DeleteReceiptRuleSet