Use DeleteReceiptRule with an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DeleteReceiptRule with an AWS SDK

The following code examples show how to use DeleteReceiptRule.

C++
SDK for C++
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

//! 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(); }
JavaScript
SDK for JavaScript (v3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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; } };
Python
SDK for Python (Boto3)
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

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
  • For API details, see DeleteReceiptRule in AWS SDK for Python (Boto3) API Reference.