Use DeleteReceiptRuleSet with an AWS SDK or CLI - AWS SDK Code Examples

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

Use DeleteReceiptRuleSet with an AWS SDK or CLI

The following code examples show how to use DeleteReceiptRuleSet.

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 set. /*! \param receiptRuleSetName: The name for the receipt rule set. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SES::deleteReceiptRuleSet(const Aws::String &receiptRuleSetName, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SES::SESClient sesClient(clientConfiguration); Aws::SES::Model::DeleteReceiptRuleSetRequest deleteReceiptRuleSetRequest; deleteReceiptRuleSetRequest.SetRuleSetName(receiptRuleSetName); Aws::SES::Model::DeleteReceiptRuleSetOutcome outcome = sesClient.DeleteReceiptRuleSet( deleteReceiptRuleSetRequest); if (outcome.IsSuccess()) { std::cout << "Successfully deleted receipt rule set." << std::endl; } else { std::cerr << "Error deleting receipt rule set. " << 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 { DeleteReceiptRuleSetCommand } 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_SET_NAME = getUniqueName("RuleSetName"); const createDeleteReceiptRuleSetCommand = () => { return new DeleteReceiptRuleSetCommand({ RuleSetName: RULE_SET_NAME }); }; const run = async () => { const deleteReceiptRuleSetCommand = createDeleteReceiptRuleSetCommand(); try { return await sesClient.send(deleteReceiptRuleSetCommand); } catch (err) { console.log("Failed to delete receipt rule set.", 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_set(self, rule_set_name): """ Deletes a rule set. When a rule set is deleted, all of the rules it contains are also deleted. :param rule_set_name: The name of the rule set to delete. """ try: self.ses_client.delete_receipt_rule_set(RuleSetName=rule_set_name) logger.info("Deleted rule set %s.", rule_set_name) except ClientError: logger.exception("Couldn't delete rule set %s.", rule_set_name) raise